Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
fix v0/v1 logic after review
Browse files Browse the repository at this point in the history
  • Loading branch information
xianny authored and dekz committed Jun 25, 2020
1 parent ddfe7d4 commit e59a823
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/services/swap_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,19 @@ export class SwapService {
);

// set the allowance target based on version. V0 is legacy param to support Nuo integrator
let allowanceTarget;
switch (swapVersion) {
case SwapVersion.V0:
allowanceTarget = this._contractAddresses.forwarder;
break;
case SwapVersion.V1:
allowanceTarget = this._contractAddresses.exchangeProxyAllowanceTarget;
break;
default:
allowanceTarget = NULL_ADDRESS;
break;
let allowanceTarget = NULL_ADDRESS;
if (isETHSell) {
switch (swapVersion) {
case SwapVersion.V0:
allowanceTarget = this._contractAddresses.erc20Proxy;
break;
case SwapVersion.V1:
allowanceTarget = this._contractAddresses.exchangeProxyAllowanceTarget;
break;
default:
allowanceTarget = NULL_ADDRESS;
break;
}
}

const apiSwapQuote: GetSwapQuoteResponse = {
Expand Down Expand Up @@ -385,7 +387,7 @@ export class SwapService {
// as the ExchangeProxy so that it can automatically unwrap WETH to ETH. If it's not,
// then we want to request quotes with the taker set to the API's takerAddress query
// parameter, which in this context is known as `from`.
takerAddress = isETHSell ? await this._getExchangeProxyFlashWalletAsync() : from || '';
takerAddress = await this._getExchangeProxyFlashWalletAsync();
break;
default:
takerAddress = from || '';
Expand Down Expand Up @@ -438,8 +440,7 @@ export class SwapService {
extensionContractType = isFromETH ? ExtensionContractType.Forwarder : ExtensionContractType.None;
break;
case SwapVersion.V1:
extensionContractType =
isFromETH || isToETH ? ExtensionContractType.ExchangeProxy : ExtensionContractType.None;
extensionContractType = ExtensionContractType.ExchangeProxy;
break;
default:
break;
Expand Down

0 comments on commit e59a823

Please sign in to comment.