0x-api icon indicating copy to clipboard operation
0x-api copied to clipboard

Error in rounding of `guaranteedPrice`

Open fntz opened this issue 2 years ago • 0 comments

Expected Behavior

guaranteedPrice should be decoded with the correct truncate mode. (Request to /quote)

Current Behavior

I want to do a Swap of ERC-20 tokens (convert DAI to MKR) Request is:

 https://kovan.api.0x.org/swap/v1/quote?sellToken=MKR&buyToken=DAI&excludedSources=Native&buyAmount=10000000000000000000

I want to buy a 10 DAI through MKR.

as a response I got:

{"Price":"0.000144284056965648","GuaranteedPrice":"0.000147169738104961","To":"0xdef1c0ded9bec7f1a1670819833240f027b25eff","Data":"0xd9627aa4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000053a803f9d450e0000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000aaf64bfcc32d0f15873a02163e7e500671a4ffcd0000000000000000000000004f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa869584cd0000000000000000000000007c07d32e18d6495efdc487a32f8d20dafba53a5e00000000000000000000000000000000000000000000007e31ee13b960fb2fde","Value":0,"GasPrice":"16000000000","Gas":"111000","BuyAmount":10000000000000000000,"SellAmount":1442840569656484,"SellTokenAddress":"0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd","AllowanceTarget":"0xf740b67da229f2f10bcbd38a7979992fcc71b8eb"}

Then when I do a transaction, I see in debug SellAmount is 1471697381049614 which is not correct. (correct is 147169738104961)

transaction debugger

Steps to Reproduce (for bugs)

1. Buy 10 DAI through MKR (request is `https://kovan.api.0x.org/swap/v1/quote?sellToken=MKR&buyToken=DAI&excludedSources=Native&buyAmount=10000000000000000000`)
2. Approve guaranteed price 
3. Send transaction to swap

Context

Blocking release.

Your Environment

kovan

fntz avatar Jul 23 '21 22:07 fntz