diff --git a/README.md b/README.md index a955dab..2b20d04 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ## Overview -This library is designed for [0x](https://0x.org/docs/introduction/introduction-to-0x) integrators, simplifying the complex task of parsing [0x transactions](https://etherscan.io/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff) into a format that is both user-friendly and easy to understand. When swapping tokens, one of the challenges is that the trade can experience slippage through Automated Market Makers ([AMMs](https://0x.org/post/what-is-an-automated-market-maker-amm)). This makes the final swap amounts difficult to predict prior to executing the trade. However, this library overcomes that challenge by parsing the transaction receipt and event logs to accurately identify the final swap amounts. +This library is designed for [0x](https://0x.org/docs/introduction/introduction-to-0x) integrators, simplifying the complex task of parsing [0x transactions](https://etherscan.io/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff) into a format that is both user-friendly and easy to understand. When swapping tokens, one of the challenges is that the trade can experience slippage through Automated Market Makers ([AMMs](https://0x.org/post/what-is-an-automated-market-maker-amm)). This makes the final swap amounts difficult to predict prior to executing the trade. However, this library overcomes that challenge by parsing the transaction receipt and event logs to accurately identify the final swap amounts. ### Demo @@ -57,7 +57,8 @@ async function main() { // You can pass any transaction hash from 0x Exchange Proxy: // https://etherscan.io/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff - const transactionHash = "0xd8637124d650268ae7680781809800e103a3a2bee9fec56083028fea6d98140b"; + const transactionHash = + "0xd8637124d650268ae7680781809800e103a3a2bee9fec56083028fea6d98140b"; const swap = await parseSwap({ transactionHash, diff --git a/src/abi/ExchangeProxyAbi.ts b/src/abi/ExchangeProxyAbi.ts deleted file mode 100644 index 0bb9eb3..0000000 --- a/src/abi/ExchangeProxyAbi.ts +++ /dev/null @@ -1,6831 +0,0 @@ -export const exchangeProxyAbi = [ - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "nonce", - type: "uint256", - }, - ], - name: "ERC1155OrderCancelled", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "taker", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "nonce", - type: "uint256", - }, - { - indexed: false, - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "erc20FillAmount", - type: "uint256", - }, - { - indexed: false, - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - indexed: false, - internalType: "uint128", - name: "erc1155FillAmount", - type: "uint128", - }, - { - indexed: false, - internalType: "address", - name: "matcher", - type: "address", - }, - ], - name: "ERC1155OrderFilled", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "taker", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { - indexed: false, - internalType: "uint256", - name: "nonce", - type: "uint256", - }, - { - indexed: false, - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { internalType: "bytes", name: "feeData", type: "bytes" }, - ], - indexed: false, - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - indexed: false, - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - indexed: false, - internalType: "struct LibNFTOrder.Property[]", - name: "erc1155TokenProperties", - type: "tuple[]", - }, - { - indexed: false, - internalType: "uint128", - name: "erc1155TokenAmount", - type: "uint128", - }, - ], - name: "ERC1155OrderPreSigned", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "nonce", - type: "uint256", - }, - ], - name: "ERC721OrderCancelled", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "taker", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "nonce", - type: "uint256", - }, - { - indexed: false, - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - indexed: false, - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - indexed: false, - internalType: "address", - name: "matcher", - type: "address", - }, - ], - name: "ERC721OrderFilled", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "taker", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { - indexed: false, - internalType: "uint256", - name: "nonce", - type: "uint256", - }, - { - indexed: false, - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { internalType: "bytes", name: "feeData", type: "bytes" }, - ], - indexed: false, - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - indexed: false, - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - indexed: false, - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - name: "ERC721OrderPreSigned", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "taker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "makerToken", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "takerToken", - type: "address", - }, - { - indexed: false, - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - indexed: false, - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - { - indexed: false, - internalType: "uint128", - name: "takerTokenFeeFilledAmount", - type: "uint128", - }, - { - indexed: false, - internalType: "uint256", - name: "protocolFeePaid", - type: "uint256", - }, - { - indexed: false, - internalType: "bytes32", - name: "pool", - type: "bytes32", - }, - ], - name: "LimitOrderFilled", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "contract IERC20Token", - name: "inputToken", - type: "address", - }, - { - indexed: false, - internalType: "contract IERC20Token", - name: "outputToken", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "inputTokenAmount", - type: "uint256", - }, - { - indexed: false, - internalType: "uint256", - name: "outputTokenAmount", - type: "uint256", - }, - { - indexed: false, - internalType: "contract ILiquidityProvider", - name: "provider", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "recipient", - type: "address", - }, - ], - name: "LiquidityProviderSwap", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32", - name: "hash", - type: "bytes32", - }, - { - indexed: true, - internalType: "bytes4", - name: "selector", - type: "bytes4", - }, - { - indexed: false, - internalType: "address", - name: "signer", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "sender", - type: "address", - }, - ], - name: "MetaTransactionExecuted", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "caller", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "migrator", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "newOwner", - type: "address", - }, - ], - name: "Migrated", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - ], - name: "OrderCancelled", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "signer", - type: "address", - }, - { - indexed: false, - internalType: "bool", - name: "allowed", - type: "bool", - }, - ], - name: "OrderSignerRegistered", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "taker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "makerToken", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "takerToken", - type: "address", - }, - { - indexed: false, - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - { - indexed: false, - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - ], - name: "OtcOrderFilled", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address", - }, - ], - name: "OwnershipTransferred", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "makerToken", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "takerToken", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "minValidSalt", - type: "uint256", - }, - ], - name: "PairCancelledLimitOrders", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "makerToken", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "takerToken", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "minValidSalt", - type: "uint256", - }, - ], - name: "PairCancelledRfqOrders", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "bytes4", - name: "selector", - type: "bytes4", - }, - { - indexed: false, - internalType: "address", - name: "oldImpl", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "newImpl", - type: "address", - }, - ], - name: "ProxyFunctionUpdated", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "quoteSigner", - type: "address", - }, - ], - name: "QuoteSignerUpdated", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - indexed: false, - internalType: "address", - name: "maker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "taker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "makerToken", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "takerToken", - type: "address", - }, - { - indexed: false, - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - indexed: false, - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - { - indexed: false, - internalType: "bytes32", - name: "pool", - type: "bytes32", - }, - ], - name: "RfqOrderFilled", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "origin", - type: "address", - }, - { - indexed: false, - internalType: "address[]", - name: "addrs", - type: "address[]", - }, - { - indexed: false, - internalType: "bool", - name: "allowed", - type: "bool", - }, - ], - name: "RfqOrderOriginsAllowed", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "taker", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "inputToken", - type: "address", - }, - { - indexed: false, - internalType: "address", - name: "outputToken", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "inputTokenAmount", - type: "uint256", - }, - { - indexed: false, - internalType: "uint256", - name: "outputTokenAmount", - type: "uint256", - }, - ], - name: "TransformedERC20", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "transformerDeployer", - type: "address", - }, - ], - name: "TransformerDeployerUpdated", - type: "event", - }, - { - 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", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder", - name: "order", - 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", - }, - { - internalType: "uint128", - name: "takerTokenFillAmount", - type: "uint128", - }, - { internalType: "address", name: "taker", type: "address" }, - { internalType: "address", name: "sender", type: "address" }, - ], - name: "_fillLimitOrder", - outputs: [ - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - stateMutability: "payable", - 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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { - internalType: "uint256", - name: "expiryAndNonce", - type: "uint256", - }, - ], - internalType: "struct LibNativeOrder.OtcOrder", - name: "order", - 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: "makerSignature", - type: "tuple", - }, - { - internalType: "uint128", - name: "takerTokenFillAmount", - type: "uint128", - }, - { internalType: "address", name: "taker", type: "address" }, - { internalType: "bool", name: "useSelfBalance", type: "bool" }, - { internalType: "address", name: "recipient", type: "address" }, - ], - name: "_fillOtcOrder", - outputs: [ - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - 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: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder", - name: "order", - 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", - }, - { - internalType: "uint128", - name: "takerTokenFillAmount", - type: "uint128", - }, - { internalType: "address", name: "taker", type: "address" }, - { internalType: "bool", name: "useSelfBalance", type: "bool" }, - { internalType: "address", name: "recipient", type: "address" }, - ], - name: "_fillRfqOrder", - outputs: [ - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - 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" }, - { - internalType: "uint256", - name: "sellAmount", - type: "uint256", - }, - { - internalType: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - { internalType: "address", name: "recipient", type: "address" }, - ], - name: "_sellHeldTokenForTokenToUniswapV3", - outputs: [{ internalType: "uint256", name: "buyAmount", type: "uint256" }], - 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 IERC20Token", - name: "inputToken", - type: "address", - }, - { - internalType: "contract IERC20Token", - name: "outputToken", - type: "address", - }, - { - internalType: "uint256", - name: "inputTokenAmount", - type: "uint256", - }, - { - internalType: "uint256", - name: "minOutputTokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "uint32", - name: "deploymentNonce", - type: "uint32", - }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - internalType: "struct ITransformERC20Feature.Transformation[]", - name: "transformations", - type: "tuple[]", - }, - { - internalType: "bool", - name: "useSelfBalance", - type: "bool", - }, - { - internalType: "address payable", - name: "recipient", - type: "address", - }, - ], - internalType: "struct ITransformERC20Feature.TransformERC20Args", - name: "args", - type: "tuple", - }, - ], - name: "_transformERC20", - outputs: [ - { - internalType: "uint256", - name: "outputTokenAmount", - type: "uint256", - }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc1155TokenProperties", - type: "tuple[]", - }, - { - internalType: "uint128", - name: "erc1155TokenAmount", - type: "uint128", - }, - ], - internalType: "struct LibNFTOrder.ERC1155Order[]", - name: "sellOrders", - 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[]", - }, - { - internalType: "uint128[]", - name: "erc1155TokenAmounts", - type: "uint128[]", - }, - { - internalType: "bytes[]", - name: "callbackData", - type: "bytes[]", - }, - { - internalType: "bool", - name: "revertIfIncomplete", - type: "bool", - }, - ], - name: "batchBuyERC1155s", - outputs: [{ internalType: "bool[]", name: "successes", type: "bool[]" }], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order[]", - name: "sellOrders", - 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[]", - }, - { - internalType: "bytes[]", - name: "callbackData", - type: "bytes[]", - }, - { - internalType: "bool", - name: "revertIfIncomplete", - type: "bool", - }, - ], - name: "batchBuyERC721s", - outputs: [{ internalType: "bool[]", name: "successes", type: "bool[]" }], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - internalType: "uint256[]", - name: "orderNonces", - type: "uint256[]", - }, - ], - name: "batchCancelERC1155Orders", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "uint256[]", - name: "orderNonces", - type: "uint256[]", - }, - ], - name: "batchCancelERC721Orders", - outputs: [], - 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", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder[]", - name: "orders", - type: "tuple[]", - }, - ], - name: "batchCancelLimitOrders", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20Token[]", - name: "makerTokens", - type: "address[]", - }, - { - internalType: "contract IERC20Token[]", - name: "takerTokens", - type: "address[]", - }, - { - internalType: "uint256[]", - name: "minValidSalts", - type: "uint256[]", - }, - ], - name: "batchCancelPairLimitOrders", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "maker", type: "address" }, - { - internalType: "contract IERC20Token[]", - name: "makerTokens", - type: "address[]", - }, - { - internalType: "contract IERC20Token[]", - name: "takerTokens", - type: "address[]", - }, - { - internalType: "uint256[]", - name: "minValidSalts", - type: "uint256[]", - }, - ], - name: "batchCancelPairLimitOrdersWithSigner", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20Token[]", - name: "makerTokens", - type: "address[]", - }, - { - internalType: "contract IERC20Token[]", - name: "takerTokens", - type: "address[]", - }, - { - internalType: "uint256[]", - name: "minValidSalts", - type: "uint256[]", - }, - ], - name: "batchCancelPairRfqOrders", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "maker", type: "address" }, - { - internalType: "contract IERC20Token[]", - name: "makerTokens", - type: "address[]", - }, - { - internalType: "contract IERC20Token[]", - name: "takerTokens", - type: "address[]", - }, - { - internalType: "uint256[]", - name: "minValidSalts", - type: "uint256[]", - }, - ], - name: "batchCancelPairRfqOrdersWithSigner", - outputs: [], - 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: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder[]", - name: "orders", - type: "tuple[]", - }, - ], - name: "batchCancelRfqOrders", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "address payable", - name: "signer", - type: "address", - }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "uint256", - name: "minGasPrice", - type: "uint256", - }, - { - internalType: "uint256", - name: "maxGasPrice", - type: "uint256", - }, - { - internalType: "uint256", - name: "expirationTimeSeconds", - type: "uint256", - }, - { internalType: "uint256", name: "salt", type: "uint256" }, - { internalType: "bytes", name: "callData", type: "bytes" }, - { internalType: "uint256", name: "value", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "feeToken", - type: "address", - }, - { - internalType: "uint256", - name: "feeAmount", - type: "uint256", - }, - ], - internalType: "struct IMetaTransactionsFeature.MetaTransactionData[]", - 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: "batchExecuteMetaTransactions", - outputs: [ - { - internalType: "bytes[]", - name: "returnResults", - type: "bytes[]", - }, - ], - 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: "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", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder[]", - name: "orders", - 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[]", - }, - { - internalType: "uint128[]", - name: "takerTokenFillAmounts", - type: "uint128[]", - }, - { - internalType: "bool", - name: "revertIfIncomplete", - type: "bool", - }, - ], - name: "batchFillLimitOrders", - outputs: [ - { - internalType: "uint128[]", - name: "takerTokenFilledAmounts", - type: "uint128[]", - }, - { - internalType: "uint128[]", - name: "makerTokenFilledAmounts", - type: "uint128[]", - }, - ], - stateMutability: "payable", - 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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder[]", - name: "orders", - 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[]", - }, - { - internalType: "uint128[]", - name: "takerTokenFillAmounts", - type: "uint128[]", - }, - { - internalType: "bool", - name: "revertIfIncomplete", - type: "bool", - }, - ], - name: "batchFillRfqOrders", - outputs: [ - { - internalType: "uint128[]", - name: "takerTokenFilledAmounts", - type: "uint128[]", - }, - { - internalType: "uint128[]", - name: "makerTokenFilledAmounts", - type: "uint128[]", - }, - ], - 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: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { - internalType: "uint256", - name: "expiryAndNonce", - type: "uint256", - }, - ], - internalType: "struct LibNativeOrder.OtcOrder[]", - name: "orders", - 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: "makerSignatures", - 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: "takerSignatures", - type: "tuple[]", - }, - { internalType: "bool[]", name: "unwrapWeth", type: "bool[]" }, - ], - name: "batchFillTakerSignedOtcOrders", - outputs: [{ internalType: "bool[]", name: "successes", type: "bool[]" }], - 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", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder[]", - name: "orders", - 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: "batchGetLimitOrderRelevantStates", - outputs: [ - { - components: [ - { - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - internalType: "enum LibNativeOrder.OrderStatus", - name: "status", - type: "uint8", - }, - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - ], - internalType: "struct LibNativeOrder.OrderInfo[]", - name: "orderInfos", - type: "tuple[]", - }, - { - internalType: "uint128[]", - name: "actualFillableTakerTokenAmounts", - type: "uint128[]", - }, - { - internalType: "bool[]", - name: "isSignatureValids", - type: "bool[]", - }, - ], - 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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder[]", - name: "orders", - 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: "batchGetRfqOrderRelevantStates", - outputs: [ - { - components: [ - { - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - internalType: "enum LibNativeOrder.OrderStatus", - name: "status", - type: "uint8", - }, - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - ], - internalType: "struct LibNativeOrder.OrderInfo[]", - name: "orderInfos", - type: "tuple[]", - }, - { - internalType: "uint128[]", - name: "actualFillableTakerTokenAmounts", - type: "uint128[]", - }, - { - internalType: "bool[]", - name: "isSignatureValids", - type: "bool[]", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order[]", - name: "sellOrders", - type: "tuple[]", - }, - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order[]", - name: "buyOrders", - 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: "sellOrderSignatures", - 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: "buyOrderSignatures", - type: "tuple[]", - }, - ], - name: "batchMatchERC721Orders", - outputs: [ - { - internalType: "uint256[]", - name: "profits", - type: "uint256[]", - }, - { internalType: "bool[]", name: "successes", type: "bool[]" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc1155TokenProperties", - type: "tuple[]", - }, - { - internalType: "uint128", - name: "erc1155TokenAmount", - type: "uint128", - }, - ], - internalType: "struct LibNFTOrder.ERC1155Order", - name: "sellOrder", - 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", - }, - { - internalType: "uint128", - name: "erc1155BuyAmount", - type: "uint128", - }, - { internalType: "bytes", name: "callbackData", type: "bytes" }, - ], - name: "buyERC1155", - outputs: [], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order", - name: "sellOrder", - 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", - }, - { internalType: "bytes", name: "callbackData", type: "bytes" }, - ], - name: "buyERC721", - outputs: [], - stateMutability: "payable", - type: "function", - }, - { - inputs: [{ internalType: "uint256", name: "orderNonce", type: "uint256" }], - name: "cancelERC1155Order", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "uint256", name: "orderNonce", type: "uint256" }], - name: "cancelERC721Order", - outputs: [], - 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", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder", - name: "order", - type: "tuple", - }, - ], - name: "cancelLimitOrder", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20Token", - name: "makerToken", - type: "address", - }, - { - internalType: "contract IERC20Token", - name: "takerToken", - type: "address", - }, - { - internalType: "uint256", - name: "minValidSalt", - type: "uint256", - }, - ], - name: "cancelPairLimitOrders", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "maker", type: "address" }, - { - internalType: "contract IERC20Token", - name: "makerToken", - type: "address", - }, - { - internalType: "contract IERC20Token", - name: "takerToken", - type: "address", - }, - { - internalType: "uint256", - name: "minValidSalt", - type: "uint256", - }, - ], - name: "cancelPairLimitOrdersWithSigner", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20Token", - name: "makerToken", - type: "address", - }, - { - internalType: "contract IERC20Token", - name: "takerToken", - type: "address", - }, - { - internalType: "uint256", - name: "minValidSalt", - type: "uint256", - }, - ], - name: "cancelPairRfqOrders", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "maker", type: "address" }, - { - internalType: "contract IERC20Token", - name: "makerToken", - type: "address", - }, - { - internalType: "contract IERC20Token", - name: "takerToken", - type: "address", - }, - { - internalType: "uint256", - name: "minValidSalt", - type: "uint256", - }, - ], - name: "cancelPairRfqOrdersWithSigner", - outputs: [], - 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: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder", - name: "order", - type: "tuple", - }, - ], - name: "cancelRfqOrder", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "createTransformWallet", - outputs: [ - { - internalType: "contract IFlashWallet", - name: "wallet", - type: "address", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "address payable", - name: "signer", - type: "address", - }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "uint256", - name: "minGasPrice", - type: "uint256", - }, - { - internalType: "uint256", - name: "maxGasPrice", - type: "uint256", - }, - { - internalType: "uint256", - name: "expirationTimeSeconds", - type: "uint256", - }, - { internalType: "uint256", name: "salt", type: "uint256" }, - { internalType: "bytes", name: "callData", type: "bytes" }, - { internalType: "uint256", name: "value", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "feeToken", - type: "address", - }, - { - internalType: "uint256", - name: "feeAmount", - type: "uint256", - }, - ], - internalType: "struct IMetaTransactionsFeature.MetaTransactionData", - 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: "executeMetaTransaction", - outputs: [{ internalType: "bytes", name: "returnResult", type: "bytes" }], - 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" }, - { internalType: "address", name: "impl", type: "address" }, - ], - name: "extend", - outputs: [], - 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", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder", - name: "order", - 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", - }, - { - internalType: "uint128", - name: "takerTokenFillAmount", - type: "uint128", - }, - ], - name: "fillLimitOrder", - outputs: [ - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - stateMutability: "payable", - 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", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder", - name: "order", - 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", - }, - { - internalType: "uint128", - name: "takerTokenFillAmount", - type: "uint128", - }, - ], - name: "fillOrKillLimitOrder", - outputs: [ - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - stateMutability: "payable", - 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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder", - name: "order", - 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", - }, - { - internalType: "uint128", - name: "takerTokenFillAmount", - type: "uint128", - }, - ], - name: "fillOrKillRfqOrder", - outputs: [ - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - 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: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { - internalType: "uint256", - name: "expiryAndNonce", - type: "uint256", - }, - ], - internalType: "struct LibNativeOrder.OtcOrder", - name: "order", - 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: "makerSignature", - type: "tuple", - }, - { - internalType: "uint128", - name: "takerTokenFillAmount", - type: "uint128", - }, - ], - name: "fillOtcOrder", - outputs: [ - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - 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: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { - internalType: "uint256", - name: "expiryAndNonce", - type: "uint256", - }, - ], - internalType: "struct LibNativeOrder.OtcOrder", - name: "order", - 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: "makerSignature", - type: "tuple", - }, - { - internalType: "uint128", - name: "takerTokenFillAmount", - type: "uint128", - }, - ], - name: "fillOtcOrderForEth", - outputs: [ - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - 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: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { - internalType: "uint256", - name: "expiryAndNonce", - type: "uint256", - }, - ], - internalType: "struct LibNativeOrder.OtcOrder", - name: "order", - 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: "makerSignature", - type: "tuple", - }, - ], - name: "fillOtcOrderWithEth", - outputs: [ - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - stateMutability: "payable", - 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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder", - name: "order", - 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", - }, - { - internalType: "uint128", - name: "takerTokenFillAmount", - type: "uint128", - }, - ], - name: "fillRfqOrder", - outputs: [ - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - { - internalType: "uint128", - name: "makerTokenFilledAmount", - type: "uint128", - }, - ], - 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: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { - internalType: "uint256", - name: "expiryAndNonce", - type: "uint256", - }, - ], - internalType: "struct LibNativeOrder.OtcOrder", - name: "order", - 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: "makerSignature", - 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: "takerSignature", - type: "tuple", - }, - ], - name: "fillTakerSignedOtcOrder", - outputs: [], - 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: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { - internalType: "uint256", - name: "expiryAndNonce", - type: "uint256", - }, - ], - internalType: "struct LibNativeOrder.OtcOrder", - name: "order", - 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: "makerSignature", - 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: "takerSignature", - type: "tuple", - }, - ], - name: "fillTakerSignedOtcOrderForEth", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc1155TokenProperties", - type: "tuple[]", - }, - { - internalType: "uint128", - name: "erc1155TokenAmount", - type: "uint128", - }, - ], - internalType: "struct LibNFTOrder.ERC1155Order", - name: "order", - type: "tuple", - }, - ], - name: "getERC1155OrderHash", - outputs: [{ internalType: "bytes32", name: "orderHash", type: "bytes32" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc1155TokenProperties", - type: "tuple[]", - }, - { - internalType: "uint128", - name: "erc1155TokenAmount", - type: "uint128", - }, - ], - internalType: "struct LibNFTOrder.ERC1155Order", - name: "order", - type: "tuple", - }, - ], - name: "getERC1155OrderInfo", - outputs: [ - { - components: [ - { - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - internalType: "enum LibNFTOrder.OrderStatus", - name: "status", - type: "uint8", - }, - { - internalType: "uint128", - name: "orderAmount", - type: "uint128", - }, - { - internalType: "uint128", - name: "remainingAmount", - type: "uint128", - }, - ], - internalType: "struct LibNFTOrder.OrderInfo", - name: "orderInfo", - type: "tuple", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order", - name: "order", - type: "tuple", - }, - ], - name: "getERC721OrderHash", - outputs: [{ internalType: "bytes32", name: "orderHash", type: "bytes32" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order", - name: "order", - type: "tuple", - }, - ], - name: "getERC721OrderStatus", - outputs: [ - { - internalType: "enum LibNFTOrder.OrderStatus", - name: "status", - type: "uint8", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "maker", type: "address" }, - { internalType: "uint248", name: "nonceRange", type: "uint248" }, - ], - name: "getERC721OrderStatusBitVector", - outputs: [{ internalType: "uint256", name: "bitVector", 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: "uint128", - name: "takerTokenFeeAmount", - type: "uint128", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder", - name: "order", - type: "tuple", - }, - ], - name: "getLimitOrderHash", - outputs: [{ internalType: "bytes32", name: "orderHash", type: "bytes32" }], - 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: "uint128", - name: "takerTokenFeeAmount", - type: "uint128", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder", - name: "order", - type: "tuple", - }, - ], - name: "getLimitOrderInfo", - outputs: [ - { - components: [ - { - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - internalType: "enum LibNativeOrder.OrderStatus", - name: "status", - type: "uint8", - }, - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - ], - internalType: "struct LibNativeOrder.OrderInfo", - name: "orderInfo", - type: "tuple", - }, - ], - 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: "uint128", - name: "takerTokenFeeAmount", - type: "uint128", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "address", - name: "feeRecipient", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.LimitOrder", - name: "order", - 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: "getLimitOrderRelevantState", - outputs: [ - { - components: [ - { - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - internalType: "enum LibNativeOrder.OrderStatus", - name: "status", - type: "uint8", - }, - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - ], - internalType: "struct LibNativeOrder.OrderInfo", - name: "orderInfo", - type: "tuple", - }, - { - internalType: "uint128", - name: "actualFillableTakerTokenAmount", - type: "uint128", - }, - { internalType: "bool", name: "isSignatureValid", type: "bool" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "address payable", - name: "signer", - type: "address", - }, - { - internalType: "address", - name: "sender", - type: "address", - }, - { - internalType: "uint256", - name: "minGasPrice", - type: "uint256", - }, - { - internalType: "uint256", - name: "maxGasPrice", - type: "uint256", - }, - { - internalType: "uint256", - name: "expirationTimeSeconds", - type: "uint256", - }, - { internalType: "uint256", name: "salt", type: "uint256" }, - { internalType: "bytes", name: "callData", type: "bytes" }, - { internalType: "uint256", name: "value", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "feeToken", - type: "address", - }, - { - internalType: "uint256", - name: "feeAmount", - type: "uint256", - }, - ], - internalType: "struct IMetaTransactionsFeature.MetaTransactionData", - name: "mtx", - type: "tuple", - }, - ], - name: "getMetaTransactionExecutedBlock", - 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: "minGasPrice", - type: "uint256", - }, - { - internalType: "uint256", - name: "maxGasPrice", - type: "uint256", - }, - { - internalType: "uint256", - name: "expirationTimeSeconds", - type: "uint256", - }, - { internalType: "uint256", name: "salt", type: "uint256" }, - { internalType: "bytes", name: "callData", type: "bytes" }, - { internalType: "uint256", name: "value", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "feeToken", - type: "address", - }, - { - internalType: "uint256", - name: "feeAmount", - type: "uint256", - }, - ], - internalType: "struct IMetaTransactionsFeature.MetaTransactionData", - name: "mtx", - type: "tuple", - }, - ], - name: "getMetaTransactionHash", - outputs: [{ internalType: "bytes32", name: "mtxHash", type: "bytes32" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "bytes32", name: "mtxHash", type: "bytes32" }], - name: "getMetaTransactionHashExecutedBlock", - 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: "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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { - internalType: "uint256", - name: "expiryAndNonce", - type: "uint256", - }, - ], - internalType: "struct LibNativeOrder.OtcOrder", - name: "order", - type: "tuple", - }, - ], - name: "getOtcOrderHash", - outputs: [{ internalType: "bytes32", name: "orderHash", type: "bytes32" }], - 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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { - internalType: "uint256", - name: "expiryAndNonce", - type: "uint256", - }, - ], - internalType: "struct LibNativeOrder.OtcOrder", - name: "order", - type: "tuple", - }, - ], - name: "getOtcOrderInfo", - outputs: [ - { - components: [ - { - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - internalType: "enum LibNativeOrder.OrderStatus", - name: "status", - type: "uint8", - }, - ], - internalType: "struct LibNativeOrder.OtcOrderInfo", - name: "orderInfo", - type: "tuple", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getProtocolFeeMultiplier", - outputs: [{ internalType: "uint32", name: "multiplier", type: "uint32" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getQuoteSigner", - outputs: [{ internalType: "address", name: "signer", type: "address" }], - 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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder", - name: "order", - type: "tuple", - }, - ], - name: "getRfqOrderHash", - outputs: [{ internalType: "bytes32", name: "orderHash", type: "bytes32" }], - 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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder", - name: "order", - type: "tuple", - }, - ], - name: "getRfqOrderInfo", - outputs: [ - { - components: [ - { - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - internalType: "enum LibNativeOrder.OrderStatus", - name: "status", - type: "uint8", - }, - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - ], - internalType: "struct LibNativeOrder.OrderInfo", - name: "orderInfo", - type: "tuple", - }, - ], - 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" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "address", - name: "txOrigin", - type: "address", - }, - { internalType: "bytes32", name: "pool", type: "bytes32" }, - { internalType: "uint64", name: "expiry", type: "uint64" }, - { internalType: "uint256", name: "salt", type: "uint256" }, - ], - internalType: "struct LibNativeOrder.RfqOrder", - name: "order", - 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: "getRfqOrderRelevantState", - outputs: [ - { - components: [ - { - internalType: "bytes32", - name: "orderHash", - type: "bytes32", - }, - { - internalType: "enum LibNativeOrder.OrderStatus", - name: "status", - type: "uint8", - }, - { - internalType: "uint128", - name: "takerTokenFilledAmount", - type: "uint128", - }, - ], - internalType: "struct LibNativeOrder.OrderInfo", - name: "orderInfo", - type: "tuple", - }, - { - internalType: "uint128", - name: "actualFillableTakerTokenAmount", - type: "uint128", - }, - { internalType: "bool", name: "isSignatureValid", type: "bool" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "bytes4", name: "selector", type: "bytes4" }, - { internalType: "uint256", name: "idx", type: "uint256" }, - ], - name: "getRollbackEntryAtIndex", - outputs: [{ internalType: "address", name: "impl", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "bytes4", name: "selector", type: "bytes4" }], - name: "getRollbackLength", - outputs: [ - { - internalType: "uint256", - name: "rollbackLength", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getTransformWallet", - outputs: [ - { - internalType: "contract IFlashWallet", - name: "wallet", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getTransformerDeployer", - outputs: [{ internalType: "address", name: "deployer", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "signer", type: "address" }, - ], - name: "isValidOrderSigner", - outputs: [{ internalType: "bool", name: "isAllowed", type: "bool" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "txOrigin", type: "address" }, - { internalType: "uint64", name: "nonceBucket", type: "uint64" }, - ], - name: "lastOtcTxOriginNonce", - outputs: [{ internalType: "uint128", name: "lastNonce", type: "uint128" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order", - name: "sellOrder", - type: "tuple", - }, - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order", - name: "buyOrder", - 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: "sellOrderSignature", - 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: "buyOrderSignature", - type: "tuple", - }, - ], - name: "matchERC721Orders", - outputs: [{ internalType: "uint256", name: "profit", type: "uint256" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "target", type: "address" }, - { internalType: "bytes", name: "data", type: "bytes" }, - { internalType: "address", name: "newOwner", type: "address" }, - ], - name: "migrate", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20Token", - name: "outputToken", - type: "address", - }, - { - 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: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - ], - name: "multiplexBatchSellEthForToken", - outputs: [ - { - internalType: "uint256", - name: "boughtAmount", - type: "uint256", - }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20Token", - name: "inputToken", - type: "address", - }, - { - 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: "uint256", - name: "sellAmount", - type: "uint256", - }, - { - internalType: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - ], - name: "multiplexBatchSellTokenForEth", - outputs: [ - { - internalType: "uint256", - name: "boughtAmount", - type: "uint256", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20Token", - name: "inputToken", - type: "address", - }, - { - internalType: "contract IERC20Token", - name: "outputToken", - type: "address", - }, - { - 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: "uint256", - name: "sellAmount", - type: "uint256", - }, - { - internalType: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - ], - name: "multiplexBatchSellTokenForToken", - outputs: [ - { - internalType: "uint256", - name: "boughtAmount", - type: "uint256", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address[]", - name: "tokens", - type: "address[]", - }, - { - components: [ - { - internalType: "enum IMultiplexFeature.MultiplexSubcall", - name: "id", - type: "uint8", - }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - internalType: "struct IMultiplexFeature.MultiHopSellSubcall[]", - name: "calls", - type: "tuple[]", - }, - { - internalType: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - ], - name: "multiplexMultiHopSellEthForToken", - outputs: [ - { - internalType: "uint256", - name: "boughtAmount", - type: "uint256", - }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - internalType: "address[]", - name: "tokens", - type: "address[]", - }, - { - components: [ - { - internalType: "enum IMultiplexFeature.MultiplexSubcall", - name: "id", - type: "uint8", - }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - internalType: "struct IMultiplexFeature.MultiHopSellSubcall[]", - name: "calls", - type: "tuple[]", - }, - { - internalType: "uint256", - name: "sellAmount", - type: "uint256", - }, - { - internalType: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - ], - name: "multiplexMultiHopSellTokenForEth", - outputs: [ - { - internalType: "uint256", - name: "boughtAmount", - type: "uint256", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address[]", - name: "tokens", - type: "address[]", - }, - { - components: [ - { - internalType: "enum IMultiplexFeature.MultiplexSubcall", - name: "id", - type: "uint8", - }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - internalType: "struct IMultiplexFeature.MultiHopSellSubcall[]", - name: "calls", - type: "tuple[]", - }, - { - internalType: "uint256", - name: "sellAmount", - type: "uint256", - }, - { - internalType: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - ], - name: "multiplexMultiHopSellTokenForToken", - outputs: [ - { - internalType: "uint256", - name: "boughtAmount", - type: "uint256", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "operator", type: "address" }, - { internalType: "address", name: "from", type: "address" }, - { internalType: "uint256", name: "tokenId", type: "uint256" }, - { internalType: "uint256", name: "value", type: "uint256" }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - name: "onERC1155Received", - outputs: [{ internalType: "bytes4", name: "success", type: "bytes4" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "operator", type: "address" }, - { internalType: "address", name: "from", type: "address" }, - { internalType: "uint256", name: "tokenId", type: "uint256" }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - name: "onERC721Received", - outputs: [{ internalType: "bytes4", name: "success", type: "bytes4" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "owner", - outputs: [ - { - internalType: "address", - name: "ownerAddress", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc1155TokenProperties", - type: "tuple[]", - }, - { - internalType: "uint128", - name: "erc1155TokenAmount", - type: "uint128", - }, - ], - internalType: "struct LibNFTOrder.ERC1155Order", - name: "order", - type: "tuple", - }, - ], - name: "preSignERC1155Order", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order", - name: "order", - type: "tuple", - }, - ], - name: "preSignERC721Order", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "signer", type: "address" }, - { internalType: "bool", name: "allowed", type: "bool" }, - ], - name: "registerAllowedOrderSigner", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address[]", - name: "origins", - type: "address[]", - }, - { internalType: "bool", name: "allowed", type: "bool" }, - ], - name: "registerAllowedRfqOrigins", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "bytes4", name: "selector", type: "bytes4" }, - { internalType: "address", name: "targetImpl", type: "address" }, - ], - name: "rollback", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc1155TokenProperties", - type: "tuple[]", - }, - { - internalType: "uint128", - name: "erc1155TokenAmount", - type: "uint128", - }, - ], - internalType: "struct LibNFTOrder.ERC1155Order", - name: "buyOrder", - 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", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - internalType: "uint128", - name: "erc1155SellAmount", - type: "uint128", - }, - { - internalType: "bool", - name: "unwrapNativeToken", - type: "bool", - }, - { internalType: "bytes", name: "callbackData", type: "bytes" }, - ], - name: "sellERC1155", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order", - name: "buyOrder", - 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", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - internalType: "bool", - name: "unwrapNativeToken", - type: "bool", - }, - { internalType: "bytes", name: "callbackData", type: "bytes" }, - ], - name: "sellERC721", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "bytes", name: "encodedPath", type: "bytes" }, - { - internalType: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - { internalType: "address", name: "recipient", type: "address" }, - ], - name: "sellEthForTokenToUniswapV3", - outputs: [{ internalType: "uint256", name: "buyAmount", type: "uint256" }], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - 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", - }, - { - internalType: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - { internalType: "bytes", name: "auxiliaryData", type: "bytes" }, - ], - name: "sellToLiquidityProvider", - outputs: [ - { - internalType: "uint256", - name: "boughtAmount", - type: "uint256", - }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - 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", - }, - ], - name: "sellToPancakeSwap", - outputs: [{ internalType: "uint256", name: "buyAmount", type: "uint256" }], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - 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" }, - ], - name: "sellToUniswap", - outputs: [{ internalType: "uint256", name: "buyAmount", type: "uint256" }], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { internalType: "bytes", name: "encodedPath", type: "bytes" }, - { - internalType: "uint256", - name: "sellAmount", - type: "uint256", - }, - { - internalType: "uint256", - name: "minBuyAmount", - type: "uint256", - }, - { - internalType: "address payable", - name: "recipient", - type: "address", - }, - ], - name: "sellTokenForEthToUniswapV3", - outputs: [{ internalType: "uint256", name: "buyAmount", type: "uint256" }], - 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" }, - ], - name: "sellTokenForTokenToUniswapV3", - outputs: [{ internalType: "uint256", name: "buyAmount", type: "uint256" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "quoteSigner", - type: "address", - }, - ], - name: "setQuoteSigner", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "transformerDeployer", - type: "address", - }, - ], - name: "setTransformerDeployer", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }], - name: "supportInterface", - outputs: [{ internalType: "bool", name: "isSupported", type: "bool" }], - stateMutability: "pure", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "newOwner", type: "address" }], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32[]", - name: "poolIds", - type: "bytes32[]", - }, - ], - name: "transferProtocolFeesForPools", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20Token", - name: "erc20", - type: "address", - }, - { internalType: "uint256", name: "amountOut", type: "uint256" }, - { - internalType: "address payable", - name: "recipientWallet", - type: "address", - }, - ], - name: "transferTrappedTokensTo", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - 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", - }, - { - components: [ - { - internalType: "uint32", - name: "deploymentNonce", - type: "uint32", - }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - internalType: "struct ITransformERC20Feature.Transformation[]", - name: "transformations", - type: "tuple[]", - }, - ], - name: "transformERC20", - outputs: [ - { - internalType: "uint256", - name: "outputTokenAmount", - type: "uint256", - }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - internalType: "int256", - name: "amount0Delta", - type: "int256", - }, - { - internalType: "int256", - name: "amount1Delta", - type: "int256", - }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - name: "uniswapV3SwapCallback", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc1155TokenProperties", - type: "tuple[]", - }, - { - internalType: "uint128", - name: "erc1155TokenAmount", - type: "uint128", - }, - ], - internalType: "struct LibNFTOrder.ERC1155Order", - name: "order", - type: "tuple", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - ], - name: "validateERC1155OrderProperties", - outputs: [], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC1155Token", - name: "erc1155Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc1155TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc1155TokenProperties", - type: "tuple[]", - }, - { - internalType: "uint128", - name: "erc1155TokenAmount", - type: "uint128", - }, - ], - internalType: "struct LibNFTOrder.ERC1155Order", - name: "order", - 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: "validateERC1155OrderSignature", - outputs: [], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order", - name: "order", - type: "tuple", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - ], - name: "validateERC721OrderProperties", - outputs: [], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "enum LibNFTOrder.TradeDirection", - name: "direction", - type: "uint8", - }, - { internalType: "address", name: "maker", type: "address" }, - { internalType: "address", name: "taker", type: "address" }, - { - internalType: "uint256", - name: "expiry", - type: "uint256", - }, - { internalType: "uint256", name: "nonce", type: "uint256" }, - { - internalType: "contract IERC20Token", - name: "erc20Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc20TokenAmount", - type: "uint256", - }, - { - components: [ - { - internalType: "address", - name: "recipient", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "bytes", - name: "feeData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Fee[]", - name: "fees", - type: "tuple[]", - }, - { - internalType: "contract IERC721Token", - name: "erc721Token", - type: "address", - }, - { - internalType: "uint256", - name: "erc721TokenId", - type: "uint256", - }, - { - components: [ - { - internalType: "contract IPropertyValidator", - name: "propertyValidator", - type: "address", - }, - { - internalType: "bytes", - name: "propertyData", - type: "bytes", - }, - ], - internalType: "struct LibNFTOrder.Property[]", - name: "erc721TokenProperties", - type: "tuple[]", - }, - ], - internalType: "struct LibNFTOrder.ERC721Order", - name: "order", - 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: "validateERC721OrderSignature", - outputs: [], - stateMutability: "view", - type: "function", - }, -] as const; diff --git a/src/abi/MinimalERC20.ts b/src/abi/MinimalERC20.ts deleted file mode 100644 index 101783e..0000000 --- a/src/abi/MinimalERC20.ts +++ /dev/null @@ -1,16 +0,0 @@ -export const minimalERC20Abi = [ - { - type: "function", - name: "decimals", - stateMutability: "view", - inputs: [], - outputs: [{ name: "", type: "uint8" }], - }, - { - type: "function", - name: "symbol", - stateMutability: "view", - inputs: [], - outputs: [{ name: "", type: "string" }], - }, -] as const; diff --git a/src/abi/PermitAndCall.ts b/src/abi/PermitAndCall.ts deleted file mode 100644 index 6fa9e5b..0000000 --- a/src/abi/PermitAndCall.ts +++ /dev/null @@ -1,177 +0,0 @@ -export const permitAndCallAbi = [ - { - inputs: [ - { - internalType: "contract IERC2612", - name: "token", - type: "address", - }, - { - internalType: "address", - name: "owner", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "uint256", - name: "deadline", - type: "uint256", - }, - { - internalType: "uint8", - name: "v", - type: "uint8", - }, - { - internalType: "bytes32", - name: "r", - type: "bytes32", - }, - { - internalType: "bytes32", - name: "s", - type: "bytes32", - }, - { - internalType: "bytes", - name: "data", - type: "bytes", - }, - ], - name: "permitAndCall", - outputs: [ - { - internalType: "bytes", - name: "", - type: "bytes", - }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20PermitAllowed", - name: "token", - type: "address", - }, - { - internalType: "address", - name: "owner", - type: "address", - }, - { - internalType: "uint256", - name: "nonce", - type: "uint256", - }, - { - internalType: "uint256", - name: "deadline", - type: "uint256", - }, - { - internalType: "bool", - name: "allowed", - type: "bool", - }, - { - internalType: "uint8", - name: "v", - type: "uint8", - }, - { - internalType: "bytes32", - name: "r", - type: "bytes32", - }, - { - internalType: "bytes32", - name: "s", - type: "bytes32", - }, - { - internalType: "bytes", - name: "data", - type: "bytes", - }, - ], - name: "permitAndCall", - outputs: [ - { - internalType: "bytes", - name: "", - type: "bytes", - }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - internalType: "contract IERC20MetaTransaction", - name: "token", - type: "address", - }, - { - internalType: "address", - name: "owner", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - { - internalType: "uint8", - name: "v", - type: "uint8", - }, - { - internalType: "bytes32", - name: "r", - type: "bytes32", - }, - { - internalType: "bytes32", - name: "s", - type: "bytes32", - }, - { - internalType: "bytes", - name: "data", - type: "bytes", - }, - ], - name: "permitAndCall", - outputs: [ - { - internalType: "bytes", - name: "", - type: "bytes", - }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [], - name: "target", - outputs: [ - { - internalType: "address payable", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, -] as const; diff --git a/src/constants.ts b/src/constants.ts deleted file mode 100644 index a7e2c35..0000000 --- a/src/constants.ts +++ /dev/null @@ -1,76 +0,0 @@ -export const EVENT_SIGNATURES = { - LimitOrderFilled: - "0xab614d2b738543c0ea21f56347cf696a3a0c42a7cbec3212a5ca22a4dcff2124", - LiquidityProviderSwap: - "0x40a6ba9513d09e3488135e0e0d10e2d4382b792720155b144cbea89ac9db6d34", - OtcOrderFilled: - "0xac75f773e3a92f1a02b12134d65e1f47f8a14eabe4eaf1e24624918e6a8b269f", - MetaTransactionExecuted: - "0x7f4fe3ff8ae440e1570c558da08440b26f89fb1c1f2910cd91ca6452955f121a", - Transfer: - "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", - TransformedERC20: - "0x0f6672f78a59ba8e5e5b5d38df3ebc67f3c792e2c9259b8d97d7f00dd78ba1b3", -} as const; - -export const FUNCTION_SELECTORS = { - permitAndCall: { - IERC2612: "0x34b4d153", // Canonical permit - IERC20PermitAllowed: "0x7f9cb4d7", // Dai permit - IERC20MetaTransaction: "0x9d50b5e4", // Meta Transaction permit - } -} as const - -export const EXCHANGE_PROXY_ABI_URL = - "https://raw.githubusercontent.com/0xProject/protocol/development/packages/contract-artifacts/artifacts/IZeroEx.json"; - -const CANONICAL_EXCHANGE_PROXY = "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"; - -export const MULTICALL3 = "0xcA11bde05977b3631167028862bE2a173976CA11"; - -export const PERMIT_AND_CALL_BY_CHAIN_ID = { - 1: "0x1291C02D288de3De7dC25353459489073D11E1Ae", - 137: "0x2Ddd30fE5c12FC4CD497526F14Bf3d1fcd3D5Db4", - 8453: "0x3CA53031Ad0B86a304845e83644983Be3340895f", -} as const; - -export const EXCHANGE_PROXY_BY_CHAIN_ID = { - 1: CANONICAL_EXCHANGE_PROXY, - 5: "0xF91bB752490473B8342a3E964E855b9f9a2A668e", - 10: "0xDEF1ABE32c034e558Cdd535791643C58a13aCC10", - 56: CANONICAL_EXCHANGE_PROXY, - 137: CANONICAL_EXCHANGE_PROXY, - 250: "0xDEF189DeAEF76E379df891899eb5A00a94cBC250", - 8453: CANONICAL_EXCHANGE_PROXY, - 42161: CANONICAL_EXCHANGE_PROXY, - 42220: CANONICAL_EXCHANGE_PROXY, - 43114: CANONICAL_EXCHANGE_PROXY, -} as const; - -export const CONTRACTS = { - weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", -} as const; - -export const NATIVE_ASSET = { - symbol: "ETH", - decimals: 18, - address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", -} as const; - -export const NATIVE_SYMBOL_BY_CHAIN_ID = { - 1: "ETH", // Ethereum - 5: "ETH", // Goerli - 10: "ETH", // Optimism - 56: "BNB", // BNB Chain - 137: "MATIC", // Polygon - 250: "FTM", // Fantom - 8453: "ETH", // Base - 42161: "ETH", // Arbitrum One - 42220: "CELO", // Celo - 43114: "AVAX", // Avalanche -} as const; - -export enum TRANSACTION_STATUS { - REVERTED = "reverted", - SUCCESS = "success", -} diff --git a/src/index.test.ts b/src/index.test.ts new file mode 100644 index 0000000..83e4418 --- /dev/null +++ b/src/index.test.ts @@ -0,0 +1,202 @@ +import { http, createPublicClient } from "viem"; +import { mainnet } from "viem/chains"; +import { test, expect } from "vitest"; +import { parseSwap } from "./index"; + +require("dotenv").config(); + +if (!process.env.ETH_MAINNET_RPC) { + throw new Error("An RPC URL required."); +} + +const publicClient = createPublicClient({ + chain: mainnet, + transport: http(process.env.ETH_MAINNET_RPC), +}); + +// https://etherscan.io/tx/0x2b9a12398613887e9813594e8583f488f0e8392d8e6e0ba8d9e140065826dd00 +test("parses swapped amounts case 1 (default)", async () => { + const transactionHash = + "0x2b9a12398613887e9813594e8583f488f0e8392d8e6e0ba8d9e140065826dd00"; + + const result = await parseSwap({ + publicClient, + transactionHash, + }); + + expect(result).toEqual({ + tokenIn: { + symbol: "USDC", + amount: "30.084159", + address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + }, + tokenOut: { + symbol: "USDT", + amount: "30.069172", + address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", + }, + }); +}); + +// https://etherscan.io/tx/0x76b744ab42b05b30624bd5027b4f7da841cdc357bb1d6ee74e3d9e049dd8a126 +test("parses swapped amounts case 2 (default)", async () => { + const transactionHash = + "0x76b744ab42b05b30624bd5027b4f7da841cdc357bb1d6ee74e3d9e049dd8a126"; + + const result = await parseSwap({ + publicClient, + transactionHash, + }); + + expect(result).toEqual({ + tokenIn: { + symbol: "USDC", + amount: "1", + address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + }, + tokenOut: { + symbol: "WETH", + amount: "0.000280757770903965", + address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + }, + }); +}); + +// https://etherscan.io/tx/0x565e8e0582b620ee06618ee0b7705dc0e7f56dfd88b5eb3e008c0858f6f806d8 +test("parses swapped amounts case 3 (default)", async () => { + const transactionHash = + "0x565e8e0582b620ee06618ee0b7705dc0e7f56dfd88b5eb3e008c0858f6f806d8"; + + const result = await parseSwap({ + publicClient, + transactionHash, + }); + + expect(result).toEqual({ + tokenIn: { + symbol: "USDC", + amount: "8.15942", + address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + }, + tokenOut: { + symbol: "WBTC", + amount: "0.00013188", + address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", + }, + }); +}); + +// https://etherscan.io/tx/0xd024750c7dcb99ace02c6b083c68d73dcfebdee252ccbeb1b83981b609693271 +test("parses swapped amounts case 4 (default)", async () => { + const transactionHash = + "0xd024750c7dcb99ace02c6b083c68d73dcfebdee252ccbeb1b83981b609693271"; + + const result = await parseSwap({ + publicClient, + transactionHash, + }); + + expect(result).toEqual({ + tokenIn: { + symbol: "USDC", + amount: "335.142587", + address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + }, + tokenOut: { + symbol: "WETH", + amount: "0.105662100963455883", + address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + }, + }); +}); + +// https://etherscan.io/tx/0x4cbcf2e2512adb7e28f19f8cf28ddc29a9f9fea93c842cf3b735eeb526fe34b3 +test("parses swapped amounts case 5 (native sell token)", async () => { + const transactionHash = + "0x4cbcf2e2512adb7e28f19f8cf28ddc29a9f9fea93c842cf3b735eeb526fe34b3"; + + const result = await parseSwap({ + publicClient, + transactionHash, + }); + + expect(result).toEqual({ + tokenIn: { + symbol: "ETH", + amount: "0.04", + address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + }, + tokenOut: { + symbol: "USDC", + amount: "126.580558", + address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + }, + }); +}); + +// https://etherscan.io/tx/0x28c5bb3768bb64e81e1f3753ed1a8c30f0484a434d6c2b4af825d258ecb3bcf0 +test("parses swapped amounts case 6 (buy DNT 404 token)", async () => { + const transactionHash = + "0x28c5bb3768bb64e81e1f3753ed1a8c30f0484a434d6c2b4af825d258ecb3bcf0"; + + const result = await parseSwap({ + publicClient, + transactionHash, + }); + + expect(result).toEqual({ + tokenIn: { + symbol: "USDC", + amount: "95", + address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + }, + tokenOut: { + symbol: "CHIB", + amount: "10.527633901274097318", + address: "0x7068263EDa099fB93BB3215c05e728c0b54b3137", + }, + }); +}); + +// https://etherscan.io/tx/0xb8beef6bf857f2fc22905b2872120abc634900b45941478aa9cf0ad1ceffcd67 +// https://gopluslabs.io/token-security/1/0xcf0c122c6b73ff809c693db761e7baebe62b6a2e +test("parses swapped amounts case 6 (buy FoT token, FLOKI)", async () => { + const transactionHash = + "0xb8beef6bf857f2fc22905b2872120abc634900b45941478aa9cf0ad1ceffcd67"; + + const result = await parseSwap({ + publicClient, + transactionHash, + }); + + expect(result).toEqual({ + tokenIn: { + symbol: "USDC", + amount: "31.580558", + address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + }, + tokenOut: { + symbol: "FLOKI", + amount: "172036.330384861", + address: "0xcf0C122c6b73ff809C693DB761e7BaeBe62b6a2E", + }, + }); +}); + +// https://explorer.celo.org/tx/0x615c5089f772a8f2074750e8c6070013d288af7681435aba1771f6bfc63d1286 +test("throws an error for unsupported chains)", async () => { + const transactionHash = + "0x615c5089f772a8f2074750e8c6070013d288af7681435aba1771f6bfc63d1286"; + + const publicClient = createPublicClient({ + chain: mainnet, + transport: http("https://rpc.ankr.com/celo"), + }); + + expect(async () => { + await parseSwap({ + publicClient, + transactionHash, + }); + }).rejects.toThrowError("chainId 42220 is unsupported…"); +}); diff --git a/src/index.ts b/src/index.ts index 8fa7275..3c1ff75 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,89 +1,140 @@ -import { http, getAddress, decodeFunctionData, createPublicClient } from "viem"; -import { mainnet } from "viem/chains"; -import { parsers } from "./parsers"; -import { permitAndCallAbi } from "./abi/PermitAndCall"; -import { - TRANSACTION_STATUS, - EXCHANGE_PROXY_ABI_URL, - EXCHANGE_PROXY_BY_CHAIN_ID, - PERMIT_AND_CALL_BY_CHAIN_ID, -} from "./constants"; -import { isChainIdSupported, isPermitAndCallChainId } from "./utils"; -import type { ParseSwapArgs } from "./types"; - -export * from "./types"; - -export async function parseSwap({ - rpcUrl, - exchangeProxyAbi, - transactionHash: hash, -}: ParseSwapArgs) { - if (!rpcUrl) throw new Error("Missing rpcUrl…"); - if (!hash) throw new Error("Missing transaction hash…"); - if (!exchangeProxyAbi) { - throw new Error( - `Missing 0x Exchange Proxy ABI: ${EXCHANGE_PROXY_ABI_URL}…` - ); - } - - const publicClient = createPublicClient({ - chain: mainnet, - transport: http(rpcUrl), - }); +import { erc20Abi, getAddress, formatUnits } from "viem"; +import type { + Chain, + Address, + Transport, + PublicClient, + TransactionReceipt, +} from "viem"; + +const NATIVE_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; + +type SupportedChainId = 1 | 8453; + +export const NATIVE_SYMBOL_BY_CHAIN_ID: { [key in SupportedChainId]: string } = + { + 1: "ETH", // Ethereum + 8453: "ETH", // Base + }; + +export function isChainIdSupported( + chainId: number +): chainId is SupportedChainId { + return [1, 10, 56, 137, 8453, 42161].includes(chainId); +} - const { getChainId, getTransaction, getTransactionReceipt } = publicClient; +export interface EnrichLogsArgs { + transactionReceipt: TransactionReceipt; + publicClient: PublicClient; +} +export interface EnrichedLog { + to: Address; + from: Address; + symbol: string; + amount: string; + address: Address; + decimals: number; +} - const [chainId, transaction, transactionReceipt] = await Promise.all([ - getChainId(), - getTransaction({ hash }), - getTransactionReceipt({ hash }), - ]); +export async function transferLogs({ + publicClient, + transactionReceipt, +}: EnrichLogsArgs): Promise { + const EVENT_SIGNATURES = { + Transfer: + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + } as const; + const { logs } = transactionReceipt; + const transferLogsAddresses = logs + .filter((log) => log.topics[0] === EVENT_SIGNATURES.Transfer) + .map((log) => ({ ...log, address: getAddress(log.address) })); + const contracts = [ + ...transferLogsAddresses.map((log) => ({ + abi: erc20Abi, + address: log.address, + functionName: "symbol", + })), + ...transferLogsAddresses.map((log) => ({ + abi: erc20Abi, + address: log.address, + functionName: "decimals", + })), + ]; + const results = await publicClient.multicall({ contracts }); + const midpoint = Math.floor(results.length / 2); + const enrichedLogs = transferLogsAddresses + .map((log, index) => { + const symbol = results[index].result as string; + const decimals = results[midpoint + index].result as number; + const amount = + log.data === "0x" ? "0" : formatUnits(BigInt(log.data), decimals); + const { address, topics } = log; + const { 1: fromHex, 2: toHex } = topics; + const from = getAddress(convertHexToAddress(fromHex)); + const to = getAddress(convertHexToAddress(toHex)); + + return { to, from, symbol, amount, address, decimals }; + }) + .filter((log) => log.amount !== "0"); + + return enrichedLogs; +} - if (transactionReceipt.status === TRANSACTION_STATUS.REVERTED) { - return null; - } +function convertHexToAddress(hexString: string): string { + return `0x${hexString.slice(-40)}`; +} +export async function parseSwap({ + publicClient, + transactionHash, +}: { + publicClient: PublicClient; + transactionHash: Address; +}) { + const chainId = await publicClient.getChainId(); if (!isChainIdSupported(chainId)) { throw new Error(`chainId ${chainId} is unsupported…`); } - const exchangeProxy = EXCHANGE_PROXY_BY_CHAIN_ID[chainId]; - - const permitAndCall = isPermitAndCallChainId(chainId) - ? PERMIT_AND_CALL_BY_CHAIN_ID[chainId] - : null; - - // The `to` property is null only in the case of a contract creation transaction, - // which never occurs in the context of the 0x-parser. Use TypeScript's non-null - // assertion operator to indicate that the `to` property will always be present. - const to = getAddress(transaction.to!); - - const isToExchangeProxy = to === exchangeProxy; - - const isToPermitAndCall = to === permitAndCall; - - if (!isToExchangeProxy && !isToPermitAndCall) { - return null; - } - - const { functionName } = isToExchangeProxy - ? decodeFunctionData({ - abi: exchangeProxyAbi, - data: transaction.input, - }) - : decodeFunctionData({ - abi: permitAndCallAbi, - data: transaction.input, - }); - - const parser = parsers[functionName]; - - return parser({ - chainId, - transaction, + const transactionReceipt = await publicClient.getTransactionReceipt({ + hash: transactionHash, + }); + const { value } = await publicClient.getTransaction({ + hash: transactionHash, + }); + const isNativeSell = value > 0n; + const logs = await transferLogs({ publicClient, - exchangeProxyAbi, transactionReceipt, - callData: transaction.input, }); + + const input = logs[0]; + const output = logs[logs.length - 1]; + if (isNativeSell) { + const sellAmount = formatUnits(value, 18); + return { + tokenIn: { + symbol: NATIVE_SYMBOL_BY_CHAIN_ID[chainId], + amount: sellAmount, + address: NATIVE_TOKEN_ADDRESS, + }, + tokenOut: { + symbol: output.symbol, + amount: output.amount, + address: output.address, + }, + }; + } + return { + tokenIn: { + symbol: input.symbol, + amount: input.amount, + address: input.address, + }, + tokenOut: { + symbol: output.symbol, + amount: output.amount, + address: output.address, + }, + }; } diff --git a/src/parsers/index.ts b/src/parsers/index.ts deleted file mode 100644 index cb79a54..0000000 --- a/src/parsers/index.ts +++ /dev/null @@ -1,658 +0,0 @@ -import { - getAddress, - formatUnits, - decodeEventLog, - decodeFunctionData, - encodeFunctionData, -} from "viem"; -import { - CONTRACTS, - NATIVE_ASSET, - EVENT_SIGNATURES, - FUNCTION_SELECTORS, - NATIVE_SYMBOL_BY_CHAIN_ID, - EXCHANGE_PROXY_BY_CHAIN_ID, -} from "../constants"; -import { minimalERC20Abi } from "../abi/MinimalERC20"; -import { transferLogs, extractTokenInfo } from "../utils"; -import { exchangeProxyAbi as exchangeProxyAbiValue } from "../abi/ExchangeProxyAbi"; -import type { - Hex, - Chain, - Transport, - PublicClient, - TransactionReceipt, -} from "viem"; -import type { - Parsers, - ParserArgs, - PermitAndCall, - FillLimitOrder, - TokenTransaction, - FillOtcOrderForEth, - TransformERC20Args, - FillOtcOrderWithEth, - ExecuteMetaTransaction, - FillTakerSignedOtcOrder, - ExecuteMetaTransactionV2, - MultiplexBatchSellTokenForEth, - MultiplexBatchSellEthForToken, - MultiplexBatchSellTokenForToken, -} from "../types"; -import { permitAndCallAbi } from "../abi/PermitAndCall"; - -export async function sellToLiquidityProvider({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const from = getAddress(transactionReceipt.from); - const inputLog = logs.find((log) => from === log.from); - const outputLog = logs.find((log) => from === log.to); - - if (inputLog && outputLog) { - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function multiplexMultiHopSellTokenForEth({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const from = getAddress(transactionReceipt.from); - const logs = await transferLogs({ publicClient, transactionReceipt }); - const inputLog = logs.find((log) => from === log.from); - const outputLog = logs.find((log) => log.address === CONTRACTS.weth); - - if (inputLog && outputLog) { - outputLog.symbol = NATIVE_ASSET.symbol; - outputLog.address = NATIVE_ASSET.address; - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function multiplexMultiHopSellEthForToken({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const from = getAddress(transactionReceipt.from); - const logs = await transferLogs({ publicClient, transactionReceipt }); - const inputLog = logs.find((log) => log.address === CONTRACTS.weth); - const outputLog = logs.find((log) => log.to === from); - - if (inputLog && outputLog) { - inputLog.symbol = NATIVE_ASSET.symbol; - inputLog.address = NATIVE_ASSET.address; - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function fillTakerSignedOtcOrder({ - callData, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: { - callData: Hex; - publicClient: PublicClient; - exchangeProxyAbi: typeof exchangeProxyAbiValue; - transactionReceipt: TransactionReceipt; -}) { - const { args } = decodeFunctionData({ - abi: exchangeProxyAbi as unknown as FillTakerSignedOtcOrder[], - data: callData, - }); - const [order] = args; - const logs = await transferLogs({ publicClient, transactionReceipt }); - const { maker, taker } = order; - const inputLog = logs.find((log) => log.from === taker); - const outputLog = logs.find((log) => log.from === maker); - - if (inputLog && outputLog) { - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function fillOtcOrder({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const fromAddress = getAddress(transactionReceipt.from); - const inputLog = logs.find((log) => log.from === fromAddress); - const outputLog = logs.find((log) => log.to === fromAddress); - - if (inputLog && outputLog) { - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function fillTakerSignedOtcOrderForEth({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const inputLog = logs.find((log) => log.address !== CONTRACTS.weth); - const outputLog = logs.find((log) => log.address === CONTRACTS.weth); - - if (inputLog && outputLog) { - outputLog.symbol = NATIVE_ASSET.symbol; - outputLog.address = NATIVE_ASSET.address; - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function sellTokenForEthToUniswapV3({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const from = getAddress(transactionReceipt.from); - const inputLog = logs.find((log) => log.from === from); - const outputLog = logs.find((log) => log.address === CONTRACTS.weth); - - if (inputLog && outputLog) { - outputLog.symbol = NATIVE_ASSET.symbol; - outputLog.address = NATIVE_ASSET.address; - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function sellTokenForTokenToUniswapV3({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const from = getAddress(transactionReceipt.from); - const inputLog = logs.find((log) => from === log.from); - const outputLog = logs.find((log) => from === log.to); - - if (inputLog && outputLog) { - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function sellEthForTokenToUniswapV3({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const from = getAddress(transactionReceipt.from); - const inputLog = logs.find((log) => log.address === CONTRACTS.weth); - const outputLog = logs.find((log) => from === log.to); - - if (inputLog && outputLog) { - inputLog.symbol = NATIVE_ASSET.symbol; - inputLog.address = NATIVE_ASSET.address; - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function sellToUniswap({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const inputLog = logs[0]; - const outputLog = logs[logs.length - 1]; - - return extractTokenInfo(inputLog, outputLog); -} - -export async function transformERC20({ - chainId, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: ParserArgs) { - const nativeSymbol = NATIVE_SYMBOL_BY_CHAIN_ID[chainId]; - - for (const log of transactionReceipt.logs) { - const { topics, data } = log; - const [eventHash] = topics; - - if (eventHash === EVENT_SIGNATURES.TransformedERC20) { - let inputSymbol: undefined | string; - let inputDecimal: undefined | number; - let outputSymbol: undefined | string; - let outputDecimal: undefined | number; - - const eventLog = decodeEventLog({ - data, - topics, - abi: exchangeProxyAbi, - }); - - const { inputToken, outputToken, inputTokenAmount, outputTokenAmount } = - eventLog.args as TransformERC20Args; - - const inputContract = { - address: inputToken, - abi: minimalERC20Abi, - } as const; - - const outputContract = { - address: outputToken, - abi: minimalERC20Abi, - } as const; - - if (inputToken === NATIVE_ASSET.address) { - inputSymbol = nativeSymbol; - inputDecimal = 18; - } else { - [{ result: inputSymbol }, { result: inputDecimal }] = - await publicClient.multicall({ - contracts: [ - { - ...inputContract, - functionName: "symbol", - }, - { - ...inputContract, - functionName: "decimals", - }, - ], - }); - } - - if (outputToken === NATIVE_ASSET.address) { - outputSymbol = nativeSymbol; - outputDecimal = 18; - } else { - [{ result: outputSymbol }, { result: outputDecimal }] = - await publicClient.multicall({ - contracts: [ - { - ...outputContract, - functionName: "symbol", - }, - { - ...outputContract, - functionName: "decimals", - }, - ], - }); - } - - // 0x-parser expects decimals to be present. If you find a transaction - // where this is not the case, please open a GitHub issue. - const inputAmount = formatUnits(inputTokenAmount, inputDecimal!); - const outputAmount = formatUnits(outputTokenAmount, outputDecimal!); - - return { - tokenIn: { - address: inputToken, - amount: inputAmount, - symbol: inputSymbol, - }, - tokenOut: { - address: outputToken, - amount: outputAmount, - symbol: outputSymbol, - }, - }; - } - } -} - -export async function multiplexMultiHopSellTokenForToken({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const from = getAddress(transactionReceipt.from); - const inputLog = logs.find((log) => from === log.from); - const outputLog = logs.find((log) => from === log.to); - - if (inputLog && outputLog) { - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function multiplexBatchSellTokenForEth({ - callData, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const { args } = decodeFunctionData({ - abi: exchangeProxyAbi as unknown as MultiplexBatchSellTokenForEth[], - data: callData, - }); - const [inputTokenAddress] = args; - - return logs.reduce( - (acc, curr) => { - const { symbol, amount, address } = curr; - - if (address === CONTRACTS.weth) { - return { - ...acc, - tokenOut: { - ...acc.tokenOut, - amount: (Number(acc.tokenOut.amount) + Number(amount)).toString(), - }, - }; - } else if (address === inputTokenAddress) { - return { - ...acc, - tokenIn: { - ...acc.tokenIn, - symbol, - address, - amount: (Number(acc.tokenIn.amount) + Number(amount)).toString(), - }, - }; - } else { - return acc; - } - }, - { - tokenIn: { address: "", amount: "", symbol: "" }, - tokenOut: { - amount: "", - symbol: NATIVE_ASSET.symbol, - address: NATIVE_ASSET.address, - }, - } - ); -} - -export async function multiplexBatchSellEthForToken({ - callData, - transaction, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: ParserArgs) { - const { value } = transaction; - const { args } = decodeFunctionData({ - abi: exchangeProxyAbi as unknown as MultiplexBatchSellEthForToken[], - data: callData, - }); - const logs = await transferLogs({ publicClient, transactionReceipt }); - const [outputToken] = args; - const divisor = 1000000000000000000n; // 1e18, for conversion from wei to ether - const etherBigInt = value / divisor; - const remainderBigInt = value % divisor; - const ether = Number(etherBigInt) + Number(remainderBigInt) / Number(divisor); - const tokenOutAmount = logs.reduce((total, log) => { - return log.address === outputToken ? total + Number(log.amount) : total; - }, 0); - const inputLog = logs.find((log) => log.address === CONTRACTS.weth); - const outputLog = logs.find((log) => log.address === outputToken); - - if (inputLog && outputLog) { - return { - tokenIn: { - symbol: NATIVE_ASSET.symbol, - amount: ether.toString(), - address: NATIVE_ASSET.address, - }, - tokenOut: { - symbol: outputLog.symbol, - amount: tokenOutAmount.toString(), - address: outputLog.address, - }, - }; - } -} - -export async function multiplexBatchSellTokenForToken({ - callData, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const { args } = decodeFunctionData({ - abi: exchangeProxyAbi as unknown as MultiplexBatchSellTokenForToken[], - data: callData, - }); - const [inputContractAddress, outputContractAddress] = args; - const tokenData = { - [inputContractAddress]: { amount: "0", symbol: "", address: "" }, - [outputContractAddress]: { amount: "0", symbol: "", address: "" }, - }; - - logs.forEach(({ address, symbol, amount }) => { - if (getAddress(address) in tokenData) { - tokenData[getAddress(address)].address = getAddress(address); - tokenData[getAddress(address)].symbol = symbol; - tokenData[getAddress(address)].amount = ( - Number(tokenData[getAddress(address)].amount) + Number(amount) - ).toString(); - } - }); - - return { - tokenIn: tokenData[inputContractAddress], - tokenOut: tokenData[outputContractAddress], - }; -} - -export async function sellToPancakeSwap({ - publicClient, - transactionReceipt, -}: ParserArgs) { - const logs = await transferLogs({ publicClient, transactionReceipt }); - const exchangeProxy = getAddress(EXCHANGE_PROXY_BY_CHAIN_ID[56]); - const from = getAddress(transactionReceipt.from); - let inputLog = logs.find((log) => log.from === from); - let outputLog = logs.find((log) => log.from !== from); - - if (inputLog === undefined) { - inputLog = logs.find((log) => log.from === exchangeProxy); - outputLog = logs.find((log) => log.from !== exchangeProxy); - } - - if (!logs.some((log) => log.to === from)) { - outputLog = logs.find((log) => log.to === exchangeProxy); - } - - if (inputLog && outputLog) { - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function fillOtcOrderForEth({ - callData, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: ParserArgs) { - const { args } = decodeFunctionData({ - abi: exchangeProxyAbi as unknown as FillOtcOrderForEth[], - data: callData, - }); - const logs = await transferLogs({ publicClient, transactionReceipt }); - const [order] = args; - const { makerToken, takerToken } = order; - const inputLog = logs.find((log) => log.address === takerToken); - const outputLog = logs.find((log) => log.address === makerToken); - - if (inputLog && outputLog) { - outputLog.symbol = NATIVE_ASSET.symbol; - outputLog.address = NATIVE_ASSET.address; - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function fillOtcOrderWithEth({ - callData, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: ParserArgs) { - const { args } = decodeFunctionData({ - abi: exchangeProxyAbi as unknown as FillOtcOrderWithEth[], - data: callData, - }); - const logs = await transferLogs({ publicClient, transactionReceipt }); - const [order] = args; - const { makerToken, takerToken } = order; - const inputLog = logs.find((log) => log.address === takerToken); - const outputLog = logs.find((log) => log.address === makerToken); - - if (inputLog && outputLog) { - inputLog.symbol = NATIVE_ASSET.symbol; - inputLog.address = NATIVE_ASSET.address; - return extractTokenInfo(inputLog, outputLog); - } -} - -export async function fillLimitOrder({ - callData, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: ParserArgs) { - const { args } = decodeFunctionData({ - abi: exchangeProxyAbi as unknown as FillLimitOrder[], - data: callData, - }); - const [order] = args; - const { maker, taker } = order; - const logs = await transferLogs({ publicClient, transactionReceipt }); - - if (typeof maker === "string" && typeof taker === "string") { - const inputLog = logs.find((log) => log.from === taker); - const outputLog = logs.find((log) => log.from === maker); - if (inputLog && outputLog) { - return extractTokenInfo(inputLog, outputLog); - } - } -} - -export async function executeMetaTransaction({ - callData, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: ParserArgs) { - const { args } = decodeFunctionData({ - abi: exchangeProxyAbi as unknown as ExecuteMetaTransaction[], - data: callData, - }); - const [metaTransaction] = args; - const { signer } = metaTransaction; - const logs = await transferLogs({ publicClient, transactionReceipt }); - - if (typeof signer === "string") { - const inputLog = logs.find((log) => log.from === signer); - const outputLog = logs.find((log) => log.to === signer); - if (inputLog && outputLog) { - return extractTokenInfo(inputLog, outputLog); - } - } -} - -async function executeMetaTransactionV2({ - chainId, - transaction, - publicClient, - exchangeProxyAbi, - transactionReceipt, - callData: callDataMtx, -}: ParserArgs): Promise { - const { args } = decodeFunctionData({ - abi: exchangeProxyAbi as unknown as ExecuteMetaTransactionV2[], - data: callDataMtx, - }); - const [metaTransaction] = args; - const { callData } = metaTransaction; - const { functionName } = decodeFunctionData({ - data: callData, - abi: exchangeProxyAbi, - }); - const parser = parsers[functionName]; - - return parser({ - chainId, - callData, - transaction, - publicClient, - exchangeProxyAbi, - transactionReceipt, - }); -} - -function permitAndCall({ - chainId, - transaction, - publicClient, - exchangeProxyAbi, - transactionReceipt, -}: ParserArgs) { - const { args } = decodeFunctionData({ - abi: permitAndCallAbi as unknown as PermitAndCall[], - data: transaction.input, - }); - let callData: Hex | undefined; - - const encodedHexData = encodeFunctionData({ - abi: permitAndCallAbi as any, - functionName: "permitAndCall", - args: [...args], - }); - - const functionSelector = encodedHexData.slice(0, 10); - - const { IERC2612, IERC20PermitAllowed, IERC20MetaTransaction } = - FUNCTION_SELECTORS.permitAndCall; - - switch (functionSelector) { - case IERC2612: - callData = args[7]; - break; - case IERC20PermitAllowed: - callData = args[8]; - break; - case IERC20MetaTransaction: - callData = args[6]; - break; - } - - if (callData) { - const { functionName: exchangeProxyFn } = decodeFunctionData({ - abi: exchangeProxyAbi, - data: callData, - }); - const parser = parsers[exchangeProxyFn]; - - return parser({ - chainId, - callData, - transaction, - publicClient, - exchangeProxyAbi, - transactionReceipt, - }); - } -} - -export const parsers: Parsers = { - fillLimitOrder, - fillOtcOrder, - fillOtcOrderForEth, - fillOtcOrderWithEth, - fillTakerSignedOtcOrder, - fillTakerSignedOtcOrderForEth, - executeMetaTransaction, - executeMetaTransactionV2, - multiplexBatchSellTokenForToken, - multiplexBatchSellTokenForEth, - multiplexBatchSellEthForToken, - multiplexMultiHopSellTokenForToken, - multiplexMultiHopSellEthForToken, - multiplexMultiHopSellTokenForEth, - permitAndCall, - sellToUniswap, - sellTokenForEthToUniswapV3, - sellEthForTokenToUniswapV3, - sellTokenForTokenToUniswapV3, - sellToLiquidityProvider, - sellToPancakeSwap, - transformERC20, -}; diff --git a/src/tests/executeMetaTransaction.test.ts b/src/tests/executeMetaTransaction.test.ts deleted file mode 100644 index cbc2daf..0000000 --- a/src/tests/executeMetaTransaction.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -const POLYGON_MAINNET_RPC = "https://rpc.ankr.com/polygon"; - -// https://polygonscan.com/tx/0xaa61b2058fafae1532565b6acadf47a8fe604518185f535e2780dd28d626e0ef -it("parses swap from executeMetaTransaction", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: POLYGON_MAINNET_RPC, - transactionHash: - "0xaa61b2058fafae1532565b6acadf47a8fe604518185f535e2780dd28d626e0ef", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "WMATIC", - amount: "8.54621988", - address: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", - }, - tokenOut: { - symbol: "PAXG", - amount: "0.00488474242697242", - address: "0x553d3D295e0f695B9228246232eDF400ed3560B5", - }, - }); -}); diff --git a/src/tests/executeMetaTransactionV2.test.ts b/src/tests/executeMetaTransactionV2.test.ts deleted file mode 100644 index 5044480..0000000 --- a/src/tests/executeMetaTransactionV2.test.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x3e22063b0a1be3e8a7a902b6a2ecd86d7753279ef368e21b99d23e431d759f71 -it("parses swap from executeMetaTransactionV2 which wraps transformERC20", async () => { - const data = await parseSwap({ - transactionHash: - "0x3e22063b0a1be3e8a7a902b6a2ecd86d7753279ef368e21b99d23e431d759f71", - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "USDC", - amount: "9960.981086", - address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - }, - tokenOut: { - symbol: "WBTC", - amount: "0.35487978", - address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", - }, - }); -}); - -// https://etherscan.io/tx/0xc772258418e5d73bcf891ef341a42c0d74d8f84beda7f9e8580eacc0d62ba3c7 -it("parses swap from executeMetaTransactionV2 which wraps multiplexBatchSellTokenForEth", async () => { - const data = await parseSwap({ - transactionHash: - "0xc772258418e5d73bcf891ef341a42c0d74d8f84beda7f9e8580eacc0d62ba3c7", - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - }); - - expect(data).toEqual({ - tokenIn: { - amount: "5000", - symbol: "USDT", - address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", - }, - tokenOut: { - amount: "2.6043201133029994", - symbol: NATIVE_ASSET.symbol, - address: NATIVE_ASSET.address, - }, - }); -}); - -// https://etherscan.io/tx/0xa4fa7313361c1be65bcec51217ad795028c8fd0ce9eacaff7aab546c29017921 -it("parses swap from executeMetaTransactionV2 which wraps multiplexBatchSellTokenForToken", async () => { - const data = await parseSwap({ - transactionHash: - "0xa4fa7313361c1be65bcec51217ad795028c8fd0ce9eacaff7aab546c29017921", - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - }); - - expect(data).toEqual({ - tokenIn: { - amount: "2.8981149999999998", - symbol: "WETH", - address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", - }, - tokenOut: { - amount: "384833.18203482", - symbol: "HEX", - address: "0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39", - }, - }); -}); - -// https://etherscan.io/tx/0xee3ffb65f6c8e07b46471cc610cf721affeefed87098c7db30a8147d50eb2a65 -it("parses swap from executeMetaTransactionV2 which wraps transformERC20", async () => { - const data = await parseSwap({ - transactionHash: - "0xee3ffb65f6c8e07b46471cc610cf721affeefed87098c7db30a8147d50eb2a65", - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - }); - - expect(data).toEqual({ - tokenIn: { - amount: "399.98912868386398826", - symbol: "cbETH", - address: "0xBe9895146f7AF43049ca1c1AE358B0541Ea49704", - }, - tokenOut: { - amount: "410.723904828710787856", - symbol: NATIVE_ASSET.symbol, - address: NATIVE_ASSET.address, - }, - }); -}); diff --git a/src/tests/fillLimitOrder.test.ts b/src/tests/fillLimitOrder.test.ts deleted file mode 100644 index cb3496c..0000000 --- a/src/tests/fillLimitOrder.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0xbe734b761ccd45cc60a5b4828eb83da96405d663567a46041b049627dddf347d -it("parses swap from fillLimitOrder", async () => { - const data = await parseSwap({ - transactionHash: - "0xbe734b761ccd45cc60a5b4828eb83da96405d663567a46041b049627dddf347d", - exchangeProxyAbi, - rpcUrl: "https://eth.llamarpc.com", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "USDT", - amount: "1.6", - address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", - }, - tokenOut: { - symbol: "WETH", - amount: "0.001", - address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", - }, - }); -}); diff --git a/src/tests/fillOtcOrder.test.ts b/src/tests/fillOtcOrder.test.ts deleted file mode 100644 index 4fb43ca..0000000 --- a/src/tests/fillOtcOrder.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { it, expect, describe } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -describe("fillOtcOrder", () => { - // https://etherscan.io/tx/0xc9579b9e3cddebd3d48ccb0a719456d7c46869b2c3a536509ea88685c7a5efbb - it("parse a swap on Ethereum", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0xc9579b9e3cddebd3d48ccb0a719456d7c46869b2c3a536509ea88685c7a5efbb", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "USDT", - amount: "50000", - address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", - }, - tokenOut: { - symbol: "LDO", - amount: "21120.508370504671821824", - address: "0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32", - }, - }); - }); - - // https://arbiscan.io/tx/0x3e48c1d1d3596ecfc1f9feb9e9613f5f5fc002b76743251c31eca8bc0aa30e21 - it("parse a swap on Arbitrum", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: "https://arb1.arbitrum.io/rpc", - transactionHash: - "0xae78f94319844585bd9e8d4ecfefa2eb70e0cd0d49f76695ee7e4783bad4c1fc", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "ARB", - amount: "2050", - address: "0x912CE59144191C1204E64559FE8253a0e49E6548", - }, - tokenOut: { - symbol: "USDC", - amount: "1918.218706", - address: "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", - }, - }); - }); -}); diff --git a/src/tests/fillOtcOrderForEth.test.ts b/src/tests/fillOtcOrderForEth.test.ts deleted file mode 100644 index 39dc4f0..0000000 --- a/src/tests/fillOtcOrderForEth.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x2c4cee137659650ef486fb46b657ec37c1b4fe18489956a5e058cf5585328fa7 -it("parses swap from fillOtcOrderForEth", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x2c4cee137659650ef486fb46b657ec37c1b4fe18489956a5e058cf5585328fa7", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "USDT", - amount: "218.441376", - address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", - }, - tokenOut: { - symbol: NATIVE_ASSET.symbol, - amount: "0.1254399221596278", - address: NATIVE_ASSET.address, - }, - }); -}); diff --git a/src/tests/fillOtcOrderWithEth.test.ts b/src/tests/fillOtcOrderWithEth.test.ts deleted file mode 100644 index 0373af9..0000000 --- a/src/tests/fillOtcOrderWithEth.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x68608bec5c30750a6a358b14eb937a07f10f72c84428bdf6eae80f52c27faf53 -it("parses swap from fillOtcOrderWithEth", async () => { - const data = await parseSwap({ - transactionHash: - "0x68608bec5c30750a6a358b14eb937a07f10f72c84428bdf6eae80f52c27faf53", - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - }); - - expect(data).toEqual({ - tokenIn: { - symbol: NATIVE_ASSET.symbol, - amount: "0.9", - address: NATIVE_ASSET.address, - }, - tokenOut: { - symbol: "USDC", - amount: "1384.074396", - address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - }, - }); -}); diff --git a/src/tests/fillTakerSignedOtcOrder.test.ts b/src/tests/fillTakerSignedOtcOrder.test.ts deleted file mode 100644 index 569c42d..0000000 --- a/src/tests/fillTakerSignedOtcOrder.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x7f31ba7cacfda809ea24d4b9f87c44fb4114608666c7dd1c6553986ce88dc92b -it("parses swap from fillTakerSignedOtcOrder", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x7f31ba7cacfda809ea24d4b9f87c44fb4114608666c7dd1c6553986ce88dc92b", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "WETH", - amount: "3.919122810830431232", - address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", - }, - tokenOut: { - symbol: "WBTC", - amount: "0.25", - address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", - }, - }); -}); diff --git a/src/tests/fillTakerSignedOtcOrderForEth.test.ts b/src/tests/fillTakerSignedOtcOrderForEth.test.ts deleted file mode 100644 index 9b94157..0000000 --- a/src/tests/fillTakerSignedOtcOrderForEth.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x5f0ed4396f68e0321e48d50611cc6663af68bf7cbee6bc8e74ff5c63d90f3b68 -it("parses swap from fillTakerSignedOtcOrderForEth", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x5f0ed4396f68e0321e48d50611cc6663af68bf7cbee6bc8e74ff5c63d90f3b68", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "USDC", - amount: "25000", - address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - }, - tokenOut: { - symbol: NATIVE_ASSET.symbol, - amount: "13.848320444784979968", - address: NATIVE_ASSET.address, - }, - }); -}); diff --git a/src/tests/index.test.ts b/src/tests/index.test.ts deleted file mode 100644 index 5aac512..0000000 --- a/src/tests/index.test.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { EXCHANGE_PROXY_ABI_URL } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0xe393e03e31ba2b938326ef0527aba08b4e7f2d144ac2a2172c57615990698ee6 -it("returns null when the transaction did not interact with 0x exchangeProxy or permitAndCall", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0xe393e03e31ba2b938326ef0527aba08b4e7f2d144ac2a2172c57615990698ee6", - }); - - expect(data).toBe(null); -}); - -// https://etherscan.io/tx/0x335b2a3faf4a15cd6f67f1ec7ed26ee04ea7cc248f5cd052967e6ae672af8d35 -it("returns null when the transaction status is reverted", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x335b2a3faf4a15cd6f67f1ec7ed26ee04ea7cc248f5cd052967e6ae672af8d35", - }); - - expect(data).toBe(null); -}); - -it("throws an error when required arguments are not passed", () => { - expect(async () => { - await parseSwap({ - transactionHash: "0x…", - exchangeProxyAbi, - } as any); - }).rejects.toThrowError("Missing rpcUrl…"); - - expect(async () => { - await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - } as any); - }).rejects.toThrowError("Missing transaction hash…"); - - expect(async () => { - await parseSwap({ - transactionHash: "0x…", - rpcUrl: ETH_MAINNET_RPC, - } as any); - }).rejects.toThrowError( - `Missing 0x Exchange Proxy ABI: ${EXCHANGE_PROXY_ABI_URL}…` - ); -}); - -it("throws an error if the chainId is not supported", () => { - expect(async () => { - await parseSwap({ - exchangeProxyAbi, - rpcUrl: "https://rpc.gnosis.gateway.fm", - transactionHash: - "0x2cd8904d385dbf4347c28062d8c20d1307202ee5e1d3aacf4b3fc067ca783a29", - }); - }).rejects.toThrowError("chainId 100 is unsupported…"); -}); diff --git a/src/tests/multiplexBatchSellEthForToken.test.ts b/src/tests/multiplexBatchSellEthForToken.test.ts deleted file mode 100644 index 3d88422..0000000 --- a/src/tests/multiplexBatchSellEthForToken.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0xe59ff84284d7e2ad87f1a6de55d5d6600b0b721242110687847e57b52a045b7d -it("parses swap from multiplexBatchSellEthForToken", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0xe59ff84284d7e2ad87f1a6de55d5d6600b0b721242110687847e57b52a045b7d", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: NATIVE_ASSET.symbol, - amount: "10", - address: NATIVE_ASSET.address, - }, - tokenOut: { - symbol: "X2Y2", - amount: "90095.36724488341", - address: "0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9", - }, - }); -}); diff --git a/src/tests/multiplexBatchSellTokenForEth.test.ts b/src/tests/multiplexBatchSellTokenForEth.test.ts deleted file mode 100644 index ba3f14d..0000000 --- a/src/tests/multiplexBatchSellTokenForEth.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x0caebae93af96f83c4d2434816d079d1b43e9061dcaca8627bd9e2c0917a3b63 -it("parses swap from multiplexBatchSellTokenForEth", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x0caebae93af96f83c4d2434816d079d1b43e9061dcaca8627bd9e2c0917a3b63", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "BORING", - amount: "181533.55587344", - address: "0xBC19712FEB3a26080eBf6f2F7849b417FdD792CA", - }, - tokenOut: { - symbol: NATIVE_ASSET.symbol, - amount: "0.48027902546177326", - address: NATIVE_ASSET.address, - }, - }); -}); diff --git a/src/tests/multiplexBatchSellTokenForToken.test.ts b/src/tests/multiplexBatchSellTokenForToken.test.ts deleted file mode 100644 index 13cb4dc..0000000 --- a/src/tests/multiplexBatchSellTokenForToken.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0xb2c5a697a3126af96d2aa20ba6dcd0daaf9ec6baa49de2a76682dfe4258d2e56 - -it("parses swap from multiplexBatchSellTokenForToken", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0xb2c5a697a3126af96d2aa20ba6dcd0daaf9ec6baa49de2a76682dfe4258d2e56", - }); - - expect(data).toEqual({ - tokenIn: { - amount: "329656.871822", - symbol: "USDC", - address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - }, - tokenOut: { - amount: "11.5568887", - symbol: "WBTC", - address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", - }, - }); -}); diff --git a/src/tests/multiplexMultiHopSellEthForToken.test.ts b/src/tests/multiplexMultiHopSellEthForToken.test.ts deleted file mode 100644 index de45c3d..0000000 --- a/src/tests/multiplexMultiHopSellEthForToken.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x00b191d47269265cfbbc94c77a114281ee939463b7a922e8bfbf7de8bc150c5c -it("parses swap from multiplexMultiHopSellEthForToken", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: "0x00b191d47269265cfbbc94c77a114281ee939463b7a922e8bfbf7de8bc150c5c", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: NATIVE_ASSET.symbol, - amount: "3", - address: NATIVE_ASSET.address, - }, - tokenOut: { - symbol: "XCAD", - amount: "2705.968001258040126473", - address: "0x7659CE147D0e714454073a5dd7003544234b6Aa0", - }, - }); -}); diff --git a/src/tests/multiplexMultiHopSellTokenForEth.test.ts b/src/tests/multiplexMultiHopSellTokenForEth.test.ts deleted file mode 100644 index 19004e3..0000000 --- a/src/tests/multiplexMultiHopSellTokenForEth.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0xba3a89b2164e5f169bc81e90a13f8946d110dffe2b53393953ea2a4fede8e81e -it("parses swap from multiplexMultiHopSellTokenForEth", async () => { - const data = await parseSwap({ - transactionHash: - "0xba3a89b2164e5f169bc81e90a13f8946d110dffe2b53393953ea2a4fede8e81e", - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "LSS", - amount: "20065.979484072366300492", - address: "0x3B9BE07d622aCcAEd78f479BC0EDabFd6397E320", - }, - tokenOut: { - symbol: NATIVE_ASSET.symbol, - amount: "3.305750792360646949", - address: NATIVE_ASSET.address, - }, - }); -}); diff --git a/src/tests/multiplexMultiHopSellTokenForToken.test.ts b/src/tests/multiplexMultiHopSellTokenForToken.test.ts deleted file mode 100644 index f60583d..0000000 --- a/src/tests/multiplexMultiHopSellTokenForToken.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0xf705df9127065ae8a8da3c1939d7096011ea13c81e4a2ed8c59ea1b039f7565d -it("parses swap from multiplexMultiHopSellTokenForToken", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: "0xf705df9127065ae8a8da3c1939d7096011ea13c81e4a2ed8c59ea1b039f7565d", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "LINK", - amount: "503.8124966", - address: "0x514910771AF9Ca656af840dff83E8264EcF986CA", - }, - tokenOut: { - symbol: "DAO", - amount: "2014.179756573835415392", - address: "0x0f51bb10119727a7e5eA3538074fb341F56B09Ad", - }, - }); -}); diff --git a/src/tests/permitAndCall.test.ts b/src/tests/permitAndCall.test.ts deleted file mode 100644 index d4571e0..0000000 --- a/src/tests/permitAndCall.test.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -const POLYGON_MAINNET_RPC = "https://rpc.ankr.com/polygon"; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -describe("permitAndCall", () => { - // https://etherscan.io/tx/0x142909f33e8b9882c73da6dc85193a81cd2bfa3bd39d485dd901d3b70e985ee4 - it("IERC2612: parses swap with permit and call on Ethereum with canonical permit", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x142909f33e8b9882c73da6dc85193a81cd2bfa3bd39d485dd901d3b70e985ee4", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "BAL", - amount: "50.883400023914484682", - address: "0xba100000625a3754423978a60c9317c58a424e3D", - }, - tokenOut: { - symbol: NATIVE_ASSET.symbol, - amount: "0.144785082557763087", - address: NATIVE_ASSET.address, - }, - }); - }); - - // https://polygonscan.com/tx/0xc020f1a4265c44474544c2b38bf086ab5f463c8bde4f5aa394db3d1429ad42b8 - it("IERC2612: parses swap with permit and call on Polygon with canonical permit", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: POLYGON_MAINNET_RPC, - transactionHash: - "0xc020f1a4265c44474544c2b38bf086ab5f463c8bde4f5aa394db3d1429ad42b8", - }); - - expect(data).toEqual({ - tokenIn: { - address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", - amount: "3.598205", - symbol: "USDC", - }, - tokenOut: { - address: "0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590", - amount: "6.876078336435440124", - symbol: "STG", - }, - }); - }); - - // https://etherscan.io/tx/0x2e48f20033a45c7a7e1f926db51b1876c5a6a2042bf8e06b17ddbdd58f3b67ab - it("IERC20PermitAllowed: parses swap with permit and call on Ethereum with dai permit ", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x2e48f20033a45c7a7e1f926db51b1876c5a6a2042bf8e06b17ddbdd58f3b67ab", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "DAI", - amount: "2502.47", - address: "0x6B175474E89094C44Da98b954EedeAC495271d0F", - }, - tokenOut: { - symbol: "USDT", - amount: "2494.136763", - address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", - }, - }); - }); - - // https://polygonscan.com/tx/0x407f0ffe42963d2f68beeac39c71d6db1530a90c9716ed4643de116abefcc642 - it("IERC20MetaTransaction: parses swap with permit and call on Polygon with meta transaction", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: POLYGON_MAINNET_RPC, - transactionHash: - "0x407f0ffe42963d2f68beeac39c71d6db1530a90c9716ed4643de116abefcc642", - }); - - expect(data).toEqual({ - tokenIn: { - address: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063", - amount: "1152.957063922541296658", - symbol: "DAI", - }, - tokenOut: { - address: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", - amount: "0.714510898374948536", - symbol: "WETH", - }, - }); - }); -}); diff --git a/src/tests/sellEthForTokenToUniswapV3.test.ts b/src/tests/sellEthForTokenToUniswapV3.test.ts deleted file mode 100644 index 890cef1..0000000 --- a/src/tests/sellEthForTokenToUniswapV3.test.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { expect, it } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x54362c24134d62243ea80dd0e7f77f0c62718f25fbffc6caafdd7b52f702359c -it("parses swap from sellEthForTokenToUniswapV3", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x54362c24134d62243ea80dd0e7f77f0c62718f25fbffc6caafdd7b52f702359c", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "ETH", - amount: "0.098091206429872", - address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - }, - tokenOut: { - symbol: "똥코인", - amount: "49330077428.84485198095946916", - address: "0x4208Aa4d7A9a10f4f8bb7f6400c1b2161D946969", - }, - }); -}); - -// https://etherscan.io/tx/0x93e0e2967309835c4eb5443b67b6c886839b6a5c0626d33c7df976153cb224d7 -it("parses swap from sellEthForTokenToUniswapV3", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x93e0e2967309835c4eb5443b67b6c886839b6a5c0626d33c7df976153cb224d7", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: NATIVE_ASSET.symbol, - amount: "0.12864375786794413", - address: NATIVE_ASSET.address, - }, - tokenOut: { - symbol: "CGPT", - amount: "3895.128022043192070174", - address: "0x25931894a86D47441213199621F1F2994e1c39Aa", - }, - }); -}); diff --git a/src/tests/sellToLiquidityProvider.test.ts b/src/tests/sellToLiquidityProvider.test.ts deleted file mode 100644 index d6c6ef9..0000000 --- a/src/tests/sellToLiquidityProvider.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x2a4379d531695dd4f142730edb7720bb9d06dfb405322e0e16acbfd8ba4fcb98 -it("parses swap from sellToLiquidityProvider", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x2a4379d531695dd4f142730edb7720bb9d06dfb405322e0e16acbfd8ba4fcb98", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "STG", - amount: "918.996239437320809884", - address: "0xAf5191B0De278C7286d6C7CC6ab6BB8A73bA2Cd6", - }, - tokenOut: { - symbol: "USDC", - amount: "692.783026", - address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - }, - }); -}); diff --git a/src/tests/sellToPancakeSwap.test.ts b/src/tests/sellToPancakeSwap.test.ts deleted file mode 100644 index e739c9d..0000000 --- a/src/tests/sellToPancakeSwap.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -const BSC_RPC = "https://bsc-dataseed.binance.org"; - -// https://bscscan.com/tx/0x2076af859a54f5f0c7d4e1cd13b3906169a5e3697d8762b59062052d53466e94 -describe("sellToPancakeSwap", () => { - it("parses swap from sellToPancakeSwap", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: BSC_RPC, - transactionHash: - "0x2076af859a54f5f0c7d4e1cd13b3906169a5e3697d8762b59062052d53466e94", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "BUSD", - amount: "1155.41", - address: "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56", - }, - tokenOut: { - symbol: "WBNB", - amount: "1.82210243305633351", - address: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", - }, - }); - }); - - // https://bscscan.com/tx/0x595b1684b8accec5fdd536dbdd9acb4ddcae9cfc21afcd65245d0a51a0e3582b - it("parses another swap from sellToPancakeSwap", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: BSC_RPC, - transactionHash: - "0x595b1684b8accec5fdd536dbdd9acb4ddcae9cfc21afcd65245d0a51a0e3582b", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "WBNB", - amount: "1.2", - address: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", - }, - tokenOut: { - symbol: "BUSD", - amount: "319.903586514927545022", - address: "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56", - }, - }); - }); - - // https://bscscan.com/tx/0x0f95c3d8429b498a28ee194082e7394b63a595e0b9bd96b14c4895f1bd80cd9b - it("parses swap from sellToPancakeSwap with transfer events that transfer zero amounts", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: BSC_RPC, - transactionHash: - "0x0f95c3d8429b498a28ee194082e7394b63a595e0b9bd96b14c4895f1bd80cd9b", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "WBNB", - amount: "1.599214125294091218", - address: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", - }, - tokenOut: { - symbol: "HELLO", - amount: "7022.195837990335108707", - address: "0x0F1cBEd8EFa0E012AdbCCB1638D0aB0147D5Ac00", - }, - }); - }); - - // https://bscscan.com/tx/0xba7e86dd27ba9b14cca0c98edc5df9c753ec8ae27ace3bacb80e87cbde33f850 - it("parses swap from sellToPancakeSwap with transfer events that transfer output amount to exchange proxy", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: BSC_RPC, - transactionHash: - "0xba7e86dd27ba9b14cca0c98edc5df9c753ec8ae27ace3bacb80e87cbde33f850", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "IDIA", - amount: "50", - address: "0x0b15Ddf19D47E6a86A56148fb4aFFFc6929BcB89", - }, - tokenOut: { - symbol: "WBNB", - amount: "0.011285266969864419", - address: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", - }, - }); - }); -}); diff --git a/src/tests/sellToUniswap.test.ts b/src/tests/sellToUniswap.test.ts deleted file mode 100644 index baaf101..0000000 --- a/src/tests/sellToUniswap.test.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0xd6a7aeda4a2978c80b03700e3136c6895b48d08cd9c8d4c88dfd19dee0a12795 -it("parses a single hop swap from sellToUniswap", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0xd6a7aeda4a2978c80b03700e3136c6895b48d08cd9c8d4c88dfd19dee0a12795", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "WETH", - amount: "0.016858343555927415", - address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", - }, - tokenOut: { - symbol: "USDT", - amount: "30.149999", - address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", - }, - }); -}); - -// https://etherscan.io/tx/0x380eebed81807391a70aac7f02cc852d441ccf0b7cf6538f7a472750e551720b -it("parses a multihop swap from sellToUniswap", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x380eebed81807391a70aac7f02cc852d441ccf0b7cf6538f7a472750e551720b", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "USDC", - amount: "1000", - address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - }, - tokenOut: { - symbol: "SOLANA", - amount: "497767771055.529611406221129532", - address: "0x3D806324b6Df5AF3c1a81aCbA14A8A62Fe6D643F", - }, - }); -}); diff --git a/src/tests/sellTokenForEthToUniswapV3.test.ts b/src/tests/sellTokenForEthToUniswapV3.test.ts deleted file mode 100644 index bc1f7fb..0000000 --- a/src/tests/sellTokenForEthToUniswapV3.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x822d38c0746b19544cedddd9a1ebaacadd3e5da55dc293738ae135fc595e269b -describe("parseSwap", () => { - it("parses swap from sellTokenForEthToUniswapV3", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x822d38c0746b19544cedddd9a1ebaacadd3e5da55dc293738ae135fc595e269b", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "✺RUG", - amount: "56322.215316673764925169", - address: "0xD2d8D78087D0E43BC4804B6F946674b2Ee406b80", - }, - tokenOut: { - symbol: NATIVE_ASSET.symbol, - amount: "0.218304893918707078", - address: NATIVE_ASSET.address, - }, - }); - }); - - it("parses swap from sellTokenForEthToUniswapV3", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0xf6271c6ae709c31b2679f9190798bc64e636feb8b49d498e6239f171783884df", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "ETHFI", - amount: "609.2", - address: "0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eB", - }, - tokenOut: { - symbol: NATIVE_ASSET.symbol, - amount: "0.519590258364550926", - address: NATIVE_ASSET.address, - }, - }); - }); -}); diff --git a/src/tests/sellTokenForTokenToUniswapV3.test.ts b/src/tests/sellTokenForTokenToUniswapV3.test.ts deleted file mode 100644 index d347ab5..0000000 --- a/src/tests/sellTokenForTokenToUniswapV3.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { it, expect } from "vitest"; -import { parseSwap } from "../index"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi" - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -// https://etherscan.io/tx/0x90dbdd630287a0412f88cbc98b0d751bc81c613bb285898dac461b523cd07a5a -it("parses swap from sellTokenForTokenToUniswapV3", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x90dbdd630287a0412f88cbc98b0d751bc81c613bb285898dac461b523cd07a5a", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "USDC", - amount: "3500", - address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - }, - tokenOut: { - symbol: "CRV", - amount: "3490.286498060619473095", - address: "0xD533a949740bb3306d119CC777fa900bA034cd52", - }, - }); -}); diff --git a/src/tests/transformERC20.test.ts b/src/tests/transformERC20.test.ts deleted file mode 100644 index 43a12ff..0000000 --- a/src/tests/transformERC20.test.ts +++ /dev/null @@ -1,233 +0,0 @@ -import { it, expect, describe } from "vitest"; -import { parseSwap } from "../index"; -import { NATIVE_ASSET } from "../constants"; -import { transformERC20 } from "../parsers"; -import { exchangeProxyAbi } from "../abi/ExchangeProxyAbi"; - -require("dotenv").config(); - -const ETH_MAINNET_RPC = process.env.ETH_MAINNET_RPC; - -if (!ETH_MAINNET_RPC) { - throw new Error("Missing environment variable `ETH_MAINNET_RPC`"); -} - -describe("transformERC20", () => { - it("returns undefined when TransformedERC20 topic is not found in logs", async () => { - const result = await transformERC20({ - transaction: { chainId: 1 }, - transactionReceipt: { logs: [] }, - } as any); - - expect(result).toBeUndefined(); - }); -}); - -describe("transformERC20 on various networks", () => { - // https://etherscan.io/tx/0x30d015e87dd5481609eec1c54433b8d4679fe641034971baf648d4528a9b0a35 - it("Ethereum mainnet: parse a swap with native input asset", async () => { - const data = await parseSwap({ - transactionHash: - "0x30d015e87dd5481609eec1c54433b8d4679fe641034971baf648d4528a9b0a35", - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - }); - - expect(data).toEqual({ - tokenIn: { - address: NATIVE_ASSET.address, - symbol: NATIVE_ASSET.symbol, - amount: "332.666067836453233036", - }, - tokenOut: { - address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", - symbol: "USDT", - amount: "500000.317382", - }, - }); - }); - - // https://etherscan.io/tx/0x4db5b7168686cdfb1469b47a67f03fb6199aa81f3d2a26c4a05835b8752d152d - it("Ethereum mainnet: parse a swap with ERC-20 input asset", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: ETH_MAINNET_RPC, - transactionHash: - "0x4db5b7168686cdfb1469b47a67f03fb6199aa81f3d2a26c4a05835b8752d152d", - }); - - expect(data).toEqual({ - tokenIn: { - symbol: "USDT", - amount: "275", - address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", - }, - tokenOut: { - symbol: "MUTE", - amount: "183.067612917791449241", - address: "0xA49d7499271aE71cd8aB9Ac515e6694C755d400c", - }, - }); - }); - - // https://arbiscan.io/tx/0x3e48c1d1d3596ecfc1f9feb9e9613f5f5fc002b76743251c31eca8bc0aa30e21 - it("parse a swap on Arbitrum", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: "https://arb1.arbitrum.io/rpc", - transactionHash: - "0x3e48c1d1d3596ecfc1f9feb9e9613f5f5fc002b76743251c31eca8bc0aa30e21", - }); - - expect(data).toEqual({ - tokenIn: { - address: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a", - amount: "36834.421293958495524657", - symbol: "GMX", - }, - tokenOut: { - address: NATIVE_ASSET.address, - amount: "1189.251717722346544033", - symbol: NATIVE_ASSET.symbol, - }, - }); - }); - - // https://optimistic.etherscan.io/tx/0x0d8125a0d77af877c5efd475e0b2a8aa7451c2b5b95e2918387f8a038aacd718 - it("parse a swap on Optimism", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: "https://mainnet.optimism.io", - transactionHash: - "0x0d8125a0d77af877c5efd475e0b2a8aa7451c2b5b95e2918387f8a038aacd718", - }); - - expect(data).toEqual({ - tokenIn: { - address: NATIVE_ASSET.address, - amount: "51", - symbol: NATIVE_ASSET.symbol, - }, - tokenOut: { - address: "0x9A601C5bb360811d96A23689066af316a30c3027", - amount: "217794.381575767372449449", - symbol: "PIKA", - }, - }); - }); - - // https://snowtrace.io/tx/0x989436aff2791d355a08b87c9a97288699ed5a44a75897a963925b1922e12dbb - it("parse a swap on Avalanche", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: "https://api.avax.network/ext/bc/C/rpc", - transactionHash: - "0x989436aff2791d355a08b87c9a97288699ed5a44a75897a963925b1922e12dbb", - }); - - expect(data).toEqual({ - tokenIn: { - address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", - amount: "25650", - symbol: "USDC", - }, - tokenOut: { - address: "0x152b9d0FdC40C096757F570A51E494bd4b943E50", - amount: "0.99966847", - symbol: "BTC.b", - }, - }); - }); - - // https://ftmscan.com/tx/0xc48de1d0482475d76a13107b4d438605abe0d2223e75167fc46d6d6a54d954c2 - it("parse a swap on Fantom", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: "https://rpc.ftm.tools", - transactionHash: - "0xc48de1d0482475d76a13107b4d438605abe0d2223e75167fc46d6d6a54d954c2", - }); - - expect(data).toEqual({ - tokenIn: { - address: NATIVE_ASSET.address, - amount: "375000", - symbol: "FTM", - }, - tokenOut: { - address: "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75", - amount: "126441.837374", - symbol: "USDC", - }, - }); - }); - - // https://bscscan.com/tx/0x789d6d51ceb6d32407c97757e4be90c12f789927453413318178bed0ebc53bc0 - it("parse a swap on BNB Chain", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: "https://rpc.ankr.com/bsc", - transactionHash: - "0x789d6d51ceb6d32407c97757e4be90c12f789927453413318178bed0ebc53bc0", - }); - - expect(data).toEqual({ - tokenIn: { - address: "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56", - amount: "400142.7162326532", - symbol: "BUSD", - }, - tokenOut: { - address: "0x55d398326f99059fF775485246999027B3197955", - amount: "399966.973708709289660215", - symbol: "USDT", - }, - }); - }); -}); - -// https://explorer.celo.org/tx/0x615c5089f772a8f2074750e8c6070013d288af7681435aba1771f6bfc63d1286 -it("parse a swap on Celo", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: "https://rpc.ankr.com/celo", - transactionHash: - "0x615c5089f772a8f2074750e8c6070013d288af7681435aba1771f6bfc63d1286", - }); - - expect(data).toEqual({ - tokenIn: { - address: "0x765DE816845861e75A25fCA122bb6898B8B1282a", - amount: "500", - symbol: "cUSD", - }, - tokenOut: { - address: "0x74c0C58B99b68cF16A717279AC2d056A34ba2bFe", - amount: "23390.112524333224016754", - symbol: "SOURCE", - }, - }); -}); - -// https://basescan.org/tx/0x26ca796e654a3667957c25e7714c5d6d5de1fc845ebf98d8ee217f9f5e2c5f34 -it("parse a swap on Base", async () => { - const data = await parseSwap({ - exchangeProxyAbi, - rpcUrl: "https://mainnet.base.org", - transactionHash: - "0x26ca796e654a3667957c25e7714c5d6d5de1fc845ebf98d8ee217f9f5e2c5f34", - }); - - expect(data).toEqual({ - tokenIn: { - address: NATIVE_ASSET.address, - amount: "0.005446885313391051", - symbol: NATIVE_ASSET.symbol, - }, - tokenOut: { - address: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", - amount: "10.049999", - symbol: "USDbC", - }, - }); -}); diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index 7507c34..0000000 --- a/src/types.ts +++ /dev/null @@ -1,138 +0,0 @@ -import { permitAndCallAbi } from "./abi/PermitAndCall"; -import { exchangeProxyAbi } from "./abi/ExchangeProxyAbi"; -import type { - Hex, - Hash, - Chain, - Address, - Transport, - Transaction, - PublicClient, - TransactionReceipt, -} from "viem"; - -export type PermitAndCallChainIds = 1 | 137 | 8453; - -export type SupportedChainId = - | 1 - | 5 - | 10 - | 56 - | 137 - | 250 - | 8453 - | 42220 - | 43114 - | 42161; - -export interface TransformERC20Args { - taker: Address; - inputToken: Address; - outputToken: Address; - inputTokenAmount: bigint; - outputTokenAmount: bigint; -} - -export interface EnrichedLog { - to: Address; - from: Address; - symbol: string; - amount: string; - address: Address; - decimals: number; -} - -export interface EnrichLogsArgs { - transactionReceipt: TransactionReceipt; - publicClient: PublicClient; -} - -export interface ParseSwapArgs { - rpcUrl: string; - transactionHash: Hash; - exchangeProxyAbi: typeof exchangeProxyAbi; -} - -type Token = { - symbol?: string; - amount: string; - address: string; -}; - -export type TokenTransaction = - | { - tokenIn: Token; - tokenOut: Token; - } - | undefined; - -export type ParserArgs = { - callData: Hex; - transaction: Transaction; - chainId: SupportedChainId; - transactionReceipt: TransactionReceipt; - exchangeProxyAbi: typeof exchangeProxyAbi; - publicClient: PublicClient; -}; - -type ParserFunction = ( - args: ParserArgs -) => TokenTransaction | Promise; - -export interface Parsers { - [key: string]: ParserFunction; -} - -export type ParseSwap = ( - args: ParseSwapArgs -) => Promise; - -export type PermitAndCall = Extract< - (typeof permitAndCallAbi)[number], - { name: "permitAndCall" } ->; - -export type ExecuteMetaTransaction = Extract< - (typeof exchangeProxyAbi)[number], - { name: "executeMetaTransaction" } ->; - -export type ExecuteMetaTransactionV2 = Extract< - (typeof exchangeProxyAbi)[number], - { name: "executeMetaTransactionV2" } ->; - -export type FillTakerSignedOtcOrder = Extract< - (typeof exchangeProxyAbi)[number], - { name: "fillTakerSignedOtcOrder" } ->; - -export type FillOtcOrderForEth = Extract< - (typeof exchangeProxyAbi)[number], - { name: "fillOtcOrderForEth" } ->; - -export type FillOtcOrderWithEth = Extract< - (typeof exchangeProxyAbi)[number], - { name: "fillOtcOrderWithEth" } ->; - -export type FillLimitOrder = Extract< - (typeof exchangeProxyAbi)[number], - { name: "fillLimitOrder" } ->; - -export type MultiplexBatchSellTokenForToken = Extract< - (typeof exchangeProxyAbi)[number], - { name: "multiplexBatchSellTokenForToken" } ->; - -export type MultiplexBatchSellEthForToken = Extract< - (typeof exchangeProxyAbi)[number], - { name: "multiplexBatchSellEthForToken" } ->; - -export type MultiplexBatchSellTokenForEth = Extract< - (typeof exchangeProxyAbi)[number], - { name: "multiplexBatchSellTokenForEth" } ->; diff --git a/src/utils/index.ts b/src/utils/index.ts deleted file mode 100644 index d3d3bd6..0000000 --- a/src/utils/index.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { getAddress, formatUnits } from "viem"; -import { EVENT_SIGNATURES } from "../constants"; -import { minimalERC20Abi } from "../abi/MinimalERC20"; -import type { - EnrichedLog, - EnrichLogsArgs, - SupportedChainId, - PermitAndCallChainIds, -} from "../types"; - -function convertHexToAddress(hexString: string): string { - return `0x${hexString.slice(-40)}`; -} - -export function isChainIdSupported( - chainId: number -): chainId is SupportedChainId { - return [1, 5, 10, 56, 137, 250, 8453, 42220, 43114, 42161].includes(chainId); -} - -export function isPermitAndCallChainId( - chainId: number -): chainId is PermitAndCallChainIds { - return [1, 137, 8453].includes(chainId); -} - -export async function transferLogs({ - publicClient, - transactionReceipt, -}: EnrichLogsArgs): Promise { - // Extract logs from transaction receipt. - const { logs } = transactionReceipt; - - // Filter logs for the "Transfer" event signature. - const transferLogsAddresses = logs - .filter((log) => log.topics[0] === EVENT_SIGNATURES.Transfer) - .map((log) => ({ ...log, address: getAddress(log.address) })); - - // Prepare contract queries for symbols and decimals. - const contracts = [ - ...transferLogsAddresses.map((log) => ({ - abi: minimalERC20Abi, - address: log.address, - functionName: "symbol", - })), - ...transferLogsAddresses.map((log) => ({ - abi: minimalERC20Abi, - address: log.address, - functionName: "decimals", - })), - ]; - - // Execute multicall to fetch symbols and decimals. - const results = await publicClient.multicall({ contracts }); - - // There are two sets of results (symbol and decimals), each of the same length. - // They are concatenated, so the midpoint separates them. - const midpoint = Math.floor(results.length / 2); - - // Enrich original logs with additional data (symbol, decimals) and - // format the transferred amount to a human-readable format. - const enrichedLogs = transferLogsAddresses - .map((log, index) => { - const symbol = results[index].result as string; - const decimals = results[midpoint + index].result as number; - const amount = formatUnits(BigInt(log.data), decimals); - const { address, topics } = log; - const { 1: fromHex, 2: toHex } = topics; - const from = getAddress(convertHexToAddress(fromHex)); - const to = getAddress(convertHexToAddress(toHex)); - - return { to, from, symbol, amount, address, decimals }; - }) - .filter((log) => log.amount !== "0"); - - return enrichedLogs; -} - -export function extractTokenInfo( - inputLog: EnrichedLog, - outputLog: EnrichedLog -) { - return { - tokenIn: { - symbol: inputLog.symbol, - amount: inputLog.amount, - address: getAddress(inputLog.address), - }, - tokenOut: { - symbol: outputLog.symbol, - amount: outputLog.amount, - address: getAddress(outputLog.address), - }, - }; -}