Get all user vault positions
To get all Fluid vault user positions, follow these steps:
Get the user positions from the VaultResolver
The VaultResolver periphery contract provides a method positionsByUser
(also see docs) which returns all user positions together with the vault data. The contract address is listed here.
This method returns an array of UserPositions (userPositions_
, see struct docs),
and a corresponding array of VaultEntireData (vaultsData_
, see struct docs).
Retrieve the position amounts and position tokens
For each UserPosition element, there are the supply
and borrow
amounts as struct params which have the total user deposit and borrow amounts for one position.
To get the supply and borrow tokens for each UserPosition, use the VaultEntireData array element at the same index. Under the property constantVariables
there are the properties supplyToken
and borrowToken
, see struct docs.
UserPosition
with the same supply & borrow token. To get the total user amounts, iterate over all UserPositions and sum up supply & borrow amounts for each token on all positions.Health factors: Collateral factor, Liquidation threshold, penalty etc.
The VaultEntireData array element also includes the vault config data. Under the property configs
(see struct docs) there are the following properties:
collateralFactor
: maximum ratio that can be borrowedliquidationThreshold
: ratio above which liquidation happensliquidationPenalty
: penalty when liquidation happensliquidationMaxLimit
: limit above which 100% could be liquidated
All of these values are percent values in 1e2 precision, so 1% = 100, 80% = 8000 etc.
Summary
To summarize the steps:
VaultResolver.positionsByUser(address user)
- Iterate through returned
UserPositions
array - In each iteration:
userPositions[i].supply
refers to the user deposit amount of tokenvaultsData[i].constantVariables.supplyToken
userPositions[i].borrow
refers to the user borrow amount of tokenvaultsData[i].constantVariables.borrowToken
- More data is available in the
UserPosition
andVaultEntireData
structs if needed, see contract docs.