Skip to content

FluidWETHWrapper ​

Git Source

Inherits: Initializable, OwnableUpgradeable, UUPSUpgradeable, ReentrancyGuard

Allows depositing, withdrawal, borrowing and repaying of assets from vaults using WETH following aave interface

wrapping/unwrapping to ETH under the hood for vault T1

State Variables ​

WETH ​

solidity
IWETH9 public immutable WETH;

VAULT ​

solidity
IFluidVaultT1 public immutable VAULT;

BORROW_TOKEN ​

below variables can be derived directly or indirectly using vault address

solidity
address public immutable BORROW_TOKEN;

VAULT_FACTORY ​

solidity
address public immutable VAULT_FACTORY;

LIQUIDITY ​

solidity
address public immutable LIQUIDITY;

VAULT_ID ​

solidity
uint256 public immutable VAULT_ID;

X8 ​

solidity
uint256 internal constant X8 = 0xff;

X19 ​

solidity
uint256 internal constant X19 = 0x7ffff;

X24 ​

solidity
uint256 internal constant X24 = 0xffffff;

X64 ​

solidity
uint256 internal constant X64 = 0xffffffffffffffff;

nftId ​

solidity
uint64 public nftId;

Functions ​

constructor ​

solidity
constructor(address vaultAddress_, address weth_);

Parameters

NameTypeDescription
vaultAddress_addressFluid Vault address
weth_addressWETH token address

initialize ​

solidity
function initialize() public initializer;

_calculateStorageSlotUintMapping ​

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

_calculateStorageSlotIntMapping ​

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

_getPositionDataRaw ​

solidity
function _getPositionDataRaw() internal view returns (uint256);

_getVaultVariables2Raw ​

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

getTickDataRaw ​

solidity
function getTickDataRaw(int256 tick_) internal view returns (uint256);

_getPositionBorrow ​

solidity
function _getPositionBorrow() internal view returns (uint256 borrow);

_getPositionSupply ​

solidity
function _getPositionSupply() internal view returns (uint256 supply);

getPosition ​

get the vault nft position on vault

solidity
function getPosition() external view returns (uint256, uint256);

Returns

NameTypeDescription
<none>uint256supply amount
<none>uint256borrow amount

supply ​

Deposit WETH as collateral to a T1 VAULT.

  • If nftId == 0, new vault position gets created (NFT mint to this)
solidity
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)
    external
    nonReentrant
    onlyOwner;

Parameters

NameTypeDescription
assetaddressThe asset to deposit in contract (weth)
amountuint256Amount of asset to deposit as collateral
onBehalfOfaddressDeposit on behalf of, should be same as msg.sender
referralCodeuint16Un-used param

withdraw ​

Withdraw WETH collateral from a T1 vault

The vault sends us ETH, which we wrap into WETH and transfer to the user.

solidity
function withdraw(address asset, uint256 amount, address to) external nonReentrant onlyOwner;

Parameters

NameTypeDescription
assetaddressThe asset to deposit in contract (weth)
amountuint256Amount of asset to borrow as collateral
toaddresswithdraw should go to this address

borrow ​

Borrow in USDC from vault, the vault will send ETH to this contract.

solidity
function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf)
    external
    nonReentrant
    onlyOwner;

Parameters

NameTypeDescription
assetaddressThe asset to borrow
amountuint256Amount of asset to borrow
interestRateModeuint256The interest rate mode at which the user wants to borrow, Not used
referralCodeuint16The code used to register the integrator originating the operation, for potential rewards.NA
onBehalfOfaddressThe address of the user who will receive the debt.

repay ​

Repay debt in USDC to VAULT.

solidity
function repay(address asset, uint256 amount, uint256 interestRateMode, address onBehalfOf)
    external
    nonReentrant
    onlyOwner;

Parameters

NameTypeDescription
assetaddressThe asset to repay (USDC)
amountuint256Amount of asset to repay
interestRateModeuint256The interest rate mode at which the user wants to borrow, Not used
onBehalfOfaddressshould be equal to msg.sender

onERC721Received ​

Accepts NFT transfers only from the configured VAULT. Records the from_ address as the NFT's owner in our mapping, so that from_ can have ownership for withdraw and borrow.

solidity
function onERC721Received(address, address, uint256 tokenId_, bytes calldata) external returns (bytes4);

spell ​

Spell allows owner aka governance to do any arbitrary call on factory

solidity
function spell(address target_, bytes memory data_) external onlyOwner returns (bytes memory response_);

Parameters

NameTypeDescription
target_addressAddress to which the call needs to be delegated
data_bytesData to execute at the delegated address

receive ​

solidity
receive() external payable;

_authorizeUpgrade ​

onlyOwner is required as this contract is upgradable

solidity
function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner;