fix: Use forceApprove instead of regular Approve
This is necessary for USDT (it was failing) --- don't change below this line --- ENG-4307 Took 29 minutes
This commit is contained in:
@@ -62,7 +62,7 @@ contract CurveExecutor is IExecutor {
|
|||||||
|
|
||||||
if (tokenApprovalNeeded && tokenIn != nativeToken) {
|
if (tokenApprovalNeeded && tokenIn != nativeToken) {
|
||||||
// slither-disable-next-line unused-return
|
// slither-disable-next-line unused-return
|
||||||
IERC20(tokenIn).approve(address(pool), type(uint256).max);
|
IERC20(tokenIn).forceApprove(address(pool), type(uint256).max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inspired by Curve's router contract: https://github.com/curvefi/curve-router-ng/blob/9ab006ca848fc7f1995b6fbbecfecc1e0eb29e2a/contracts/Router.vy#L44
|
/// Inspired by Curve's router contract: https://github.com/curvefi/curve-router-ng/blob/9ab006ca848fc7f1995b6fbbecfecc1e0eb29e2a/contracts/Router.vy#L44
|
||||||
|
|||||||
@@ -266,16 +266,16 @@ contract CurveExecutorTest is Test, Constants {
|
|||||||
function testStableSwapPool() public {
|
function testStableSwapPool() public {
|
||||||
// Swapping CRVUSD -> USDT on a StableSwap pool, deployed by factory 0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d (plain pool)
|
// Swapping CRVUSD -> USDT on a StableSwap pool, deployed by factory 0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d (plain pool)
|
||||||
uint256 amountIn = 1 ether;
|
uint256 amountIn = 1 ether;
|
||||||
deal(CRVUSD_ADDR, address(curveExecutorExposed), amountIn);
|
deal(USDT_ADDR, address(curveExecutorExposed), amountIn);
|
||||||
|
|
||||||
bytes memory data =
|
bytes memory data =
|
||||||
_getData(CRVUSD_ADDR, USDT_ADDR, CRVUSD_USDT_POOL, 1);
|
_getData(USDT_ADDR, CRVUSD_ADDR, CRVUSD_USDT_POOL, 1);
|
||||||
|
|
||||||
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
|
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
|
||||||
|
|
||||||
assertEq(amountOut, 999910);
|
assertEq(amountOut, 10436946786333182306400100);
|
||||||
assertEq(
|
assertEq(
|
||||||
IERC20(USDT_ADDR).balanceOf(address(curveExecutorExposed)),
|
IERC20(CRVUSD_ADDR).balanceOf(address(curveExecutorExposed)),
|
||||||
amountOut
|
amountOut
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user