mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Update minimum swap mining fee to 2 Sats/vbyte
This commit is contained in:
parent
1c696beb5d
commit
6ef62a1fa4
@ -566,12 +566,12 @@ class Logics:
|
|||||||
"mining_fee_rate"
|
"mining_fee_rate"
|
||||||
]
|
]
|
||||||
|
|
||||||
# Hardcap mining fee suggested at 50 sats/vbyte
|
# Hardcap mining fee suggested at 100 sats/vbyte
|
||||||
if suggested_mining_fee_rate > 50:
|
if suggested_mining_fee_rate > 100:
|
||||||
suggested_mining_fee_rate = 50
|
suggested_mining_fee_rate = 100
|
||||||
|
|
||||||
onchain_payment.suggested_mining_fee_rate = max(
|
onchain_payment.suggested_mining_fee_rate = max(
|
||||||
1.05, LNNode.estimate_fee(amount_sats=preliminary_amount)["mining_fee_rate"]
|
2.05, LNNode.estimate_fee(amount_sats=preliminary_amount)["mining_fee_rate"]
|
||||||
)
|
)
|
||||||
onchain_payment.swap_fee_rate = cls.compute_swap_fee_rate(
|
onchain_payment.swap_fee_rate = cls.compute_swap_fee_rate(
|
||||||
onchain_payment.balance
|
onchain_payment.balance
|
||||||
@ -688,13 +688,13 @@ class Logics:
|
|||||||
|
|
||||||
if mining_fee_rate:
|
if mining_fee_rate:
|
||||||
# not a valid mining fee
|
# not a valid mining fee
|
||||||
if float(mining_fee_rate) < 1:
|
if float(mining_fee_rate) < 2:
|
||||||
return False, {
|
return False, {
|
||||||
"bad_address": "The mining fee is too low, must be higher than 1 Sat/vbyte"
|
"bad_address": "The mining fee is too low, must be higher than 2 Sat/vbyte"
|
||||||
}
|
}
|
||||||
elif float(mining_fee_rate) > 50:
|
elif float(mining_fee_rate) > 100:
|
||||||
return False, {
|
return False, {
|
||||||
"bad_address": "The mining fee is too high, must be less than 50 Sats/vbyte"
|
"bad_address": "The mining fee is too high, must be less than 100 Sats/vbyte"
|
||||||
}
|
}
|
||||||
order.payout_tx.mining_fee_rate = float(mining_fee_rate)
|
order.payout_tx.mining_fee_rate = float(mining_fee_rate)
|
||||||
# If not mining ee provider use backend's suggested fee rate
|
# If not mining ee provider use backend's suggested fee rate
|
||||||
@ -703,7 +703,7 @@ class Logics:
|
|||||||
|
|
||||||
tx = order.payout_tx
|
tx = order.payout_tx
|
||||||
tx.address = address
|
tx.address = address
|
||||||
tx.mining_fee_sats = int(tx.mining_fee_rate * 141)
|
tx.mining_fee_sats = int(tx.mining_fee_rate * 200)
|
||||||
tx.num_satoshis = cls.payout_amount(order, user)[1]["invoice_amount"]
|
tx.num_satoshis = cls.payout_amount(order, user)[1]["invoice_amount"]
|
||||||
tx.sent_satoshis = int(
|
tx.sent_satoshis = int(
|
||||||
float(tx.num_satoshis)
|
float(tx.num_satoshis)
|
||||||
@ -1738,10 +1738,19 @@ class Logics:
|
|||||||
)
|
)
|
||||||
if not order.is_swap:
|
if not order.is_swap:
|
||||||
platform_summary["routing_budget_sats"] = order.payout.routing_budget_sats
|
platform_summary["routing_budget_sats"] = order.payout.routing_budget_sats
|
||||||
|
# Start Deprecated after v0.3.1
|
||||||
|
platform_summary["routing_fee_sats"] = order.payout.fee
|
||||||
|
# End Deprecated after v0.3.1
|
||||||
platform_summary["trade_revenue_sats"] = int(
|
platform_summary["trade_revenue_sats"] = int(
|
||||||
order.trade_escrow.num_satoshis
|
order.trade_escrow.num_satoshis
|
||||||
- order.payout.num_satoshis
|
- order.payout.num_satoshis
|
||||||
- order.payout.routing_budget_sats
|
# Start Deprecated after v0.3.1 (will be `- order.payout.routing_budget_sats`)
|
||||||
|
- (
|
||||||
|
order.payout.fee
|
||||||
|
if order.payout.routing_budget_sats == 0
|
||||||
|
else order.payout.routing_budget_sats
|
||||||
|
)
|
||||||
|
# End Deprecated after v0.3.1
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
platform_summary["routing_fee_sats"] = 0
|
platform_summary["routing_fee_sats"] = 0
|
||||||
|
@ -227,10 +227,20 @@ class OnchainPayment(models.Model):
|
|||||||
)
|
)
|
||||||
# fee in sats/vbyte with mSats decimals fee_msat
|
# fee in sats/vbyte with mSats decimals fee_msat
|
||||||
suggested_mining_fee_rate = models.DecimalField(
|
suggested_mining_fee_rate = models.DecimalField(
|
||||||
max_digits=6, decimal_places=3, default=1.05, null=False, blank=False
|
max_digits=6,
|
||||||
|
decimal_places=3,
|
||||||
|
default=2.05,
|
||||||
|
null=False,
|
||||||
|
blank=False,
|
||||||
|
validators=[MinValueValidator(1), MaxValueValidator(999)],
|
||||||
)
|
)
|
||||||
mining_fee_rate = models.DecimalField(
|
mining_fee_rate = models.DecimalField(
|
||||||
max_digits=6, decimal_places=3, default=1.05, null=False, blank=False
|
max_digits=6,
|
||||||
|
decimal_places=3,
|
||||||
|
default=2.05,
|
||||||
|
null=False,
|
||||||
|
blank=False,
|
||||||
|
validators=[MinValueValidator(1), MaxValueValidator(999)],
|
||||||
)
|
)
|
||||||
mining_fee_sats = models.PositiveBigIntegerField(default=0, null=False, blank=False)
|
mining_fee_sats = models.PositiveBigIntegerField(default=0, null=False, blank=False)
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import React, { useEffect } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Grid, Typography, TextField, List, Divider, ListItemText, ListItem } from '@mui/material';
|
import { Grid, Typography, TextField, List, Divider, ListItemText, ListItem } from '@mui/material';
|
||||||
import { Order } from '../../../models';
|
import { Order } from '../../../models';
|
||||||
import WalletsButton from '../WalletsButton';
|
|
||||||
import { LoadingButton } from '@mui/lab';
|
import { LoadingButton } from '@mui/lab';
|
||||||
import { pn } from '../../../utils';
|
import { pn } from '../../../utils';
|
||||||
|
|
||||||
@ -35,8 +34,15 @@ export const OnchainPayoutForm = ({
|
|||||||
}: OnchainPayoutFormProps): JSX.Element => {
|
}: OnchainPayoutFormProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const invalidFee = onchain.miningFee < 1 || onchain.miningFee > 50;
|
const minMiningFee = 2;
|
||||||
const costPerVByte = 141;
|
const maxMiningFee = 100;
|
||||||
|
const invalidFee = onchain.miningFee < minMiningFee || onchain.miningFee > maxMiningFee;
|
||||||
|
const costPerVByte = 200;
|
||||||
|
|
||||||
|
const handleMiningFeeChange = (e) => {
|
||||||
|
const miningFee = Number(e.target.value);
|
||||||
|
setOnchain({ ...onchain, miningFee });
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setOnchain({ ...onchain, miningFee: order.suggested_mining_fee_rate });
|
setOnchain({ ...onchain, miningFee: order.suggested_mining_fee_rate });
|
||||||
@ -76,9 +82,9 @@ export const OnchainPayoutForm = ({
|
|||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
primary={
|
primary={
|
||||||
pn(Math.floor(Math.max(1, onchain.miningFee) * costPerVByte)) +
|
pn(Math.floor(Math.max(minMiningFee, onchain.miningFee) * costPerVByte)) +
|
||||||
' Sats (' +
|
' Sats (' +
|
||||||
Math.max(1, onchain.miningFee) +
|
Math.max(minMiningFee, onchain.miningFee) +
|
||||||
' Sats/vByte)'
|
' Sats/vByte)'
|
||||||
}
|
}
|
||||||
secondary={t('Mining fee')}
|
secondary={t('Mining fee')}
|
||||||
@ -94,7 +100,7 @@ export const OnchainPayoutForm = ({
|
|||||||
{pn(
|
{pn(
|
||||||
Math.floor(
|
Math.floor(
|
||||||
order.invoice_amount -
|
order.invoice_amount -
|
||||||
Math.max(1, onchain.miningFee) * costPerVByte -
|
Math.max(minMiningFee, onchain.miningFee) * costPerVByte -
|
||||||
(order.invoice_amount * order.swap_fee_rate) / 100,
|
(order.invoice_amount * order.swap_fee_rate) / 100,
|
||||||
),
|
),
|
||||||
) + ' Sats'}
|
) + ' Sats'}
|
||||||
@ -131,11 +137,11 @@ export const OnchainPayoutForm = ({
|
|||||||
value={onchain.miningFee}
|
value={onchain.miningFee}
|
||||||
type='number'
|
type='number'
|
||||||
inputProps={{
|
inputProps={{
|
||||||
max: 50,
|
max: maxMiningFee,
|
||||||
min: 1,
|
min: minMiningFee,
|
||||||
style: { textAlign: 'center' },
|
style: { textAlign: 'center' },
|
||||||
}}
|
}}
|
||||||
onChange={(e) => setOnchain({ ...onchain, miningFee: Number(e.target.value) })}
|
onChange={handleMiningFeeChange}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
Loading…
Reference in New Issue
Block a user