Skip to content

Commit

Permalink
usdt
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielZlotin committed Oct 31, 2024
1 parent 07120ae commit c4fbb69
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 21 deletions.
37 changes: 19 additions & 18 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,25 @@ AdminWithdrawTest:test_tokens() (gas: 879919)
LiquidityHubAccessTest:test_revert_execute_onlyAllowed() (gas: 15345)
LiquidityHubAccessTest:test_revert_reactorCallback_onlyReactor() (gas: 10576)
LiquidityHubAccessTest:test_revert_validationCallback_onlySelf() (gas: 11914)
LiquidityHubExecuteTest:test_decayOnNegativeSlippage() (gas: 341784)
LiquidityHubExecuteTest:test_emitEvents() (gas: 355157)
LiquidityHubExecuteTest:test_gas() (gas: 236423)
LiquidityHubExecuteTest:test_gasToAdmin() (gas: 338749)
LiquidityHubExecuteTest:test_inTokenSlippage() (gas: 377108)
LiquidityHubExecuteTest:test_longLimit() (gas: 341287)
LiquidityHubExecuteTest:test_nativeOutput() (gas: 302419)
LiquidityHubExecuteTest:test_nativeOutputSwapperLimit() (gas: 302496)
LiquidityHubExecuteTest:test_nativeSlippageToRef() (gas: 302090)
LiquidityHubExecuteTest:test_optionalRef() (gas: 301076)
LiquidityHubExecuteTest:test_optionalRefshare() (gas: 301346)
LiquidityHubExecuteTest:test_revert_swapperLimit() (gas: 332086)
LiquidityHubExecuteTest:test_slippageToRef() (gas: 341418)
LiquidityHubExecuteTest:test_swapperLimit() (gas: 339278)
LiquidityHubExecuteTest:test_swapperLimitRespectsSurplus() (gas: 343993)
PartialOrderE2ETest:test_e2e_exactMirrorMatch() (gas: 452677)
PartialOrderE2ETest:test_e2e_multiplePartialInputs() (gas: 624846)
PartialOrderE2ETest:test_e2e_partialInputMatch() (gas: 472533)
LiquidityHubExecuteTest:test_decayOnNegativeSlippage() (gas: 352300)
LiquidityHubExecuteTest:test_emitEvents() (gas: 365709)
LiquidityHubExecuteTest:test_gas() (gas: 259247)
LiquidityHubExecuteTest:test_gasToAdmin() (gas: 349265)
LiquidityHubExecuteTest:test_inTokenSlippage() (gas: 387624)
LiquidityHubExecuteTest:test_longLimit() (gas: 351803)
LiquidityHubExecuteTest:test_nativeOutput() (gas: 302429)
LiquidityHubExecuteTest:test_nativeOutputSwapperLimit() (gas: 302506)
LiquidityHubExecuteTest:test_nativeSlippageToRef() (gas: 302100)
LiquidityHubExecuteTest:test_optionalRef() (gas: 313209)
LiquidityHubExecuteTest:test_optionalRefshare() (gas: 313425)
LiquidityHubExecuteTest:test_revert_swapperLimit() (gas: 362502)
LiquidityHubExecuteTest:test_slippageToRef() (gas: 351912)
LiquidityHubExecuteTest:test_swapperLimit() (gas: 349794)
LiquidityHubExecuteTest:test_swapperLimitRespectsSurplus() (gas: 354509)
LiquidityHubExecuteTest:test_usdtOutput() (gas: 277)
PartialOrderE2ETest:test_e2e_exactMirrorMatch() (gas: 463135)
PartialOrderE2ETest:test_e2e_multiplePartialInputs() (gas: 635296)
PartialOrderE2ETest:test_e2e_partialInputMatch() (gas: 482991)
PartialOrderReactorTest:test_execute_swapFullAmount() (gas: 199131)
PartialOrderReactorTest:test_execute_swapPartial() (gas: 309736)
PartialOrderReactorTest:test_execute_swapPartialOdd() (gas: 199121)
Expand Down
2 changes: 1 addition & 1 deletion out/LiquidityHub.sol/LiquidityHub.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/LiquidityHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ contract LiquidityHub is IReactorCallback, IValidationCallback {
}

function _outputReactor(address token, uint256 amount) private {
if (token == address(0)) Address.sendValue(payable(address(reactor)), amount);
else IERC20(token).safeIncreaseAllowance(address(reactor), amount);
if (token == address(0)) {
Address.sendValue(payable(address(reactor)), amount);
} else {
uint256 allowance = IERC20(token).allowance(address(this), address(reactor));
IERC20(token).safeApprove(address(reactor), 0);
IERC20(token).safeApprove(address(reactor), allowance + amount);
}
}

function _transfer(address token, address to, uint256 amount) private {
Expand Down
16 changes: 16 additions & 0 deletions test/LiquidityHub.execute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ contract LiquidityHubExecuteTest is BaseTest {
assertEq(swapper.balance, outAmount + (slippage / (100 - refshare)));
}

function test_usdtOutput() public {
if (block.chainid != 1) return;

outToken = ERC20Mock(0xdAC17F958D2ee523a2206206994597C13D831ec7);

SignedOrder memory order = _order();
deal(address(outToken), address(config.executor), outAmount + gasAmount + slippage);

IMulticall3.Call[] memory calls = new IMulticall3.Call[](0);
hoax(config.admin.owner());
config.executor.execute(order, calls, 0);

assertEq(inToken.balanceOf(swapper), 9 ether);
assertEq(swapper.balance, outAmount + (slippage / (100 - refshare)));
}

function test_slippageToRef() public {
SignedOrder memory order = _order();

Expand Down

0 comments on commit c4fbb69

Please sign in to comment.