Skip to content

FluidReserveContract ​

Git Source

Inherits:Error, ReserveContractAuth, UUPSUpgradeable

This contract manages the approval of tokens for use by protocols and the execution of rebalances on protocols

Functions ​

onlyRebalancer ​

Checks that the sender is a rebalancer

solidity
modifier onlyRebalancer();

constructor ​

solidity
constructor();

initialize ​

initializes the contract

solidity
function initialize(address[] memory _auths, address[] memory _rebalancers, address owner_)
    public
    initializer
    validAddress(owner_);

Parameters

NameTypeDescription
_authsaddress[]The addresses that have the auth to approve and revoke protocol token allowances
_rebalancersaddress[]The addresses that can execute a rebalance on a protocol
owner_addressowner address is able to upgrade contract and update auth users

_authorizeUpgrade ​

solidity
function _authorizeUpgrade(address) internal override onlyOwner;

renounceOwnership ​

override renounce ownership as it could leave the contract in an unwanted state if called by mistake.

solidity
function renounceOwnership() public view override onlyOwner;

rebalanceFToken ​

Executes a rebalance on a fToken protocol by calling that protocol's rebalance function

solidity
function rebalanceFToken(address protocol_, uint256 value_) public payable onlyRebalancer;

Parameters

NameTypeDescription
protocol_addressThe protocol to rebalance
value_uint256any msg.value to send along (as fetched from resolver!)

rebalanceVault ​

Executes a rebalance on a vaultT1 protocol by calling that protocol's rebalance function

solidity
function rebalanceVault(address protocol_, uint256 value_) public payable onlyRebalancer;

Parameters

NameTypeDescription
protocol_addressThe protocol to rebalance
value_uint256any msg.value to send along (as fetched from resolver!)

rebalanceDexVault ​

Executes a rebalance on a DEX vault protocol by calling that protocol's rebalance function

solidity
function rebalanceDexVault(
    address protocol_,
    uint256 value_,
    int256 colToken0MinMax_,
    int256 colToken1MinMax_,
    int256 debtToken0MinMax_,
    int256 debtToken1MinMax_
) public payable onlyRebalancer;

Parameters

NameTypeDescription
protocol_addressThe protocol to rebalance
value_uint256any msg.value to send along (as fetched from resolver!)
colToken0MinMax_int256if vault supply is more than Liquidity Layer then deposit difference through reserve/rebalance contract
colToken1MinMax_int256if vault supply is less than Liquidity Layer then withdraw difference to reserve/rebalance contract
debtToken0MinMax_int256if vault borrow is more than Liquidity Layer then borrow difference to reserve/rebalance contract
debtToken1MinMax_int256if vault borrow is less than Liquidity Layer then payback difference through reserve/rebalance contract

rebalanceFTokens ​

calls rebalanceFToken multiple times

don't need onlyRebalancer modifier as it is already checked in rebalanceFToken function

solidity
function rebalanceFTokens(address[] calldata protocols_, uint256[] calldata values_) external payable;

rebalanceVaults ​

calls rebalanceVault multiple times

don't need onlyRebalancer modifier as it is already checked in rebalanceVault function

solidity
function rebalanceVaults(address[] calldata protocols_, uint256[] calldata values_) external payable;

rebalanceDexVaults ​

calls rebalanceDexVault multiple times

don't need onlyRebalancer modifier as it is already checked in rebalanceDexVault function

solidity
function rebalanceDexVaults(
    address[] calldata protocols_,
    uint256[] calldata values_,
    int256[] calldata colToken0MinMaxs_,
    int256[] calldata colToken1MinMaxs_,
    int256[] calldata debtToken0MinMaxs_,
    int256[] calldata debtToken1MinMaxs_
) external payable;

withdrawFunds ​

Withdraws funds from the contract to a specified receiver

This function can only be called by the owner, which is always the Governance address

solidity
function withdrawFunds(address[] memory tokens_, uint256[] memory amounts_, address receiver_) external onlyOwner;

Parameters

NameTypeDescription
tokens_address[]The tokens to withdraw
amounts_uint256[]The amounts of each token to withdraw
receiver_addressThe address to receive the withdrawn funds

getProtocolTokens ​

Gets the tokens that are approved for use by a protocol

solidity
function getProtocolTokens(address protocol_) external view returns (address[] memory result_);

Parameters

NameTypeDescription
protocol_addressThe protocol to get the tokens for

Returns

NameTypeDescription
result_address[]The tokens that are approved for use by the protocol

getProtocolAllowances ​

Gets the allowances that are approved to a protocol

solidity
function getProtocolAllowances(address protocol_) public view returns (TokenAllowance[] memory allowances_);

Parameters

NameTypeDescription
protocol_addressThe protocol to get the tokens for

Returns

NameTypeDescription
allowances_TokenAllowance[]The tokens that are approved for use by the protocol

getAllProtocolAllowances ​

Gets the allowances that are approved to a protocol

solidity
function getAllProtocolAllowances() public view returns (ProtocolTokenAllowance[] memory allowances_);

Returns

NameTypeDescription
allowances_ProtocolTokenAllowance[]The tokens that are approved for use by all the protocols

receive ​

allow receive native token

solidity
receive() external payable;