FluidWETHWrapper ​
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 ​
IWETH9 public immutable WETH;
VAULT ​
IFluidVaultT1 public immutable VAULT;
BORROW_TOKEN ​
below variables can be derived directly or indirectly using vault address
address public immutable BORROW_TOKEN;
VAULT_FACTORY ​
address public immutable VAULT_FACTORY;
LIQUIDITY ​
address public immutable LIQUIDITY;
VAULT_ID ​
uint256 public immutable VAULT_ID;
X8 ​
uint256 internal constant X8 = 0xff;
X19 ​
uint256 internal constant X19 = 0x7ffff;
X24 ​
uint256 internal constant X24 = 0xffffff;
X64 ​
uint256 internal constant X64 = 0xffffffffffffffff;
nftId ​
uint64 public nftId;
Functions ​
constructor ​
constructor(address vaultAddress_, address weth_);
Parameters
Name | Type | Description |
---|---|---|
vaultAddress_ | address | Fluid Vault address |
weth_ | address | WETH token address |
initialize ​
function initialize() public initializer;
_calculateStorageSlotUintMapping ​
function _calculateStorageSlotUintMapping(uint256 slot_, uint256 key_) internal pure returns (bytes32);
_calculateStorageSlotIntMapping ​
function _calculateStorageSlotIntMapping(uint256 slot_, int256 key_) internal pure returns (bytes32);
_getPositionDataRaw ​
function _getPositionDataRaw() internal view returns (uint256);
_getVaultVariables2Raw ​
function _getVaultVariables2Raw() internal view returns (uint256);
getTickDataRaw ​
function getTickDataRaw(int256 tick_) internal view returns (uint256);
_getPositionBorrow ​
function _getPositionBorrow() internal view returns (uint256 borrow);
_getPositionSupply ​
function _getPositionSupply() internal view returns (uint256 supply);
getPosition ​
get the vault nft position on vault
function getPosition() external view returns (uint256, uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | supply amount |
<none> | uint256 | borrow amount |
supply ​
Deposit WETH as collateral to a T1 VAULT.
- If
nftId
== 0, new vault position gets created (NFT mint to this)
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)
external
nonReentrant
onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
asset | address | The asset to deposit in contract (weth) |
amount | uint256 | Amount of asset to deposit as collateral |
onBehalfOf | address | Deposit on behalf of, should be same as msg.sender |
referralCode | uint16 | Un-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.
function withdraw(address asset, uint256 amount, address to) external nonReentrant onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
asset | address | The asset to deposit in contract (weth) |
amount | uint256 | Amount of asset to borrow as collateral |
to | address | withdraw should go to this address |
borrow ​
Borrow in USDC from vault, the vault will send ETH to this contract.
function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf)
external
nonReentrant
onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
asset | address | The asset to borrow |
amount | uint256 | Amount of asset to borrow |
interestRateMode | uint256 | The interest rate mode at which the user wants to borrow, Not used |
referralCode | uint16 | The code used to register the integrator originating the operation, for potential rewards.NA |
onBehalfOf | address | The address of the user who will receive the debt. |
repay ​
Repay debt in USDC to VAULT.
function repay(address asset, uint256 amount, uint256 interestRateMode, address onBehalfOf)
external
nonReentrant
onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
asset | address | The asset to repay (USDC) |
amount | uint256 | Amount of asset to repay |
interestRateMode | uint256 | The interest rate mode at which the user wants to borrow, Not used |
onBehalfOf | address | should 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.
function onERC721Received(address, address, uint256 tokenId_, bytes calldata) external returns (bytes4);
spell ​
Spell allows owner aka governance to do any arbitrary call on factory
function spell(address target_, bytes memory data_) external onlyOwner returns (bytes memory response_);
Parameters
Name | Type | Description |
---|---|---|
target_ | address | Address to which the call needs to be delegated |
data_ | bytes | Data to execute at the delegated address |
receive ​
receive() external payable;
_authorizeUpgrade ​
onlyOwner is required as this contract is upgradable
function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner;