Skip to content

Commit

Permalink
fix: prefix incrementor
Browse files Browse the repository at this point in the history
  • Loading branch information
marktoda committed Aug 22, 2023
1 parent 0d81086 commit b0d62e3
Show file tree
Hide file tree
Showing 53 changed files with 66 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
181978
150412
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-DutchOrder-ExecuteBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
196879
196869
Original file line number Diff line number Diff line change
@@ -1 +1 @@
206650
206640
Original file line number Diff line number Diff line change
@@ -1 +1 @@
260307
260297
Original file line number Diff line number Diff line change
@@ -1 +1 @@
190411
190401
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-DutchOrder-ExecuteSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148194
148189
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133756
133751
Original file line number Diff line number Diff line change
@@ -1 +1 @@
137605
157500
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150633
150956
Original file line number Diff line number Diff line change
@@ -1 +1 @@
197283
197273
Original file line number Diff line number Diff line change
@@ -1 +1 @@
207049
207039
Original file line number Diff line number Diff line change
@@ -1 +1 @@
260720
260710
Original file line number Diff line number Diff line change
@@ -1 +1 @@
190809
190799
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148401
148396
Original file line number Diff line number Diff line change
@@ -1 +1 @@
95568
133963
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157716
157711
Original file line number Diff line number Diff line change
@@ -1 +1 @@
178116
178111
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-LimitOrderReactor-ExecuteBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
189056
189046
Original file line number Diff line number Diff line change
@@ -1 +1 @@
197889
197879
Original file line number Diff line number Diff line change
@@ -1 +1 @@
250617
250607
Original file line number Diff line number Diff line change
@@ -1 +1 @@
182582
182572
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-LimitOrderReactor-ExecuteSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
144333
144328
Original file line number Diff line number Diff line change
@@ -1 +1 @@
129895
129890
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133743
153638
Original file line number Diff line number Diff line change
@@ -1 +1 @@
363478
363463
2 changes: 1 addition & 1 deletion .forge-snapshots/EthOutputTestEthOutput.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
156223
156218
Original file line number Diff line number Diff line change
@@ -1 +1 @@
176915
176910
Original file line number Diff line number Diff line change
@@ -1 +1 @@
162907
162902
Original file line number Diff line number Diff line change
@@ -1 +1 @@
166046
166041
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146873
146868
2 changes: 1 addition & 1 deletion .forge-snapshots/ProtocolFeesGasComparisonTest-NoFees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
149267
149262
Original file line number Diff line number Diff line change
@@ -1 +1 @@
124929
124924
2 changes: 1 addition & 1 deletion .forge-snapshots/SwapRouter02ExecutorExecute.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
262973
262968
Original file line number Diff line number Diff line change
@@ -1 +1 @@
118092
118087
2 changes: 1 addition & 1 deletion .forge-snapshots/testExclusiveFillerSucceeds.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174066
174061
4 changes: 2 additions & 2 deletions src/base/ProtocolFees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract contract ProtocolFees is Owned {
);

