Skip to content

Commit

Permalink
👷🏻 🧹 Add semantically clear USDCToSwapForWETH variable
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyrharper committed Jul 10, 2024
1 parent 06efec5 commit e2840cc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/MarginPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ contract MarginPaymaster is IPaymaster, Zap {
address(weth),
address(_USDC)
) * 110) / 100; // 10% slippage

uint256 USDCToSwapForWETH = costOfGasInUSDC;
address sender = abi.decode(context, (address));

uint256 availableUSDCInWallet = getUSDCAvailableInWallet(sender);

// draw funds from wallet before accessing margin
Expand All @@ -108,7 +107,7 @@ contract MarginPaymaster is IPaymaster, Zap {
sUSDId,
-int256(sUSDToWithdrawFromMargin)
);
costOfGasInUSDC =
USDCToSwapForWETH =
_zapOut(sUSDToWithdrawFromMargin) +
availableUSDCInWallet;
}
Expand All @@ -121,7 +120,7 @@ contract MarginPaymaster is IPaymaster, Zap {
tokenOut: address(weth),
fee: 500, // 0.05%, top uni pool for USDC/WETH liquidity based on https://www.geckoterminal.com/base/uniswap-v3-base/pools
recipient: address(this),
amountIn: costOfGasInUSDC,
amountIn: USDCToSwapForWETH,
amountOutMinimum: actualGasCostInWei, // TODO: should this be required? -> could cause failures
sqrtPriceLimitX96: 0
});
Expand Down

0 comments on commit e2840cc

Please sign in to comment.