RoboSats / robosats

A simple and private bitcoin exchange
https://learn.robosats.com
GNU Affero General Public License v3.0
725 stars 142 forks source link

Claiming rewards does not support routing_budget_ppm #1382

Open jerryfletcher21 opened 3 months ago

jerryfletcher21 commented 3 months ago

Describe the bug The /api/order update_invoice and /api/rewards requests are similar: they accept a signed invoice to be paid by the coordinator. The amounts of the invoice are also similar, since trades ended up in a dispute will be refunded by rewards. The first one supports the parameter routing_budget_ppm that allows the user to specify the routing budget (to be subtracted from the invoice amount), while the second one does not support it and instead uses the default of 1000 ppm or 10 sats.

in api/logics.py: update_invoice:

routing_budget_sats = float(num_satoshis) * (
    float(routing_budget_ppm) / 1_000_000
)
num_satoshis = int(num_satoshis - routing_budget_sats)

withdraw_rewards:

num_satoshis = user.robot.earned_rewards
routing_budget_sats = int(
    max(
        num_satoshis * float(config("PROPORTIONAL_ROUTING_FEE_LIMIT")),
        float(config("MIN_FLAT_ROUTING_FEE_LIMIT_REWARD")),
    )
)  # 1000 ppm or 10 sats

Expected behavior I think also /api/rewards should support routing_budget_ppm. The drawback is that by supporting it, the invoice amount will change depending on the value of routing_budget_ppm, so in the main client there will have to be a similar page like for update_invoice that let changing the value of routing_budget_ppm and showing the resulting invoice amount.

KoalaSat commented 3 months ago

Cool, people usually try first with the cheapest option, and retry other if not, but this will help for recurrent buyers if they know routing is complicated between the nodes