testSwapBuyWethIntegral passed
This commit is contained in:
@@ -66,4 +66,35 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes {
|
||||
}
|
||||
}
|
||||
|
||||
function testSwapBuyWethIntegral(uint256 specifiedAmount) public {
|
||||
OrderSide side = OrderSide.Buy;
|
||||
|
||||
bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR));
|
||||
|
||||
uint256[] memory limits = adapter.getLimits(pair, USDC, WETH);
|
||||
|
||||
vm.assume(specifiedAmount < limits[1]);
|
||||
vm.assume(specifiedAmount > limits[3]);
|
||||
|
||||
deal(address(USDC), address(this), type(uint256).max);
|
||||
USDC.approve(address(adapter), type(uint256).max);
|
||||
|
||||
uint256 usdc_balance = USDC.balanceOf(address(this));
|
||||
uint256 weth_balance = WETH.balanceOf(address(this));
|
||||
|
||||
Trade memory trade = adapter.swap(pair, USDC, WETH, side, specifiedAmount);
|
||||
|
||||
if (trade.calculatedAmount > 0) {
|
||||
assertEq(specifiedAmount,
|
||||
WETH.balanceOf(address(this)) + weth_balance
|
||||
);
|
||||
|
||||
assertEq(
|
||||
trade.calculatedAmount,
|
||||
usdc_balance - USDC.balanceOf(address(this))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user