I'm wanting to use the 0x swap quote API but I'm struggling to understand some of the response params.
Let's say for example I'm doing an arbitration and I'm starting with 10 WETH, then I sell the WETH for DAI, and then use the 0x swap quote API to find DAI -> WETH swaps that net me more than the 10 original WETH.
How should I be calculacting the actual profit so it considers tx fees, protocol fees, gas, slippage, etc?
The 0x response has a bunch of fees and minimums, estimates, prices, a "value" field that I think maybe encapsulates multiple fees in one.. I'm struggling to understand how I should compute my profit.
It's going to be something like:
let netProfit = quote.buyAmount - originalWETHAmount - (quote.gas * quote.gasPrice) - quote.value - ? - ??
Can anyone help me make sense of this?