Batch Trades
A flexible set of methods that enable almost any combination of lending, borrowing and providing liquidity on Notional.
Batch Lend
struct BatchLend {
uint16 currencyId;
// True if the contract should try to transfer underlying tokens instead
// of asset tokens
bool depositUnderlying;
// Array of tightly packed 32 byte objects that represent trades.
bytes32[] trades;
}
// Method signature on Notional
function batchLend(address account, BatchLend[] calldata actions) external;
// Example function for encoding a BatchLend array
function encodeLendTrade(
uint16 currencyId,
uint8 marketIndex,
uint88 fCashAmount,
uint32 minImpliedRate,
bool useUnderlying
) internal pure returns (BatchLend[] memory action) {
action = new BatchLend[](1);
action[0].currencyId = currencyId;
action[0].depositUnderlying = useUnderlying;
action[0].trades = new bytes32[](1);
action[0].trades[0] = bytes32(
(uint256(uint8(TradeActionType.Lend)) << 248) |
(uint256(marketIndex) << 240) |
(uint256(fCashAmount) << 152) |
(uint256(minImpliedRate) << 120)
);
}Batch Balance Trade Action
Deposit Action
Trades
Withdraw
Examples
Deposit ETH and Borrow DAI
Lend ETH and Borrow DAI
Last updated