V1 - Swap quote mismatch
Hi 👋
I'm trying to get fixed input swap quote and I noticed it's not correct for some pools. In below example PAGO/ALGO pool on the testnet.
from tinyman.v1.client import TinymanTestnetClient
client = TinymanTestnetClient(algod_client)
asset1 = client.fetch_asset(92772865)
asset2 = client.fetch_asset(0)
amount = 80
asset_in = asset1
pool = client.fetch_pool(asset1, asset2)
quote = pool.fetch_fixed_input_swap_quote(asset_in(amount * 10 ** asset_in.decimals), slippage=0.05)
I get the following quote for ALGO out amount and min out amount
while in the Tinyman app I get

which is almost the same but still slightly different.
When I make the transaction from the app the value I receive is matching the minimum value from the app but it seems like the total value (min + excess) is matching the value calculated by the SDK https://testnet.algoexplorer.io/tx/group/MEYPju6fy6LvBzph49xU%2BmvYyj3bpdf4A0FlmYTykU0%3D


Looks like the bug is on the app side not SDK but maybe you can double check it and confirm?
Hi @kasia-antos , I have double-checked it and I confirm this case; thank you for reporting it.
The reason is rounding error. The smart contract only supports integers, and division results are rounded down to an integer (Ex. 10/4=2). SDKs should follow the same arithmetic to be able to get the exact result.
We will be checking the possible improvements. The JS SDK uses big interger and results are converted to int directly, but Python SDK converts the float results to the integer at the end.
The result calculated on the web app should be closer to the actual result. We need to double-check this part.
The effect will be less for the assets with decimal places. In this case, PAGO has no decimal places so the input amount is 80 micro unit, rounding error is more visible. For ALGO, which has 6 decimals, 80 Algo is 80.000.000 micro-unit. So, I assume fixing this is important but not urgent.
Update: This issue is fixed for Tinyman V2 calculations.