0

I am trying to encode arguments to call the UniswapV3ExchangeAdapter through the Set-Protocol TradeModule. The UniswapV3ExchangeAdapter has a function which is called generateDataParam that given hops and fees returns the data needed to make the trade calls. I am calling it with:

  '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
  '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
] [ '500' ] 

which is returning:

0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 However when I try to feed this into the tradeModuleInstance.methods.trade I get the error param.substring is not a function which is basically a revert or a failure to encode parameters.

The code which I'm using to call the trade function:

const tx = tradeModuleInstance.methods.trade(
    setTokenAddress,
    process.env.uniswapAdapter,
    sourceToken,
    sourceUnits,
    targetToken,
    minTargetUnits,
    // web3.utils.hexToBytes(generatedParams), tried this to to no avail
    Uint8Array.from(Buffer.from(generatedParams.slice(2), 'hex')),
  )

The full parameters I'm calling the trade function with are (set address redacted):

0x[redacted] 
UniswapV3ExchangeAdapter 
0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 
1000000000 
0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 
200000 
[
  192,  42, 170, 57, 178,  35, 254, 141,  10,
   14,  92,  79, 39, 234, 217,   8,  60, 117,
  108, 194,   0,  1, 244, 160, 184, 105, 145,
  198,  33, 139, 54, 193, 209, 157,  74,  46,
  158, 176, 206, 54,   6, 235,  72
]

I am not sure how to pass this data argument from the generatedParams so that UniswapV3 can work with it. Any tips?

1 Answer 1

0

I managed to fix this by using directly the generatedParams parameter into the trade function without any encoding and it worked.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.