Skip to content

Internals ​

Fluid "VaultT4" (Vault Type 4). Fluid vault protocol main operate contract. T4 -> Smart collateral | Smart debt

_colOperateBefore ​

solidity
function _colOperateBefore(int256 newColToken0_, int256 newColToken1_, int256 colSharesMinMax_, address to_) internal returns (int256 shares_)

_debtOperateBefore ​

solidity
function _debtOperateBefore(int256 newDebtToken0_, int256 newDebtToken1_, int256 debtSharesMinMax_, address to_) internal returns (int256 shares_)

_colOperatePerfectBefore ​

solidity
function _colOperatePerfectBefore(int256 perfectColShares_, int256 colToken0MinMax_, int256 colToken1MinMax_) internal returns (int256 newColToken0_, int256 newColToken1_)

_debtOperatePerfectPayback ​

solidity
function _debtOperatePerfectPayback(int256 perfectDebtShares_, int256 debtToken0MinMax_, int256 debtToken1MinMax_) internal returns (int256 newDebtToken0_, int256 newDebtToken1_)

_colOperatePerfectAfter ​

solidity
function _colOperatePerfectAfter(int256 perfectColShares_, int256 colToken0MinMax_, int256 colToken1MinMax_, address to_) internal returns (int256 newColToken0_, int256 newColToken1_)

_debtOperatePerfectBorrow ​

solidity
function _debtOperatePerfectBorrow(int256 perfectDebtShares_, int256 debtToken0MinMax_, int256 debtToken1MinMax_, address to_) internal returns (int256 newDebtToken0_, int256 newDebtToken1_)

constructor ​

solidity
constructor(struct Structs.ConstantViews constants_) internal

FluidVaultT4Operate ​

SmartOperate ​

solidity
struct SmartOperate {
  uint256 initialEth;
  int256 colShares;
  int256 debtShares;
  uint256 vaultVariables;
}

operate ​

solidity
function operate(uint256 nftId_, int256 newColToken0_, int256 newColToken1_, int256 colSharesMinMax_, int256 newDebtToken0_, int256 newDebtToken1_, int256 debtSharesMinMax_, 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 for token0 (positive for deposit, negative for withdrawal)
newColToken1_int256The change in collateral amount for token1 (positive for deposit, negative for withdrawal)
colSharesMinMax_int256Min or max collateral shares to mint or burn (positive for deposit, negative for withdrawal)
newDebtToken0_int256The change in debt amount for token0 (positive for borrowing, negative for repayment)
newDebtToken1_int256The change in debt amount for token1 (positive for borrowing, negative for repayment)
debtSharesMinMax_int256Min or max debt shares to burn or mint (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)

SmartOperatePerfect ​

solidity
struct SmartOperatePerfect {
  uint256 initialEth;
  int256 newColToken0;
  int256 newColToken1;
  int256 newDebtToken0;
  int256 newDebtToken1;
  uint256 vaultVariables;
}

operatePerfect ​

solidity
function operatePerfect(uint256 nftId_, int256 perfectColShares_, int256 colToken0MinMax_, int256 colToken1MinMax_, int256 perfectDebtShares_, int256 debtToken0MinMax_, int256 debtToken1MinMax_, 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)
perfectDebtShares_int256The change in debt shares (positive for borrowing, negative for repayment)
debtToken0MinMax_int256Min or max debt amount for token0 to borrow or payback (positive for borrowing, negative for repayment)
debtToken1MinMax_int256Min or max debt amount for token1 to borrow or payback (positive for borrowing, negative for repayment)
to_address

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 - final debt shares amount (can only change on max payback) 4 - token0 borrow or payback amount 5 - token1 borrow or payback amount

constructor ​

solidity
constructor(struct Structs.ConstantViews constants_) public