@0x/asset-swapper: Use IZeroExContract in EP swap quote consumer.

This commit is contained in:
Lawrence Forman
2020-08-20 16:56:40 -04:00
parent 3cd03ed0f1
commit b30f87f50c
2 changed files with 9 additions and 5 deletions

View File

@@ -37,6 +37,10 @@
{
"note": "Add `refundReceiver` to `ExchangeProxySwapQuoteConsumer` options.",
"pr": 2657
},
{
"note": "Use `IZeroExContract` in EP swap quote consumer.",
"pr": "TODO"
}
]
},

View File

@@ -1,5 +1,5 @@
import { ContractAddresses } from '@0x/contract-addresses';
import { ITransformERC20Contract } from '@0x/contract-wrappers';
import { IZeroExContract } from '@0x/contract-wrappers';
import {
assetDataUtils,
encodeAffiliateFeeTransformerData,
@@ -45,7 +45,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
affiliateFeeTransformer: number;
};
private readonly _transformFeature: ITransformERC20Contract;
private readonly _exchangeProxy: IZeroExContract;
constructor(
supportedProvider: SupportedProvider,
@@ -58,7 +58,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
this.provider = provider;
this.chainId = chainId;
this.contractAddresses = contractAddresses;
this._transformFeature = new ITransformERC20Contract(contractAddresses.exchangeProxy, supportedProvider);
this._exchangeProxy = new IZeroExContract(contractAddresses.exchangeProxy, supportedProvider);
this.transformerNonces = {
wethTransformer: findTransformerNonce(
contractAddresses.transformers.wethTransformer,
@@ -165,7 +165,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
});
const minBuyAmount = BigNumber.max(0, quote.worstCaseQuoteInfo.makerAssetAmount.minus(buyTokenFeeAmount));
const calldataHexString = this._transformFeature
const calldataHexString = this._exchangeProxy
.transformERC20(
isFromETH ? ETH_TOKEN_ADDRESS : sellToken,
isToETH ? ETH_TOKEN_ADDRESS : buyToken,
@@ -183,7 +183,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
return {
calldataHexString,
ethAmount,
toAddress: this._transformFeature.address,
toAddress: this._exchangeProxy.address,
allowanceTarget: this.contractAddresses.exchangeProxyAllowanceTarget,
};
}