project-serum / serum-dex

Project Serum Rust Monorepo
https://projectserum.com
Apache License 2.0
627 stars 330 forks source link

Spillover when converting from USDC/USDT to another token #261

Open amerfarooq opened 1 year ago

amerfarooq commented 1 year ago

When I try to do a swap on Serum from USDC/USDT to some other token, I’ve noticed that there is some spillover. Here are some transactions that showcase this behavior:

3YS8Skg4sSX92Fc4PkXXdhfvskoATNoN1r5eLjgYX6245NJg1HwSVzUM6d4AD8LVa6W9fabJZ79vJWsLY8AZ67CE

Here, I could have received up to 0.17 SOL but only get 0.1 SOL and the rest is returned.

5oDj65D2UDuxq7d8fmGzuxN7fKheQ6taw3mxjXUzj8dPbc57PGS23vbTELmVxk9dfsg9gYzJ7eys6CLRYVqe29Ni

Similarly, here I could have received up to 0.35 SOL but only got 0.3 SOL.

What is the reason for this truncation in the output balance? By the way, this only happens if you exchange the USDC to SOL. If you convert SOL to USDC, you see no such spillover e.g.

4trewrpt1Ns6smDy7xVS1XEkBC9qqStA6pQabpGnazR93sVYtDvG9o379Ua2A8arh52xQSy7yhexRVxCZ6Q58ntn