From a7acf2951d845f3db9174dbf6fe2bba64ee080e2 Mon Sep 17 00:00:00 2001 From: Andy <112491550+abls@users.noreply.github.com> Date: Mon, 24 Apr 2023 06:03:23 -0400 Subject: [PATCH] MetaTransaction V2 Utility Packages (#714) * add utility class for MetaTransactionsV2, update artifacts, update wrappers * fix exports * update artifacts, update wrappers * update changelogs --- packages/contract-artifacts/CHANGELOG.json | 10 +- .../contract-artifacts/artifacts/IZeroEx.json | 535 +++++-- packages/contract-wrappers/CHANGELOG.json | 10 +- .../src/generated-wrappers/i_zero_ex.ts | 1266 +++++++++++++++-- packages/protocol-utils/CHANGELOG.json | 10 +- packages/protocol-utils/src/index.ts | 1 + .../src/meta_transactions_v2.ts | 143 ++ .../test/meta_transactions_v2_test.ts | 66 + 8 files changed, 1808 insertions(+), 233 deletions(-) create mode 100644 packages/protocol-utils/src/meta_transactions_v2.ts create mode 100644 packages/protocol-utils/test/meta_transactions_v2_test.ts diff --git a/packages/contract-artifacts/CHANGELOG.json b/packages/contract-artifacts/CHANGELOG.json index 8ace1c93e5..a69efac4ee 100644 --- a/packages/contract-artifacts/CHANGELOG.json +++ b/packages/contract-artifacts/CHANGELOG.json @@ -1,4 +1,12 @@ [ + { + "version": "3.19.0", + "changes": [ + { + "note": "Regenerate IZeroEx artifact" + } + ] + }, { "timestamp": 1674517560, "version": "3.18.3", @@ -648,4 +656,4 @@ } ] } -] \ No newline at end of file +] diff --git a/packages/contract-artifacts/artifacts/IZeroEx.json b/packages/contract-artifacts/artifacts/IZeroEx.json index f88e072f08..37ed2da40b 100644 --- a/packages/contract-artifacts/artifacts/IZeroEx.json +++ b/packages/contract-artifacts/artifacts/IZeroEx.json @@ -26,7 +26,7 @@ { "indexed": false, "internalType": "uint256", "name": "nonce", "type": "uint256" }, { "indexed": false, - "internalType": "contract IERC20TokenV06", + "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, @@ -59,7 +59,7 @@ { "indexed": false, "internalType": "uint256", "name": "nonce", "type": "uint256" }, { "indexed": false, - "internalType": "contract IERC20TokenV06", + "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, @@ -124,7 +124,7 @@ { "indexed": false, "internalType": "uint256", "name": "nonce", "type": "uint256" }, { "indexed": false, - "internalType": "contract IERC20TokenV06", + "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, @@ -156,7 +156,7 @@ { "indexed": false, "internalType": "uint256", "name": "nonce", "type": "uint256" }, { "indexed": false, - "internalType": "contract IERC20TokenV06", + "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, @@ -235,13 +235,13 @@ "inputs": [ { "indexed": false, - "internalType": "contract IERC20TokenV06", + "internalType": "contract IERC20Token", "name": "inputToken", "type": "address" }, { "indexed": false, - "internalType": "contract IERC20TokenV06", + "internalType": "contract IERC20Token", "name": "outputToken", "type": "address" }, @@ -423,8 +423,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -471,8 +471,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -516,8 +516,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -559,6 +559,76 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "components": [ + { "internalType": "contract IERC20Token", "name": "inputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "outputToken", "type": "address" }, + { "internalType": "uint256", "name": "sellAmount", "type": "uint256" }, + { + "components": [ + { + "internalType": "enum IMultiplexFeature.MultiplexSubcall", + "name": "id", + "type": "uint8" + }, + { "internalType": "uint256", "name": "sellAmount", "type": "uint256" }, + { "internalType": "bytes", "name": "data", "type": "bytes" } + ], + "internalType": "struct IMultiplexFeature.BatchSellSubcall[]", + "name": "calls", + "type": "tuple[]" + }, + { "internalType": "bool", "name": "useSelfBalance", "type": "bool" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "address", "name": "payer", "type": "address" } + ], + "internalType": "struct IMultiplexFeature.BatchSellParams", + "name": "params", + "type": "tuple" + }, + { "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" } + ], + "name": "_multiplexBatchSell", + "outputs": [{ "internalType": "uint256", "name": "boughtAmount", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address[]", "name": "tokens", "type": "address[]" }, + { "internalType": "uint256", "name": "sellAmount", "type": "uint256" }, + { + "components": [ + { + "internalType": "enum IMultiplexFeature.MultiplexSubcall", + "name": "id", + "type": "uint8" + }, + { "internalType": "bytes", "name": "data", "type": "bytes" } + ], + "internalType": "struct IMultiplexFeature.MultiHopSellSubcall[]", + "name": "calls", + "type": "tuple[]" + }, + { "internalType": "bool", "name": "useSelfBalance", "type": "bool" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "address", "name": "payer", "type": "address" } + ], + "internalType": "struct IMultiplexFeature.MultiHopSellParams", + "name": "params", + "type": "tuple" + }, + { "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" } + ], + "name": "_multiplexMultiHopSell", + "outputs": [{ "internalType": "uint256", "name": "boughtAmount", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { "internalType": "bytes", "name": "encodedPath", "type": "bytes" }, @@ -571,13 +641,26 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedPath", "type": "bytes" }, + { "internalType": "uint256", "name": "sellAmount", "type": "uint256" }, + { "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "address", "name": "payer", "type": "address" } + ], + "name": "_sellTokenForTokenToUniswapV3", + "outputs": [{ "internalType": "uint256", "name": "buyAmount", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { "components": [ { "internalType": "address payable", "name": "taker", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "inputToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "outputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "inputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "outputToken", "type": "address" }, { "internalType": "uint256", "name": "inputTokenAmount", "type": "uint256" }, { "internalType": "uint256", "name": "minOutputTokenAmount", "type": "uint256" }, { @@ -611,7 +694,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -677,7 +760,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -750,8 +833,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -775,8 +858,8 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06[]", "name": "makerTokens", "type": "address[]" }, - { "internalType": "contract IERC20TokenV06[]", "name": "takerTokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "makerTokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "takerTokens", "type": "address[]" }, { "internalType": "uint256[]", "name": "minValidSalts", "type": "uint256[]" } ], "name": "batchCancelPairLimitOrders", @@ -787,8 +870,8 @@ { "inputs": [ { "internalType": "address", "name": "maker", "type": "address" }, - { "internalType": "contract IERC20TokenV06[]", "name": "makerTokens", "type": "address[]" }, - { "internalType": "contract IERC20TokenV06[]", "name": "takerTokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "makerTokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "takerTokens", "type": "address[]" }, { "internalType": "uint256[]", "name": "minValidSalts", "type": "uint256[]" } ], "name": "batchCancelPairLimitOrdersWithSigner", @@ -798,8 +881,8 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06[]", "name": "makerTokens", "type": "address[]" }, - { "internalType": "contract IERC20TokenV06[]", "name": "takerTokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "makerTokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "takerTokens", "type": "address[]" }, { "internalType": "uint256[]", "name": "minValidSalts", "type": "uint256[]" } ], "name": "batchCancelPairRfqOrders", @@ -810,8 +893,8 @@ { "inputs": [ { "internalType": "address", "name": "maker", "type": "address" }, - { "internalType": "contract IERC20TokenV06[]", "name": "makerTokens", "type": "address[]" }, - { "internalType": "contract IERC20TokenV06[]", "name": "takerTokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "makerTokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "takerTokens", "type": "address[]" }, { "internalType": "uint256[]", "name": "minValidSalts", "type": "uint256[]" } ], "name": "batchCancelPairRfqOrdersWithSigner", @@ -823,8 +906,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -856,7 +939,7 @@ { "internalType": "uint256", "name": "salt", "type": "uint256" }, { "internalType": "bytes", "name": "callData", "type": "bytes" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "feeToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "feeToken", "type": "address" }, { "internalType": "uint256", "name": "feeAmount", "type": "uint256" } ], "internalType": "struct IMetaTransactionsFeature.MetaTransactionData[]", @@ -888,8 +971,53 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "address payable", "name": "signer", "type": "address" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "uint256", "name": "expirationTimeSeconds", "type": "uint256" }, + { "internalType": "uint256", "name": "salt", "type": "uint256" }, + { "internalType": "bytes", "name": "callData", "type": "bytes" }, + { "internalType": "contract IERC20Token", "name": "feeToken", "type": "address" }, + { + "components": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "internalType": "struct IMetaTransactionsFeatureV2.MetaTransactionFeeData[]", + "name": "fees", + "type": "tuple[]" + } + ], + "internalType": "struct IMetaTransactionsFeatureV2.MetaTransactionDataV2[]", + "name": "mtxs", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "enum LibSignature.SignatureType", + "name": "signatureType", + "type": "uint8" + }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "internalType": "struct LibSignature.Signature[]", + "name": "signatures", + "type": "tuple[]" + } + ], + "name": "batchExecuteMetaTransactionsV2", + "outputs": [{ "internalType": "bytes[]", "name": "returnResults", "type": "bytes[]" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -935,8 +1063,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -980,8 +1108,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1034,8 +1162,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -1089,8 +1217,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1147,7 +1275,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -1186,7 +1314,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -1266,7 +1394,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -1331,7 +1459,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -1403,8 +1531,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -1428,8 +1556,8 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint256", "name": "minValidSalt", "type": "uint256" } ], "name": "cancelPairLimitOrders", @@ -1440,8 +1568,8 @@ { "inputs": [ { "internalType": "address", "name": "maker", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint256", "name": "minValidSalt", "type": "uint256" } ], "name": "cancelPairLimitOrdersWithSigner", @@ -1451,8 +1579,8 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint256", "name": "minValidSalt", "type": "uint256" } ], "name": "cancelPairRfqOrders", @@ -1463,8 +1591,8 @@ { "inputs": [ { "internalType": "address", "name": "maker", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint256", "name": "minValidSalt", "type": "uint256" } ], "name": "cancelPairRfqOrdersWithSigner", @@ -1476,8 +1604,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1516,7 +1644,7 @@ { "internalType": "uint256", "name": "salt", "type": "uint256" }, { "internalType": "bytes", "name": "callData", "type": "bytes" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "feeToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "feeToken", "type": "address" }, { "internalType": "uint256", "name": "feeAmount", "type": "uint256" } ], "internalType": "struct IMetaTransactionsFeature.MetaTransactionData", @@ -1544,6 +1672,51 @@ "stateMutability": "payable", "type": "function" }, + { + "inputs": [ + { + "components": [ + { "internalType": "address payable", "name": "signer", "type": "address" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "uint256", "name": "expirationTimeSeconds", "type": "uint256" }, + { "internalType": "uint256", "name": "salt", "type": "uint256" }, + { "internalType": "bytes", "name": "callData", "type": "bytes" }, + { "internalType": "contract IERC20Token", "name": "feeToken", "type": "address" }, + { + "components": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "internalType": "struct IMetaTransactionsFeatureV2.MetaTransactionFeeData[]", + "name": "fees", + "type": "tuple[]" + } + ], + "internalType": "struct IMetaTransactionsFeatureV2.MetaTransactionDataV2", + "name": "mtx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "enum LibSignature.SignatureType", + "name": "signatureType", + "type": "uint8" + }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "internalType": "struct LibSignature.Signature", + "name": "signature", + "type": "tuple" + } + ], + "name": "executeMetaTransactionV2", + "outputs": [{ "internalType": "bytes", "name": "returnResult", "type": "bytes" }], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { "internalType": "bytes4", "name": "selector", "type": "bytes4" }, @@ -1558,8 +1731,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -1604,8 +1777,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -1647,8 +1820,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1688,8 +1861,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1730,8 +1903,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1772,8 +1945,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1813,8 +1986,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1857,8 +2030,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1910,8 +2083,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -1968,7 +2141,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -2016,7 +2189,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -2076,7 +2249,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -2123,7 +2296,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -2175,8 +2348,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -2202,8 +2375,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -2240,8 +2413,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerTokenFeeAmount", "type": "uint128" }, @@ -2303,7 +2476,7 @@ { "internalType": "uint256", "name": "salt", "type": "uint256" }, { "internalType": "bytes", "name": "callData", "type": "bytes" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "feeToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "feeToken", "type": "address" }, { "internalType": "uint256", "name": "feeAmount", "type": "uint256" } ], "internalType": "struct IMetaTransactionsFeature.MetaTransactionData", @@ -2328,7 +2501,7 @@ { "internalType": "uint256", "name": "salt", "type": "uint256" }, { "internalType": "bytes", "name": "callData", "type": "bytes" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "feeToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "feeToken", "type": "address" }, { "internalType": "uint256", "name": "feeAmount", "type": "uint256" } ], "internalType": "struct IMetaTransactionsFeature.MetaTransactionData", @@ -2352,8 +2525,75 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "address payable", "name": "signer", "type": "address" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "uint256", "name": "expirationTimeSeconds", "type": "uint256" }, + { "internalType": "uint256", "name": "salt", "type": "uint256" }, + { "internalType": "bytes", "name": "callData", "type": "bytes" }, + { "internalType": "contract IERC20Token", "name": "feeToken", "type": "address" }, + { + "components": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "internalType": "struct IMetaTransactionsFeatureV2.MetaTransactionFeeData[]", + "name": "fees", + "type": "tuple[]" + } + ], + "internalType": "struct IMetaTransactionsFeatureV2.MetaTransactionDataV2", + "name": "mtx", + "type": "tuple" + } + ], + "name": "getMetaTransactionV2ExecutedBlock", + "outputs": [{ "internalType": "uint256", "name": "blockNumber", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address payable", "name": "signer", "type": "address" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "uint256", "name": "expirationTimeSeconds", "type": "uint256" }, + { "internalType": "uint256", "name": "salt", "type": "uint256" }, + { "internalType": "bytes", "name": "callData", "type": "bytes" }, + { "internalType": "contract IERC20Token", "name": "feeToken", "type": "address" }, + { + "components": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "internalType": "struct IMetaTransactionsFeatureV2.MetaTransactionFeeData[]", + "name": "fees", + "type": "tuple[]" + } + ], + "internalType": "struct IMetaTransactionsFeatureV2.MetaTransactionDataV2", + "name": "mtx", + "type": "tuple" + } + ], + "name": "getMetaTransactionV2Hash", + "outputs": [{ "internalType": "bytes32", "name": "mtxHash", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "mtxHash", "type": "bytes32" }], + "name": "getMetaTransactionV2HashExecutedBlock", + "outputs": [{ "internalType": "uint256", "name": "blockNumber", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -2375,8 +2615,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -2422,8 +2662,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -2447,8 +2687,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -2483,8 +2723,8 @@ "inputs": [ { "components": [ - { "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "makerToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "takerToken", "type": "address" }, { "internalType": "uint128", "name": "makerAmount", "type": "uint128" }, { "internalType": "uint128", "name": "takerAmount", "type": "uint128" }, { "internalType": "address", "name": "maker", "type": "address" }, @@ -2592,7 +2832,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -2631,7 +2871,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -2712,7 +2952,7 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06", "name": "outputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "outputToken", "type": "address" }, { "components": [ { @@ -2736,7 +2976,7 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06", "name": "inputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "inputToken", "type": "address" }, { "components": [ { @@ -2761,8 +3001,8 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06", "name": "inputToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "outputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "inputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "outputToken", "type": "address" }, { "components": [ { @@ -2897,7 +3137,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -2945,7 +3185,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -3022,7 +3262,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -3089,7 +3329,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -3158,8 +3398,8 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06", "name": "inputToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "outputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "inputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "outputToken", "type": "address" }, { "internalType": "contract ILiquidityProvider", "name": "provider", "type": "address" }, { "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint256", "name": "sellAmount", "type": "uint256" }, @@ -3173,7 +3413,7 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06[]", "name": "tokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "tokens", "type": "address[]" }, { "internalType": "uint256", "name": "sellAmount", "type": "uint256" }, { "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }, { "internalType": "enum IPancakeSwapFeature.ProtocolFork", "name": "fork", "type": "uint8" } @@ -3185,7 +3425,7 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06[]", "name": "tokens", "type": "address[]" }, + { "internalType": "contract IERC20Token[]", "name": "tokens", "type": "address[]" }, { "internalType": "uint256", "name": "sellAmount", "type": "uint256" }, { "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }, { "internalType": "bool", "name": "isSushi", "type": "bool" } @@ -3256,7 +3496,7 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06", "name": "erc20", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20", "type": "address" }, { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, { "internalType": "address payable", "name": "recipientWallet", "type": "address" } ], @@ -3267,8 +3507,8 @@ }, { "inputs": [ - { "internalType": "contract IERC20TokenV06", "name": "inputToken", "type": "address" }, - { "internalType": "contract IERC20TokenV06", "name": "outputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "inputToken", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "outputToken", "type": "address" }, { "internalType": "uint256", "name": "inputTokenAmount", "type": "uint256" }, { "internalType": "uint256", "name": "minOutputTokenAmount", "type": "uint256" }, { @@ -3306,7 +3546,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -3355,7 +3595,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -3418,7 +3658,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -3466,7 +3706,7 @@ { "internalType": "address", "name": "taker", "type": "address" }, { "internalType": "uint256", "name": "expiry", "type": "uint256" }, { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "contract IERC20TokenV06", "name": "erc20Token", "type": "address" }, + { "internalType": "contract IERC20Token", "name": "erc20Token", "type": "address" }, { "internalType": "uint256", "name": "erc20TokenAmount", "type": "uint256" }, { "components": [ @@ -3568,6 +3808,22 @@ "takerTokenFilledAmount": "How much maker token was filled." } }, + "_multiplexBatchSell((address,address,uint256,(uint8,uint256,bytes)[],bool,address,address),uint256)": { + "details": "Executes a multiplex BatchSell using the given parameters. Internal only.", + "params": { + "minBuyAmount": "The minimum amount of `params.outputToken` that must be bought for this function to not revert.", + "params": "The parameters for the BatchSell." + }, + "returns": { "boughtAmount": "The amount of `params.outputToken` bought." } + }, + "_multiplexMultiHopSell((address[],uint256,(uint8,bytes)[],bool,address,address),uint256)": { + "details": "Executes a multiplex MultiHopSell using the given parameters. Internal only.", + "params": { + "minBuyAmount": "The minimum amount of the output token that must be bought for this function to not revert.", + "params": "The parameters for the MultiHopSell." + }, + "returns": { "boughtAmount": "The amount of the output token bought." } + }, "_sellHeldTokenForTokenToUniswapV3(bytes,uint256,uint256,address)": { "details": "Sell a token for another token directly against uniswap v3. Private variant, uses tokens held by `address(this)`.", "params": { @@ -3578,6 +3834,17 @@ }, "returns": { "buyAmount": "Amount of the last token in the path bought." } }, + "_sellTokenForTokenToUniswapV3(bytes,uint256,uint256,address,address)": { + "details": "Sell a token for another token directly against uniswap v3. Internal variant.", + "params": { + "encodedPath": "Uniswap-encoded path.", + "minBuyAmount": "Minimum amount of the last token in the path to buy.", + "payer": "The address to pull the sold tokens from.", + "recipient": "The recipient of the bought tokens. Can be zero for payer.", + "sellAmount": "amount of the first token in the path to sell." + }, + "returns": { "buyAmount": "Amount of the last token in the path bought." } + }, "_transformERC20((address,address,address,uint256,uint256,(uint32,bytes)[],bool,address))": { "details": "Internal version of `transformERC20()`. Only callable from within.", "params": { "args": "A `TransformERC20Args` struct." }, @@ -3666,6 +3933,14 @@ }, "returns": { "returnResults": "The ABI-encoded results of the underlying calls." } }, + "batchExecuteMetaTransactionsV2((address,address,uint256,uint256,bytes,address,(address,uint256)[])[],(uint8,uint8,bytes32,bytes32)[])": { + "details": "Execute multiple meta-transactions.", + "params": { + "mtxs": "The meta-transactions.", + "signatures": "The signature by each respective `mtx.signer`." + }, + "returns": { "returnResults": "The ABI-encoded results of the underlying calls." } + }, "batchFillLimitOrders((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256)[],(uint8,uint8,bytes32,bytes32)[],uint128[],bool)": { "details": "Fills multiple limit orders.", "params": { @@ -3698,7 +3973,7 @@ "makerSignatures": "Array of maker signatures for each order.", "orders": "Array of OTC orders.", "takerSignatures": "Array of taker signatures for each order.", - "unwrapWeth": "Array of booleans representing whether or not to unwrap bought WETH into ETH for each order. Should be set to false if the maker token is not WETH." + "unwrapWeth": "Array of booleans representing whether or not to unwrap bought WETH into ETH for each order. Should be set to false if the maker token is not WETH." }, "returns": { "successes": "Array of booleans representing whether or not each order in `orders` was filled successfully." @@ -3811,6 +4086,11 @@ "params": { "mtx": "The meta-transaction.", "signature": "The signature by `mtx.signer`." }, "returns": { "returnResult": "The ABI-encoded result of the underlying call." } }, + "executeMetaTransactionV2((address,address,uint256,uint256,bytes,address,(address,uint256)[]),(uint8,uint8,bytes32,bytes32))": { + "details": "Execute a single meta-transaction.", + "params": { "mtx": "The meta-transaction.", "signature": "The signature by `mtx.signer`." }, + "returns": { "returnResult": "The ABI-encoded result of the underlying call." } + }, "extend(bytes4,address)": { "details": "Register or replace a function.", "params": { @@ -3861,7 +4141,7 @@ } }, "fillOtcOrderForEth((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),uint128)": { - "details": "Fill an OTC order for up to `takerTokenFillAmount` taker tokens. Unwraps bought WETH into ETH before sending it to the taker.", + "details": "Fill an OTC order for up to `takerTokenFillAmount` taker tokens. Unwraps bought WETH into ETH before sending it to the taker.", "params": { "makerSignature": "The order signature from the maker.", "order": "The OTC order.", @@ -3901,7 +4181,7 @@ } }, "fillTakerSignedOtcOrderForEth((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),(uint8,uint8,bytes32,bytes32))": { - "details": "Fully fill an OTC order. \"Meta-transaction\" variant, requires order to be signed by both maker and taker. Unwraps bought WETH into ETH before sending it to the taker.", + "details": "Fully fill an OTC order. \"Meta-transaction\" variant, requires order to be signed by both maker and taker. Unwraps bought WETH into ETH before sending it to the taker.", "params": { "makerSignature": "The order signature from the maker.", "order": "The OTC order.", @@ -3972,6 +4252,21 @@ "params": { "mtxHash": "The meta-transaction hash." }, "returns": { "blockNumber": "The block height when the meta-transactioin was executed." } }, + "getMetaTransactionV2ExecutedBlock((address,address,uint256,uint256,bytes,address,(address,uint256)[]))": { + "details": "Get the block at which a meta-transaction has been executed.", + "params": { "mtx": "The meta-transaction." }, + "returns": { "blockNumber": "The block height when the meta-transactioin was executed." } + }, + "getMetaTransactionV2Hash((address,address,uint256,uint256,bytes,address,(address,uint256)[]))": { + "details": "Get the EIP712 hash of a meta-transaction.", + "params": { "mtx": "The meta-transaction." }, + "returns": { "mtxHash": "The EIP712 hash of `mtx`." } + }, + "getMetaTransactionV2HashExecutedBlock(bytes32)": { + "details": "Get the block at which a meta-transaction hash has been executed.", + "params": { "mtxHash": "The EIP712 hash of the MetaTransactionDataV2 struct." }, + "returns": { "blockNumber": "The block height when the meta-transactioin was executed." } + }, "getOtcOrderHash((address,address,uint128,uint128,address,address,address,uint256))": { "details": "Get the canonical hash of an OTC order.", "params": { "order": "The OTC order." }, diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index e91b1512f8..03f638b19f 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -1,4 +1,12 @@ [ + { + "version": "13.23.0", + "changes": [ + { + "note": "Regenerate IZeroEx wrapper" + } + ] + }, { "timestamp": 1681969282, "version": "13.22.21", @@ -1675,4 +1683,4 @@ } ] } -] \ No newline at end of file +] diff --git a/packages/contract-wrappers/src/generated-wrappers/i_zero_ex.ts b/packages/contract-wrappers/src/generated-wrappers/i_zero_ex.ts index 1f09649b67..44e4a0500d 100644 --- a/packages/contract-wrappers/src/generated-wrappers/i_zero_ex.ts +++ b/packages/contract-wrappers/src/generated-wrappers/i_zero_ex.ts @@ -1,3 +1,6 @@ +// 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, EncoderOverrides, @@ -32,6 +35,7 @@ import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/ import { Web3Wrapper } from '@0x/web3-wrapper'; import { assert } from '@0x/assert'; import * as ethers from 'ethers'; +// tslint:enable:no-unused-variable export type IZeroExEventArgs = | IZeroExERC1155OrderCancelledEventArgs @@ -262,6 +266,9 @@ export interface IZeroExTransformerDeployerUpdatedEventArgs extends DecodedLogAr } /* istanbul ignore next */ +// tslint:disable:array-type +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name export class IZeroExContract extends BaseContract { /** * @ignore @@ -1451,6 +1458,128 @@ export class IZeroExContract extends BaseContract { stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [ + { + name: 'params', + type: 'tuple', + components: [ + { + name: 'inputToken', + type: 'address', + }, + { + name: 'outputToken', + type: 'address', + }, + { + name: 'sellAmount', + type: 'uint256', + }, + { + name: 'calls', + type: 'tuple[]', + components: [ + { + name: 'id', + type: 'uint8', + }, + { + name: 'sellAmount', + type: 'uint256', + }, + { + name: 'data', + type: 'bytes', + }, + ], + }, + { + name: 'useSelfBalance', + type: 'bool', + }, + { + name: 'recipient', + type: 'address', + }, + { + name: 'payer', + type: 'address', + }, + ], + }, + { + name: 'minBuyAmount', + type: 'uint256', + }, + ], + name: '_multiplexBatchSell', + outputs: [ + { + name: 'boughtAmount', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + name: 'params', + type: 'tuple', + components: [ + { + name: 'tokens', + type: 'address[]', + }, + { + name: 'sellAmount', + type: 'uint256', + }, + { + name: 'calls', + type: 'tuple[]', + components: [ + { + name: 'id', + type: 'uint8', + }, + { + name: 'data', + type: 'bytes', + }, + ], + }, + { + name: 'useSelfBalance', + type: 'bool', + }, + { + name: 'recipient', + type: 'address', + }, + { + name: 'payer', + type: 'address', + }, + ], + }, + { + name: 'minBuyAmount', + type: 'uint256', + }, + ], + name: '_multiplexMultiHopSell', + outputs: [ + { + name: 'boughtAmount', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { @@ -1480,6 +1609,39 @@ export class IZeroExContract extends BaseContract { stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [ + { + name: 'encodedPath', + type: 'bytes', + }, + { + name: 'sellAmount', + type: 'uint256', + }, + { + name: 'minBuyAmount', + type: 'uint256', + }, + { + name: 'recipient', + type: 'address', + }, + { + name: 'payer', + type: 'address', + }, + ], + name: '_sellTokenForTokenToUniswapV3', + outputs: [ + { + name: 'buyAmount', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { @@ -2092,6 +2254,85 @@ export class IZeroExContract extends BaseContract { stateMutability: 'payable', type: 'function', }, + { + inputs: [ + { + name: 'mtxs', + type: 'tuple[]', + components: [ + { + name: 'signer', + type: 'address', + }, + { + name: 'sender', + type: 'address', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'callData', + type: 'bytes', + }, + { + name: 'feeToken', + type: 'address', + }, + { + name: 'fees', + type: 'tuple[]', + components: [ + { + name: 'recipient', + type: 'address', + }, + { + name: 'amount', + type: 'uint256', + }, + ], + }, + ], + }, + { + name: 'signatures', + type: 'tuple[]', + components: [ + { + name: 'signatureType', + type: 'uint8', + }, + { + name: 'v', + type: 'uint8', + }, + { + name: 'r', + type: 'bytes32', + }, + { + name: 's', + type: 'bytes32', + }, + ], + }, + ], + name: 'batchExecuteMetaTransactionsV2', + outputs: [ + { + name: 'returnResults', + type: 'bytes[]', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { @@ -3353,6 +3594,85 @@ export class IZeroExContract extends BaseContract { stateMutability: 'payable', type: 'function', }, + { + inputs: [ + { + name: 'mtx', + type: 'tuple', + components: [ + { + name: 'signer', + type: 'address', + }, + { + name: 'sender', + type: 'address', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'callData', + type: 'bytes', + }, + { + name: 'feeToken', + type: 'address', + }, + { + name: 'fees', + type: 'tuple[]', + components: [ + { + name: 'recipient', + type: 'address', + }, + { + name: 'amount', + type: 'uint256', + }, + ], + }, + ], + }, + { + name: 'signature', + type: 'tuple', + components: [ + { + name: 'signatureType', + type: 'uint8', + }, + { + name: 'v', + type: 'uint8', + }, + { + name: 'r', + type: 'bytes32', + }, + { + name: 's', + type: 'bytes32', + }, + ], + }, + ], + name: 'executeMetaTransactionV2', + outputs: [ + { + name: 'returnResult', + type: 'bytes', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { @@ -4941,6 +5261,137 @@ export class IZeroExContract extends BaseContract { stateMutability: 'view', type: 'function', }, + { + inputs: [ + { + name: 'mtx', + type: 'tuple', + components: [ + { + name: 'signer', + type: 'address', + }, + { + name: 'sender', + type: 'address', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'callData', + type: 'bytes', + }, + { + name: 'feeToken', + type: 'address', + }, + { + name: 'fees', + type: 'tuple[]', + components: [ + { + name: 'recipient', + type: 'address', + }, + { + name: 'amount', + type: 'uint256', + }, + ], + }, + ], + }, + ], + name: 'getMetaTransactionV2ExecutedBlock', + outputs: [ + { + name: 'blockNumber', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + name: 'mtx', + type: 'tuple', + components: [ + { + name: 'signer', + type: 'address', + }, + { + name: 'sender', + type: 'address', + }, + { + name: 'expirationTimeSeconds', + type: 'uint256', + }, + { + name: 'salt', + type: 'uint256', + }, + { + name: 'callData', + type: 'bytes', + }, + { + name: 'feeToken', + type: 'address', + }, + { + name: 'fees', + type: 'tuple[]', + components: [ + { + name: 'recipient', + type: 'address', + }, + { + name: 'amount', + type: 'uint256', + }, + ], + }, + ], + }, + ], + name: 'getMetaTransactionV2Hash', + outputs: [ + { + name: 'mtxHash', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + name: 'mtxHash', + type: 'bytes32', + }, + ], + name: 'getMetaTransactionV2HashExecutedBlock', + outputs: [ + { + name: 'blockNumber', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, { inputs: [ { @@ -7182,14 +7633,14 @@ export class IZeroExContract extends BaseContract { public getFunctionSignature(methodName: string): string { const index = this._methodABIIndex[methodName]; - const methodAbi = IZeroExContract.ABI()[index] as MethodAbi; + const methodAbi = IZeroExContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion const functionSignature = methodAbiToFunctionSignature(methodAbi); return functionSignature; } public getABIDecodedTransactionData(methodName: string, callData: string): T { const functionSignature = this.getFunctionSignature(methodName); - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const abiEncoder = self._lookupAbiEncoder(functionSignature); const abiDecodedCallData = abiEncoder.strictDecode(callData); return abiDecodedCallData; @@ -7200,7 +7651,7 @@ export class IZeroExContract extends BaseContract { return this._encoderOverrides.decodeOutput(methodName, callData); } const functionSignature = this.getFunctionSignature(methodName); - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const abiEncoder = self._lookupAbiEncoder(functionSignature); const abiDecodedCallData = abiEncoder.strictDecodeReturnValue(callData); return abiDecodedCallData; @@ -7208,7 +7659,7 @@ export class IZeroExContract extends BaseContract { public getSelector(methodName: string): string { const functionSignature = this.getFunctionSignature(methodName); - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const abiEncoder = self._lookupAbiEncoder(functionSignature); return abiEncoder.getSelector(); } @@ -7243,7 +7694,7 @@ export class IZeroExContract extends BaseContract { taker: string, sender: string, ): ContractTxFunctionObj<[BigNumber, BigNumber]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); assert.isString('taker', taker); @@ -7342,7 +7793,7 @@ export class IZeroExContract extends BaseContract { useSelfBalance: boolean, recipient: string, ): ContractTxFunctionObj<[BigNumber, BigNumber]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); assert.isString('taker', taker); @@ -7443,7 +7894,7 @@ export class IZeroExContract extends BaseContract { useSelfBalance: boolean, recipient: string, ): ContractTxFunctionObj<[BigNumber, BigNumber]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); assert.isString('taker', taker); @@ -7515,6 +7966,161 @@ export class IZeroExContract extends BaseContract { }, }; } + /** + * Executes a multiplex BatchSell using the given + * parameters. Internal only. + * @param params The parameters for the BatchSell. + * @param minBuyAmount The minimum amount of `params.outputToken` that + * must be bought for this function to not revert. + */ + public _multiplexBatchSell( + params: { + inputToken: string; + outputToken: string; + sellAmount: BigNumber; + calls: Array<{ id: number | BigNumber; sellAmount: BigNumber; data: string }>; + useSelfBalance: boolean; + recipient: string; + payer: string; + }, + minBuyAmount: BigNumber, + ): ContractTxFunctionObj { + const self = this as any as IZeroExContract; + + assert.isBigNumber('minBuyAmount', minBuyAmount); + const functionSignature = + '_multiplexBatchSell((address,address,uint256,(uint8,uint256,bytes)[],bool,address,address),uint256)'; + + return { + selector: self._lookupAbiEncoder(functionSignature).getSelector(), + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + 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, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + }, + async createAccessListAsync( + txData?: Partial | undefined, + defaultBlock?: BlockParam, + ): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.createAccessListAsync(txDataWithDefaults, defaultBlock); + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + 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(rawCallResult); + }, + getABIEncodedTransactionData(): string { + return self._strictEncodeArguments(functionSignature, [params, minBuyAmount]); + }, + }; + } + /** + * Executes a multiplex MultiHopSell using the given + * parameters. Internal only. + * @param params The parameters for the MultiHopSell. + * @param minBuyAmount The minimum amount of the output token that must + * be bought for this function to not revert. + */ + public _multiplexMultiHopSell( + params: { + tokens: string[]; + sellAmount: BigNumber; + calls: Array<{ id: number | BigNumber; data: string }>; + useSelfBalance: boolean; + recipient: string; + payer: string; + }, + minBuyAmount: BigNumber, + ): ContractTxFunctionObj { + const self = this as any as IZeroExContract; + + assert.isBigNumber('minBuyAmount', minBuyAmount); + const functionSignature = + '_multiplexMultiHopSell((address[],uint256,(uint8,bytes)[],bool,address,address),uint256)'; + + return { + selector: self._lookupAbiEncoder(functionSignature).getSelector(), + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + 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, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + }, + async createAccessListAsync( + txData?: Partial | undefined, + defaultBlock?: BlockParam, + ): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.createAccessListAsync(txDataWithDefaults, defaultBlock); + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + 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(rawCallResult); + }, + getABIEncodedTransactionData(): string { + return self._strictEncodeArguments(functionSignature, [params, minBuyAmount]); + }, + }; + } /** * Sell a token for another token directly against uniswap v3. * Private variant, uses tokens held by `address(this)`. @@ -7529,7 +8135,7 @@ export class IZeroExContract extends BaseContract { minBuyAmount: BigNumber, recipient: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('encodedPath', encodedPath); assert.isBigNumber('sellAmount', sellAmount); assert.isBigNumber('minBuyAmount', minBuyAmount); @@ -7594,6 +8200,88 @@ export class IZeroExContract extends BaseContract { }, }; } + /** + * Sell a token for another token directly against uniswap v3. Internal variant. + * @param encodedPath Uniswap-encoded path. + * @param sellAmount amount of the first token in the path to sell. + * @param minBuyAmount Minimum amount of the last token in the path to buy. + * @param recipient The recipient of the bought tokens. Can be zero for payer. + * @param payer The address to pull the sold tokens from. + */ + public _sellTokenForTokenToUniswapV3( + encodedPath: string, + sellAmount: BigNumber, + minBuyAmount: BigNumber, + recipient: string, + payer: string, + ): ContractTxFunctionObj { + const self = this as any as IZeroExContract; + assert.isString('encodedPath', encodedPath); + assert.isBigNumber('sellAmount', sellAmount); + assert.isBigNumber('minBuyAmount', minBuyAmount); + assert.isString('recipient', recipient); + assert.isString('payer', payer); + const functionSignature = '_sellTokenForTokenToUniswapV3(bytes,uint256,uint256,address,address)'; + + return { + selector: self._lookupAbiEncoder(functionSignature).getSelector(), + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + 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, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + }, + async createAccessListAsync( + txData?: Partial | undefined, + defaultBlock?: BlockParam, + ): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.createAccessListAsync(txDataWithDefaults, defaultBlock); + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + 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(rawCallResult); + }, + getABIEncodedTransactionData(): string { + return self._strictEncodeArguments(functionSignature, [ + encodedPath, + sellAmount, + minBuyAmount, + recipient.toLowerCase(), + payer.toLowerCase(), + ]); + }, + }; + } /** * Internal version of `transformERC20()`. Only callable from within. * @param args A `TransformERC20Args` struct. @@ -7608,7 +8296,7 @@ export class IZeroExContract extends BaseContract { useSelfBalance: boolean; recipient: string; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = '_transformERC20((address,address,address,uint256,uint256,(uint32,bytes)[],bool,address))'; @@ -7699,7 +8387,7 @@ export class IZeroExContract extends BaseContract { callbackData: string[], revertIfIncomplete: boolean, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('sellOrders', sellOrders); assert.isArray('signatures', signatures); assert.isArray('erc1155TokenAmounts', erc1155TokenAmounts); @@ -7796,7 +8484,7 @@ export class IZeroExContract extends BaseContract { callbackData: string[], revertIfIncomplete: boolean, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('sellOrders', sellOrders); assert.isArray('signatures', signatures); assert.isArray('callbackData', callbackData); @@ -7870,7 +8558,7 @@ export class IZeroExContract extends BaseContract { * @param orderNonces The order nonces. */ public batchCancelERC1155Orders(orderNonces: BigNumber[]): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('orderNonces', orderNonces); const functionSignature = 'batchCancelERC1155Orders(uint256[])'; @@ -7935,7 +8623,7 @@ export class IZeroExContract extends BaseContract { * @param orderNonces The order nonces. */ public batchCancelERC721Orders(orderNonces: BigNumber[]): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('orderNonces', orderNonces); const functionSignature = 'batchCancelERC721Orders(uint256[])'; @@ -8013,7 +8701,7 @@ export class IZeroExContract extends BaseContract { salt: BigNumber; }>, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + 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)[])'; @@ -8085,7 +8773,7 @@ export class IZeroExContract extends BaseContract { takerTokens: string[], minValidSalts: BigNumber[], ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('makerTokens', makerTokens); assert.isArray('takerTokens', takerTokens); assert.isArray('minValidSalts', minValidSalts); @@ -8160,7 +8848,7 @@ export class IZeroExContract extends BaseContract { takerTokens: string[], minValidSalts: BigNumber[], ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('maker', maker); assert.isArray('makerTokens', makerTokens); assert.isArray('takerTokens', takerTokens); @@ -8239,7 +8927,7 @@ export class IZeroExContract extends BaseContract { takerTokens: string[], minValidSalts: BigNumber[], ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('makerTokens', makerTokens); assert.isArray('takerTokens', takerTokens); assert.isArray('minValidSalts', minValidSalts); @@ -8314,7 +9002,7 @@ export class IZeroExContract extends BaseContract { takerTokens: string[], minValidSalts: BigNumber[], ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('maker', maker); assert.isArray('makerTokens', makerTokens); assert.isArray('takerTokens', takerTokens); @@ -8398,7 +9086,7 @@ export class IZeroExContract extends BaseContract { salt: BigNumber; }>, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('orders', orders); const functionSignature = 'batchCancelRfqOrders((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256)[])'; @@ -8476,7 +9164,7 @@ export class IZeroExContract extends BaseContract { }>, signatures: Array<{ signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }>, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('mtxs', mtxs); assert.isArray('signatures', signatures); const functionSignature = @@ -8535,6 +9223,82 @@ export class IZeroExContract extends BaseContract { }, }; } + /** + * Execute multiple meta-transactions. + * @param mtxs The meta-transactions. + * @param signatures The signature by each respective `mtx.signer`. + */ + public batchExecuteMetaTransactionsV2( + mtxs: Array<{ + signer: string; + sender: string; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + callData: string; + feeToken: string; + fees: Array<{ recipient: string; amount: BigNumber }>; + }>, + signatures: Array<{ signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }>, + ): ContractTxFunctionObj { + const self = this as any as IZeroExContract; + assert.isArray('mtxs', mtxs); + assert.isArray('signatures', signatures); + const functionSignature = + 'batchExecuteMetaTransactionsV2((address,address,uint256,uint256,bytes,address,(address,uint256)[])[],(uint8,uint8,bytes32,bytes32)[])'; + + return { + selector: self._lookupAbiEncoder(functionSignature).getSelector(), + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + 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, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + }, + async createAccessListAsync( + txData?: Partial | undefined, + defaultBlock?: BlockParam, + ): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.createAccessListAsync(txDataWithDefaults, defaultBlock); + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + 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(rawCallResult); + }, + getABIEncodedTransactionData(): string { + return self._strictEncodeArguments(functionSignature, [mtxs, signatures]); + }, + }; + } /** * Fills multiple limit orders. * @param orders Array of limit orders. @@ -8562,7 +9326,7 @@ export class IZeroExContract extends BaseContract { takerTokenFillAmounts: BigNumber[], revertIfIncomplete: boolean, ): ContractTxFunctionObj<[BigNumber[], BigNumber[]]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('orders', orders); assert.isArray('signatures', signatures); assert.isArray('takerTokenFillAmounts', takerTokenFillAmounts); @@ -8656,7 +9420,7 @@ export class IZeroExContract extends BaseContract { takerTokenFillAmounts: BigNumber[], revertIfIncomplete: boolean, ): ContractTxFunctionObj<[BigNumber[], BigNumber[]]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('orders', orders); assert.isArray('signatures', signatures); assert.isArray('takerTokenFillAmounts', takerTokenFillAmounts); @@ -8730,8 +9494,8 @@ export class IZeroExContract extends BaseContract { * @param orders Array of OTC orders. * @param makerSignatures Array of maker signatures for each order. * @param takerSignatures Array of taker signatures for each order. - * @param unwrapWeth Array of booleans representing whether or not to - * unwrap bought WETH into ETH for each order. Should be set to + * @param unwrapWeth Array of booleans representing whether or not to + * unwrap bought WETH into ETH for each order. Should be set to * false if the maker token is not WETH. */ public batchFillTakerSignedOtcOrders( @@ -8749,7 +9513,7 @@ export class IZeroExContract extends BaseContract { takerSignatures: Array<{ signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }>, unwrapWeth: boolean[], ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('orders', orders); assert.isArray('makerSignatures', makerSignatures); assert.isArray('takerSignatures', takerSignatures); @@ -8841,7 +9605,7 @@ export class IZeroExContract extends BaseContract { ): ContractTxFunctionObj< [Array<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }>, BigNumber[], boolean[]] > { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('orders', orders); assert.isArray('signatures', signatures); const functionSignature = @@ -8939,7 +9703,7 @@ export class IZeroExContract extends BaseContract { ): ContractTxFunctionObj< [Array<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }>, BigNumber[], boolean[]] > { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('orders', orders); assert.isArray('signatures', signatures); const functionSignature = @@ -9053,7 +9817,7 @@ export class IZeroExContract extends BaseContract { sellOrderSignatures: Array<{ signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }>, buyOrderSignatures: Array<{ signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }>, ): ContractTxFunctionObj<[BigNumber[], boolean[]]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('sellOrders', sellOrders); assert.isArray('buyOrders', buyOrders); assert.isArray('sellOrderSignatures', sellOrderSignatures); @@ -9152,7 +9916,7 @@ export class IZeroExContract extends BaseContract { erc1155BuyAmount: BigNumber, callbackData: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('erc1155BuyAmount', erc1155BuyAmount); assert.isString('callbackData', callbackData); @@ -9244,7 +10008,7 @@ export class IZeroExContract extends BaseContract { signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, callbackData: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('callbackData', callbackData); const functionSignature = @@ -9311,7 +10075,7 @@ export class IZeroExContract extends BaseContract { * @param orderNonce The order nonce. */ public cancelERC1155Order(orderNonce: BigNumber): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('orderNonce', orderNonce); const functionSignature = 'cancelERC1155Order(uint256)'; @@ -9376,7 +10140,7 @@ export class IZeroExContract extends BaseContract { * @param orderNonce The order nonce. */ public cancelERC721Order(orderNonce: BigNumber): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('orderNonce', orderNonce); const functionSignature = 'cancelERC721Order(uint256)'; @@ -9452,7 +10216,7 @@ export class IZeroExContract extends BaseContract { expiry: BigNumber; salt: BigNumber; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'cancelLimitOrder((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256))'; @@ -9524,7 +10288,7 @@ export class IZeroExContract extends BaseContract { takerToken: string, minValidSalt: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('makerToken', makerToken); assert.isString('takerToken', takerToken); assert.isBigNumber('minValidSalt', minValidSalt); @@ -9603,7 +10367,7 @@ export class IZeroExContract extends BaseContract { takerToken: string, minValidSalt: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('maker', maker); assert.isString('makerToken', makerToken); assert.isString('takerToken', takerToken); @@ -9682,7 +10446,7 @@ export class IZeroExContract extends BaseContract { takerToken: string, minValidSalt: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('makerToken', makerToken); assert.isString('takerToken', takerToken); assert.isBigNumber('minValidSalt', minValidSalt); @@ -9761,7 +10525,7 @@ export class IZeroExContract extends BaseContract { takerToken: string, minValidSalt: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('maker', maker); assert.isString('makerToken', makerToken); assert.isString('takerToken', takerToken); @@ -9843,7 +10607,7 @@ export class IZeroExContract extends BaseContract { expiry: BigNumber; salt: BigNumber; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'cancelRfqOrder((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256))'; @@ -9907,7 +10671,7 @@ export class IZeroExContract extends BaseContract { * Only callable by the owner. */ public createTransformWallet(): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'createTransformWallet()'; return { @@ -9983,7 +10747,7 @@ export class IZeroExContract extends BaseContract { }, signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'executeMetaTransaction((address,address,uint256,uint256,uint256,uint256,bytes,uint256,address,uint256),(uint8,uint8,bytes32,bytes32))'; @@ -10041,13 +10805,88 @@ export class IZeroExContract extends BaseContract { }, }; } + /** + * Execute a single meta-transaction. + * @param mtx The meta-transaction. + * @param signature The signature by `mtx.signer`. + */ + public executeMetaTransactionV2( + mtx: { + signer: string; + sender: string; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + callData: string; + feeToken: string; + fees: Array<{ recipient: string; amount: BigNumber }>; + }, + signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, + ): ContractTxFunctionObj { + const self = this as any as IZeroExContract; + + const functionSignature = + 'executeMetaTransactionV2((address,address,uint256,uint256,bytes,address,(address,uint256)[]),(uint8,uint8,bytes32,bytes32))'; + + return { + selector: self._lookupAbiEncoder(functionSignature).getSelector(), + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + 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, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + }, + async createAccessListAsync( + txData?: Partial | undefined, + defaultBlock?: BlockParam, + ): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.createAccessListAsync(txDataWithDefaults, defaultBlock); + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + 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(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 { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('selector', selector); assert.isString('impl', impl); const functionSignature = 'extend(bytes4,address)'; @@ -10131,7 +10970,7 @@ export class IZeroExContract extends BaseContract { signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, takerTokenFillAmount: BigNumber, ): ContractTxFunctionObj<[BigNumber, BigNumber]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); const functionSignature = @@ -10220,7 +11059,7 @@ export class IZeroExContract extends BaseContract { signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, takerTokenFillAmount: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); const functionSignature = @@ -10302,7 +11141,7 @@ export class IZeroExContract extends BaseContract { signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, takerTokenFillAmount: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); const functionSignature = @@ -10382,7 +11221,7 @@ export class IZeroExContract extends BaseContract { makerSignature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, takerTokenFillAmount: BigNumber, ): ContractTxFunctionObj<[BigNumber, BigNumber]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); const functionSignature = @@ -10467,7 +11306,7 @@ export class IZeroExContract extends BaseContract { makerSignature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, takerTokenFillAmount: BigNumber, ): ContractTxFunctionObj<[BigNumber, BigNumber]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); const functionSignature = @@ -10548,7 +11387,7 @@ export class IZeroExContract extends BaseContract { }, makerSignature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, ): ContractTxFunctionObj<[BigNumber, BigNumber]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'fillOtcOrderWithEth((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32))'; @@ -10633,7 +11472,7 @@ export class IZeroExContract extends BaseContract { signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, takerTokenFillAmount: BigNumber, ): ContractTxFunctionObj<[BigNumber, BigNumber]> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('takerTokenFillAmount', takerTokenFillAmount); const functionSignature = @@ -10716,7 +11555,7 @@ export class IZeroExContract extends BaseContract { makerSignature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, takerSignature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'fillTakerSignedOtcOrder((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),(uint8,uint8,bytes32,bytes32))'; @@ -10797,7 +11636,7 @@ export class IZeroExContract extends BaseContract { makerSignature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, takerSignature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'fillTakerSignedOtcOrderForEth((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),(uint8,uint8,bytes32,bytes32))'; @@ -10873,7 +11712,7 @@ export class IZeroExContract extends BaseContract { erc1155TokenProperties: Array<{ propertyValidator: string; propertyData: string }>; erc1155TokenAmount: BigNumber; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getERC1155OrderHash((uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[],uint128))'; @@ -10954,7 +11793,7 @@ export class IZeroExContract extends BaseContract { orderAmount: BigNumber; remainingAmount: BigNumber; }> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getERC1155OrderInfo((uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[],uint128))'; @@ -11037,7 +11876,7 @@ export class IZeroExContract extends BaseContract { erc721TokenId: BigNumber; erc721TokenProperties: Array<{ propertyValidator: string; propertyData: string }>; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getERC721OrderHash((uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[]))'; @@ -11112,7 +11951,7 @@ export class IZeroExContract extends BaseContract { erc721TokenId: BigNumber; erc721TokenProperties: Array<{ propertyValidator: string; propertyData: string }>; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getERC721OrderStatus((uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[]))'; @@ -11179,7 +12018,7 @@ export class IZeroExContract extends BaseContract { * `nonceRange` to be these 248 bits. */ public getERC721OrderStatusBitVector(maker: string, nonceRange: BigNumber): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('maker', maker); assert.isBigNumber('nonceRange', nonceRange); const functionSignature = 'getERC721OrderStatusBitVector(address,uint248)'; @@ -11255,7 +12094,7 @@ export class IZeroExContract extends BaseContract { expiry: BigNumber; salt: BigNumber; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getLimitOrderHash((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256))'; @@ -11331,7 +12170,7 @@ export class IZeroExContract extends BaseContract { expiry: BigNumber; salt: BigNumber; }): ContractTxFunctionObj<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getLimitOrderInfo((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256))'; @@ -11421,7 +12260,7 @@ export class IZeroExContract extends BaseContract { ): ContractTxFunctionObj< [{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }, BigNumber, boolean] > { - const self = (this as any) as IZeroExContract; + 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))'; @@ -11500,7 +12339,7 @@ export class IZeroExContract extends BaseContract { feeToken: string; feeAmount: BigNumber; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getMetaTransactionExecutedBlock((address,address,uint256,uint256,uint256,uint256,bytes,uint256,address,uint256))'; @@ -11574,7 +12413,7 @@ export class IZeroExContract extends BaseContract { feeToken: string; feeAmount: BigNumber; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getMetaTransactionHash((address,address,uint256,uint256,uint256,uint256,bytes,uint256,address,uint256))'; @@ -11637,7 +12476,7 @@ export class IZeroExContract extends BaseContract { * @param mtxHash The meta-transaction hash. */ public getMetaTransactionHashExecutedBlock(mtxHash: string): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('mtxHash', mtxHash); const functionSignature = 'getMetaTransactionHashExecutedBlock(bytes32)'; @@ -11694,6 +12533,210 @@ export class IZeroExContract extends BaseContract { }, }; } + /** + * Get the block at which a meta-transaction has been executed. + * @param mtx The meta-transaction. + */ + public getMetaTransactionV2ExecutedBlock(mtx: { + signer: string; + sender: string; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + callData: string; + feeToken: string; + fees: Array<{ recipient: string; amount: BigNumber }>; + }): ContractTxFunctionObj { + const self = this as any as IZeroExContract; + + const functionSignature = + 'getMetaTransactionV2ExecutedBlock((address,address,uint256,uint256,bytes,address,(address,uint256)[]))'; + + return { + selector: self._lookupAbiEncoder(functionSignature).getSelector(), + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + 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, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + }, + async createAccessListAsync( + txData?: Partial | undefined, + defaultBlock?: BlockParam, + ): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.createAccessListAsync(txDataWithDefaults, defaultBlock); + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + 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(rawCallResult); + }, + getABIEncodedTransactionData(): string { + return self._strictEncodeArguments(functionSignature, [mtx]); + }, + }; + } + /** + * Get the EIP712 hash of a meta-transaction. + * @param mtx The meta-transaction. + */ + public getMetaTransactionV2Hash(mtx: { + signer: string; + sender: string; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + callData: string; + feeToken: string; + fees: Array<{ recipient: string; amount: BigNumber }>; + }): ContractTxFunctionObj { + const self = this as any as IZeroExContract; + + const functionSignature = + 'getMetaTransactionV2Hash((address,address,uint256,uint256,bytes,address,(address,uint256)[]))'; + + return { + selector: self._lookupAbiEncoder(functionSignature).getSelector(), + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + 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, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + }, + async createAccessListAsync( + txData?: Partial | undefined, + defaultBlock?: BlockParam, + ): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.createAccessListAsync(txDataWithDefaults, defaultBlock); + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + 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(rawCallResult); + }, + getABIEncodedTransactionData(): string { + return self._strictEncodeArguments(functionSignature, [mtx]); + }, + }; + } + /** + * Get the block at which a meta-transaction hash has been executed. + * @param mtxHash The EIP712 hash of the MetaTransactionDataV2 struct. + */ + public getMetaTransactionV2HashExecutedBlock(mtxHash: string): ContractTxFunctionObj { + const self = this as any as IZeroExContract; + assert.isString('mtxHash', mtxHash); + const functionSignature = 'getMetaTransactionV2HashExecutedBlock(bytes32)'; + + return { + selector: self._lookupAbiEncoder(functionSignature).getSelector(), + async sendTransactionAsync( + txData?: Partial | undefined, + opts: SendTransactionOpts = { shouldValidate: true }, + ): Promise { + 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, + opts: AwaitTransactionSuccessOpts = { shouldValidate: true }, + ): PromiseWithTransactionHash { + return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts); + }, + async estimateGasAsync(txData?: Partial | undefined): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + }, + async createAccessListAsync( + txData?: Partial | undefined, + defaultBlock?: BlockParam, + ): Promise { + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({ + data: this.getABIEncodedTransactionData(), + ...txData, + }); + return self._web3Wrapper.createAccessListAsync(txDataWithDefaults, defaultBlock); + }, + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + 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(rawCallResult); + }, + getABIEncodedTransactionData(): string { + return self._strictEncodeArguments(functionSignature, [mtxHash]); + }, + }; + } /** * Get the canonical hash of an OTC order. * @param order The OTC order. @@ -11708,7 +12751,7 @@ export class IZeroExContract extends BaseContract { txOrigin: string; expiryAndNonce: BigNumber; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getOtcOrderHash((address,address,uint128,uint128,address,address,address,uint256))'; @@ -11779,7 +12822,7 @@ export class IZeroExContract extends BaseContract { txOrigin: string; expiryAndNonce: BigNumber; }): ContractTxFunctionObj<{ orderHash: string; status: number }> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getOtcOrderInfo((address,address,uint128,uint128,address,address,address,uint256))'; @@ -11844,7 +12887,7 @@ export class IZeroExContract extends BaseContract { * gas price to arrive at the required protocol fee to fill a native order. */ public getProtocolFeeMultiplier(): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getProtocolFeeMultiplier()'; return { @@ -11904,7 +12947,7 @@ export class IZeroExContract extends BaseContract { * Return the optional signer for `transformERC20()` calldata. */ public getQuoteSigner(): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getQuoteSigner()'; return { @@ -11976,7 +13019,7 @@ export class IZeroExContract extends BaseContract { expiry: BigNumber; salt: BigNumber; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getRfqOrderHash((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256))'; @@ -12050,7 +13093,7 @@ export class IZeroExContract extends BaseContract { expiry: BigNumber; salt: BigNumber; }): ContractTxFunctionObj<{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }> { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getRfqOrderInfo((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256))'; @@ -12138,7 +13181,7 @@ export class IZeroExContract extends BaseContract { ): ContractTxFunctionObj< [{ orderHash: string; status: number; takerTokenFilledAmount: BigNumber }, BigNumber, boolean] > { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getRfqOrderRelevantState((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32))'; @@ -12207,7 +13250,7 @@ export class IZeroExContract extends BaseContract { * @param idx The index in the rollback history. */ public getRollbackEntryAtIndex(selector: string, idx: BigNumber): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('selector', selector); assert.isBigNumber('idx', idx); const functionSignature = 'getRollbackEntryAtIndex(bytes4,uint256)'; @@ -12270,7 +13313,7 @@ export class IZeroExContract extends BaseContract { * @param selector The function selector. */ public getRollbackLength(selector: string): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('selector', selector); const functionSignature = 'getRollbackLength(bytes4)'; @@ -12332,7 +13375,7 @@ export class IZeroExContract extends BaseContract { * context for transformations. */ public getTransformWallet(): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getTransformWallet()'; return { @@ -12392,7 +13435,7 @@ export class IZeroExContract extends BaseContract { * Return the allowed deployer for transformers. */ public getTransformerDeployer(): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'getTransformerDeployer()'; return { @@ -12454,7 +13497,7 @@ export class IZeroExContract extends BaseContract { * @param signer The address that is providing a signature */ public isValidOrderSigner(maker: string, signer: string): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('maker', maker); assert.isString('signer', signer); const functionSignature = 'isValidOrderSigner(address,address)'; @@ -12519,7 +13562,7 @@ export class IZeroExContract extends BaseContract { * @param nonceBucket The nonce bucket index. */ public lastOtcTxOriginNonce(txOrigin: string, nonceBucket: BigNumber): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('txOrigin', txOrigin); assert.isBigNumber('nonceBucket', nonceBucket); const functionSignature = 'lastOtcTxOriginNonce(address,uint64)'; @@ -12617,7 +13660,7 @@ export class IZeroExContract extends BaseContract { sellOrderSignature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, buyOrderSignature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'matchERC721Orders((uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[]),(uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[]),(uint8,uint8,bytes32,bytes32),(uint8,uint8,bytes32,bytes32))'; @@ -12691,7 +13734,7 @@ export class IZeroExContract extends BaseContract { * @param newOwner The address of the new owner. */ public migrate(target: string, data: string, newOwner: string): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('target', target); assert.isString('data', data); assert.isString('newOwner', newOwner); @@ -12767,7 +13810,7 @@ export class IZeroExContract extends BaseContract { calls: Array<{ id: number | BigNumber; sellAmount: BigNumber; data: string }>, minBuyAmount: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('outputToken', outputToken); assert.isArray('calls', calls); assert.isBigNumber('minBuyAmount', minBuyAmount); @@ -12841,7 +13884,7 @@ export class IZeroExContract extends BaseContract { sellAmount: BigNumber, minBuyAmount: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('inputToken', inputToken); assert.isArray('calls', calls); assert.isBigNumber('sellAmount', sellAmount); @@ -12923,7 +13966,7 @@ export class IZeroExContract extends BaseContract { sellAmount: BigNumber, minBuyAmount: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('inputToken', inputToken); assert.isString('outputToken', outputToken); assert.isArray('calls', calls); @@ -13007,7 +14050,7 @@ export class IZeroExContract extends BaseContract { calls: Array<{ id: number | BigNumber; data: string }>, minBuyAmount: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('tokens', tokens); assert.isArray('calls', calls); assert.isBigNumber('minBuyAmount', minBuyAmount); @@ -13082,7 +14125,7 @@ export class IZeroExContract extends BaseContract { sellAmount: BigNumber, minBuyAmount: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('tokens', tokens); assert.isArray('calls', calls); assert.isBigNumber('sellAmount', sellAmount); @@ -13159,7 +14202,7 @@ export class IZeroExContract extends BaseContract { sellAmount: BigNumber, minBuyAmount: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('tokens', tokens); assert.isArray('calls', calls); assert.isBigNumber('sellAmount', sellAmount); @@ -13241,7 +14284,7 @@ export class IZeroExContract extends BaseContract { value: BigNumber, data: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('operator', operator); assert.isString('from', from); assert.isBigNumber('tokenId', tokenId); @@ -13328,7 +14371,7 @@ export class IZeroExContract extends BaseContract { tokenId: BigNumber, data: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('operator', operator); assert.isString('from', from); assert.isBigNumber('tokenId', tokenId); @@ -13397,7 +14440,7 @@ export class IZeroExContract extends BaseContract { * The owner of this contract. */ public owner(): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'owner()'; return { @@ -13473,7 +14516,7 @@ export class IZeroExContract extends BaseContract { erc1155TokenProperties: Array<{ propertyValidator: string; propertyData: string }>; erc1155TokenAmount: BigNumber; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'preSignERC1155Order((uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[],uint128))'; @@ -13550,7 +14593,7 @@ export class IZeroExContract extends BaseContract { erc721TokenId: BigNumber; erc721TokenProperties: Array<{ propertyValidator: string; propertyData: string }>; }): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'preSignERC721Order((uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[]))'; @@ -13615,7 +14658,7 @@ export class IZeroExContract extends BaseContract { * @param allowed True to register, false to unregister. */ public registerAllowedOrderSigner(signer: string, allowed: boolean): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('signer', signer); assert.isBoolean('allowed', allowed); const functionSignature = 'registerAllowedOrderSigner(address,bool)'; @@ -13680,7 +14723,7 @@ export class IZeroExContract extends BaseContract { * @param allowed True to register, false to unregister. */ public registerAllowedRfqOrigins(origins: string[], allowed: boolean): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('origins', origins); assert.isBoolean('allowed', allowed); const functionSignature = 'registerAllowedRfqOrigins(address[],bool)'; @@ -13744,7 +14787,7 @@ export class IZeroExContract extends BaseContract { * @param targetImpl The address of an older implementation of the function. */ public rollback(selector: string, targetImpl: string): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('selector', selector); assert.isString('targetImpl', targetImpl); const functionSignature = 'rollback(bytes4,address)'; @@ -13839,7 +14882,7 @@ export class IZeroExContract extends BaseContract { unwrapNativeToken: boolean, callbackData: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('erc1155TokenId', erc1155TokenId); assert.isBigNumber('erc1155SellAmount', erc1155SellAmount); @@ -13942,7 +14985,7 @@ export class IZeroExContract extends BaseContract { unwrapNativeToken: boolean, callbackData: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('erc721TokenId', erc721TokenId); assert.isBoolean('unwrapNativeToken', unwrapNativeToken); @@ -14020,7 +15063,7 @@ export class IZeroExContract extends BaseContract { minBuyAmount: BigNumber, recipient: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('encodedPath', encodedPath); assert.isBigNumber('minBuyAmount', minBuyAmount); assert.isString('recipient', recipient); @@ -14106,7 +15149,7 @@ export class IZeroExContract extends BaseContract { minBuyAmount: BigNumber, auxiliaryData: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('inputToken', inputToken); assert.isString('outputToken', outputToken); assert.isString('provider', provider); @@ -14190,7 +15233,7 @@ export class IZeroExContract extends BaseContract { minBuyAmount: BigNumber, fork: number | BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('tokens', tokens); assert.isBigNumber('sellAmount', sellAmount); assert.isBigNumber('minBuyAmount', minBuyAmount); @@ -14263,7 +15306,7 @@ export class IZeroExContract extends BaseContract { minBuyAmount: BigNumber, isSushi: boolean, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('tokens', tokens); assert.isBigNumber('sellAmount', sellAmount); assert.isBigNumber('minBuyAmount', minBuyAmount); @@ -14336,7 +15379,7 @@ export class IZeroExContract extends BaseContract { minBuyAmount: BigNumber, recipient: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('encodedPath', encodedPath); assert.isBigNumber('sellAmount', sellAmount); assert.isBigNumber('minBuyAmount', minBuyAmount); @@ -14414,7 +15457,7 @@ export class IZeroExContract extends BaseContract { minBuyAmount: BigNumber, recipient: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('encodedPath', encodedPath); assert.isBigNumber('sellAmount', sellAmount); assert.isBigNumber('minBuyAmount', minBuyAmount); @@ -14485,7 +15528,7 @@ export class IZeroExContract extends BaseContract { * @param quoteSigner The address of the new calldata signer. */ public setQuoteSigner(quoteSigner: string): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('quoteSigner', quoteSigner); const functionSignature = 'setQuoteSigner(address)'; @@ -14549,7 +15592,7 @@ export class IZeroExContract extends BaseContract { * for transformers. */ public setTransformerDeployer(transformerDeployer: string): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('transformerDeployer', transformerDeployer); const functionSignature = 'setTransformerDeployer(address)'; @@ -14612,7 +15655,7 @@ export class IZeroExContract extends BaseContract { * @param interfaceId The interface identifier, as specified in ERC165. */ public supportInterface(interfaceId: string): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('interfaceId', interfaceId); const functionSignature = 'supportInterface(bytes4)'; @@ -14679,7 +15722,7 @@ export class IZeroExContract extends BaseContract { * @param newOwner The address that will become the owner. */ public transferOwnership(newOwner: string): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('newOwner', newOwner); const functionSignature = 'transferOwnership(address)'; @@ -14742,7 +15785,7 @@ export class IZeroExContract extends BaseContract { * @param poolIds Staking pool IDs */ public transferProtocolFeesForPools(poolIds: string[]): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isArray('poolIds', poolIds); const functionSignature = 'transferProtocolFeesForPools(bytes32[])'; @@ -14810,7 +15853,7 @@ export class IZeroExContract extends BaseContract { amountOut: BigNumber, recipientWallet: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('erc20', erc20); assert.isBigNumber('amountOut', amountOut); assert.isString('recipientWallet', recipientWallet); @@ -14893,7 +15936,7 @@ export class IZeroExContract extends BaseContract { minOutputTokenAmount: BigNumber, transformations: Array<{ deploymentNonce: number | BigNumber; data: string }>, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isString('inputToken', inputToken); assert.isString('outputToken', outputToken); assert.isBigNumber('inputTokenAmount', inputTokenAmount); @@ -14974,7 +16017,7 @@ export class IZeroExContract extends BaseContract { amount1Delta: BigNumber, data: string, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('amount0Delta', amount0Delta); assert.isBigNumber('amount1Delta', amount1Delta); assert.isString('data', data); @@ -15061,7 +16104,7 @@ export class IZeroExContract extends BaseContract { }, erc1155TokenId: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('erc1155TokenId', erc1155TokenId); const functionSignature = @@ -15143,7 +16186,7 @@ export class IZeroExContract extends BaseContract { }, signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'validateERC1155OrderSignature((uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[],uint128),(uint8,uint8,bytes32,bytes32))'; @@ -15228,7 +16271,7 @@ export class IZeroExContract extends BaseContract { }, erc721TokenId: BigNumber, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; assert.isBigNumber('erc721TokenId', erc721TokenId); const functionSignature = @@ -15309,7 +16352,7 @@ export class IZeroExContract extends BaseContract { }, signature: { signatureType: number | BigNumber; v: number | BigNumber; r: string; s: string }, ): ContractTxFunctionObj { - const self = (this as any) as IZeroExContract; + const self = this as any as IZeroExContract; const functionSignature = 'validateERC721OrderSignature((uint8,address,address,uint256,uint256,address,uint256,(address,uint256,bytes)[],address,uint256,(address,bytes)[]),(uint8,uint8,bytes32,bytes32))'; @@ -15472,3 +16515,6 @@ export class IZeroExContract extends BaseContract { } } +// 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 diff --git a/packages/protocol-utils/CHANGELOG.json b/packages/protocol-utils/CHANGELOG.json index dc8c306de3..3ee48d1ccc 100644 --- a/packages/protocol-utils/CHANGELOG.json +++ b/packages/protocol-utils/CHANGELOG.json @@ -1,4 +1,12 @@ [ + { + "version": "11.22.0", + "changes": [ + { + "note": "Add MetaTransactionV2 utilities" + } + ] + }, { "version": "11.21.0", "changes": [ @@ -681,4 +689,4 @@ } ] } -] \ No newline at end of file +] diff --git a/packages/protocol-utils/src/index.ts b/packages/protocol-utils/src/index.ts index 957ecc5d49..6ca289f4fc 100644 --- a/packages/protocol-utils/src/index.ts +++ b/packages/protocol-utils/src/index.ts @@ -12,6 +12,7 @@ export const NFTOrder = { export * from './eip712_utils'; export * from './orders'; export * from './meta_transactions'; +export * from './meta_transactions_v2'; export * from './signature_utils'; export * from './transformer_utils'; export * from './constants'; diff --git a/packages/protocol-utils/src/meta_transactions_v2.ts b/packages/protocol-utils/src/meta_transactions_v2.ts new file mode 100644 index 0000000000..da3b01b240 --- /dev/null +++ b/packages/protocol-utils/src/meta_transactions_v2.ts @@ -0,0 +1,143 @@ +import { getContractAddressesForChainOrThrow } from '@0x/contract-addresses'; +import { EIP712TypedData } from '@0x/types'; +import { BigNumber, hexUtils, NULL_ADDRESS } from '@0x/utils'; +import { ZERO } from './constants'; +import { + createExchangeProxyEIP712Domain, + EIP712_DOMAIN_PARAMETERS, + getExchangeProxyEIP712Hash, + getTypeHash, +} from './eip712_utils'; + +export interface MetaTransactionV2Fee { + recipient: string, + amount: BigNumber, +} + +const MTX_DEFAULT_VALUES = { + signer: NULL_ADDRESS, + sender: NULL_ADDRESS, + expirationTimeSeconds: ZERO, + salt: ZERO, + callData: hexUtils.leftPad(0), + feeToken: NULL_ADDRESS, + fees: [] as MetaTransactionV2Fee[], + chainId: 1, + verifyingContract: getContractAddressesForChainOrThrow(1).exchangeProxy, +}; + +export type MetaTransactionV2Fields = typeof MTX_DEFAULT_VALUES; + +export class MetaTransactionV2 { + public static readonly FEE_STRUCT_NAME = 'MetaTransactionFeeData'; + public static readonly FEE_STRUCT_ABI = [ + { type: 'address', name: 'recipient' }, + { type: 'uint256', name: 'amount' }, + ]; + public static readonly FEE_TYPE_HASH = getTypeHash(MetaTransactionV2.FEE_STRUCT_NAME, MetaTransactionV2.FEE_STRUCT_ABI); + + public static readonly MTX_STRUCT_NAME = 'MetaTransactionDataV2'; + public static readonly MTX_STRUCT_ABI = [ + { type: 'address', name: 'signer' }, + { type: 'address', name: 'sender' }, + { type: 'uint256', name: 'expirationTimeSeconds' }, + { type: 'uint256', name: 'salt' }, + { type: 'bytes', name: 'callData' }, + { type: 'address', name: 'feeToken' }, + { type: `${MetaTransactionV2.FEE_STRUCT_NAME}[]`, name: 'fees' }, + ]; + public static readonly MTX_TYPE_HASH = getTypeHash( + MetaTransactionV2.MTX_STRUCT_NAME, + MetaTransactionV2.MTX_STRUCT_ABI, + { [MetaTransactionV2.FEE_STRUCT_NAME]: MetaTransactionV2.FEE_STRUCT_ABI } + ); + + public signer: string; + public sender: string; + public expirationTimeSeconds: BigNumber; + public salt: BigNumber; + public callData: string; + public feeToken: string; + public fees: MetaTransactionV2Fee[]; + public chainId: number; + public verifyingContract: string; + + public constructor(fields: Partial = {}) { + const _fields = { ...MTX_DEFAULT_VALUES, ...fields }; + this.signer = _fields.signer; + this.sender = _fields.sender; + this.expirationTimeSeconds = _fields.expirationTimeSeconds; + this.salt = _fields.salt; + this.callData = _fields.callData; + this.feeToken = _fields.feeToken; + this.fees = _fields.fees; + this.chainId = _fields.chainId; + this.verifyingContract = _fields.verifyingContract; + } + + public clone(fields: Partial = {}): MetaTransactionV2 { + return new MetaTransactionV2({ + signer: this.signer, + sender: this.sender, + expirationTimeSeconds: this.expirationTimeSeconds, + salt: this.salt, + callData: this.callData, + feeToken: this.feeToken, + fees: this.fees, + chainId: this.chainId, + verifyingContract: this.verifyingContract, + ...fields, + }); + } + + public getStructHash(): string { + const feesHash = hexUtils.hash(hexUtils.concat( + ...this.fees.map((fee) => hexUtils.hash(hexUtils.concat( + hexUtils.leftPad(MetaTransactionV2.FEE_TYPE_HASH), + hexUtils.leftPad(fee.recipient), + hexUtils.leftPad(fee.amount), + ))) + )); + + return hexUtils.hash( + hexUtils.concat( + hexUtils.leftPad(MetaTransactionV2.MTX_TYPE_HASH), + hexUtils.leftPad(this.signer), + hexUtils.leftPad(this.sender), + hexUtils.leftPad(this.expirationTimeSeconds), + hexUtils.leftPad(this.salt), + hexUtils.hash(this.callData), + hexUtils.leftPad(this.feeToken), + hexUtils.leftPad(feesHash), + ), + ); + } + + public getEIP712TypedData(): EIP712TypedData { + return { + types: { + EIP712Domain: EIP712_DOMAIN_PARAMETERS, + [MetaTransactionV2.MTX_STRUCT_NAME]: MetaTransactionV2.MTX_STRUCT_ABI, + [MetaTransactionV2.FEE_STRUCT_NAME]: MetaTransactionV2.FEE_STRUCT_ABI, + }, + domain: createExchangeProxyEIP712Domain(this.chainId, this.verifyingContract) as any, + primaryType: MetaTransactionV2.MTX_STRUCT_NAME, + message: { + signer: this.signer, + sender: this.sender, + expirationTimeSeconds: this.expirationTimeSeconds.toString(10), + salt: this.salt.toString(10), + callData: this.callData, + feeToken: this.feeToken, + fees: this.fees.map(({recipient, amount}) => ({ + recipient, + amount: amount.toString(10), + })) as any, + }, + }; + } + + public getHash(): string { + return getExchangeProxyEIP712Hash(this.getStructHash(), this.chainId, this.verifyingContract); + } +} diff --git a/packages/protocol-utils/test/meta_transactions_v2_test.ts b/packages/protocol-utils/test/meta_transactions_v2_test.ts new file mode 100644 index 0000000000..1f52a751b1 --- /dev/null +++ b/packages/protocol-utils/test/meta_transactions_v2_test.ts @@ -0,0 +1,66 @@ +import { chaiSetup, } from '@0x/dev-utils'; +import { BigNumber } from '@0x/utils'; +import { expect } from 'chai'; +import { MetaTransactionV2 } from '../src/meta_transactions_v2'; + +chaiSetup.configure(); + +describe('mtxs v2', () => { + describe('MetaTransactionV2 (no fees)', () => { + const mtx = new MetaTransactionV2({ + signer: '0x349e8d89e8b37214d9ce3949fc5754152c525bc3', + sender: '0x83c62b2e67dea0df2a27be0def7a22bd7102642c', + expirationTimeSeconds: new BigNumber(9101112), + salt: new BigNumber(2001), + callData: '0x12345678', + feeToken: '0xcc3c7ea403427154ec908203ba6c418bd699f7ce', + fees: [] as any, + chainId: 8008, + verifyingContract: '0x6701704d2421c64ee9aa93ec7f96ede81c4be77d', + }); + + it('can get the struct hash', () => { + const actual = mtx.getStructHash(); + const expected = '0x57db4055edfed82a6d86103197c21390bf29412fb4585e08c708454e03d92516'; + expect(actual).to.eq(expected); + }); + + it('can get the EIP712 hash', () => { + const actual = mtx.getHash(); + const expected = '0x05fc975cb9f37cc442a2975bc479502ce33d2d068fe8a1d6f50dbb11c1499137'; + expect(actual).to.eq(expected); + }); + }); + + describe('MetaTransactionV2 (two fees)', () => { + const mtx = new MetaTransactionV2({ + signer: '0x349e8d89e8b37214d9ce3949fc5754152c525bc3', + sender: '0x83c62b2e67dea0df2a27be0def7a22bd7102642c', + expirationTimeSeconds: new BigNumber(9101112), + salt: new BigNumber(2001), + callData: '0x12345678', + feeToken: '0xcc3c7ea403427154ec908203ba6c418bd699f7ce', + fees: [{ + recipient: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + amount: new BigNumber(1000000), + }, { + recipient: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', + amount: new BigNumber(1000), + }] as any, + chainId: 8008, + verifyingContract: '0x6701704d2421c64ee9aa93ec7f96ede81c4be77d', + }); + + it('can get the struct hash', () => { + const actual = mtx.getStructHash(); + const expected = '0x441c8b8a8f25c1716f2880326d008d07d0b8eb9606623c0a81dd5d9fa14dd12e'; + expect(actual).to.eq(expected); + }); + + it('can get the EIP712 hash', () => { + const actual = mtx.getHash(); + const expected = '0xfc85ef2149bd49fcc8fee2571ed8f0ecd671dec03845637ab1ded3d891ac3386'; + expect(actual).to.eq(expected); + }); + }); +});