// First store - OK
storeExpectedBalances(deltas1);
// Second store without compare - REVERTS
storeExpectedBalances(deltas2);
// Correct pattern:
storeExpectedBalances(deltas1);
// ... operations ...
compareBalances();
storeExpectedBalances(deltas2); // Now OK
// This reverts - nothing to compare against
compareBalances();
// If account has 10 WETH and you set delta = +5
// Expected balance = 10 + 5 = 15 WETH
// For spending tokens, use negative delta
// If spending up to 1000 USDC:
BalanceDelta({token: usdc, amount: -1000 * 10**6})
// Uniswap's amountOutMinimum is often sufficient
ISwapRouter.ExactInputSingleParams({
// ...
amountOutMinimum: minWethOut, // Built-in slippage protection
// ...
})