Compare commits

...

3 Commits

Author SHA1 Message Date
dextracker
b0b76024d5 prettier and lint 2023-04-05 14:48:59 -04:00
dextracker
16039a7193 add deprecated tag 2023-04-05 14:32:41 -04:00
dextracker
b67ec9548a remove old fallback function sell/buy enforcement logic 2023-04-05 10:28:27 -04:00

View File

@ -119,7 +119,9 @@ contract FillQuoteTransformer is Transformer {
/// @dev Intermediate state variables to get around stack limits. /// @dev Intermediate state variables to get around stack limits.
struct FillState { struct FillState {
uint256 ethRemaining; uint256 ethRemaining;
/// deprecated
uint256 boughtAmount; uint256 boughtAmount;
/// deprecated
uint256 soldAmount; uint256 soldAmount;
uint256 protocolFee; uint256 protocolFee;
uint256 takerTokenBalanceRemaining; uint256 takerTokenBalanceRemaining;
@ -208,19 +210,6 @@ contract FillQuoteTransformer is Transformer {
// Fill the orders. // Fill the orders.
for (uint256 i = 0; i < data.fillSequence.length; ++i) { for (uint256 i = 0; i < data.fillSequence.length; ++i) {
// Check if we've hit our targets.
if (data.side == Side.Sell) {
// Market sell check.
if (state.soldAmount >= data.fillAmount) {
break;
}
} else {
// Market buy check.
if (state.boughtAmount >= data.fillAmount) {
break;
}
}
state.currentOrderType = OrderType(data.fillSequence[i]); state.currentOrderType = OrderType(data.fillSequence[i]);
uint256 orderIndex = state.currentIndices[uint256(state.currentOrderType)]; uint256 orderIndex = state.currentIndices[uint256(state.currentOrderType)];
// Fill the order. // Fill the order.
@ -238,30 +227,10 @@ contract FillQuoteTransformer is Transformer {
} }
// Accumulate totals. // Accumulate totals.
state.soldAmount = state.soldAmount.safeAdd(results.takerTokenSoldAmount);
state.boughtAmount = state.boughtAmount.safeAdd(results.makerTokenBoughtAmount);
state.ethRemaining = state.ethRemaining.safeSub(results.protocolFeePaid); state.ethRemaining = state.ethRemaining.safeSub(results.protocolFeePaid);
state.takerTokenBalanceRemaining = state.takerTokenBalanceRemaining.safeSub(results.takerTokenSoldAmount);
state.currentIndices[uint256(state.currentOrderType)]++; state.currentIndices[uint256(state.currentOrderType)]++;
} }
// Ensure we hit our targets.
if (data.side == Side.Sell) {
// Market sell check.
if (state.soldAmount < data.fillAmount) {
LibTransformERC20RichErrors
.IncompleteFillSellQuoteError(address(data.sellToken), state.soldAmount, data.fillAmount)
.rrevert();
}
} else {
// Market buy check.
if (state.boughtAmount < data.fillAmount) {
LibTransformERC20RichErrors
.IncompleteFillBuyQuoteError(address(data.buyToken), state.boughtAmount, data.fillAmount)
.rrevert();
}
}
// Refund unspent protocol fees. // Refund unspent protocol fees.
if (state.ethRemaining > 0 && data.refundReceiver != address(0)) { if (state.ethRemaining > 0 && data.refundReceiver != address(0)) {
bool transferSuccess; bool transferSuccess;