Why didn't support token to ETH trade?


#1

Hello, any one here? I saw 0x v2 added an forwarder contract address, but it can only support ETH to token, why didn’t you consider of supporting token to ETH trade?


#2

When you submit an Ethereum transaction, you can specify an amount of ETH to go with the transaction. That means in a single transaction you can send ETH along with the trade you want to execute, the contract can convert your ETH into WETH, and execute any trades you’ve provided it in a single transaction.

You can’t do the same thing with tokens. You have to set allowances to be able to trade tokens; within Ethereum there’s no way around this. So if you’re trading tokens, you have to have one transaction to set allowances for your tokens and another transaction to execute the trade. You could potentially have a contract that trades tokens based on your allowances then converts WETH back to ETH before it sends it to you, but you’d still have to have at least two transactions to set allowances before executing the trade.


#3

Thank you for your reply!

According to this, we wanna to design a proxy wrapper contract, the flow like this:

User(Maker)
Taker(MarketMaker)
PW(Our proxy wrapper contract)
0xEX(0x exchange contract)
0xPC(0x proxy contract)
0xET(0x etherToken contract)

TokenA
WETH

User set TokenA allowance to PW
PW set TokenA allowance to 0xPC

  1. User place a order
    makerToken is TokenA
    takerToken is WETH

  2. taker send a fillOrder tx to PW

  3. PW transfer User’s TokenA to PW

  4. PW generate a new order, almost same data with original order, only salt, signature, maker, taker(taker address specified as “taker”) is different

  5. PW send a fillOrder tx to 0xEX

  6. 0xEX notify that 0xPC to transfer PW’s TokenA to taker

  7. 0xEX notify that 0xPC to transfer taker’s WETH to PW

  8. PW send a withdraw tx to 0x 0xET, and get ETH back

  9. PW send a internal tx, transfer ETH to User

And the step 2-9, is within one transaction, Dose it could be be possible?