// Assuming that wrapper has been deployed:
IWrappedfCash wrapper = IWrappedfCash(
WrappedfCashFactory.computeAddress(2, 1664064000)
uint256 depositAmountUnderlying,
) = getDepositFromfCashLend(
100e8, // 100e18 fDAI at maturity
1664064000, // same maturity as wrapper
0.05e9, // No lending below 5% APY
block.timestamp // calculate at current time
// Approve the Notional for DAI transfers
DAI.approve(address(notional), depositAmountUnderlying);
BatchLend[] memory action = new BatchLend(1);
action[0].currencyId = 2;
action[0].useUnderlying = true;
action[0].trades = new bytes32[](1);
action[0].trades[0] = encodedTrade;
// Encode the batch lending as calldata, Notional will execute this trade
// after exectuing a transfer between accounts.
bytes memory callData = abi.encodeWithSelector(
NotionalProxy.batchLend.selector,
// In this call, Notional will do the following:
// - Transfer 100e8 fDAI to the wrapper, minting 100e8 wrapped fDAI to
// - address(this) temporarily incurs a -100e8 fDAI balance. If this is not
// collateralized, the transaction will reverti.
// - address(this) lends 100e8 fDAI to net off their fDAI balance to exactly
// zero using the batchLend encoded call.
// - address(this) now has no fDAI in Notional, and 100e8 fDAI in the wrapper
Notional.safeTransferFrom(
address(this), // Transfer fCash from this address
address(wrapper), // Send fCash to wrapper
wrapper.fCashId(), // Get the wrapper's fCash id
100e8, // Send the 100e8 fDAI being purchased above
callData // Execute the encoded trade on behalf of address(this)