The documentation for the 0x API "quote" endpoint indicates that adding a feeRecipientTradeSurplus parameter to the query should generate a transaction where any "trade surplus fees" get sent to that specified address, rather than the transaction-sender. The FAQ page further describes "trade surplus" (under the "Can I collect trade surplus (a.k.a. positive slippage)?" question) by saying "Trade surplus occurs when the user ends up receiving more tokens than their quoted amount".
I believe this means that when using the "quote" endpoint and whatever buyAmount is specified, if the price has slipped favorably for the trader and they end up with slightly more of that token than literally the buyAmount value, that is considered the "trade surplus".
However, in practice, when adding the feeRecipientTradeSurplus parameter to a call to the "quote" endpoint, no change is seen in the returned data calldata compared to not including that parameter, and when simulating the generated transaction, none of the extra buyAmount is sent to the feeRecipientTradeSurplus address. Example call:
https://api.0x.org/swap/v1/quote?
buyToken=0x98968f0747E0A261532cAcC0BE296375F5c08398&
sellToken=WETH&
buyAmount=1030000000000000000&
feeRecipientTradeSurplus=0xdf2E60Af57C411F848B1eA12B10a404d194bce27
The token this is being attempted against only has liquidity on Sushi; is there a limitation to that specific liquidity provider that isn't working for this parameter? Or am I using this parameter incorrectly?
feeRecipientTradeSurplusaddress, to something only indicating selling.As a side request, I wonder if it would be possible to enable it for BUY actions too. In this instance, the token has specific things it can be used for (swapping for a token in an NFT pool) and end-users would have no use for extra small fractions of the token (it's dust that then is effectively lost since it's not worth the gas to move).
– MidnightLightning Sep 12 '23 at 00:33