Add ETH pseudo-address when wrapping/unwrapping in Multiplex multihop (#230)

* Add ETH pseudo-address when wrapping/unwrapping in Multiplex multihop

* Update changelog
This commit is contained in:
mzhu25 2021-05-05 22:29:24 -07:00 committed by GitHub
parent 1d6ca5f6b5
commit 1e6476ada7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -5,6 +5,10 @@
{ {
"note": "Tweak compiler settings for smaller sampler bytecode", "note": "Tweak compiler settings for smaller sampler bytecode",
"pr": 229 "pr": 229
},
{
"note": "Fix Multiplex multihop encoding for ETH buys/sells",
"pr": 230
} }
] ]
}, },

View File

@ -565,14 +565,17 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
private _encodeMultiplexMultiHopFillCalldata(quote: SwapQuote, opts: ExchangeProxyContractOpts): string { private _encodeMultiplexMultiHopFillCalldata(quote: SwapQuote, opts: ExchangeProxyContractOpts): string {
const wrappedMultiHopCalls = []; const wrappedMultiHopCalls = [];
const tokens: string[] = [];
if (opts.isFromETH) { if (opts.isFromETH) {
wrappedMultiHopCalls.push({ wrappedMultiHopCalls.push({
selector: DUMMY_WETH_CONTRACT.getSelector('deposit'), selector: DUMMY_WETH_CONTRACT.getSelector('deposit'),
data: NULL_BYTES, data: NULL_BYTES,
}); });
tokens.push(ETH_TOKEN_ADDRESS);
} }
const [firstHopOrder, secondHopOrder] = quote.orders; const [firstHopOrder, secondHopOrder] = quote.orders;
const intermediateToken = firstHopOrder.makerToken; const intermediateToken = firstHopOrder.makerToken;
tokens.push(quote.takerToken, intermediateToken, quote.makerToken);
for (const order of [firstHopOrder, secondHopOrder]) { for (const order of [firstHopOrder, secondHopOrder]) {
switch (order.source) { switch (order.source) {
case ERC20BridgeSource.UniswapV2: case ERC20BridgeSource.UniswapV2:
@ -607,11 +610,12 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
selector: DUMMY_WETH_CONTRACT.getSelector('withdraw'), selector: DUMMY_WETH_CONTRACT.getSelector('withdraw'),
data: NULL_BYTES, data: NULL_BYTES,
}); });
tokens.push(ETH_TOKEN_ADDRESS);
} }
return this._exchangeProxy return this._exchangeProxy
.multiHopFill( .multiHopFill(
{ {
tokens: [quote.takerToken, intermediateToken, quote.makerToken], tokens,
sellAmount: quote.worstCaseQuoteInfo.totalTakerAmount, sellAmount: quote.worstCaseQuoteInfo.totalTakerAmount,
calls: wrappedMultiHopCalls, calls: wrappedMultiHopCalls,
}, },