-
Notifications
You must be signed in to change notification settings - Fork 465
@0x/contracts-exchange-forwarder
: ERC20Bridge buy support in Forwarder
#2356
Conversation
e05d09f
to
91774b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought of another edge case that I couldn't comment on in this review: what happens if the ERC20Bridge
transfer actually transfers more of the asset than expected? This isn't reflected in the fillResults
.
contracts/exchange-forwarder/contracts/src/MixinExchangeWrapper.sol
Outdated
Show resolved
Hide resolved
contracts/exchange-forwarder/contracts/src/libs/LibConstants.sol
Outdated
Show resolved
Hide resolved
contracts/exchange-forwarder/contracts/src/MixinExchangeWrapper.sol
Outdated
Show resolved
Hide resolved
contracts/exchange-forwarder/contracts/src/MixinExchangeWrapper.sol
Outdated
Show resolved
Hide resolved
|
"pr": 2356 | ||
} | ||
], | ||
"timestamp": 1574461784 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No timestamp for unpublished versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, these changes look solid!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good!
Just some small changes and a Q, but otherwise g2g.
.transferAssetToSender(erc721AssetData, invalidAmount) | ||
.awaitTransactionSuccessAsync({ from: receiver }); | ||
const expectedError = new ForwarderRevertErrors.Erc721AmountMustEqualOneError(invalidAmount); | ||
expect(tx).to.revertWith(expectedError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(tx).to.revertWith(expectedError); | |
return expect(tx).to.revertWith(expectedError); |
.transferAssetToSender(randomBytes, TRANSFER_AMOUNT) | ||
.awaitTransactionSuccessAsync({ from: receiver }); | ||
const expectedError = new ForwarderRevertErrors.UnsupportedAssetProxyError(hexSlice(randomBytes, 0, 4)); | ||
expect(tx).to.revertWith(expectedError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(tx).to.revertWith(expectedError); | |
return expect(tx).to.revertWith(expectedError); |
import { deployForwarderAsync } from './deploy_forwarder'; | ||
import { ForwarderTestFactory } from './forwarder_test_factory'; | ||
|
||
blockchainTests.resets.only('Forwarder <> ERC20Bridge integration tests', env => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blockchainTests.resets.only('Forwarder <> ERC20Bridge integration tests', env => { | |
blockchainTests.resets('Forwarder <> ERC20Bridge integration tests', env => { |
// Account for the ERC20Bridge transfering more of the maker asset than expected. | ||
if (makerAssetProxyId == erc20BridgeProxyId) { | ||
uint256 balanceAfter = IERC20Token(tokenAddress).balanceOf(address(this)); | ||
makerAssetAcquiredAmount = LibSafeMath.max256( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we just set makerAssetAcquiredAmount
to max(makerAssetAcquiredAmount, balanceAfter)
? Would that be so wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two edge cases:
- someone accidentally transfers tokens to the Forwarder
makerAsset
is WETH, which seems silly but given the flexibility of the bridge pattern I could see there being a use case for this at some point 🤷♂
@0x/contracts-exchange-forwarder
: ERC20Bridge buy support in Forwarder
210bc91
to
4157665
Compare
Description
Adds support for ERC20Bridge orders in the Forwarder. The changes to the Forwarder contracts themselves are pretty small, the only notable exception is the addition of an
_isPercentageFee
function which checks whether thetakerFeeAssetData
is equalish to themakerAssetData
, e.g. we support orders where the maker asset if from an ERC20 bridge and the taker fee asset is the non-bridge equivalent.The bulk of the code additions are from test stuff, including:
_isPercentageFee
and_transferAssetToSender
ERC20BridgeProxy
to theDeploymentManager
Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.