project-serum / swap

Swap on the Serum Order Book
Apache License 2.0
78 stars 90 forks source link

Incorrect assumption: referrer == (rebate token account / fee discount account) #17

Open Arrowana opened 2 years ago

Arrowana commented 2 years ago

The code mixes up both

https://github.com/project-serum/swap/blob/master/programs/swap/src/lib.rs#L505-L555

When creating an order we need the rebate token account, which gives the rebate on the fees, while settle funds need the referrer to take the UI cut.

New order

https://github.com/project-serum/serum-dex/blob/master/dex/src/state.rs#L1814-L1818

Settle funds

https://github.com/project-serum/serum-dex/blob/master/dex/src/state.rs#L2086

Serum swap is using both as the same thing. anchor CPI is also doing the term "referral" for both situations.

But how to handle both of those as remaining_accounts?