FluidVaultPositionsResolver ​
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 ​
uint256 internal constant PAGE_SIZE = 3000Functions ​
constructor ​
constructor sets the immutable vault factory address
constructor(IFluidVaultFactory vaultFactory_) Variables(vaultFactory_);Parameters
| Name | Type | Description |
|---|---|---|
vaultFactory_ | IFluidVaultFactory | The 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.
function getAllVaultNftIdsPaged(address vault_, uint256 page_)
public
view
returns (uint256[] memory nftIds_, bool hasNextPage_);Parameters
| Name | Type | Description |
|---|---|---|
vault_ | address | The address of the vault. |
page_ | uint256 | The current page to fetch (pagination index). start with page 0. |
Returns
| Name | Type | Description |
|---|---|---|
nftIds_ | uint256[] | Array of NFT token IDs for the specified page. |
hasNextPage_ | bool | True 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!
function getAllVaultNftIds(address vault_) public view returns (uint256[] memory nftIds_);Parameters
| Name | Type | Description |
|---|---|---|
vault_ | address | The address of the vault. |
Returns
| Name | Type | Description |
|---|---|---|
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.
function getVaultPositionsForNftIds(uint256[] memory nftIds_, address vault_)
public
view
returns (UserPosition[] memory positions_);Parameters
| Name | Type | Description |
|---|---|---|
nftIds_ | uint256[] | Array of NFT IDs. Split reading into chunks if this runs out of gas! |
vault_ | address | The address of the vault. |
Returns
| Name | Type | Description |
|---|---|---|
positions_ | UserPosition[] | Array of UserPosition for the NFT IDs. |
getPositionsForNftIds ​
Gets user positions for a set of NFT IDs.
function getPositionsForNftIds(uint256[] memory nftIds_) public view returns (UserPosition[] memory positions_);Parameters
| Name | Type | Description |
|---|---|---|
nftIds_ | uint256[] | Array of NFT IDs. Split reading into chunks if this runs out of gas! |
Returns
| Name | Type | Description |
|---|---|---|
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!
function getAllVaultPositions(address vault_) public view returns (UserPosition[] memory positions_);Parameters
| Name | Type | Description |
|---|---|---|
vault_ | address | The address of the vault. |
Returns
| Name | Type | Description |
|---|---|---|
positions_ | UserPosition[] | Array of UserPosition for each position in the vault. |
_getVaultVariablesRaw ​
Get the raw variables of a vault.
function _getVaultVariablesRaw(address vault_) internal view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
vault_ | address | The address of the vault. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The raw variables of the vault. |
_getVaultVariables2Raw ​
Get the raw variables of a vault (slot 1).
function _getVaultVariables2Raw(address vault_) internal view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
vault_ | address | The address of the vault. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The raw variables of the vault (slot 1). |
_calculateStorageSlotUintMapping ​
Calculates the storage slot for a mapping.
function _calculateStorageSlotUintMapping(uint256 slot_, uint256 key_) internal pure returns (bytes32);Parameters
| Name | Type | Description |
|---|---|---|
slot_ | uint256 | The slot index. |
key_ | uint256 | The mapping key. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | The calculated storage slot. |
_calculateStorageSlotIntMapping ​
Calculating the slot ID for Liquidity contract for single mapping
function _calculateStorageSlotIntMapping(uint256 slot_, int256 key_) public pure returns (bytes32);_getPositionDataRaw ​
Get the position data of a vault.
function _getPositionDataRaw(address vault_, uint256 positionId_) internal view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
vault_ | address | The address of the vault. |
positionId_ | uint256 | The ID of the position. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The position data of the vault. |
_getTickDataRaw ​
Get the raw tick data of a vault.
function _getTickDataRaw(address vault_, int256 tick_) internal view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
vault_ | address | The address of the vault. |
tick_ | int256 | The tick value. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The raw tick data of the vault. |
_tokenByIndex ​
Returns a token ID at a given index.
function _tokenByIndex(uint256 index_) internal pure returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
index_ | uint256 | The index to fetch. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The tokenId at the given index. |
_getVaultAddress ​
Computes the address of a vault based on its given ID.
function _getVaultAddress(uint256 vaultId_) internal view returns (address vault_);Parameters
| Name | Type | Description |
|---|---|---|
vaultId_ | uint256 | The ID of the vault. |
Returns
| Name | Type | Description |
|---|---|---|
vault_ | address | The computed vault address. |
_vaultByNftId ​
Returns the vault address for a given NFT ID.
function _vaultByNftId(uint256 nftId_) internal view returns (address vault_);Parameters
| Name | Type | Description |
|---|---|---|
nftId_ | uint256 | The NFT ID. |
Returns
| Name | Type | Description |
|---|---|---|
vault_ | address | The vault address associated with the NFT ID. |
_vaultAndOwnerByNftId ​
Returns the vault address and NFT owner for a given NFT ID.
function _vaultAndOwnerByNftId(uint256 nftId_) internal view returns (address vault_, address nftOwner_);Parameters
| Name | Type | Description |
|---|---|---|
nftId_ | uint256 | The NFT ID. |
Returns
| Name | Type | Description |
|---|---|---|
vault_ | address | The vault address. |
nftOwner_ | address | The NFT owner address. |
_getVaultPosition ​
Gets the vault position for a given vault, NFT, and exchange prices.
function _getVaultPosition(
address vault_,
uint256 nftId_,
uint256 vaultSupplyExchangePrice_,
uint256 vaultBorrowExchangePrice_,
address nftOwner_
) internal view returns (UserPosition memory userPosition_);Parameters
| Name | Type | Description |
|---|---|---|
vault_ | address | The vault address. |
nftId_ | uint256 | The NFT ID. |
vaultSupplyExchangePrice_ | uint256 | The vault supply exchange price. |
vaultBorrowExchangePrice_ | uint256 | The vault borrow exchange price. |
nftOwner_ | address | The NFT owner. |
Returns
| Name | Type | Description |
|---|---|---|
userPosition_ | UserPosition | The UserPosition struct with the decoded position. |
Errors ​
FluidVaultPositionsResolver__AddressZero ​
thrown if an input param address is zero
error FluidVaultPositionsResolver__AddressZero();FluidVaultPositionsResolver__InvalidParams ​
error FluidVaultPositionsResolver__InvalidParams();
