1

I'm trying to decode FillQuoteTransformer input data for 0x protocol. I'm able to decode other transformer very well but am stuck with this one. It does technically decode the data but I'm not sure its absolutely correct. I'm verifying if the decode was successful by doing the following i.e create a dummy txn, then recompute the data from the dummy txn and compare the two.

The bytes slightly differ on recompute.

const decodeTransformation = (data) => {
  for (let i = 0; i < transformParsers.length; i++) {
    try {
      const parser = transformParsers[i];
      const interface = new ethers.utils.Interface(parser.abi);

      const funSig = interface.getSighash("abiDecodeStruct");
      const fullData = `${funSig}${data.substring(2)}`;
      const dummyTxn = interface.parseTransaction({ data: fullData });

      /**
       * parseTransaction matches for subset of data bytes to function args so it results in false positives
       * recompute the data bytes and compare with original to see if its the required one
       */
      const recomputedData = interface.encodeFunctionData("abiDecodeStruct", dummyTxn.args);
      if (fullData != recomputedData) {
        console.log({ abi: parser.parse.name, f: fullData, r: recomputedData });
        continue;
      }

      return { parserName: parser.parse.name, data: parser.parse(dummyTxn.args) };
    } catch (e) {
      // no-op. parse failed so try next abi
      continue;
    }
  }
  console.error("\n#### ZeroEx Transformer NOT FOUND ####\n", data, "\n###############################\n");
  return undefined;
};

This is the transaction I'm trying to decode for.

https://etherscan.io/tx/0x6c1e94e8d7c5ec7f67b8a82b156f2e0a510d477dd20681bd3279e6c9e14572be

As per my understanding after going through the protocol repo these are the transformers that are used.

Are these the only transformers in use or are there more? I couldn't find more in the repo.

FillQuoteTransformer
AffiliateFeeTransformer
PayTakerTransformer
PositiveSlippageFeeTransformer
WethTransformer

Abi for these are not available since they don't have any external functions so I cloned the repo [https://github.com/0xProject/protocol/tree/main], added a dummy function to the transformer contracts and compiled the contracts to get the required abi.

eg, I added this function to FillQuoteTransformer and other transformers. (parameters adjusted as required)

function abiDecodeStruct(TransformData calldata data) external pure {}

Original transformer data (\n added so its easier to read)

0000000000000000000000000000000000000000000000000000000000000020000000
0000000000000000000000000000000000000000000000000000000000000000000000
000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000
000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000
0000000000000000000000000000000000000140000000000000000000000000000000
0000000000000000000000000000000320000000000000000000000000000000000000
0000000000000000000000000320000000000000000000000000000000000000000000
00000000000000000002e0000000000000000000000000000000000000000000000000
7ce66c50e2840000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0320000000000000000000000000000000000000000000000000000000000000000100
0000000000000000000000000000000000000000000000000000000000002000000000
000000000000000000000012556e697377617056330000000000000000000000000000
00000000000000000000000000000000007ce66c50e284000000000000000000000000
000000000000000000000000000000000003dcfcfd0500000000000000000000000000
0000000000000000000000000000000000008000000000000000000000000000000000
000000000000000000000000000000c0000000000000000000000000e592427a0aece9
2de3edee1f18e0157c0586156400000000000000000000000000000000000000000000
0000000000000000006000000000000000000000000000000000000000000000000000
0000000000000100000000000000000000000000000000000000000000000000000000
0000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4dac17f958d2ee523
a2206206994597c13d831ec70000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000010000000000
0000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000

Recomputed data (\n added so its easier to read)

0000000000000000000000000000000000000000000000000000000000000020000000
0000000000000000000000000000000000000000000000000000000000000000000000
000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000
000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000
0000000000000000000000000000000000000140000000000000000000000000000000
00000000000000000000000000000002e0000000000000000000000000000000000000
0000000000000000000000000300000000000000000000000000000000000000000000
0000000000000000000320000000000000000000000000000000000000000000000000
7ce66c50e2840000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0360000000000000000000000000000000000000000000000000000000000000000100
0000000000000000000000000000000000000000000000000000000000002000000000
000000000000000000000012556e697377617056330000000000000000000000000000
00000000000000000000000000000000007ce66c50e284000000000000000000000000
000000000000000000000000000000000003dcfcfd0500000000000000000000000000
0000000000000000000000000000000000008000000000000000000000000000000000
000000000000000000000000000000c0000000000000000000000000e592427a0aece9
2de3edee1f18e0157c0586156400000000000000000000000000000000000000000000
0000000000000000006000000000000000000000000000000000000000000000000000
0000000000000100000000000000000000000000000000000000000000000000000000
0000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4dac17f958d2ee523
a2206206994597c13d831ec70000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000010000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000

The gist to the abis I generated are here

https://gist.github.com/nischitpra/01991eb0b43e8e78b5b979e280463eaf

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.