GODrums / BetterFloat

Enhance your website experience on CSFloat, Skinport & Skinbid
https://betterfloat.com/
Other
39 stars 10 forks source link

fix: sp% for currencies other than USD #54

Closed alxcar closed 8 months ago

alxcar commented 8 months ago

Fixed a bug where the SP% was significantly inaccurate for every currency other than USD. The current implementation used the display price on float, regardless of its currency:

const sellPrice = Number(container.querySelector('.mat-column-price')?.textContent?.replace('$', ''));

It also compared it to price values in USD, if it was even able to extract the number correctly. This issue applied to all instances of the SP container (popout, sales history, etc.), leading to discrepancies between currencies:

image image

image image

The proposed solution involves dividing the user's local currency by its rate vs USD, ensuring it matches Buff's USD price:

const currencyRate = await getCSFCurrencyRate(CSFloatHelpers.userCurrency) 
const priceResultUSD = priceResult.price_difference / currencyRate

While the SP% in the sales history is still somewhat inaccurate (as it occasionally compares months-old transactions in today's market), it will now hold true regardless of the user's currency:

image

GODrums commented 8 months ago

Another great find! It seems like I missed a lot of stuff when adapting to CSFloat's currency conversion update.

Also opened an issue to create a tooltip to explain the data behind the sp% (should be easy to do whenever I finally integrate a front-end framework).