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

Commit

Permalink
use flash wallet address in contract-addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
dekz committed Jul 15, 2020
1 parent feaf5d4 commit fb9b8d9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
9 changes: 2 additions & 7 deletions src/services/swap_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@0x/asset-swapper';
import { SwapQuoteRequestOpts } from '@0x/asset-swapper/lib/src/types';
import { ContractAddresses, getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
import { ERC20TokenContract, ITransformERC20Contract, WETH9Contract } from '@0x/contract-wrappers';
import { ERC20TokenContract, WETH9Contract } from '@0x/contract-wrappers';
import { assetDataUtils, SupportedProvider } from '@0x/order-utils';
import { BigNumber, decodeThrownErrorAsRevertError, RevertError } from '@0x/utils';
import { TxData, Web3Wrapper } from '@0x/web3-wrapper';
Expand Down Expand Up @@ -60,7 +60,6 @@ export class SwapService {
// Result caches, stored for a few minutes and refetched
// when the result has expired
private readonly _gstBalanceResultCache: ResultCache<BigNumber>;
private readonly _flashWalletResultCache: ResultCache<string>;
private readonly _tokenDecimalResultCache: ResultCache<number>;

constructor(orderbook: Orderbook, provider: SupportedProvider) {
Expand All @@ -78,10 +77,6 @@ export class SwapService {
this._gstBalanceResultCache = createResultCache<BigNumber>(() =>
gasTokenContract.balanceOf(GST2_WALLET_ADDRESSES[CHAIN_ID]).callAsync(),
);
this._flashWalletResultCache = createResultCache<string>(() => {
const transformer = new ITransformERC20Contract(this._contractAddresses.exchangeProxy, this._provider);
return transformer.getTransformWallet().callAsync();
});
this._tokenDecimalResultCache = createResultCache<number>(
(tokenAddress: string) => serviceUtils.fetchTokenDecimalsIfRequiredAsync(tokenAddress, this._web3Wrapper),
// tslint:disable-next-line:custom-no-magic-numbers
Expand Down Expand Up @@ -387,7 +382,7 @@ export class SwapService {
// In V1 the taker is always the ExchangeProxy's FlashWallet
// as it allows us to optionally transform assets (i.e Deposit ETH into WETH)
// Since the FlashWallet is the taker it needs to be forwarded to the quote provider
takerAddress = (await this._flashWalletResultCache.getResultAsync()).result;
takerAddress = this._contractAddresses.exchangeProxyFlashWallet;
break;
default:
throw new Error(`Unsupported Swap version: ${swapVersion}`);
Expand Down
7 changes: 3 additions & 4 deletions test/rfqt_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// tslint:disable:max-file-line-count
import { ERC20BridgeSource, rfqtMocker, SignedOrder } from '@0x/asset-swapper';
import { ContractAddresses } from '@0x/contract-addresses';
import { ITransformERC20Contract, WETH9Contract } from '@0x/contract-wrappers';
import { WETH9Contract } from '@0x/contract-wrappers';
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
import { expect } from '@0x/contracts-test-utils';
import { BlockchainLifecycle, web3Factory } from '@0x/dev-utils';
Expand Down Expand Up @@ -95,9 +95,7 @@ describe(SUITE_NAME, () => {
let DEFAULT_RFQT_RESPONSE_DATA;
let signedOrder;
before(async () => {
const flashWalletAddress = await new ITransformERC20Contract(CONTRACT_ADDRESSES.exchangeProxy, provider)
.getTransformWallet()
.callAsync();
const flashWalletAddress = CONTRACT_ADDRESSES.exchangeProxyFlashWallet;
DEFAULT_RFQT_RESPONSE_DATA = {
endpoint: 'https://mock-rfqt1.club',
responseCode: 200,
Expand All @@ -112,6 +110,7 @@ describe(SUITE_NAME, () => {
};
const order: SignedOrder = {
...ganacheZrxWethOrderExchangeProxy,
takerAddress: flashWalletAddress,
makerAssetAmount: new BigNumber(ganacheZrxWethOrderExchangeProxy.makerAssetAmount),
takerAssetAmount: new BigNumber(ganacheZrxWethOrderExchangeProxy.takerAssetAmount),
takerFee: new BigNumber(ganacheZrxWethOrderExchangeProxy.takerFee),
Expand Down
1 change: 0 additions & 1 deletion test/utils/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const ganacheZrxWethOrderExchangeProxy = {
chainId: 1337,
exchangeAddress: '0x48bacb9266a570d521063ef5dd96e61686dbe788',
makerAddress: '0x5409ed021d9299bf6814279a6a1411a7e866a631',
takerAddress: '0xdec8629610e2f4087bd9cc441d10ca8be0c6f6c5',
feeRecipientAddress: '0x1000000000000000000000000000000000000011',
senderAddress: '0x0000000000000000000000000000000000000000',
makerAssetAmount: '100000000000000000',
Expand Down

0 comments on commit fb9b8d9

Please sign in to comment.