Skip to content

FluidVaultPositionsResolver ​

Git Source

Inherits:Variables, Structs

Title: Fluid Vault protocol Positions Resolver for all vault types.

This contract resolves positions for Fluid Vaults, providing functionality to retrieve NFT IDs and positions for a given vault.

State Variables ​

PAGE_SIZE ​

solidity
uint256 internal constant PAGE_SIZE = 3000

Functions ​

constructor ​

constructor sets the immutable vault factory address

solidity
constructor(IFluidVaultFactory vaultFactory_) Variables(vaultFactory_);

Parameters

NameTypeDescription
vaultFactory_IFluidVaultFactoryThe FluidVaultFactory contract address

getAllVaultNftIdsPaged ​

Returns the NFT token IDs for a given vault using a paged approach, reading 3000 nfts per page.

Use this method on chains where retrieving all token IDs at once may run out of gas. Call this repeatedly with increasing page numbers until hasNextPage is false, then use getVaultPositionsForNftIds.

solidity
function getAllVaultNftIdsPaged(address vault_, uint256 page_)
    public
    view
    returns (uint256[] memory nftIds_, bool hasNextPage_);

Parameters

NameTypeDescription
vault_addressThe address of the vault.
page_uint256The current page to fetch (pagination index). start with page 0.

Returns

NameTypeDescription
nftIds_uint256[]Array of NFT token IDs for the specified page.
hasNextPage_boolTrue if there are more pages to fetch, false if this is the last page.

getAllVaultNftIds ​

Returns all NFT token IDs for the specified vault. Use getAllVaultNftIdsPaged if this runs out of gas!

solidity
function getAllVaultNftIds(address vault_) public view returns (uint256[] memory nftIds_);

Parameters

NameTypeDescription
vault_addressThe address of the vault.

Returns

NameTypeDescription
nftIds_uint256[]Array of NFT token IDs belonging to the vault.

getVaultPositionsForNftIds ​

Gets user positions for NFT IDs assumed to belong to a specific vault.

solidity
function getVaultPositionsForNftIds(uint256[] memory nftIds_, address vault_)
    public
    view
    returns (UserPosition[] memory positions_);

Parameters

NameTypeDescription
nftIds_uint256[]Array of NFT IDs. Split reading into chunks if this runs out of gas!
vault_addressThe address of the vault.

Returns

NameTypeDescription
positions_UserPosition[]Array of UserPosition for the NFT IDs.

getPositionsForNftIds ​

Gets user positions for a set of NFT IDs.

solidity
function getPositionsForNftIds(uint256[] memory nftIds_) public view returns (UserPosition[] memory positions_);

Parameters

NameTypeDescription
nftIds_uint256[]Array of NFT IDs. Split reading into chunks if this runs out of gas!

Returns

NameTypeDescription
positions_UserPosition[]Array of UserPosition for each NFT ID.

getAllVaultPositions ​

Gets all positions for the given vault. Use getAllVaultNftIds first if this runs out of gas!

solidity
function getAllVaultPositions(address vault_) public view returns (UserPosition[] memory positions_);

Parameters

NameTypeDescription
vault_addressThe address of the vault.

Returns

NameTypeDescription
positions_UserPosition[]Array of UserPosition for each position in the vault.

_getVaultVariablesRaw ​

Get the raw variables of a vault.

solidity
function _getVaultVariablesRaw(address vault_) internal view returns (uint256);

Parameters

NameTypeDescription
vault_addressThe address of the vault.

Returns

NameTypeDescription
<none>uint256The raw variables of the vault.

_getVaultVariables2Raw ​

Get the raw variables of a vault (slot 1).

solidity
function _getVaultVariables2Raw(address vault_) internal view returns (uint256);

Parameters

NameTypeDescription
vault_addressThe address of the vault.

Returns

NameTypeDescription
<none>uint256The raw variables of the vault (slot 1).

_calculateStorageSlotUintMapping ​

Calculates the storage slot for a mapping.

solidity
function _calculateStorageSlotUintMapping(uint256 slot_, uint256 key_) internal pure returns (bytes32);

Parameters

NameTypeDescription
slot_uint256The slot index.
key_uint256The mapping key.

Returns

NameTypeDescription
<none>bytes32The calculated storage slot.

_calculateStorageSlotIntMapping ​

Calculating the slot ID for Liquidity contract for single mapping

solidity
function _calculateStorageSlotIntMapping(uint256 slot_, int256 key_) public pure returns (bytes32);

_getPositionDataRaw ​

Get the position data of a vault.

solidity
function _getPositionDataRaw(address vault_, uint256 positionId_) internal view returns (uint256);

Parameters

NameTypeDescription
vault_addressThe address of the vault.
positionId_uint256The ID of the position.

Returns

NameTypeDescription
<none>uint256The position data of the vault.

_getTickDataRaw ​

Get the raw tick data of a vault.

solidity
function _getTickDataRaw(address vault_, int256 tick_) internal view returns (uint256);

Parameters

NameTypeDescription
vault_addressThe address of the vault.
tick_int256The tick value.

Returns

NameTypeDescription
<none>uint256The raw tick data of the vault.

_tokenByIndex ​

Returns a token ID at a given index.

solidity
function _tokenByIndex(uint256 index_) internal pure returns (uint256);

Parameters

NameTypeDescription
index_uint256The index to fetch.

Returns

NameTypeDescription
<none>uint256The tokenId at the given index.

_getVaultAddress ​

Computes the address of a vault based on its given ID.

solidity
function _getVaultAddress(uint256 vaultId_) internal view returns (address vault_);

Parameters

NameTypeDescription
vaultId_uint256The ID of the vault.

Returns

NameTypeDescription
vault_addressThe computed vault address.

_vaultByNftId ​

Returns the vault address for a given NFT ID.

solidity
function _vaultByNftId(uint256 nftId_) internal view returns (address vault_);

Parameters

NameTypeDescription
nftId_uint256The NFT ID.

Returns

NameTypeDescription
vault_addressThe vault address associated with the NFT ID.

_vaultAndOwnerByNftId ​

Returns the vault address and NFT owner for a given NFT ID.

solidity
function _vaultAndOwnerByNftId(uint256 nftId_) internal view returns (address vault_, address nftOwner_);

Parameters

NameTypeDescription
nftId_uint256The NFT ID.

Returns

NameTypeDescription
vault_addressThe vault address.
nftOwner_addressThe NFT owner address.

_getVaultPosition ​

Gets the vault position for a given vault, NFT, and exchange prices.

solidity
function _getVaultPosition(
    address vault_,
    uint256 nftId_,
    uint256 vaultSupplyExchangePrice_,
    uint256 vaultBorrowExchangePrice_,
    address nftOwner_
) internal view returns (UserPosition memory userPosition_);

Parameters

NameTypeDescription
vault_addressThe vault address.
nftId_uint256The NFT ID.
vaultSupplyExchangePrice_uint256The vault supply exchange price.
vaultBorrowExchangePrice_uint256The vault borrow exchange price.
nftOwner_addressThe NFT owner.

Returns

NameTypeDescription
userPosition_UserPositionThe UserPosition struct with the decoded position.

Errors ​

FluidVaultPositionsResolver__AddressZero ​

thrown if an input param address is zero

solidity
error FluidVaultPositionsResolver__AddressZero();

FluidVaultPositionsResolver__InvalidParams ​

solidity
error FluidVaultPositionsResolver__InvalidParams();