Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update btcdirect payment methods with fees #3171

Conversation

thisconnect
Copy link
Collaborator

No description provided.

@thisconnect thisconnect force-pushed the frontend-btcdirect-disclaimers branch from 451b028 to f98d242 Compare February 11, 2025 13:57
@thisconnect thisconnect changed the title frontend: simplify types Update btcdirect payment methods with fees Feb 11, 2025
@thisconnect thisconnect force-pushed the frontend-btcdirect-disclaimers branch from 61d2afa to 24ce8e8 Compare February 11, 2025 15:50
const formattedCardFee = cardFee && cardFee * 100;
const formattedBankTransferFee = bankTransferFee && bankTransferFee * 100;
const formattedSofortFee = sofortFee && sofortFee * 100;
const formattedBancontactFee = bancontactFee && bancontactFee * 100;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not ideal, with 0.036 fee I get 3.5999999999999996%

probably better we do such math stuff in the backend 😇

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we could store the fees in the backend deals as 3.6 instead of 0.036 so that we don't have to convert in the frontend. Would that be good enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that makes sense. Looks to me that we do not use fee other than isBest calculation here

if len(deals) > 1 {
bestDealIndex := 0
for i, deal := range deals {
oldBestDeal := deals[bestDealIndex]
if deal.Fee < oldBestDeal.Fee {
bestDealIndex = i
}
}
deals[bestDealIndex].IsBest = true
}

change in last commit

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, ty

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to percentages in last commit.

@thisconnect thisconnect force-pushed the frontend-btcdirect-disclaimers branch 2 times, most recently from 11f91a8 to 2737571 Compare February 12, 2025 08:38
@thisconnect thisconnect marked this pull request as ready for review February 12, 2025 08:42
@thisconnect
Copy link
Collaborator Author

@Beerosagos PTAL

Copy link
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I'm not sure about hiding deals in the frontend, tho. See my comment below 😇

@@ -45,21 +44,6 @@ type TProps = {
setInfo: (into: TInfoContentProps) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: into

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, fixedup into this commit

case 'sofort':
case 'bancontact':
// hide these payment methods in the overview
return '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really robust, imo. If the only available deals in a specific situation were the hidden ones, this would show a component without available options. It would be better to have a "hidden" field in the deal struct that can be set in the backend and properly checked in the frontend.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know sofort or bancontact (not available in CH), aren't these some kind of fiat banktransfers anyway?

Hidden field sounds more robust, but I am not 100% confident about how to do the backend changes... I'll dm you later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed I'll leave in ths PR, and we can add isHidden in a new PR

backend/exchanges/btcdirect.go Outdated Show resolved Hide resolved
@thisconnect thisconnect force-pushed the frontend-btcdirect-disclaimers branch from 2737571 to 468a5ce Compare February 12, 2025 12:32
// - Payment is the payment method offered in the deal (usually different payment methods bring different fees).
// - IsFast is usually associated with card payments. It is used by the frontend to display the `fast` tag in deals list.
type ExchangeDeal struct {
Fee float32 `json:"fee"`
Payment PaymentMethod `json:"payment"`
IsFast bool `json:"isFast"`
IsBest bool `json:"isBest"`
IsLocal bool `json:"isLocal"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed in dm, we keep the badges we have right now, but skip "Local payments" for now and rethink what badges it should show.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, @Beerosagos PTAL

@thisconnect thisconnect force-pushed the frontend-btcdirect-disclaimers branch from 468a5ce to 941332d Compare February 12, 2025 14:23
Copy link
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a last comment 😇

Payment: CardPayment,
IsFast: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the isFast here like for the other card payments (e.g. moonpay)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack. fixedup and force pushed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, @Beerosagos PTAL should be all good now to merge this

const cardFee = exchange.deals.find(feeDetail => feeDetail.payment === 'card')?.fee;
const bankTransferFee = exchange.deals.find(feeDetail => feeDetail.payment === 'bank-transfer')?.fee;
const bancontactFee = exchange.deals.find(feeDetail => feeDetail.payment === 'bancontact')?.fee;
const sofortFee = exchange.deals.find(feeDetail => feeDetail.payment === 'sofort')?.fee;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one, sorry: I think that this could scale better by refactoring the payment methods fees as a map.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but I think it could simplify the code a bit

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this function just got a bit more ugly :)

@thisconnect thisconnect force-pushed the frontend-btcdirect-disclaimers branch from 941332d to fa3ae6b Compare February 12, 2025 15:49
Added a BTC Direct infobox that is shown when user clicks (i) button.

Added an exchange option btcdirect-otc for the old OTC infobox that is
shown for the BTC Direct OTC option.

Also moved getBTCDirectLink to infocontent so we do not have circular
dependencies/imports.
Added SOFORT and Bancontact payment options for BTC Direct.

Also changed exchange fee to percentage:

So that the frontend does not have to convert this number to
percentage which can lead to JavaScript rounding errors such as
displaying 3.5999999999999996% instead of 3.6%.
Adjusted fontsize ans spacing so the BTC Direct does not break
onto 2 lines.
@thisconnect thisconnect force-pushed the frontend-btcdirect-disclaimers branch from fa3ae6b to b24c9f9 Compare February 13, 2025 08:06
Copy link
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 👍

@thisconnect thisconnect merged commit be00431 into BitBoxSwiss:staging-btcdirect Feb 13, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants