Lawrence Forman 5083fab06a
That time DevUtils wouldn't die (#97)
* `@0x/contracts-utils`: Allow for excess return data in `LibERC20TokenV06` compat* functions

* `@0x/contracts-zero-ex`: Add DevUtils-like functions to `NativeOrdersFeature`

* `@0x/contract-artifacts`: Update IZeroEx artifact

* `@0x/contract-wrappers`: Update IZeroExContract wrapper

* `@0x/contracts-zero-ex`: Address review feedback

* `@0x/contracts-utils`: Add `LibSafeMathV06.safeDowncastToUint128()`

* `@0x/contracts-zero-ex`: Fix changelog and add cancelled get relevant state tests

* `@0x/contracts-utils`: Fix changelog

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-01-04 17:52:29 -05:00

6634 lines
275 KiB
TypeScript

// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable
import {
AwaitTransactionSuccessOpts,
ContractFunctionObj,
ContractTxFunctionObj,
SendTransactionOpts,
BaseContract,
SubscriptionManager,
PromiseWithTransactionHash,
methodAbiToFunctionSignature,
linkLibrariesInBytecode,
} from '@0x/base-contract';
import { schemas } from '@0x/json-schemas';
import {
BlockParam,
BlockParamLiteral,
BlockRange,
CallData,
ContractAbi,
ContractArtifact,
DecodedLogArgs,
LogWithDecodedArgs,
MethodAbi,
TransactionReceiptWithDecodedLogs,
TxData,
TxDataPayable,
SupportedProvider,
} from 'ethereum-types';
import { BigNumber, classUtils, hexUtils, logUtils, providerUtils } from '@0x/utils';
import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert';
import * as ethers from 'ethers';
// tslint:enable:no-unused-variable
export type IZeroExEventArgs =
| IZeroExLimitOrderFilledEventArgs
| IZeroExMetaTransactionExecutedEventArgs
| IZeroExMigratedEventArgs
| IZeroExOrderCancelledEventArgs
| IZeroExOwnershipTransferredEventArgs
| IZeroExPairCancelledLimitOrdersEventArgs
| IZeroExPairCancelledRfqOrdersEventArgs
| IZeroExProxyFunctionUpdatedEventArgs
| IZeroExQuoteSignerUpdatedEventArgs
| IZeroExRfqOrderFilledEventArgs
| IZeroExRfqOrderOriginsAllowedEventArgs
| IZeroExTransformedERC20EventArgs
| IZeroExTransformerDeployerUpdatedEventArgs;
export enum IZeroExEvents {
LimitOrderFilled = 'LimitOrderFilled',
MetaTransactionExecuted = 'MetaTransactionExecuted',
Migrated = 'Migrated',
OrderCancelled = 'OrderCancelled',
OwnershipTransferred = 'OwnershipTransferred',
PairCancelledLimitOrders = 'PairCancelledLimitOrders',
PairCancelledRfqOrders = 'PairCancelledRfqOrders',
ProxyFunctionUpdated = 'ProxyFunctionUpdated',
QuoteSignerUpdated = 'QuoteSignerUpdated',
RfqOrderFilled = 'RfqOrderFilled',
RfqOrderOriginsAllowed = 'RfqOrderOriginsAllowed',
TransformedERC20 = 'TransformedERC20',
TransformerDeployerUpdated = 'TransformerDeployerUpdated',
}
export interface IZeroExLimitOrderFilledEventArgs extends DecodedLogArgs {
orderHash: string;
maker: string;
taker: string;
feeRecipient: string;
makerToken: string;
takerToken: string;
takerTokenFilledAmount: BigNumber;
makerTokenFilledAmount: BigNumber;
takerTokenFeeFilledAmount: BigNumber;
protocolFeePaid: BigNumber;
pool: string;
}
export interface IZeroExMetaTransactionExecutedEventArgs extends DecodedLogArgs {
hash: string;
selector: string;
signer: string;
sender: string;
}
export interface IZeroExMigratedEventArgs extends DecodedLogArgs {
caller: string;
migrator: string;
newOwner: string;
}
export interface IZeroExOrderCancelledEventArgs extends DecodedLogArgs {
orderHash: string;
maker: string;
}
export interface IZeroExOwnershipTransferredEventArgs extends DecodedLogArgs {
previousOwner: string;
newOwner: string;
}
export interface IZeroExPairCancelledLimitOrdersEventArgs extends DecodedLogArgs {
maker: string;
makerToken: string;
takerToken: string;
minValidSalt: BigNumber;
}
export interface IZeroExPairCancelledRfqOrdersEventArgs extends DecodedLogArgs {
maker: string;
makerToken: string;
takerToken: string;
minValidSalt: BigNumber;
}
export interface IZeroExProxyFunctionUpdatedEventArgs extends DecodedLogArgs {
selector: string;
oldImpl: string;
newImpl: string;
}
export interface IZeroExQuoteSignerUpdatedEventArgs extends DecodedLogArgs {
quoteSigner: string;
}
export interface IZeroExRfqOrderFilledEventArgs extends DecodedLogArgs {
orderHash: string;
maker: string;
taker: string;
makerToken: string;
takerToken: string;
takerTokenFilledAmount: BigNumber;
makerTokenFilledAmount: BigNumber;
pool: string;
}
export interface IZeroExRfqOrderOriginsAllowedEventArgs extends DecodedLogArgs {
origin: string;
addrs: string[];
allowed: boolean;
}
export interface IZeroExTransformedERC20EventArgs extends DecodedLogArgs {
taker: string;
inputToken: string;
outputToken: string;
inputTokenAmount: BigNumber;
outputTokenAmount: BigNumber;
}
export interface IZeroExTransformerDeployerUpdatedEventArgs extends DecodedLogArgs {
transformerDeployer: string;
}
/* istanbul ignore next */
// tslint:disable:array-type
// tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name
export class IZeroExContract extends BaseContract {
/**
* @ignore
*/
public static deployedBytecode: string | undefined;
public static contractName = 'IZeroEx';
private readonly _methodABIIndex: { [name: string]: number } = {};
private readonly _subscriptionManager: SubscriptionManager<IZeroExEventArgs, IZeroExEvents>;
public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact },
): Promise<IZeroExContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
return IZeroExContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
}
public static async deployWithLibrariesFrom0xArtifactAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact },
): Promise<IZeroExContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
const libraryAddresses = await IZeroExContract._deployLibrariesAsync(
artifact,
libraryArtifacts,
new Web3Wrapper(provider),
txDefaults,
);
const bytecode = linkLibrariesInBytecode(artifact, libraryAddresses);
return IZeroExContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
}
public static async deployAsync(
bytecode: string,
abi: ContractAbi,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractAbi },
): Promise<IZeroExContract> {
assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
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(`IZeroEx successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new IZeroExContract(
txReceipt.contractAddress as string,
provider,
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = [];
return contractInstance;
}
/**
* @returns The contract ABI
*/
public static ABI(): ContractAbi {
const abi = [
{
anonymous: false,
inputs: [
{
name: 'orderHash',
type: 'bytes32',
indexed: false,
},
{
name: 'maker',
type: 'address',
indexed: false,
},
{
name: 'taker',
type: 'address',
indexed: false,
},
{
name: 'feeRecipient',
type: 'address',
indexed: false,
},
{
name: 'makerToken',
type: 'address',
indexed: false,
},
{
name: 'takerToken',
type: 'address',
indexed: false,
},
{
name: 'takerTokenFilledAmount',
type: 'uint128',
indexed: false,
},
{
name: 'makerTokenFilledAmount',
type: 'uint128',
indexed: false,
},
{
name: 'takerTokenFeeFilledAmount',
type: 'uint128',
indexed: false,
},
{
name: 'protocolFeePaid',
type: 'uint256',
indexed: false,
},
{
name: 'pool',
type: 'bytes32',
indexed: false,
},
],
name: 'LimitOrderFilled',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'hash',
type: 'bytes32',
indexed: false,
},
{
name: 'selector',
type: 'bytes4',
indexed: true,
},
{
name: 'signer',
type: 'address',
indexed: false,
},
{
name: 'sender',
type: 'address',
indexed: false,
},
],
name: 'MetaTransactionExecuted',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'caller',
type: 'address',
indexed: false,
},
{
name: 'migrator',
type: 'address',
indexed: false,
},
{
name: 'newOwner',
type: 'address',
indexed: false,
},
],
name: 'Migrated',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'orderHash',
type: 'bytes32',
indexed: false,
},
{
name: 'maker',
type: 'address',
indexed: false,
},
],
name: 'OrderCancelled',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'previousOwner',
type: 'address',
indexed: true,
},
{
name: 'newOwner',
type: 'address',
indexed: true,
},
],
name: 'OwnershipTransferred',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'maker',
type: 'address',
indexed: false,
},
{
name: 'makerToken',
type: 'address',
indexed: false,
},
{
name: 'takerToken',
type: 'address',
indexed: false,
},
{
name: 'minValidSalt',
type: 'uint256',
indexed: false,
},
],
name: 'PairCancelledLimitOrders',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'maker',
type: 'address',
indexed: false,
},
{
name: 'makerToken',
type: 'address',
indexed: false,
},
{
name: 'takerToken',
type: 'address',
indexed: false,
},
{
name: 'minValidSalt',
type: 'uint256',
indexed: false,
},
],
name: 'PairCancelledRfqOrders',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'selector',
type: 'bytes4',
indexed: true,
},
{
name: 'oldImpl',
type: 'address',
indexed: false,
},
{
name: 'newImpl',
type: 'address',
indexed: false,
},
],
name: 'ProxyFunctionUpdated',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'quoteSigner',
type: 'address',
indexed: false,
},
],
name: 'QuoteSignerUpdated',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'orderHash',
type: 'bytes32',
indexed: false,
},
{
name: 'maker',
type: 'address',
indexed: false,
},
{
name: 'taker',
type: 'address',
indexed: false,
},
{
name: 'makerToken',
type: 'address',
indexed: false,
},
{
name: 'takerToken',
type: 'address',
indexed: false,
},
{
name: 'takerTokenFilledAmount',
type: 'uint128',
indexed: false,
},
{
name: 'makerTokenFilledAmount',
type: 'uint128',
indexed: false,
},
{
name: 'pool',
type: 'bytes32',
indexed: false,
},
],
name: 'RfqOrderFilled',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'origin',
type: 'address',
indexed: false,
},
{
name: 'addrs',
type: 'address[]',
indexed: false,
},
{
name: 'allowed',
type: 'bool',
indexed: false,
},
],
name: 'RfqOrderOriginsAllowed',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'taker',
type: 'address',
indexed: true,
},
{
name: 'inputToken',
type: 'address',
indexed: false,
},
{
name: 'outputToken',
type: 'address',
indexed: false,
},
{
name: 'inputTokenAmount',
type: 'uint256',
indexed: false,
},
{
name: 'outputTokenAmount',
type: 'uint256',
indexed: false,
},
],
name: 'TransformedERC20',
outputs: [],
type: 'event',
},
{
anonymous: false,
inputs: [
{
name: 'transformerDeployer',
type: 'address',
indexed: false,
},
],
name: 'TransformerDeployerUpdated',
outputs: [],
type: 'event',
},
{
inputs: [
{
name: 'sender',
type: 'address',
},
{
name: 'mtx',
type: 'tuple',
components: [
{
name: 'signer',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'minGasPrice',
type: 'uint256',
},
{
name: 'maxGasPrice',
type: 'uint256',
},
{
name: 'expirationTimeSeconds',
type: 'uint256',
},
{
name: 'salt',
type: 'uint256',
},
{
name: 'callData',
type: 'bytes',
},
{
name: 'value',
type: 'uint256',
},
{
name: 'feeToken',
type: 'address',
},
{
name: 'feeAmount',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
],
name: '_executeMetaTransaction',
outputs: [
{
name: 'returnResult',
type: 'bytes',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'takerTokenFeeAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'feeRecipient',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
{
name: 'takerTokenFillAmount',
type: 'uint128',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
],
name: '_fillLimitOrder',
outputs: [
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
{
name: 'makerTokenFilledAmount',
type: 'uint128',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'txOrigin',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
{
name: 'takerTokenFillAmount',
type: 'uint128',
},
{
name: 'taker',
type: 'address',
},
],
name: '_fillRfqOrder',
outputs: [
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
{
name: 'makerTokenFilledAmount',
type: 'uint128',
},
],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'token',
type: 'address',
},
{
name: 'owner',
type: 'address',
},
{
name: 'to',
type: 'address',
},
{
name: 'amount',
type: 'uint256',
},
],
name: '_spendERC20Tokens',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'args',
type: 'tuple',
components: [
{
name: 'taker',
type: 'address',
},
{
name: 'inputToken',
type: 'address',
},
{
name: 'outputToken',
type: 'address',
},
{
name: 'inputTokenAmount',
type: 'uint256',
},
{
name: 'minOutputTokenAmount',
type: 'uint256',
},
{
name: 'transformations',
type: 'tuple[]',
components: [
{
name: 'deploymentNonce',
type: 'uint32',
},
{
name: 'data',
type: 'bytes',
},
],
},
],
},
],
name: '_transformERC20',
outputs: [
{
name: 'outputTokenAmount',
type: 'uint256',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'orders',
type: 'tuple[]',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'takerTokenFeeAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'feeRecipient',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
],
name: 'batchCancelLimitOrders',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'makerTokens',
type: 'address[]',
},
{
name: 'takerTokens',
type: 'address[]',
},
{
name: 'minValidSalts',
type: 'uint256[]',
},
],
name: 'batchCancelPairLimitOrders',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'makerTokens',
type: 'address[]',
},
{
name: 'takerTokens',
type: 'address[]',
},
{
name: 'minValidSalts',
type: 'uint256[]',
},
],
name: 'batchCancelPairRfqOrders',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'orders',
type: 'tuple[]',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'txOrigin',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
],
name: 'batchCancelRfqOrders',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'mtxs',
type: 'tuple[]',
components: [
{
name: 'signer',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'minGasPrice',
type: 'uint256',
},
{
name: 'maxGasPrice',
type: 'uint256',
},
{
name: 'expirationTimeSeconds',
type: 'uint256',
},
{
name: 'salt',
type: 'uint256',
},
{
name: 'callData',
type: 'bytes',
},
{
name: 'value',
type: 'uint256',
},
{
name: 'feeToken',
type: 'address',
},
{
name: 'feeAmount',
type: 'uint256',
},
],
},
{
name: 'signatures',
type: 'tuple[]',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
],
name: 'batchExecuteMetaTransactions',
outputs: [
{
name: 'returnResults',
type: 'bytes[]',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'orders',
type: 'tuple[]',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'takerTokenFeeAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'feeRecipient',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signatures',
type: 'tuple[]',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
],
name: 'batchGetLimitOrderRelevantStates',
outputs: [
{
name: 'orderInfos',
type: 'tuple[]',
components: [
{
name: 'orderHash',
type: 'bytes32',
},
{
name: 'status',
type: 'uint8',
},
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
],
},
{
name: 'actualFillableTakerTokenAmounts',
type: 'uint128[]',
},
{
name: 'isSignatureValids',
type: 'bool[]',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'orders',
type: 'tuple[]',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'txOrigin',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signatures',
type: 'tuple[]',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
],
name: 'batchGetRfqOrderRelevantStates',
outputs: [
{
name: 'orderInfos',
type: 'tuple[]',
components: [
{
name: 'orderHash',
type: 'bytes32',
},
{
name: 'status',
type: 'uint8',
},
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
],
},
{
name: 'actualFillableTakerTokenAmounts',
type: 'uint128[]',
},
{
name: 'isSignatureValids',
type: 'bool[]',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'takerTokenFeeAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'feeRecipient',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
],
name: 'cancelLimitOrder',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'minValidSalt',
type: 'uint256',
},
],
name: 'cancelPairLimitOrders',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'minValidSalt',
type: 'uint256',
},
],
name: 'cancelPairRfqOrders',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'txOrigin',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
],
name: 'cancelRfqOrder',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'createTransformWallet',
outputs: [
{
name: 'wallet',
type: 'address',
},
],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'mtx',
type: 'tuple',
components: [
{
name: 'signer',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'minGasPrice',
type: 'uint256',
},
{
name: 'maxGasPrice',
type: 'uint256',
},
{
name: 'expirationTimeSeconds',
type: 'uint256',
},
{
name: 'salt',
type: 'uint256',
},
{
name: 'callData',
type: 'bytes',
},
{
name: 'value',
type: 'uint256',
},
{
name: 'feeToken',
type: 'address',
},
{
name: 'feeAmount',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
],
name: 'executeMetaTransaction',
outputs: [
{
name: 'returnResult',
type: 'bytes',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'selector',
type: 'bytes4',
},
{
name: 'impl',
type: 'address',
},
],
name: 'extend',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'takerTokenFeeAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'feeRecipient',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
{
name: 'takerTokenFillAmount',
type: 'uint128',
},
],
name: 'fillLimitOrder',
outputs: [
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
{
name: 'makerTokenFilledAmount',
type: 'uint128',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'takerTokenFeeAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'feeRecipient',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
{
name: 'takerTokenFillAmount',
type: 'uint128',
},
],
name: 'fillOrKillLimitOrder',
outputs: [
{
name: 'makerTokenFilledAmount',
type: 'uint128',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'txOrigin',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
{
name: 'takerTokenFillAmount',
type: 'uint128',
},
],
name: 'fillOrKillRfqOrder',
outputs: [
{
name: 'makerTokenFilledAmount',
type: 'uint128',
},
],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'txOrigin',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
{
name: 'takerTokenFillAmount',
type: 'uint128',
},
],
name: 'fillRfqOrder',
outputs: [
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
{
name: 'makerTokenFilledAmount',
type: 'uint128',
},
],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'getAllowanceTarget',
outputs: [
{
name: 'target',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'takerTokenFeeAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'feeRecipient',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
],
name: 'getLimitOrderHash',
outputs: [
{
name: 'orderHash',
type: 'bytes32',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'takerTokenFeeAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'feeRecipient',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
],
name: 'getLimitOrderInfo',
outputs: [
{
name: 'orderInfo',
type: 'tuple',
components: [
{
name: 'orderHash',
type: 'bytes32',
},
{
name: 'status',
type: 'uint8',
},
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
],
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'takerTokenFeeAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'feeRecipient',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
],
name: 'getLimitOrderRelevantState',
outputs: [
{
name: 'orderInfo',
type: 'tuple',
components: [
{
name: 'orderHash',
type: 'bytes32',
},
{
name: 'status',
type: 'uint8',
},
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
],
},
{
name: 'actualFillableTakerTokenAmount',
type: 'uint128',
},
{
name: 'isSignatureValid',
type: 'bool',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'mtx',
type: 'tuple',
components: [
{
name: 'signer',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'minGasPrice',
type: 'uint256',
},
{
name: 'maxGasPrice',
type: 'uint256',
},
{
name: 'expirationTimeSeconds',
type: 'uint256',
},
{
name: 'salt',
type: 'uint256',
},
{
name: 'callData',
type: 'bytes',
},
{
name: 'value',
type: 'uint256',
},
{
name: 'feeToken',
type: 'address',
},
{
name: 'feeAmount',
type: 'uint256',
},
],
},
],
name: 'getMetaTransactionExecutedBlock',
outputs: [
{
name: 'blockNumber',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'mtx',
type: 'tuple',
components: [
{
name: 'signer',
type: 'address',
},
{
name: 'sender',
type: 'address',
},
{
name: 'minGasPrice',
type: 'uint256',
},
{
name: 'maxGasPrice',
type: 'uint256',
},
{
name: 'expirationTimeSeconds',
type: 'uint256',
},
{
name: 'salt',
type: 'uint256',
},
{
name: 'callData',
type: 'bytes',
},
{
name: 'value',
type: 'uint256',
},
{
name: 'feeToken',
type: 'address',
},
{
name: 'feeAmount',
type: 'uint256',
},
],
},
],
name: 'getMetaTransactionHash',
outputs: [
{
name: 'mtxHash',
type: 'bytes32',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'mtxHash',
type: 'bytes32',
},
],
name: 'getMetaTransactionHashExecutedBlock',
outputs: [
{
name: 'blockNumber',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getProtocolFeeMultiplier',
outputs: [
{
name: 'multiplier',
type: 'uint32',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getQuoteSigner',
outputs: [
{
name: 'signer',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'txOrigin',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
],
name: 'getRfqOrderHash',
outputs: [
{
name: 'orderHash',
type: 'bytes32',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'txOrigin',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
],
name: 'getRfqOrderInfo',
outputs: [
{
name: 'orderInfo',
type: 'tuple',
components: [
{
name: 'orderHash',
type: 'bytes32',
},
{
name: 'status',
type: 'uint8',
},
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
],
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'order',
type: 'tuple',
components: [
{
name: 'makerToken',
type: 'address',
},
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerAmount',
type: 'uint128',
},
{
name: 'takerAmount',
type: 'uint128',
},
{
name: 'maker',
type: 'address',
},
{
name: 'taker',
type: 'address',
},
{
name: 'txOrigin',
type: 'address',
},
{
name: 'pool',
type: 'bytes32',
},
{
name: 'expiry',
type: 'uint64',
},
{
name: 'salt',
type: 'uint256',
},
],
},
{
name: 'signature',
type: 'tuple',
components: [
{
name: 'signatureType',
type: 'uint8',
},
{
name: 'v',
type: 'uint8',
},
{
name: 'r',
type: 'bytes32',
},
{
name: 's',
type: 'bytes32',
},
],
},
],
name: 'getRfqOrderRelevantState',
outputs: [
{
name: 'orderInfo',
type: 'tuple',
components: [
{
name: 'orderHash',
type: 'bytes32',
},
{
name: 'status',
type: 'uint8',
},
{
name: 'takerTokenFilledAmount',
type: 'uint128',
},
],
},
{
name: 'actualFillableTakerTokenAmount',
type: 'uint128',
},
{
name: 'isSignatureValid',
type: 'bool',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'selector',
type: 'bytes4',
},
{
name: 'idx',
type: 'uint256',
},
],
name: 'getRollbackEntryAtIndex',
outputs: [
{
name: 'impl',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'selector',
type: 'bytes4',
},
],
name: 'getRollbackLength',
outputs: [
{
name: 'rollbackLength',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'token',
type: 'address',
},
{
name: 'owner',
type: 'address',
},
],
name: 'getSpendableERC20BalanceOf',
outputs: [
{
name: 'amount',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getTransformWallet',
outputs: [
{
name: 'wallet',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getTransformerDeployer',
outputs: [
{
name: 'deployer',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'hash',
type: 'bytes32',
},
{
name: 'signer',
type: 'address',
},
{
name: 'signature',
type: 'bytes',
},
],
name: 'isValidHashSignature',
outputs: [
{
name: 'isValid',
type: 'bool',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'target',
type: 'address',
},
{
name: 'data',
type: 'bytes',
},
{
name: 'newOwner',
type: 'address',
},
],
name: 'migrate',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'owner',
outputs: [
{
name: 'ownerAddress',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
name: 'origins',
type: 'address[]',
},
{
name: 'allowed',
type: 'bool',
},
],
name: 'registerAllowedRfqOrigins',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'selector',
type: 'bytes4',
},
{
name: 'targetImpl',
type: 'address',
},
],
name: 'rollback',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'inputToken',
type: 'address',
},
{
name: 'outputToken',
type: 'address',
},
{
name: 'provider',
type: 'address',
},
{
name: 'recipient',
type: 'address',
},
{
name: 'sellAmount',
type: 'uint256',
},
{
name: 'minBuyAmount',
type: 'uint256',
},
{
name: 'auxiliaryData',
type: 'bytes',
},
],
name: 'sellToLiquidityProvider',
outputs: [
{
name: 'boughtAmount',
type: 'uint256',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'tokens',
type: 'address[]',
},
{
name: 'sellAmount',
type: 'uint256',
},
{
name: 'minBuyAmount',
type: 'uint256',
},
{
name: 'isSushi',
type: 'bool',
},
],
name: 'sellToUniswap',
outputs: [
{
name: 'buyAmount',
type: 'uint256',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'quoteSigner',
type: 'address',
},
],
name: 'setQuoteSigner',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'transformerDeployer',
type: 'address',
},
],
name: 'setTransformerDeployer',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'newOwner',
type: 'address',
},
],
name: 'transferOwnership',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'poolIds',
type: 'bytes32[]',
},
],
name: 'transferProtocolFeesForPools',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
name: 'inputToken',
type: 'address',
},
{
name: 'outputToken',
type: 'address',
},
{
name: 'inputTokenAmount',
type: 'uint256',
},
{
name: 'minOutputTokenAmount',
type: 'uint256',
},
{
name: 'transformations',
type: 'tuple[]',
components: [
{
name: 'deploymentNonce',
type: 'uint32',
},
{
name: 'data',
type: 'bytes',
},
],
},
],
name: 'transformERC20',
outputs: [
{
name: 'outputTokenAmount',
type: 'uint256',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
name: 'hash',
type: 'bytes32',
},
{
name: 'signer',
type: 'address',
},
{
name: 'signature',
type: 'bytes',
},
],
name: 'validateHashSignature',
outputs: [],
stateMutability: 'view',
type: 'function',
},
] as ContractAbi;
return abi;
}
protected static async _deployLibrariesAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
web3Wrapper: Web3Wrapper,
txDefaults: Partial<TxData>,
libraryAddresses: { [libraryName: string]: string } = {},
): Promise<{ [libraryName: string]: string }> {
const links = artifact.compilerOutput.evm.bytecode.linkReferences;
// Go through all linked libraries, recursively deploying them if necessary.
for (const link of Object.values(links)) {
for (const libraryName of Object.keys(link)) {
if (!libraryAddresses[libraryName]) {
// Library not yet deployed.
const libraryArtifact = libraryArtifacts[libraryName];
if (!libraryArtifact) {
throw new Error(`Missing artifact for linked library "${libraryName}"`);
}
// Deploy any dependent libraries used by this library.
await IZeroExContract._deployLibrariesAsync(
libraryArtifact,
libraryArtifacts,
web3Wrapper,
txDefaults,
libraryAddresses,
);
// Deploy this library.
const linkedLibraryBytecode = linkLibrariesInBytecode(libraryArtifact, libraryAddresses);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: linkedLibraryBytecode,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const { contractAddress } = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`${libraryArtifact.contractName} successfully deployed at ${contractAddress}`);
libraryAddresses[libraryArtifact.contractName] = contractAddress as string;
}
}
}
return libraryAddresses;
}
public getFunctionSignature(methodName: string): string {
const index = this._methodABIIndex[methodName];
const methodAbi = IZeroExContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion
const functionSignature = methodAbiToFunctionSignature(methodAbi);
return functionSignature;
}
public getABIDecodedTransactionData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as IZeroExContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecode<T>(callData);
return abiDecodedCallData;
}
public getABIDecodedReturnData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as IZeroExContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecodeReturnValue<T>(callData);
return abiDecodedCallData;
}
public getSelector(methodName: string): string {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as IZeroExContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
return abiEncoder.getSelector();
}
/**
* Execute a meta-transaction via `sender`. Privileged variant.
* Only callable from within.
* @param sender Who is executing the meta-transaction.
* @param mtx The meta-transaction.
* @param signature The signature by `mtx.signer`.
*/
public _executeMetaTransaction(
sender: string,
mtx: {
signer: string;
sender: string;
minGasPrice: BigNumber;
maxGasPrice: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
callData: string;
value: BigNumber;
feeToken: string;
feeAmount: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
assert.isString('sender', sender);
const functionSignature =
'_executeMetaTransaction(address,(address,address,uint256,uint256,uint256,uint256,bytes,uint256,address,uint256),(uint8,uint8,bytes32,bytes32))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [sender.toLowerCase(), mtx, signature]);
},
};
}
/**
* Fill a limit order. Internal variant. ETH protocol fees can be
* attached to this call. Any unspent ETH will be refunded to
* `msg.sender` (not `sender`).
* @param order The limit order.
* @param signature The order signature.
* @param takerTokenFillAmount Maximum taker token to fill this order with.
* @param taker The order taker.
* @param sender The order sender.
*/
public _fillLimitOrder(
order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
takerTokenFeeAmount: BigNumber;
maker: string;
taker: string;
sender: string;
feeRecipient: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
takerTokenFillAmount: BigNumber,
taker: string,
sender: string,
): ContractTxFunctionObj<[BigNumber, BigNumber]> {
const self = (this as any) as IZeroExContract;
assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount);
assert.isString('taker', taker);
assert.isString('sender', sender);
const functionSignature =
'_fillLimitOrder((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128,address,address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<[BigNumber, BigNumber]> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [
order,
signature,
takerTokenFillAmount,
taker.toLowerCase(),
sender.toLowerCase(),
]);
},
};
}
/**
* Fill an RFQ order. Internal variant.
* @param order The RFQ order.
* @param signature The order signature.
* @param takerTokenFillAmount Maximum taker token to fill this order with.
* @param taker The order taker.
*/
public _fillRfqOrder(
order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
maker: string;
taker: string;
txOrigin: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
takerTokenFillAmount: BigNumber,
taker: string,
): ContractTxFunctionObj<[BigNumber, BigNumber]> {
const self = (this as any) as IZeroExContract;
assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount);
assert.isString('taker', taker);
const functionSignature =
'_fillRfqOrder((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128,address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<[BigNumber, BigNumber]> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [
order,
signature,
takerTokenFillAmount,
taker.toLowerCase(),
]);
},
};
}
/**
* Transfers ERC20 tokens from `owner` to `to`.
* Only callable from within.
* @param token The token to spend.
* @param owner The owner of the tokens.
* @param to The recipient of the tokens.
* @param amount The amount of `token` to transfer.
*/
public _spendERC20Tokens(token: string, owner: string, to: string, amount: BigNumber): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('token', token);
assert.isString('owner', owner);
assert.isString('to', to);
assert.isBigNumber('amount', amount);
const functionSignature = '_spendERC20Tokens(address,address,address,uint256)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [
token.toLowerCase(),
owner.toLowerCase(),
to.toLowerCase(),
amount,
]);
},
};
}
/**
* Internal version of `transformERC20()`. Only callable from within.
* @param args A `TransformERC20Args` struct.
*/
public _transformERC20(args: {
taker: string;
inputToken: string;
outputToken: string;
inputTokenAmount: BigNumber;
minOutputTokenAmount: BigNumber;
transformations: Array<{ deploymentNonce: number | BigNumber; data: string }>;
}): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
const functionSignature = '_transformERC20((address,address,address,uint256,uint256,(uint32,bytes)[]))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [args]);
},
};
}
/**
* Cancel multiple limit orders. The caller must be the maker.
* Silently succeeds if the order has already been cancelled.
* @param orders The limit orders.
*/
public batchCancelLimitOrders(
orders: Array<{
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
takerTokenFeeAmount: BigNumber;
maker: string;
taker: string;
sender: string;
feeRecipient: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}>,
): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isArray('orders', orders);
const functionSignature =
'batchCancelLimitOrders((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256)[])';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [orders]);
},
};
}
/**
* Cancel all limit orders for a given maker and pair with a salt less
* than the value provided. The caller must be the maker. Subsequent
* calls to this function with the same caller and pair require the
* new salt to be >= the old salt.
* @param makerTokens The maker tokens.
* @param takerTokens The taker tokens.
* @param minValidSalts The new minimum valid salts.
*/
public batchCancelPairLimitOrders(
makerTokens: string[],
takerTokens: string[],
minValidSalts: BigNumber[],
): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isArray('makerTokens', makerTokens);
assert.isArray('takerTokens', takerTokens);
assert.isArray('minValidSalts', minValidSalts);
const functionSignature = 'batchCancelPairLimitOrders(address[],address[],uint256[])';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [makerTokens, takerTokens, minValidSalts]);
},
};
}
/**
* Cancel all RFQ orders for a given maker and pair with a salt less
* than the value provided. The caller must be the maker. Subsequent
* calls to this function with the same caller and pair require the
* new salt to be >= the old salt.
* @param makerTokens The maker tokens.
* @param takerTokens The taker tokens.
* @param minValidSalts The new minimum valid salts.
*/
public batchCancelPairRfqOrders(
makerTokens: string[],
takerTokens: string[],
minValidSalts: BigNumber[],
): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isArray('makerTokens', makerTokens);
assert.isArray('takerTokens', takerTokens);
assert.isArray('minValidSalts', minValidSalts);
const functionSignature = 'batchCancelPairRfqOrders(address[],address[],uint256[])';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [makerTokens, takerTokens, minValidSalts]);
},
};
}
/**
* Cancel multiple RFQ orders. The caller must be the maker.
* Silently succeeds if the order has already been cancelled.
* @param orders The RFQ orders.
*/
public batchCancelRfqOrders(
orders: Array<{
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
maker: string;
taker: string;
txOrigin: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}>,
): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isArray('orders', orders);
const functionSignature =
'batchCancelRfqOrders((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256)[])';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [orders]);
},
};
}
/**
* Execute multiple meta-transactions.
* @param mtxs The meta-transactions.
* @param signatures The signature by each respective `mtx.signer`.
*/
public batchExecuteMetaTransactions(
mtxs: Array<{
signer: string;
sender: string;
minGasPrice: BigNumber;
maxGasPrice: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
callData: string;
value: BigNumber;
feeToken: string;
feeAmount: BigNumber;
}>,
signatures: Array<{ signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }>,
): ContractTxFunctionObj<string[]> {
const self = (this as any) as IZeroExContract;
assert.isArray('mtxs', mtxs);
assert.isArray('signatures', signatures);
const functionSignature =
'batchExecuteMetaTransactions((address,address,uint256,uint256,uint256,uint256,bytes,uint256,address,uint256)[],(uint8,uint8,bytes32,bytes32)[])';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string[]> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string[]>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [mtxs, signatures]);
},
};
}
/**
* Batch version of `getLimitOrderRelevantState()`.
* @param orders The limit orders.
* @param signatures The order signatures.
*/
public batchGetLimitOrderRelevantStates(
orders: Array<{
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
takerTokenFeeAmount: BigNumber;
maker: string;
taker: string;
sender: string;
feeRecipient: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}>,
signatures: Array<{ signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }>,
): ContractTxFunctionObj<
[Array<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }>, BigNumber[], boolean[]]
> {
const self = (this as any) as IZeroExContract;
assert.isArray('orders', orders);
assert.isArray('signatures', signatures);
const functionSignature =
'batchGetLimitOrderRelevantStates((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256)[],(uint8,uint8,bytes32,bytes32)[])';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<
[
Array<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }>,
BigNumber[],
boolean[]
]
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<
[
Array<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }>,
BigNumber[],
boolean[]
]
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [orders, signatures]);
},
};
}
/**
* Batch version of `getRfqOrderRelevantState()`.
* @param orders The RFQ orders.
* @param signatures The order signatures.
*/
public batchGetRfqOrderRelevantStates(
orders: Array<{
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
maker: string;
taker: string;
txOrigin: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}>,
signatures: Array<{ signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }>,
): ContractTxFunctionObj<
[Array<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }>, BigNumber[], boolean[]]
> {
const self = (this as any) as IZeroExContract;
assert.isArray('orders', orders);
assert.isArray('signatures', signatures);
const functionSignature =
'batchGetRfqOrderRelevantStates((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256)[],(uint8,uint8,bytes32,bytes32)[])';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<
[
Array<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }>,
BigNumber[],
boolean[]
]
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<
[
Array<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }>,
BigNumber[],
boolean[]
]
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [orders, signatures]);
},
};
}
/**
* Cancel a single limit order. The caller must be the maker.
* Silently succeeds if the order has already been cancelled.
* @param order The limit order.
*/
public cancelLimitOrder(order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
takerTokenFeeAmount: BigNumber;
maker: string;
taker: string;
sender: string;
feeRecipient: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'cancelLimitOrder((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order]);
},
};
}
/**
* Cancel all limit orders for a given maker and pair with a salt less
* than the value provided. The caller must be the maker. Subsequent
* calls to this function with the same caller and pair require the
* new salt to be >= the old salt.
* @param makerToken The maker token.
* @param takerToken The taker token.
* @param minValidSalt The new minimum valid salt.
*/
public cancelPairLimitOrders(
makerToken: string,
takerToken: string,
minValidSalt: BigNumber,
): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('makerToken', makerToken);
assert.isString('takerToken', takerToken);
assert.isBigNumber('minValidSalt', minValidSalt);
const functionSignature = 'cancelPairLimitOrders(address,address,uint256)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [
makerToken.toLowerCase(),
takerToken.toLowerCase(),
minValidSalt,
]);
},
};
}
/**
* Cancel all RFQ orders for a given maker and pair with a salt less
* than the value provided. The caller must be the maker. Subsequent
* calls to this function with the same caller and pair require the
* new salt to be >= the old salt.
* @param makerToken The maker token.
* @param takerToken The taker token.
* @param minValidSalt The new minimum valid salt.
*/
public cancelPairRfqOrders(
makerToken: string,
takerToken: string,
minValidSalt: BigNumber,
): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('makerToken', makerToken);
assert.isString('takerToken', takerToken);
assert.isBigNumber('minValidSalt', minValidSalt);
const functionSignature = 'cancelPairRfqOrders(address,address,uint256)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [
makerToken.toLowerCase(),
takerToken.toLowerCase(),
minValidSalt,
]);
},
};
}
/**
* Cancel a single RFQ order. The caller must be the maker.
* Silently succeeds if the order has already been cancelled.
* @param order The RFQ order.
*/
public cancelRfqOrder(order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
maker: string;
taker: string;
txOrigin: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'cancelRfqOrder((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order]);
},
};
}
/**
* Deploy a new flash wallet instance and replace the current one with it.
* Useful if we somehow break the current wallet instance.
* Only callable by the owner.
*/
public createTransformWallet(): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature = 'createTransformWallet()';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, []);
},
};
}
/**
* Execute a single meta-transaction.
* @param mtx The meta-transaction.
* @param signature The signature by `mtx.signer`.
*/
public executeMetaTransaction(
mtx: {
signer: string;
sender: string;
minGasPrice: BigNumber;
maxGasPrice: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
callData: string;
value: BigNumber;
feeToken: string;
feeAmount: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'executeMetaTransaction((address,address,uint256,uint256,uint256,uint256,bytes,uint256,address,uint256),(uint8,uint8,bytes32,bytes32))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [mtx, signature]);
},
};
}
/**
* Register or replace a function.
* @param selector The function selector.
* @param impl The implementation contract for the function.
*/
public extend(selector: string, impl: string): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('selector', selector);
assert.isString('impl', impl);
const functionSignature = 'extend(bytes4,address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [selector, impl.toLowerCase()]);
},
};
}
/**
* Fill a limit order. The taker and sender will be the caller.
* @param order The limit order. ETH protocol fees can be attached to this
* call. Any unspent ETH will be refunded to the caller.
* @param signature The order signature.
* @param takerTokenFillAmount Maximum taker token amount to fill this order
* with.
*/
public fillLimitOrder(
order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
takerTokenFeeAmount: BigNumber;
maker: string;
taker: string;
sender: string;
feeRecipient: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
takerTokenFillAmount: BigNumber,
): ContractTxFunctionObj<[BigNumber, BigNumber]> {
const self = (this as any) as IZeroExContract;
assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount);
const functionSignature =
'fillLimitOrder((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<[BigNumber, BigNumber]> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order, signature, takerTokenFillAmount]);
},
};
}
/**
* Fill an RFQ order for exactly `takerTokenFillAmount` taker tokens.
* The taker will be the caller. ETH protocol fees can be
* attached to this call. Any unspent ETH will be refunded to
* the caller.
* @param order The limit order.
* @param signature The order signature.
* @param takerTokenFillAmount How much taker token to fill this order with.
*/
public fillOrKillLimitOrder(
order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
takerTokenFeeAmount: BigNumber;
maker: string;
taker: string;
sender: string;
feeRecipient: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
takerTokenFillAmount: BigNumber,
): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount);
const functionSignature =
'fillOrKillLimitOrder((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order, signature, takerTokenFillAmount]);
},
};
}
/**
* Fill an RFQ order for exactly `takerTokenFillAmount` taker tokens.
* The taker will be the caller.
* @param order The RFQ order.
* @param signature The order signature.
* @param takerTokenFillAmount How much taker token to fill this order with.
*/
public fillOrKillRfqOrder(
order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
maker: string;
taker: string;
txOrigin: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
takerTokenFillAmount: BigNumber,
): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount);
const functionSignature =
'fillOrKillRfqOrder((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order, signature, takerTokenFillAmount]);
},
};
}
/**
* Fill an RFQ order for up to `takerTokenFillAmount` taker tokens.
* The taker will be the caller.
* @param order The RFQ order.
* @param signature The order signature.
* @param takerTokenFillAmount Maximum taker token amount to fill this order
* with.
*/
public fillRfqOrder(
order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
maker: string;
taker: string;
txOrigin: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
takerTokenFillAmount: BigNumber,
): ContractTxFunctionObj<[BigNumber, BigNumber]> {
const self = (this as any) as IZeroExContract;
assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount);
const functionSignature =
'fillRfqOrder((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<[BigNumber, BigNumber]> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order, signature, takerTokenFillAmount]);
},
};
}
/**
* Get the address of the allowance target.
*/
public getAllowanceTarget(): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature = 'getAllowanceTarget()';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, []);
},
};
}
/**
* Get the canonical hash of a limit order.
* @param order The limit order.
*/
public getLimitOrderHash(order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
takerTokenFeeAmount: BigNumber;
maker: string;
taker: string;
sender: string;
feeRecipient: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'getLimitOrderHash((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order]);
},
};
}
/**
* Get the order info for a limit order.
* @param order The limit order.
*/
public getLimitOrderInfo(order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
takerTokenFeeAmount: BigNumber;
maker: string;
taker: string;
sender: string;
feeRecipient: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}): ContractTxFunctionObj<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'getLimitOrderInfo((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<{
orderHash: string;
status: number;
takerTokenFilledAmount: BigNumber;
}>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order]);
},
};
}
/**
* Get order info, fillable amount, and signature validity for a limit order.
* Fillable amount is determined using balances and allowances of the maker.
* @param order The limit order.
* @param signature The order signature.
*/
public getLimitOrderRelevantState(
order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
takerTokenFeeAmount: BigNumber;
maker: string;
taker: string;
sender: string;
feeRecipient: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
): ContractTxFunctionObj<
[{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }, BigNumber, boolean]
> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'getLimitOrderRelevantState((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<[{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }, BigNumber, boolean]> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<
[{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }, BigNumber, boolean]
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order, signature]);
},
};
}
/**
* Get the block at which a meta-transaction has been executed.
* @param mtx The meta-transaction.
*/
public getMetaTransactionExecutedBlock(mtx: {
signer: string;
sender: string;
minGasPrice: BigNumber;
maxGasPrice: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
callData: string;
value: BigNumber;
feeToken: string;
feeAmount: BigNumber;
}): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'getMetaTransactionExecutedBlock((address,address,uint256,uint256,uint256,uint256,bytes,uint256,address,uint256))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [mtx]);
},
};
}
/**
* Get the EIP712 hash of a meta-transaction.
* @param mtx The meta-transaction.
*/
public getMetaTransactionHash(mtx: {
signer: string;
sender: string;
minGasPrice: BigNumber;
maxGasPrice: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
callData: string;
value: BigNumber;
feeToken: string;
feeAmount: BigNumber;
}): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'getMetaTransactionHash((address,address,uint256,uint256,uint256,uint256,bytes,uint256,address,uint256))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [mtx]);
},
};
}
/**
* Get the block at which a meta-transaction hash has been executed.
* @param mtxHash The meta-transaction hash.
*/
public getMetaTransactionHashExecutedBlock(mtxHash: string): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
assert.isString('mtxHash', mtxHash);
const functionSignature = 'getMetaTransactionHashExecutedBlock(bytes32)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [mtxHash]);
},
};
}
/**
* Get the protocol fee multiplier. This should be multiplied by the
* gas price to arrive at the required protocol fee to fill a native order.
*/
public getProtocolFeeMultiplier(): ContractTxFunctionObj<number> {
const self = (this as any) as IZeroExContract;
const functionSignature = 'getProtocolFeeMultiplier()';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<number> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<number>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, []);
},
};
}
/**
* Return the optional signer for `transformERC20()` calldata.
*/
public getQuoteSigner(): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature = 'getQuoteSigner()';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, []);
},
};
}
/**
* Get the canonical hash of an RFQ order.
* @param order The RFQ order.
*/
public getRfqOrderHash(order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
maker: string;
taker: string;
txOrigin: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'getRfqOrderHash((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order]);
},
};
}
/**
* Get the order info for an RFQ order.
* @param order The RFQ order.
*/
public getRfqOrderInfo(order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
maker: string;
taker: string;
txOrigin: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
}): ContractTxFunctionObj<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'getRfqOrderInfo((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<{
orderHash: string;
status: number;
takerTokenFilledAmount: BigNumber;
}>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order]);
},
};
}
/**
* Get order info, fillable amount, and signature validity for an RFQ order.
* Fillable amount is determined using balances and allowances of the maker.
* @param order The RFQ order.
* @param signature The order signature.
*/
public getRfqOrderRelevantState(
order: {
makerToken: string;
takerToken: string;
makerAmount: BigNumber;
takerAmount: BigNumber;
maker: string;
taker: string;
txOrigin: string;
pool: string;
expiry: BigNumber;
salt: BigNumber;
},
signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string },
): ContractTxFunctionObj<
[{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }, BigNumber, boolean]
> {
const self = (this as any) as IZeroExContract;
const functionSignature =
'getRfqOrderRelevantState((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32))';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<[{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }, BigNumber, boolean]> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<
[{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }, BigNumber, boolean]
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [order, signature]);
},
};
}
/**
* Retrieve an entry in the rollback history for a function.
* @param selector The function selector.
* @param idx The index in the rollback history.
*/
public getRollbackEntryAtIndex(selector: string, idx: BigNumber): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
assert.isString('selector', selector);
assert.isBigNumber('idx', idx);
const functionSignature = 'getRollbackEntryAtIndex(bytes4,uint256)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [selector, idx]);
},
};
}
/**
* Retrieve the length of the rollback history for a function.
* @param selector The function selector.
*/
public getRollbackLength(selector: string): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
assert.isString('selector', selector);
const functionSignature = 'getRollbackLength(bytes4)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [selector]);
},
};
}
/**
* Gets the maximum amount of an ERC20 token `token` that can be
* pulled from `owner`.
* @param token The token to spend.
* @param owner The owner of the tokens.
*/
public getSpendableERC20BalanceOf(token: string, owner: string): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
assert.isString('token', token);
assert.isString('owner', owner);
const functionSignature = 'getSpendableERC20BalanceOf(address,address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [token.toLowerCase(), owner.toLowerCase()]);
},
};
}
/**
* Return the current wallet instance that will serve as the execution
* context for transformations.
*/
public getTransformWallet(): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature = 'getTransformWallet()';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, []);
},
};
}
/**
* Return the allowed deployer for transformers.
*/
public getTransformerDeployer(): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature = 'getTransformerDeployer()';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, []);
},
};
}
/**
* Check that `hash` was signed by `signer` given `signature`.
* @param hash The hash that was signed.
* @param signer The signer of the hash.
* @param signature The signature. The last byte of this signature should
* be a member of the `SignatureType` enum.
*/
public isValidHashSignature(hash: string, signer: string, signature: string): ContractTxFunctionObj<boolean> {
const self = (this as any) as IZeroExContract;
assert.isString('hash', hash);
assert.isString('signer', signer);
assert.isString('signature', signature);
const functionSignature = 'isValidHashSignature(bytes32,address,bytes)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<boolean> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [hash, signer.toLowerCase(), signature]);
},
};
}
/**
* Execute a migration function in the context of the ZeroEx contract.
* The result of the function being called should be the magic bytes
* 0x2c64c5ef (`keccack('MIGRATE_SUCCESS')`). Only callable by the owner.
* The owner will be temporarily set to `address(this)` inside the call.
* Before returning, the owner will be set to `newOwner`.
* @param target The migrator contract address.
* @param data The call data.
* @param newOwner The address of the new owner.
*/
public migrate(target: string, data: string, newOwner: string): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('target', target);
assert.isString('data', data);
assert.isString('newOwner', newOwner);
const functionSignature = 'migrate(address,bytes,address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [
target.toLowerCase(),
data,
newOwner.toLowerCase(),
]);
},
};
}
/**
* The owner of this contract.
*/
public owner(): ContractTxFunctionObj<string> {
const self = (this as any) as IZeroExContract;
const functionSignature = 'owner()';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, []);
},
};
}
/**
* Mark what tx.origin addresses are allowed to fill an order that
* specifies the message sender as its txOrigin.
* @param origins An array of origin addresses to update.
* @param allowed True to register, false to unregister.
*/
public registerAllowedRfqOrigins(origins: string[], allowed: boolean): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isArray('origins', origins);
assert.isBoolean('allowed', allowed);
const functionSignature = 'registerAllowedRfqOrigins(address[],bool)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [origins, allowed]);
},
};
}
/**
* Roll back to a prior implementation of a function.
* @param selector The function selector.
* @param targetImpl The address of an older implementation of the function.
*/
public rollback(selector: string, targetImpl: string): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('selector', selector);
assert.isString('targetImpl', targetImpl);
const functionSignature = 'rollback(bytes4,address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [selector, targetImpl.toLowerCase()]);
},
};
}
/**
* Sells `sellAmount` of `inputToken` to the liquidity provider
* at the given `provider` address.
* @param inputToken The token being sold.
* @param outputToken The token being bought.
* @param provider The address of the on-chain liquidity provider to
* trade with.
* @param recipient The recipient of the bought tokens. If equal to
* address(0), `msg.sender` is assumed to be the recipient.
* @param sellAmount The amount of `inputToken` to sell.
* @param minBuyAmount The minimum acceptable amount of `outputToken` to
* buy. Reverts if this amount is not satisfied.
* @param auxiliaryData Auxiliary data supplied to the `provider` contract.
*/
public sellToLiquidityProvider(
inputToken: string,
outputToken: string,
provider: string,
recipient: string,
sellAmount: BigNumber,
minBuyAmount: BigNumber,
auxiliaryData: string,
): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
assert.isString('inputToken', inputToken);
assert.isString('outputToken', outputToken);
assert.isString('provider', provider);
assert.isString('recipient', recipient);
assert.isBigNumber('sellAmount', sellAmount);
assert.isBigNumber('minBuyAmount', minBuyAmount);
assert.isString('auxiliaryData', auxiliaryData);
const functionSignature = 'sellToLiquidityProvider(address,address,address,address,uint256,uint256,bytes)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [
inputToken.toLowerCase(),
outputToken.toLowerCase(),
provider.toLowerCase(),
recipient.toLowerCase(),
sellAmount,
minBuyAmount,
auxiliaryData,
]);
},
};
}
/**
* Efficiently sell directly to uniswap/sushiswap.
* @param tokens Sell path.
* @param sellAmount of `tokens[0]` Amount to sell.
* @param minBuyAmount Minimum amount of `tokens[-1]` to buy.
* @param isSushi Use sushiswap if true.
*/
public sellToUniswap(
tokens: string[],
sellAmount: BigNumber,
minBuyAmount: BigNumber,
isSushi: boolean,
): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
assert.isArray('tokens', tokens);
assert.isBigNumber('sellAmount', sellAmount);
assert.isBigNumber('minBuyAmount', minBuyAmount);
assert.isBoolean('isSushi', isSushi);
const functionSignature = 'sellToUniswap(address[],uint256,uint256,bool)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [tokens, sellAmount, minBuyAmount, isSushi]);
},
};
}
/**
* Replace the optional signer for `transformERC20()` calldata.
* Only callable by the owner.
* @param quoteSigner The address of the new calldata signer.
*/
public setQuoteSigner(quoteSigner: string): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('quoteSigner', quoteSigner);
const functionSignature = 'setQuoteSigner(address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [quoteSigner.toLowerCase()]);
},
};
}
/**
* Replace the allowed deployer for transformers.
* Only callable by the owner.
* @param transformerDeployer The address of the new trusted deployer
* for transformers.
*/
public setTransformerDeployer(transformerDeployer: string): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('transformerDeployer', transformerDeployer);
const functionSignature = 'setTransformerDeployer(address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [transformerDeployer.toLowerCase()]);
},
};
}
/**
* Transfers ownership of the contract to a new address.
* @param newOwner The address that will become the owner.
*/
public transferOwnership(newOwner: string): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('newOwner', newOwner);
const functionSignature = 'transferOwnership(address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [newOwner.toLowerCase()]);
},
};
}
/**
* Transfers protocol fees from the `FeeCollector` pools into
* the staking contract.
* @param poolIds Staking pool IDs
*/
public transferProtocolFeesForPools(poolIds: string[]): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isArray('poolIds', poolIds);
const functionSignature = 'transferProtocolFeesForPools(bytes32[])';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [poolIds]);
},
};
}
/**
* Executes a series of transformations to convert an ERC20 `inputToken`
* to an ERC20 `outputToken`.
* @param inputToken The token being provided by the sender. If
* `0xeee...`, ETH is implied and should be provided with the call.`
* @param outputToken The token to be acquired by the sender. `0xeee...`
* implies ETH.
* @param inputTokenAmount The amount of `inputToken` to take from the sender.
* @param minOutputTokenAmount The minimum amount of `outputToken` the sender
* must receive for the entire transformation to succeed.
* @param transformations The transformations to execute on the token
* balance(s) in sequence.
*/
public transformERC20(
inputToken: string,
outputToken: string,
inputTokenAmount: BigNumber,
minOutputTokenAmount: BigNumber,
transformations: Array<{ deploymentNonce: number | BigNumber; data: string }>,
): ContractTxFunctionObj<BigNumber> {
const self = (this as any) as IZeroExContract;
assert.isString('inputToken', inputToken);
assert.isString('outputToken', outputToken);
assert.isBigNumber('inputTokenAmount', inputTokenAmount);
assert.isBigNumber('minOutputTokenAmount', minOutputTokenAmount);
assert.isArray('transformations', transformations);
const functionSignature = 'transformERC20(address,address,uint256,uint256,(uint32,bytes)[])';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [
inputToken.toLowerCase(),
outputToken.toLowerCase(),
inputTokenAmount,
minOutputTokenAmount,
transformations,
]);
},
};
}
/**
* Validate that `hash` was signed by `signer` given `signature`.
* Reverts otherwise.
* @param hash The hash that was signed.
* @param signer The signer of the hash.
* @param signature The signature. The last byte of this signature should
* be a member of the `SignatureType` enum.
*/
public validateHashSignature(hash: string, signer: string, signature: string): ContractTxFunctionObj<void> {
const self = (this as any) as IZeroExContract;
assert.isString('hash', hash);
assert.isString('signer', signer);
assert.isString('signature', signature);
const functionSignature = 'validateHashSignature(bytes32,address,bytes)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ data: this.getABIEncodedTransactionData(), ...txData },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
data: this.getABIEncodedTransactionData(),
...txData,
});
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync(
{ data: this.getABIEncodedTransactionData(), ...callData },
defaultBlock,
);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [hash, signer.toLowerCase(), signature]);
},
};
}
/**
* Subscribe to an event type emitted by the IZeroEx contract.
* @param eventName The IZeroEx contract event you would like to subscribe to.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
* the value is the value you are interested in. E.g `{maker: aUserAddressHex}`
* @param callback Callback that gets called when a log is added/removed
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
* @return Subscription token used later to unsubscribe
*/
public subscribe<ArgsType extends IZeroExEventArgs>(
eventName: IZeroExEvents,
indexFilterValues: IndexedFilterValues,
callback: EventCallback<ArgsType>,
isVerbose: boolean = false,
blockPollingIntervalMs?: number,
): string {
assert.doesBelongToStringEnum('eventName', eventName, IZeroExEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const subscriptionToken = this._subscriptionManager.subscribe<ArgsType>(
this.address,
eventName,
indexFilterValues,
IZeroExContract.ABI(),
callback,
isVerbose,
blockPollingIntervalMs,
);
return subscriptionToken;
}
/**
* Cancel a subscription
* @param subscriptionToken Subscription token returned by `subscribe()`
*/
public unsubscribe(subscriptionToken: string): void {
this._subscriptionManager.unsubscribe(subscriptionToken);
}
/**
* Cancels all existing subscriptions
*/
public unsubscribeAll(): void {
this._subscriptionManager.unsubscribeAll();
}
/**
* Gets historical logs without creating a subscription
* @param eventName The IZeroEx contract event you would like to subscribe to.
* @param blockRange Block range to get logs from.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
* @return Array of logs that match the parameters
*/
public async getLogsAsync<ArgsType extends IZeroExEventArgs>(
eventName: IZeroExEvents,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.doesBelongToStringEnum('eventName', eventName, IZeroExEvents);
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const logs = await this._subscriptionManager.getLogsAsync<ArgsType>(
this.address,
eventName,
blockRange,
indexFilterValues,
IZeroExContract.ABI(),
);
return logs;
}
constructor(
address: string,
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
deployedBytecode: string | undefined = IZeroExContract.deployedBytecode,
) {
super(
'IZeroEx',
IZeroExContract.ABI(),
address,
supportedProvider,
txDefaults,
logDecodeDependencies,
deployedBytecode,
);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
this._subscriptionManager = new SubscriptionManager<IZeroExEventArgs, IZeroExEvents>(
IZeroExContract.ABI(),
this._web3Wrapper,
);
IZeroExContract.ABI().forEach((item, index) => {
if (item.type === 'function') {
const methodAbi = item as MethodAbi;
this._methodABIIndex[methodAbi.name] = index;
}
});
}
}
// tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
// tslint:enable:trailing-comma whitespace no-trailing-whitespace