Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await zrxVault.setStakingProxy(stakingProxy.address).awaitTransactionSuccessAsync();
await zrxVault.removeAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync();
await zrxVault.addAuthorizedAddress(governor.address).awaitTransactionSuccessAsync();
await zrxVault.transferOwnership(governor.address).awaitTransactionSuccessAsync();
logUtils.log('ZrxVault configured!');
logUtils.log('Configuring StakingProxy...');
await stakingProxy.addAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync();
const staking = new StakingContract(stakingProxy.address, provider, txDefaults);
await staking.addExchangeAddress(exchange.address).awaitTransactionSuccessAsync();
await stakingProxy.removeAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync();
await stakingProxy.addAuthorizedAddress(governor.address).awaitTransactionSuccessAsync();
await stakingProxy.transferOwnership(governor.address).awaitTransactionSuccessAsync();
logUtils.log('StakingProxy configured!');
logUtils.log('Transfering ownership of 2.0 contracts...');
const oldAssetProxyOwner = new ZeroExGovernorContract(deployedAddresses.assetProxyOwner, provider, txDefaults);
await submitAndExecuteTransactionAsync(
oldAssetProxyOwner,
deployedAddresses.exchangeV2, // Exchange 2.1 address
ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(),
);
await submitAndExecuteTransactionAsync(
oldAssetProxyOwner,
deployedAddresses.erc20Proxy,
ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(),
);
await submitAndExecuteTransactionAsync(
oldAssetProxyOwner,
deployedAddresses.erc721Proxy,
ownableInterface.transferOwnership(governor.address).getABIEncodedTransactionData(),
);
configs.zeroExGovernor.owners,
configs.zeroExGovernor.required,
configs.zeroExGovernor.secondsTimeLocked,
);
logUtils.log('Configuring Exchange...');
await exchange.setProtocolFeeCollectorAddress(stakingProxy.address).awaitTransactionSuccessAsync();
await exchange.setProtocolFeeMultiplier(new BigNumber(150000)).awaitTransactionSuccessAsync();
await exchange.registerAssetProxy(deployedAddresses.erc20Proxy).awaitTransactionSuccessAsync();
await exchange.registerAssetProxy(deployedAddresses.erc721Proxy).awaitTransactionSuccessAsync();
await exchange.registerAssetProxy(deployedAddresses.erc1155Proxy).awaitTransactionSuccessAsync();
await exchange.registerAssetProxy(deployedAddresses.multiAssetProxy).awaitTransactionSuccessAsync();
await exchange.registerAssetProxy(deployedAddresses.staticCallProxy).awaitTransactionSuccessAsync();
await exchange.registerAssetProxy(erc20BridgeProxy.address).awaitTransactionSuccessAsync();
await exchange.transferOwnership(governor.address).awaitTransactionSuccessAsync();
logUtils.log('Exchange configured!');
logUtils.log('Configuring ERC20BridgeProxy...');
await erc20BridgeProxy.addAuthorizedAddress(exchange.address).awaitTransactionSuccessAsync();
await erc20BridgeProxy.addAuthorizedAddress(deployedAddresses.multiAssetProxy).awaitTransactionSuccessAsync();
await erc20BridgeProxy.transferOwnership(governor.address).awaitTransactionSuccessAsync();
logUtils.log('ERC20BridgeProxy configured!');
logUtils.log('Configuring ZrxVault...');
await zrxVault.addAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync();
await zrxVault.setStakingProxy(stakingProxy.address).awaitTransactionSuccessAsync();
await zrxVault.removeAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync();
await zrxVault.addAuthorizedAddress(governor.address).awaitTransactionSuccessAsync();
await zrxVault.transferOwnership(governor.address).awaitTransactionSuccessAsync();
logUtils.log('ZrxVault configured!');
logUtils.log('Configuring StakingProxy...');
(err: Error) => {
logUtils.log(`Polling tokenBalance failed: ${err}`);
intervalUtils.clearAsyncExcludingInterval(tokenPollInterval);
reject(err);
},
);
public async getGithubIssuesAsync(page: number): Promise {
const url = `${this._urlBase}/repos/${this._owner}/${this._repo}/issues?access_token=${
this._accessToken
}&state=all&per_page=100&page=${page}`;
const resp = await this._limiter.schedule(() => fetchAsync(url));
const respJson: GithubIssueResponse[] = await resp.json();
if (!respJson[0]) {
logUtils.log(respJson);
}
return respJson;
}
}
public async getTokenInfoAsync(): Promise {
logUtils.log('Getting token information from Paradex.');
const resp = await fetchAsync(TOKEN_INFO_ENDPOINT, {
headers: { 'API-KEY': this._apiKey },
});
const tokens: ParadexTokenInfoResponse = await resp.json();
logUtils.log(`Got information for ${tokens.length} tokens.`);
return tokens;
}
async function getAndSaveMarketOrderbookAsync(oasisSource: OasisSource, market: OasisMarket): Promise {
logUtils.log(`${market.id}: Retrieving orderbook.`);
const orderBook = await oasisSource.getMarketOrderbookAsync(market.id);
const observedTimestamp = Date.now();
logUtils.log(`${market.id}: Parsing orders.`);
const orders = parseOasisOrders(orderBook, market, observedTimestamp);
if (orders.length > 0) {
logUtils.log(`${market.id}: Saving ${orders.length} orders.`);
const TokenOrderRepository = connection.getRepository(TokenOrder);
await TokenOrderRepository.save(orders, { chunk: Math.ceil(orders.length / BATCH_SAVE_SIZE) });
} else {
logUtils.log(`${market.id}: 0 orders to save.`);
}
}
async function getCancelEventsAsync(eventsSource: ExchangeEventsSource, endBlock: number): Promise {
logUtils.log('Checking existing cancel events...');
const repository = connection.getRepository(ExchangeCancelEvent);
const startBlock = await getStartBlockAsync(repository);
logUtils.log(`Getting cancel events starting at ${startBlock}...`);
const eventLogs = await eventsSource.getCancelEventsAsync(startBlock, endBlock);
logUtils.log('Parsing cancel events...');
const events = parseExchangeCancelEvents(eventLogs);
logUtils.log(`Retrieved and parsed ${events.length} total cancel events.`);
await saveEventsAsync(startBlock === EXCHANGE_START_BLOCK, repository, events);
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString);
const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: txData,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`WETH9 successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new WETH9Contract(
txReceipt.contractAddress as string,
provider,
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = [];
return contractInstance;
}
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString);
const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: txData,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`IWallet successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new IWalletContract(
txReceipt.contractAddress as string,
provider,
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = [];
return contractInstance;
}
[_exchange] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[_exchange],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, [_exchange]);
const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData },
txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`DutchAuction successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new DutchAuctionContract(
txReceipt.contractAddress as string,
provider,
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = [_exchange];
return contractInstance;
}