Skip to content

Commit c73c32d

Browse files
authored
Merge pull request #368 from 1inch/audit/oz-n-05
[SC-1465] Consistent Order Within a Contract
2 parents 60d57d8 + a32f3b5 commit c73c32d

File tree

2 files changed

+42
-44
lines changed

2 files changed

+42
-44
lines changed

contracts/extensions/FeeTaker.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,6 @@ contract FeeTaker is IPostInteraction, AmountGetterWithFee, Ownable {
161161
}
162162
}
163163

164-
/**
165-
* @dev Parses fee data from `extraData`.
166-
* Override this function if whitelist structure in postInteraction is different from getters.
167-
*/
168-
function _isWhitelistedPostInteractionImpl(bytes calldata whitelistData, address taker) internal view virtual returns (bool isWhitelisted, bytes calldata tail) {
169-
return _isWhitelistedGetterImpl(whitelistData, taker);
170-
}
171-
172164
/**
173165
* @dev Calculates fee amounts depending on whether the taker is in the whitelist and whether they have an _ACCESS_TOKEN.
174166
* `extraData` consists of:
@@ -189,6 +181,14 @@ contract FeeTaker is IPostInteraction, AmountGetterWithFee, Ownable {
189181
protocolFeeAmount = takingAmount.mulDiv(resolverFee, denominator) + integratorFeeTotal - integratorFeeAmount;
190182
}
191183

184+
/**
185+
* @dev Parses fee data from `extraData`.
186+
* Override this function if whitelist structure in postInteraction is different from getters.
187+
*/
188+
function _isWhitelistedPostInteractionImpl(bytes calldata whitelistData, address taker) internal view virtual returns (bool isWhitelisted, bytes calldata tail) {
189+
return _isWhitelistedGetterImpl(whitelistData, taker);
190+
}
191+
192192
function _sendEth(address target, uint256 amount) private {
193193
(bool success, ) = target.call{value: amount}("");
194194
if (!success) {

contracts/interfaces/IOrderMixin.sol

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,12 @@ interface IOrderMixin {
7373
);
7474

7575
/**
76-
* @notice Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes
77-
* @param maker Maker address
78-
* @param slot Slot number to return bitmask for
79-
* @return result Each bit represents whether corresponding was already invalidated
80-
*/
81-
function bitInvalidatorForOrder(address maker, uint256 slot) external view returns(uint256 result);
82-
83-
/**
84-
* @notice Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes
85-
* @param maker Address of the order maker
86-
* @param orderHash Hash of the order
87-
* @return remaining Remaining amount of the order
88-
*/
89-
function remainingInvalidatorForOrder(address maker, bytes32 orderHash) external view returns(uint256 remaining);
90-
91-
/**
92-
* @notice Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes
93-
* @param maker Address of the order maker
94-
* @param orderHash Hash of the order
95-
* @return remainingRaw Inverse of the remaining amount of the order if order was filled at least once, otherwise 0
76+
* @notice Delegates execution to custom implementation. Could be used to validate if `transferFrom` works properly
77+
* @dev The function always reverts and returns the simulation results in revert data.
78+
* @param target Addresses that will be delegated
79+
* @param data Data that will be passed to delegatee
9680
*/
97-
function rawRemainingInvalidatorForOrder(address maker, bytes32 orderHash) external view returns(uint256 remainingRaw);
81+
function simulate(address target, bytes calldata data) external;
9882

9983
/**
10084
* @notice Cancels order's quote
@@ -117,21 +101,6 @@ interface IOrderMixin {
117101
*/
118102
function bitsInvalidateForOrder(MakerTraits makerTraits, uint256 additionalMask) external;
119103

120-
/**
121-
* @notice Returns order hash, hashed with limit order protocol contract EIP712
122-
* @param order Order
123-
* @return orderHash Hash of the order
124-
*/
125-
function hashOrder(IOrderMixin.Order calldata order) external view returns(bytes32 orderHash);
126-
127-
/**
128-
* @notice Delegates execution to custom implementation. Could be used to validate if `transferFrom` works properly
129-
* @dev The function always reverts and returns the simulation results in revert data.
130-
* @param target Addresses that will be delegated
131-
* @param data Data that will be passed to delegatee
132-
*/
133-
function simulate(address target, bytes calldata data) external;
134-
135104
/**
136105
* @notice Fills order's quote, fully or partially (whichever is possible).
137106
* @param order Order quote to fill
@@ -213,4 +182,33 @@ interface IOrderMixin {
213182
TakerTraits takerTraits,
214183
bytes calldata args
215184
) external returns(uint256 makingAmount, uint256 takingAmount, bytes32 orderHash);
185+
186+
/**
187+
* @notice Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes
188+
* @param maker Maker address
189+
* @param slot Slot number to return bitmask for
190+
* @return result Each bit represents whether corresponding was already invalidated
191+
*/
192+
function bitInvalidatorForOrder(address maker, uint256 slot) external view returns(uint256 result);
193+
194+
/**
195+
* @notice Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes
196+
* @param orderHash Hash of the order
197+
* @return remaining Remaining amount of the order
198+
*/
199+
function remainingInvalidatorForOrder(address maker, bytes32 orderHash) external view returns(uint256 remaining);
200+
201+
/**
202+
* @notice Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes
203+
* @param orderHash Hash of the order
204+
* @return remainingRaw Inverse of the remaining amount of the order if order was filled at least once, otherwise 0
205+
*/
206+
function rawRemainingInvalidatorForOrder(address maker, bytes32 orderHash) external view returns(uint256 remainingRaw);
207+
208+
/**
209+
* @notice Returns order hash, hashed with limit order protocol contract EIP712
210+
* @param order Order
211+
* @return orderHash Hash of the order
212+
*/
213+
function hashOrder(IOrderMixin.Order calldata order) external view returns(bytes32 orderHash);
216214
}

0 commit comments

Comments
 (0)