unchecked {
for (uint256 i = 0; i < outputsLength; i++) {
for (uint256 i = 0; i < outputsLength; ++i) {
newOutputs[i] = order.outputs[i];
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ abstract contract ProtocolFees is Owned {
newOutputs[outputsLength + i] = feeOutput;

unchecked {
i++;
++i;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/DutchDecayLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ library DutchDecayLib {
uint256 outputLength = outputs.length;
result = new OutputToken[](outputLength);
unchecked {
for (uint256 i = 0; i < outputLength; i++) {
for (uint256 i = 0; i < outputLength; ++i) {
result[i] = decay(outputs[i], decayStartTime, decayEndTime);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/DutchOrderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ library DutchOrderLib {
unchecked {
bytes memory packedHashes = new bytes(32 * outputs.length);

for (uint256 i = 0; i < outputs.length; i++) {
for (uint256 i = 0; i < outputs.length; ++i) {
bytes32 outputHash = hash(outputs[i]);
assembly {
mstore(add(add(packedHashes, 0x20), mul(i, 0x20)), outputHash)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ExclusivityOverrideLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ library ExclusivityOverrideLib {
output.amount = output.amount.mulDivDown(BPS + exclusivityOverrideBps, BPS);

unchecked {
i++;
++i;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/reactors/BaseReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran
ResolvedOrder[] memory resolvedOrders = new ResolvedOrder[](ordersLength);

unchecked {
for (uint256 i = 0; i < ordersLength; i++) {
for (uint256 i = 0; i < ordersLength; ++i) {
resolvedOrders[i] = resolve(orders[i]);
}
}
Expand All @@ -81,7 +81,7 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran
ResolvedOrder[] memory resolvedOrders = new ResolvedOrder[](ordersLength);

unchecked {
for (uint256 i = 0; i < ordersLength; i++) {
for (uint256 i = 0; i < ordersLength; ++i) {
resolvedOrders[i] = resolve(orders[i]);
}
}
Expand All @@ -96,7 +96,7 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran
function _prepare(ResolvedOrder[] memory orders) internal {
uint256 ordersLength = orders.length;
unchecked {
for (uint256 i = 0; i < ordersLength; i++) {
for (uint256 i = 0; i < ordersLength; ++i) {
ResolvedOrder memory order = orders[i];
_injectFees(order);
order.validate(msg.sender);
Expand All @@ -112,7 +112,7 @@ abstract contract BaseReactor is IReactor, ReactorEvents, ProtocolFees, Reentran
// attempt to transfer all currencies to all recipients
unchecked {
// transfer output tokens to their respective recipients
for (uint256 i = 0; i < ordersLength; i++) {
for (uint256 i = 0; i < ordersLength; ++i) {
ResolvedOrder memory resolvedOrder = orders[i];
uint256 outputsLength = resolvedOrder.outputs.length;
for (uint256 j = 0; j < outputsLength; j++) {
Expand Down
2 changes: 1 addition & 1 deletion src/reactors/DutchOrderReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contract DutchOrderReactor is BaseReactor {

if (order.input.startAmount != order.input.endAmount) {
unchecked {
for (uint256 i = 0; i < order.outputs.length; i++) {
for (uint256 i = 0; i < order.outputs.length; ++i) {
if (order.outputs[i].startAmount != order.outputs[i].endAmount) {
revert InputAndOutputDecay();
}
Expand Down
2 changes: 1 addition & 1 deletion src/reactors/ExclusiveDutchOrderReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract ExclusiveDutchOrderReactor is BaseReactor {

if (order.input.startAmount != order.input.endAmount) {
unchecked {
for (uint256 i = 0; i < order.outputs.length; i++) {
for (uint256 i = 0; i < order.outputs.length; ++i) {
if (order.outputs[i].startAmount != order.outputs[i].endAmount) {
revert InputAndOutputDecay();
}
Expand Down
6 changes: 3 additions & 3 deletions src/sample-executors/SwapRouter02Executor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ contract SwapRouter02Executor is IReactorCallback, Owned {
) = abi.decode(callbackData, (address[], address[], bytes[]));

unchecked {
for (uint256 i = 0; i < tokensToApproveForSwapRouter02.length; i++) {
for (uint256 i = 0; i < tokensToApproveForSwapRouter02.length; ++i) {
ERC20(tokensToApproveForSwapRouter02[i]).safeApprove(address(swapRouter02), type(uint256).max);
}

for (uint256 i = 0; i < tokensToApproveForReactor.length; i++) {
for (uint256 i = 0; i < tokensToApproveForReactor.length; ++i) {
ERC20(tokensToApproveForReactor[i]).safeApprove(address(reactor), type(uint256).max);
}
}
Expand All @@ -94,7 +94,7 @@ contract SwapRouter02Executor is IReactorCallback, Owned {
/// @param tokensToApprove Max approve these tokens to swapRouter02
/// @param multicallData Pass into swapRouter02.multicall()
function multicall(ERC20[] calldata tokensToApprove, bytes[] calldata multicallData) external onlyOwner {
for (uint256 i = 0; i < tokensToApprove.length; i++) {
for (uint256 i = 0; i < tokensToApprove.length; ++i) {
tokensToApprove[i].safeApprove(address(swapRouter02), type(uint256).max);
}
swapRouter02.multicall(type(uint256).max, multicallData);
Expand Down
2 changes: 1 addition & 1 deletion test/base/BaseReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ abstract contract BaseReactorTest is GasSnapshot, ReactorEvents, Test, DeployPer
{
signedOrders = new SignedOrder[](requests.length);
orderHashes = new bytes32[](requests.length);
for (uint256 i = 0; i < requests.length; i++) {
for (uint256 i = 0; i < requests.length; ++i) {
(SignedOrder memory signed, bytes32 hash) = createAndSignOrder(requests[i]);
signedOrders[i] = signed;
orderHashes[i] = hash;
Expand Down
4 changes: 2 additions & 2 deletions test/base/ProtocolFees.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ contract ProtocolFeesTest is Test {
vm.assume(feeBps <= 5);
vm.assume(outputAmounts.length > 0);
OutputToken[] memory outputs = new OutputToken[](outputAmounts.length);
for (uint256 i = 0; i < outputAmounts.length; i++) {
for (uint256 i = 0; i < outputAmounts.length; ++i) {
outputs[i] = OutputToken(address(tokenOut), outputAmounts[i], RECIPIENT);
}
ResolvedOrder memory order = ResolvedOrder({
Expand All @@ -118,7 +118,7 @@ contract ProtocolFeesTest is Test {
ResolvedOrder memory afterFees = fees.takeFees(order);
assertGe(afterFees.outputs.length, outputs.length);

for (uint256 i = 0; i < outputAmounts.length; i++) {
for (uint256 i = 0; i < outputAmounts.length; ++i) {
address tokenAddress = order.outputs[i].token;
uint256 baseAmount = order.outputs[i].amount;

Expand Down
4 changes: 2 additions & 2 deletions test/lib/ExclusivityOverrideLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ contract ExclusivityOverrideLibTest is Test {
vm.assume(exclusive != address(0));
vm.assume(overrideAmt < 10000 && overrideAmt > 0);
uint256[] memory amounts = new uint256[](fuzzAmounts.length);
for (uint256 i = 0; i < fuzzAmounts.length; i++) {
for (uint256 i = 0; i < fuzzAmounts.length; ++i) {
amounts[i] = fuzzAmounts[i];
}

Expand All @@ -143,7 +143,7 @@ contract ExclusivityOverrideLibTest is Test {
vm.prank(caller);
ResolvedOrder memory handled = exclusivity.handleOverride(order, exclusive, block.timestamp + 1, overrideAmt);
// assert overrideAmt applied
for (uint256 i = 0; i < amounts.length; i++) {
for (uint256 i = 0; i < amounts.length; ++i) {
assertEq(handled.outputs[i].amount, amounts[i] * (10000 + overrideAmt) / 10000);
assertEq(handled.outputs[i].recipient, recipient);
}
Expand Down
4 changes: 2 additions & 2 deletions test/reactors/DutchOrderReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ contract DutchOrderReactorExecuteTest is PermitSignature, DeployPermit2, BaseRea
returns (SignedOrder memory signedOrder, bytes32 orderHash)
{
DutchOutput[] memory outputs = new DutchOutput[](request.outputs.length);
for (uint256 i = 0; i < request.outputs.length; i++) {
for (uint256 i = 0; i < request.outputs.length; ++i) {
OutputToken memory output = request.outputs[i];
outputs[i] = DutchOutput({
token: output.token,
Expand Down Expand Up @@ -611,7 +611,7 @@ contract DutchOrderReactorExecuteTest is PermitSignature, DeployPermit2, BaseRea

function generateSignedOrders(DutchOrder[] memory orders) private view returns (SignedOrder[] memory result) {
result = new SignedOrder[](orders.length);
for (uint256 i = 0; i < orders.length; i++) {
for (uint256 i = 0; i < orders.length; ++i) {
bytes memory sig = signOrder(swapperPrivateKey, address(permit2), orders[i]);
result[i] = SignedOrder(abi.encode(orders[i]), sig);
}
Expand Down
8 changes: 4 additions & 4 deletions test/reactors/ExclusiveDutchOrderReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ contract ExclusiveDutchOrderReactorExecuteTest is PermitSignature, DeployPermit2
returns (SignedOrder memory signedOrder, bytes32 orderHash)
{
DutchOutput[] memory outputs = new DutchOutput[](request.outputs.length);
for (uint256 i = 0; i < request.outputs.length; i++) {
for (uint256 i = 0; i < request.outputs.length; ++i) {
OutputToken memory output = request.outputs[i];
outputs[i] = DutchOutput({
token: output.token,
Expand Down Expand Up @@ -339,13 +339,13 @@ contract ExclusiveDutchOrderReactorExecuteTest is PermitSignature, DeployPermit2
tokenIn.mint(address(swapper), amountIn);
tokenIn.forceApprove(swapper, address(permit2), type(uint256).max);
uint256 amountOutSum = 0;
for (uint256 i = 0; i < amountOuts.length; i++) {
for (uint256 i = 0; i < amountOuts.length; ++i) {
amountOutSum += amountOuts[i] * (10000 + overrideAmt) / 10000;
}
tokenOut.mint(address(fillContract), uint256(amountOutSum));

uint256[] memory amounts = new uint256[](amountOuts.length);
for (uint256 i = 0; i < amountOuts.length; i++) {
for (uint256 i = 0; i < amountOuts.length; ++i) {
amounts[i] = amountOuts[i];
}

Expand Down Expand Up @@ -377,7 +377,7 @@ contract ExclusiveDutchOrderReactorExecuteTest is PermitSignature, DeployPermit2
returns (SignedOrder[] memory result)
{
result = new SignedOrder[](orders.length);
for (uint256 i = 0; i < orders.length; i++) {
for (uint256 i = 0; i < orders.length; ++i) {
bytes memory sig = signOrder(swapperPrivateKey, address(permit2), orders[i]);
result[i] = SignedOrder(abi.encode(orders[i]), sig);
}
Expand Down
Loading

0 comments on commit b0d62e3

Please sign in to comment.