Skip to content

Internals ​

Fluid "VaultT2" (Vault Type 2). Fluid vault protocol main contract. T2 -> Smart collateral | Normal debt 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.

_colLiquidatePerfectAfter ​

solidity
function _colLiquidatePerfectAfter(uint256 perfectColShares_, uint256 token0ColAmtPerUnitShares_, uint256 token1ColAmtPerUnitShares_, address to_) internal returns (uint256 newColToken0_, uint256 newColToken1_)

constructor ​

solidity
constructor(struct Structs.ConstantViews constants_) internal

FluidVaultT2 ​

operate ​

solidity
function operate(uint256 nftId_, int256 newColToken0_, int256 newColToken1_, int256 colSharesMinMax_, int256 newDebt_, address to_) external payable returns (uint256, int256, int256)

Performs operations on a vault position

This function allows users to modify their vault position by adjusting collateral and debt

Parameters ​

NameTypeDescription
nftId_uint256The ID of the NFT representing the vault position
newColToken0_int256The change in collateral amount of token0 (positive for deposit, negative for withdrawal)
newColToken1_int256The change in collateral amount of token1 (positive for deposit, negative for withdrawal)
colSharesMinMax_int256min or max collateral shares to mint or burn (positive for deposit, negative for withdrawal)
newDebt_int256The change in debt amount (positive for borrowing, negative for repayment)
to_addressThe address to receive withdrawn collateral or borrowed tokens (if address(0), defaults to msg.sender)

Return Values ​

NameTypeDescription
[0]uint256nftId_ The ID of the NFT representing the updated vault position
[1]int256supplyAmt_ Final supply amount (negative if withdrawal occurred)
[2]int256borrowAmt_ Final borrow amount (negative if repayment occurred)

operatePerfect ​

solidity
function operatePerfect(uint256 nftId_, int256 perfectColShares_, int256 colToken0MinMax_, int256 colToken1MinMax_, int256 newDebt_, address to_) external payable returns (uint256, int256[] r_)

Performs operations on a vault position with perfect collateral shares

This function allows users to modify their vault position by adjusting collateral and debt

Parameters ​

NameTypeDescription
nftId_uint256The ID of the NFT representing the vault position
perfectColShares_int256The change in collateral shares (positive for deposit, negative for withdrawal)
colToken0MinMax_int256min or max collateral amount of token0 to withdraw or deposit (positive for deposit, negative for withdrawal)
colToken1MinMax_int256min or max collateral amount of token1 to withdraw or deposit (positive for deposit, negative for withdrawal)
newDebt_int256The change in debt amount (positive for borrowing, negative for repayment)
to_addressThe address to receive withdrawn collateral or borrowed tokens (if address(0), defaults to msg.sender)

Return Values ​

NameTypeDescription
[0]uint256nftId_ The ID of the NFT representing the updated vault position
r_int256[]int256 array of return values: 0 - final col shares amount (can only change on max withdrawal) 1 - token0 deposit or withdraw amount 2 - token1 deposit or withdraw amount 3 - newDebt_ will only change if user sent type(int).min

liquidate ​

solidity
function liquidate(uint256 debtAmt_, uint256 colPerUnitDebt_, uint256 token0ColAmtPerUnitShares_, uint256 token1ColAmtPerUnitShares_, address to_, bool absorb_) public payable returns (uint256 actualDebt_, uint256 actualColShares_, uint256 token0Col_, uint256 token1Col_)

Liquidates a vault position

This function allows users to liquidate a vault position by adjusting collateral and debt

Parameters ​

NameTypeDescription
debtAmt_uint256The amount of debt to liquidate
colPerUnitDebt_uint256The collateral shares per unit of debt
token0ColAmtPerUnitShares_uint256The collateral amount of token0 per unit of shares to withdraw
token1ColAmtPerUnitShares_uint256The collateral amount of token1 per unit of shares to withdraw
to_addressThe address to receive withdrawn collateral (if address(0), defaults to msg.sender)
absorb_boolWhether to liquidate absorbed liquidity as well

Return Values ​

NameTypeDescription
actualDebt_uint256The actual amount of debt liquidated
actualColShares_uint256The actual amount of collateral shares liquidated
token0Col_uint256The amount of token0 collateral withdrawn
token1Col_uint256The amount of token1 collateral withdrawn

liquidatePerfect ​

solidity
function liquidatePerfect(uint256 debtAmt_, uint256 colPerUnitDebt_, uint256 token0ColAmtPerUnitShares_, uint256 token1ColAmtPerUnitShares_, address to_, bool absorb_) external payable returns (uint256 actualDebt_, uint256 actualColShares_, uint256 token0Col_, uint256 token1Col_)

Liquidates a vault position with perfect collateral shares

This function allows users to liquidate a vault position by adjusting collateral and debt

Parameters ​

NameTypeDescription
debtAmt_uint256The amount of debt to liquidate
colPerUnitDebt_uint256The collateral shares per unit of debt
token0ColAmtPerUnitShares_uint256The collateral amount of token0 per unit of shares to withdraw
token1ColAmtPerUnitShares_uint256The collateral amount of token1 per unit of shares to withdraw
to_addressThe address to receive withdrawn collateral (if address(0), defaults to msg.sender)
absorb_boolWhether to liquidate absorbed liquidity as well

Return Values ​

NameTypeDescription
actualDebt_uint256The actual amount of debt liquidated
actualColShares_uint256The actual amount of collateral shares liquidated
token0Col_uint256The amount of token0 collateral withdrawn
token1Col_uint256The amount of token1 collateral withdrawn

constructor ​

solidity
constructor(struct Structs.ConstantViews constants_) public