Internals ​
Fluid "VaultT3" (Vault Type 3). Fluid vault protocol main contract. T3 -> Normal collateral | Smart 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.
_debtLiquidateBefore ​
function _debtLiquidateBefore(uint256 token0DebtAmt_, uint256 token1DebtAmt_, uint256 debtSharesMin_) internal returns (uint256 shares_)
_debtLiquidatePerfectPayback ​
function _debtLiquidatePerfectPayback(uint256 perfectDebtShares_, uint256 token0DebtAmtPerUnitShares_, uint256 token1DebtAmtPerUnitShares_) internal returns (uint256 token0DebtPaid_, uint256 token1DebtPaid_)
constructor ​
constructor(struct Structs.ConstantViews constants_) internal
FluidVaultT3 ​
operate ​
function operate(uint256 nftId_, int256 newCol_, 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 ​
Name | Type | Description |
---|---|---|
nftId_ | uint256 | The ID of the NFT representing the vault position |
newCol_ | int256 | The change in collateral amount (positive for deposit, negative for withdrawal) |
newDebtToken0_ | int256 | The change in debt amount for token0 (positive for borrowing, negative for repayment) |
newDebtToken1_ | int256 | The change in debt amount for token1 (positive for borrowing, negative for repayment) |
debtSharesMinMax_ | int256 | Min or max debt shares to burn or mint (positive for borrowing, negative for repayment) |
to_ | address | The address to receive withdrawn collateral or borrowed tokens (if address(0), defaults to msg.sender) |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | nftId_ The ID of the NFT representing the updated vault position |
[1] | int256 | supplyAmt_ Final supply amount (negative if withdrawal occurred) |
[2] | int256 | borrowAmt_ Final borrow amount (negative if repayment occurred) |
operatePerfect ​
function operatePerfect(uint256 nftId_, int256 newCol_, 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 ​
Name | Type | Description |
---|---|---|
nftId_ | uint256 | The ID of the NFT representing the vault position |
newCol_ | int256 | The change in collateral amount (positive for deposit, negative for withdrawal) |
perfectDebtShares_ | int256 | The change in debt shares (positive for borrowing, negative for repayment) |
debtToken0MinMax_ | int256 | Min or max debt amount for token0 to payback or borrow (positive for borrowing, negative for repayment) |
debtToken1MinMax_ | int256 | Min or max debt amount for token1 to payback or borrow (positive for borrowing, negative for repayment) |
to_ | address | The address to receive withdrawn collateral or borrowed tokens (if address(0), defaults to msg.sender) |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | nftId_ The ID of the NFT representing the updated vault position |
r_ | int256[] | int256 array of return values: 0 - col amount, will only change if user sends type(int).min 1 - final debt shares amount (can only change on max payback) 2 - token0 borrow or payback amount 3 - token1 borrow or payback amount |
liquidate ​
function liquidate(uint256 token0DebtAmt_, uint256 token1DebtAmt_, uint256 debtSharesMin_, uint256 colPerUnitDebt_, address to_, bool absorb_) external payable returns (uint256 actualDebtShares_, uint256 actualCol_)
Liquidates a vault position
This function allows users to liquidate a vault position by adjusting collateral and debt
Parameters ​
Name | Type | Description |
---|---|---|
token0DebtAmt_ | uint256 | The amount of debt in token0 to payback |
token1DebtAmt_ | uint256 | The amount of debt in token1 to payback |
debtSharesMin_ | uint256 | The minimum number of debt shares to liquidate |
colPerUnitDebt_ | uint256 | The collateral amount per unit of debt shares |
to_ | address | The address to receive withdrawn collateral (if address(0), defaults to msg.sender) |
absorb_ | bool | Whether to liquidate absorbed liquidity as well |
Return Values ​
Name | Type | Description |
---|---|---|
actualDebtShares_ | uint256 | The actual number of debt shares liquidated |
actualCol_ | uint256 | The actual amount of collateral withdrawn |
LiquidatePerfect ​
struct LiquidatePerfect {
uint256 vaultVariables;
uint256 initialEth;
}
liquidatePerfect ​
function liquidatePerfect(uint256 debtShares_, uint256 token0DebtAmtPerUnitShares_, uint256 token1DebtAmtPerUnitShares_, uint256 colPerUnitDebt_, address to_, bool absorb_) external payable returns (uint256 actualDebtShares_, uint256 token0Debt_, uint256 token1Debt_, uint256 actualCol_)
Liquidates a vault position with perfect collateral shares
This function allows users to liquidate a vault position by adjusting collateral and debt
Parameters ​
Name | Type | Description |
---|---|---|
debtShares_ | uint256 | The amount of debt shares to liquidate |
token0DebtAmtPerUnitShares_ | uint256 | The amount of debt in token0 per unit of debt shares (if sent 0 then entire payback is in token1) |
token1DebtAmtPerUnitShares_ | uint256 | The amount of debt in token1 per unit of debt shares (if sent 0 then entire payback is in token0) |
colPerUnitDebt_ | uint256 | The collateral amount per unit of debt shares |
to_ | address | The address to receive withdrawn collateral (if address(0), defaults to msg.sender) |
absorb_ | bool | Whether to liquidate absorbed liquidity as well |
Return Values ​
Name | Type | Description |
---|---|---|
actualDebtShares_ | uint256 | The actual number of debt shares liquidated |
token0Debt_ | uint256 | The amount of debt in token0 that was paid back |
token1Debt_ | uint256 | The amount of debt in token1 that was paid back |
actualCol_ | uint256 | The actual amount of collateral withdrawn |
constructor ​
constructor(struct Structs.ConstantViews constants_) public