Wrapped fCash
A simplified compatibility wrapper for lending and holding fCash.
Wrapped fCash (wfCash) is a compatibility layer for developers who want to integrate with Notional lending but unable to use fCash's native ERC1155 specification. wfCash is compatible with ERC20 and ERC4626.
Technical Walkthrough: https://www.youtube.com/watch?v=RvCYFR2Yjls
GitHub: https://github.com/notional-finance/wrapped-fcash
Deployment
Each wfCash contract is deployed from the WrappedfCashFactory
using a CREATE2
opcode and parameterized by a currency id and a maturity. Currency IDs are autoincrementing IDs generated by the Notional contract and correspond to a currency pair (i.e. USDC/cUSDC, DAI/cDAI, etc) that can be lent and borrowed on Notional.
The maturity is the unix timestamp of the block time when the fCash will mature.
One canonical wfCash contract can be deployed permissionlessly for every currencyId and maturity combination through the WrappedfCashFactory. Each wfCash contract is a OpenZeppelin BeaconProxy
that refers to a single BeaconImplementation
of the wfCashERC4626
contract.
The ERC4626 standard stipulates a single asset token for the contract. In this case we use the underlying token (i.e. DAI, USDC) rather than the money market token (i.e. cDAI, cUSDC). This choice was made in case the money market token changes in the future, the underlying token will not change in the future. As a consequence, ERC4626 interactions will be less gas efficient.
Example: Deploying an wfCash Wrapper
Lending (Minting wfCash)
Lending fCash can be done by calling mintViaAsset
, mintViaUnderlying
, mint
or deposit
. ERC4626 is provided as a compatibility layer but due to the computation required it is not the most gas efficient implementation. Using the non-ERC4626 mintViaAsset
or mintViaUnderlying
function is significantly more gas efficient and allows the user to apply slippage restrictions.
Creating wfCash tokens can also be done by using an ERC1155 safeTransferFrom
to the corresponding wfCash contract from the main Notional contract. This allows accounts to seamlessly enter and exit wfCash positions from Notional ERC1155.
Notional ERC1155 fCash is automatically considered as collateral for borrowing. However, wfCash cannot be used in this way since it is held in escrow by the wfCash contract. This should not be a limitation for lend-only accounts.
Example: Minting Directly from wfCash
Example: Mint via ERC1155 Transfer
This achieves the same as the method calls above but is approximately 20% more gas efficient if most of the computation is done off chain.
Redemption
wfCash can be redeemed anytime before or after maturity. Redeeming fCash prior to maturity means selling it on Notional for cash (i.e. underlying or money market tokens). Selling fCash is subject to prevailing market interest rates and therefore does not guarantee that the holder will receive their promised fixed interest.
fCash (and wfCash is no different) settles to money market tokens (i.e. cTokens or aTokens) at maturity and will accrue the variable money market interest rate from that point forward. Accounts that redeem their wfCash after maturity will receive their fixed interest as well as any accrued variable rate interest on top.
Before or after maturity, redeeming wfCash can be done by calling redeem
, redeemToUnderlying
, redeemToAsset
, or withdraw
. Accounts are also able to call redeem
and specify the transferfCash
boolean in RedeemOpts
to have the wfCash transfer the ERC1155 fCash token to their Notional account.
Do NOT expect that the withdraw
method will return exactly the amount of assets specified. Due to rounding issues embedded within the contracts, there will be a dust amount of difference between the amount of assets supplied to the method and how much it actually withdraws to the user. Use balanceOf before and after the method call to get the exact amount of assets withdrawn.
withdraw
will transfer slightly less than the amount specified, to ensure that it always transfers slightly more increase the the amount specified by 10^(native token decimals - 4). (i.e. for 6 decimal USDC increase by 10^2 and for 10^18 DAI increase by 10^14).
redeem
does not have these issues and can be used for more accurate accounting.
Example: Redeeming wfCash
Last updated