Merge pull request #2616 from 0xProject/fix/dfb-revert

Fix DFB instability
This commit is contained in:
Lawrence Forman
2020-07-07 01:08:51 -04:00
committed by GitHub
5 changed files with 31 additions and 21 deletions

View File

@@ -1,4 +1,13 @@
[
{
"version": "3.3.1",
"changes": [
{
"note": "Fix instability with DFB.",
"pr": 2616
}
]
},
{
"version": "3.3.0",
"changes": [

View File

@@ -75,14 +75,18 @@ contract DexForwarderBridge is
freesGasTokensFromCollector
returns (bytes4 success)
{
require(msg.sender == _getERC20BridgeProxyAddress(), "DexForwarderBridge/SENDER_NOT_AUTHORIZED");
require(
msg.sender == _getERC20BridgeProxyAddress(),
"DexForwarderBridge/SENDER_NOT_AUTHORIZED"
);
TransferFromState memory state;
(
state.inputToken,
state.calls
) = abi.decode(bridgeData, (address, BridgeCall[]));
state.initialInputTokenBalance = IERC20Token(state.inputToken).balanceOf(address(this));
state.initialInputTokenBalance =
IERC20Token(state.inputToken).balanceOf(address(this));
for (uint256 i = 0; i < state.calls.length; ++i) {
// Stop if the we've sold all our input tokens.
@@ -122,11 +126,6 @@ contract DexForwarderBridge is
);
}
}
// Revert if we were not able to sell our entire input token balance.
require(
state.totalInputTokenSold >= state.initialInputTokenBalance,
"DexForwarderBridge/INCOMPLETE_FILL"
);
// Always succeed.
return BRIDGE_SUCCESS;
}

View File

@@ -30,7 +30,6 @@ blockchainTests.resets('DexForwarderBridge unit tests', env => {
const BRIDGE_SUCCESS = '0xdc1600f3';
const BRIDGE_FAILURE = '0xffffffff';
const BRIDGE_REVERT_ERROR = 'oopsie';
const INCOMPLETE_FILL_REVERT = 'DexForwarderBridge/INCOMPLETE_FILL';
const NOT_AUTHORIZED_REVERT = 'DexForwarderBridge/SENDER_NOT_AUTHORIZED';
const DEFAULTS = {
toAddress: randomAddress(),
@@ -165,27 +164,26 @@ blockchainTests.resets('DexForwarderBridge unit tests', env => {
await callBridgeTransferFromAsync({ bridgeData, sellAmount: ZERO_AMOUNT });
});
it('fails with no bridge calls and an input balance', async () => {
it('succeeds with no bridge calls and an input balance', async () => {
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls: [],
});
return expect(callBridgeTransferFromAsync({ bridgeData, sellAmount: new BigNumber(1) })).to.revertWith(
INCOMPLETE_FILL_REVERT,
);
await callBridgeTransferFromAsync({
bridgeData,
sellAmount: new BigNumber(1),
});
});
it('fails if entire input token balance is not consumed', async () => {
it('succeeds if entire input token balance is not consumed', async () => {
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls: allBridgeCalls,
});
return expect(
callBridgeTransferFromAsync({
bridgeData,
sellAmount: totalFillableInputAmount.plus(1),
}),
).to.revertWith(INCOMPLETE_FILL_REVERT);
await callBridgeTransferFromAsync({
bridgeData,
sellAmount: totalFillableInputAmount.plus(1),
});
});
it('fails if not authorized', async () => {

View File

@@ -9,6 +9,10 @@
{
"note": "Add EP flash wallet and affiliate fee transformer",
"pr": 2622
},
{
"note": "Update DFB addresses",
"pr": 2616
}
]
},

View File

@@ -31,7 +31,7 @@
"chainlinkStopLimit": "0xeb27220f95f364e1d9531992c48613f231839f53",
"curveBridge": "0x6dc7950423ada9f56fb2c93a23edb787f1e29088",
"maximumGasPrice": "0xe2bfd35306495d11e3c9db0d8de390cda24563cf",
"dexForwarderBridge": "0x5591360f8c7640fea5771c9682d6b5ecb776e1f8",
"dexForwarderBridge": "0xc47b7094f378e54347e281aab170e8cca69d880a",
"multiBridge": "0xc03117a8c9bde203f70aa911cb64a7a0df5ba1e1",
"exchangeProxyGovernor": "0x618f9c67ce7bf1a50afa1e7e0238422601b0ff6e",
"exchangeProxy": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
@@ -169,7 +169,7 @@
"chainlinkStopLimit": "0x0000000000000000000000000000000000000000",
"curveBridge": "0x90c62c91a9f655f4f739e6cee85c84f9ccf47323",
"maximumGasPrice": "0x67a094cf028221ffdd93fc658f963151d05e2a74",
"dexForwarderBridge": "0x6cce442a48ab07635462a40594054f34f44195ff",
"dexForwarderBridge": "0x0ea9f5c5cf7a4e6630cb01c5cca11d289963b188",
"multiBridge": "0x0000000000000000000000000000000000000000",
"exchangeProxyGovernor": "0x618f9c67ce7bf1a50afa1e7e0238422601b0ff6e",
"exchangeProxy": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",