Skip to content

FluidVaultT4 ​

Git Source

Inherits:Internals

Functions ​

operate ​

Performs operations on a vault position

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

solidity
function operate(
    uint256 nftId_,
    int256 newColToken0_,
    int256 newColToken1_,
    int256 colSharesMinMax_,
    int256 newDebtToken0_,
    int256 newDebtToken1_,
    int256 debtSharesMinMax_,
    address to_
) external payable _dexFromAddress returns (uint256, int256, int256);

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 funds (if address(0), defaults to msg.sender)

Returns

NameTypeDescription
<none>uint256supplyAmt_ Final supply amount (negative if withdrawal occurred)
<none>int256borrowAmt_ Final borrow amount (negative if repayment occurred)
<none>int256

operatePerfect ​

Performs operations on a vault position with perfect collateral shares

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

solidity
function operatePerfect(
    uint256 nftId_,
    int256 perfectColShares_,
    int256 colToken0MinMax_,
    int256 colToken1MinMax_,
    int256 perfectDebtShares_,
    int256 debtToken0MinMax_,
    int256 debtToken1MinMax_,
    address to_
) external payable _dexFromAddress returns (uint256, int256[] memory r_);

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_addressThe address to receive funds (if address(0), defaults to msg.sender)

Returns

NameTypeDescription
<none>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

liquidate ​

Liquidates a vault position

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

solidity
function liquidate(
    uint256 token0DebtAmt_,
    uint256 token1DebtAmt_,
    uint256 debtSharesMin_,
    uint256 colPerUnitDebt_,
    uint256 token0ColAmtPerUnitShares_,
    uint256 token1ColAmtPerUnitShares_,
    address to_,
    bool absorb_
)
    external
    payable
    _dexFromAddress
    returns (uint256 actualDebtShares_, uint256 actualColShares_, uint256 token0Col_, uint256 token1Col_);

Parameters

NameTypeDescription
token0DebtAmt_uint256The amount of debt in token0 to payback
token1DebtAmt_uint256The amount of debt in token1 to payback
debtSharesMin_uint256The minimum number of debt shares to liquidate
colPerUnitDebt_uint256The collateral amount per unit of debt shares
token0ColAmtPerUnitShares_uint256The collateral amount per unit of debt shares for token0 (in 1e18)
token1ColAmtPerUnitShares_uint256The collateral amount per unit of debt shares for token1 (in 1e18)
to_addressThe address to receive withdrawn collateral (if address(0), defaults to msg.sender)
absorb_boolWhether to liquidate absorbed liquidity as well

Returns

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

liquidatePerfect ​

Liquidates a vault position with perfect collateral shares

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

solidity
function liquidatePerfect(
    uint256 debtShares_,
    uint256 token0DebtAmtPerUnitShares_,
    uint256 token1DebtAmtPerUnitShares_,
    uint256 colPerUnitDebt_,
    uint256 token0ColAmtPerUnitShares_,
    uint256 token1ColAmtPerUnitShares_,
    address to_,
    bool absorb_
)
    external
    payable
    _dexFromAddress
    returns (
        uint256 actualDebtShares_,
        uint256 token0Debt_,
        uint256 token1Debt_,
        uint256 actualColShares_,
        uint256 token0Col_,
        uint256 token1Col_
    );

Parameters

NameTypeDescription
debtShares_uint256The number of debt shares to liquidate
token0DebtAmtPerUnitShares_uint256The debt amount per unit of debt shares for token0 (in 1e18)
token1DebtAmtPerUnitShares_uint256The debt amount per unit of debt shares for token1 (in 1e18)
colPerUnitDebt_uint256The collateral amount per unit of debt shares (in 1e18)
token0ColAmtPerUnitShares_uint256The collateral amount per unit of debt shares for token0 (in 1e18)
token1ColAmtPerUnitShares_uint256The collateral amount per unit of debt shares for token1 (in 1e18)
to_addressThe address to receive withdrawn collateral or borrowed tokens (if address(0), defaults to msg.sender)
absorb_boolWhether to liquidate absorbed liquidity as well

Returns

NameTypeDescription
actualDebtShares_uint256The actual number of debt shares liquidated
token0Debt_uint256The amount of debt in token0 that was paid back
token1Debt_uint256The amount of debt in token1 that was paid back
actualColShares_uint256The actual number of collateral shares liquidated
token0Col_uint256The amount of collateral in token0 that was withdrawn
token1Col_uint256The amount of collateral in token1 that was withdrawn

constructor ​

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

Structs ​

LiquidatePerfect ​

solidity
struct LiquidatePerfect {
    uint256 vaultVariables;
    uint256 initialEth;
}