Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Preamble
Discussion: #47
Simple Summary
A pluggable asset proxy for transferring ERC20 maker assets to a taker.
Abstract
Introduce a new asset proxy that allows for a custom contract to be called that transfers ERC20 maker tokens to the taker. The asset proxy simply calls this contract and asserts that the taker's balance has increased by the required
amount
.Motivation
Liquidity is a primary concern for the 0x ecosystem. One potentially impactful way to supplement liquidity is to source liquidity from other on-chain exchanges and networks. By introducing a new asset proxy that is able to exchange taker tokens for maker tokens in an arbitrary manner, we can tap into these other liquidity sources.
Specification
A custom "bridge" contract is specified in the asset data for this asset proxy. This bridge contract is called, converting ERC20 taker tokens into maker tokens. The asset proxy then confirms that the taker's balance has increased by the
amount
required.Asset data
The
bridgeContract
does the heavy lifting of actually swapping tokens and implements theIERC20Bridge
interface:IERC20Bridge interface
Flow
makerAddress
as theIERC20Bridge
contract, with aWallet
signature type.fillOrder()
on this order.IERC20Bridge
).ERC20BridgeProxy.transferFrom()
is invoked to transferamount
of maker tokens to the taker.ERC20BridgeProxy
usesIERC20(makerToken).balanceOf()
to get the maker token balance of the taker.ERC20BridgeProxy
callsbridgeContract.withdrawTo()
.IERC20Bridge
interacts with on-chain liquidity sources to swap taker tokens for maker tokens and sending them to the taker.bridgeContract.withdrawTo()
does not return the magic value0xb5d40d78
, revert.amount
, revert.Pros and Cons
PROS
Implementation
The
ERC20BridgeProxy
would look like:A
bridgeContract
for Eth2Dai would look like:Copyright
Copyright and related rights waived via CC0.