Vault Factory

IFluidVaultFactory

mint

function mint(uint256 vaultId_, address user_) external returns (uint256 tokenId_)

Minting an NFT Vault for the user

ownerOf

function ownerOf(uint256 tokenId) external view returns (address owner)

returns owner of Vault which is also an NFT

isGlobalAuth

function isGlobalAuth(address auth_) external view returns (bool)

Global auth is auth for all vaults

isVaultAuth

function isVaultAuth(address vault_, address auth_) external view returns (bool)

Vault auth is auth for a specific vault

totalVaults

function totalVaults() external view returns (uint256)

Total vaults deployed.

getVaultAddress

function getVaultAddress(uint256 vaultId) external view returns (address)

Compute vaultAddress

readFromStorage

function readFromStorage(bytes32 slot_) external view returns (uint256 result_)

read uint256 result_ for a storage slot_ key

FluidVaultRewards

This contract is designed to adjust the supply rate magnifier for a vault based on the current collateral supply & supply rate. The adjustment aims to dynamically scale the rewards given to lenders as the TVL in the vault changes.

The magnifier is adjusted based on a regular most used reward type where rewardRate = totalRewardsAnnually / totalSupply. Reward rate is applied by adjusting the supply magnifier on vault. Adjustments are made via the rebalance function, which is restricted to be called by designated rebalancers only.

validAddress

modifier validAddress(address value_)

Validates that an address is not the zero address

onlyRebalancer

modifier onlyRebalancer()

Validates that an address is a rebalancer (taken from reserve contract)

constructor

constructor(contract IFluidReserveContract reserveContract_, contract IFluidVaultT1 vault_, contract IFluidLiquidity liquidity_, uint256 rewardsAmt_, uint256 duration_, address initiator_, address collateralToken_) public

Constructs the FluidVaultRewards contract.

Parameters

NameTypeDescription
reserveContract_contract IFluidReserveContractThe address of the reserve contract where rebalancers are defined.
vault_contract IFluidVaultT1The vault to which this contract will apply new magnifier parameter.
liquidity_contract IFluidLiquidityFluid liquidity address
rewardsAmt_uint256Amounts of rewards to distribute
duration_uint256rewards duration
initiator_addressaddress that can start rewards with start()
collateralToken_addressvault collateral token address

rebalance

function rebalance() external

Rebalances the supply rate magnifier based on the current collateral supply. Can only be called by an authorized rebalancer.

calculateMagnifier

function calculateMagnifier() public view returns (uint256 magnifier_, bool ended_)

Calculates the new supply rate magnifier based on the current collateral supply (vaultTVL()).

Return Values

NameTypeDescription
magnifier_uint256The calculated magnifier value.
ended_bool

currentMagnifier

function currentMagnifier() public view returns (uint256)

returns the currently configured supply magnifier at the VAULT.

vaultTVL

function vaultTVL() public view returns (uint256 tvl_)

returns the current total value locked as collateral (TVL) in the VAULT.

getSupplyRate

function getSupplyRate() public view returns (uint256 supplyRate_)

start

function start() external

ErrorTypes

VaultFactory__InvalidOperation

uint256 internal constant VaultFactory__InvalidOperation = 30001;

VaultFactory__Unauthorized

uint256 internal constant VaultFactory__Unauthorized = 30002;

VaultFactory__SameTokenNotAllowed

uint256 internal constant VaultFactory__SameTokenNotAllowed = 30003;

VaultFactory__InvalidParams

uint256 internal constant VaultFactory__InvalidParams = 30004;

VaultFactory__InvalidVault

uint256 internal constant VaultFactory__InvalidVault = 30005;

VaultFactory__InvalidVaultAddress

uint256 internal constant VaultFactory__InvalidVaultAddress = 30006;

VaultFactory__OnlyDelegateCallAllowed

uint256 internal constant VaultFactory__OnlyDelegateCallAllowed = 30007;