I would like to collect fees on trade using 0x API. But the gas in the quote response is doubled or more when adding feeRecipient
and buyTokenPercentageFee
which doubles the gas price users are paying. Is this correct? Is there any way to prevent this, and how are other projects using 0x collecting fees without adding more gas fees at least not doubled?
1 Answer
When you define feeRecipient and buyTokenPercentageFee you are adding additional logic to callData: an additional transfer to your feeRecipient address. This causes the blockchain to charge more gas for that additinal operation.
There is no way to prevent this at the moment, rule of thumb, more bytes on callData more gas is charged.
On other side, normally that additional operation not doubles the gas, are you putting skipValidation=false and passing takerAddress on the API call? If you do so 0x API will it give you a more exact gas estimation.
-
Yes, that makes sense. So the question... is it correct that it doubles the gas?– mtx devMar 21 at 11:10
-
Not necessarily doubles the gas. I think when there is no way to do the estimation they just put a fixed value depending on gas price. Mar 21 at 22:18