I am using a 0x Quote API to convert BUSD to USDC by exploring the feeRecipient and buyTokenPercentageFee but have confusion in the calculation. Initial Quote without buyTokenPercentageFee Request https://bsc.api.0x.org/swap/v1/price?buyToken=USDC&sellToken=BUSD&sellAmount=100000000000000000000 Response { "chainId": 56, "price": "0.9997365742860093", "estimatedPriceImpact": "0", "value": "0", "gasPrice": "5000000000", "gas": "250000", "estimatedGas": "250000", "protocolFee": "0", "minimumProtocolFee": "0", "buyTokenAddress": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", "buyAmount": "99973657428600930000", "sellTokenAddress":::Listen
I am using a 0x Quote API to convert BUSD to USDC by exploring the feeRecipient and buyTokenPercentageFee but have confusion in the calculation.
Initial Quote without buyTokenPercentageFee
Request
https://bsc.api.0x.org/swap/v1/price?buyToken=USDC&sellToken=BUSD&sellAmount=100000000000000000000
Response
{ "chainId": 56, "price": "0.9997365742860093", "estimatedPriceImpact": "0", "value": "0", "gasPrice": "5000000000", "gas": "250000", "estimatedGas": "250000", "protocolFee": "0", "minimumProtocolFee": "0", "buyTokenAddress": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", "buyAmount": "99973657428600930000", "sellTokenAddress": "0xe9e7cea3dedca5984780bafc599bd69add087d56", "sellAmount": "100000000000000000000", }
The buyAmount am receiving is 99973657428600930000 (99.97 in ether)
For the same quote if I apply buyTokenPercentageFee as 1 the quote I receive is
Request
https://bsc.api.0x.org/swap/v1/price?buyToken=USDC&sellToken=BUSD&sellAmount=100000000000000000000&feeRecipient=0xa8aac589a67ecfade31efde49a062cc21d68a64e&buyTokenPercentageFee=1
Response
{ "chainId": 56, "price": "0.009996", "estimatedPriceImpact": "98.9299", "value": "0", "gasPrice": "5000000000", "gas": "255000", "estimatedGas": "255000", "protocolFee": "0", "minimumProtocolFee": "0", "buyTokenAddress": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", "buyAmount": "50479800000000000000", "sellTokenAddress": "0xe9e7cea3dedca5984780bafc599bd69add087d56", "sellAmount": "100000000000000000000" }
The buyAmount am receiving is 50479800000000000000 (50.47 in ether). Which does not look like 1% of buyAmount. The percentage its applying is nearly ~50%.
So if anyone can explain how its been calculated will be great.
Thank you