mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-05 22:10:10 +00:00
Reward robots for counterpart slashed bonds
This commit is contained in:
parent
78b4d1fcec
commit
ce25a6b3c7
@ -93,6 +93,9 @@ MIN_FLAT_ROUTING_FEE_LIMIT_REWARD = 2
|
|||||||
|
|
||||||
# Reward tip. Reward for every finished trade in the referral program (Satoshis)
|
# Reward tip. Reward for every finished trade in the referral program (Satoshis)
|
||||||
REWARD_TIP = 100
|
REWARD_TIP = 100
|
||||||
|
# Fraction rewarded to user from the slashed bond of a counterpart.
|
||||||
|
# It should not be close to 1, or could be exploited by an attacker trading with himself to DDOS the LN node.
|
||||||
|
SLASHED_BOND_REWARD_SPLIT = 0.5
|
||||||
|
|
||||||
# Username for HTLCs escrows
|
# Username for HTLCs escrows
|
||||||
ESCROW_USERNAME = 'admin'
|
ESCROW_USERNAME = 'admin'
|
||||||
|
@ -106,6 +106,9 @@ class UserProfileAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
|
|||||||
"is_referred",
|
"is_referred",
|
||||||
"telegram_enabled",
|
"telegram_enabled",
|
||||||
"total_contracts",
|
"total_contracts",
|
||||||
|
"pending_rewards",
|
||||||
|
"earned_rewards",
|
||||||
|
"claimed_rewards",
|
||||||
"platform_rating",
|
"platform_rating",
|
||||||
"total_ratings",
|
"total_ratings",
|
||||||
"avg_rating",
|
"avg_rating",
|
||||||
|
@ -244,6 +244,8 @@ class Logics:
|
|||||||
pass
|
pass
|
||||||
order.status = Order.Status.EXP
|
order.status = Order.Status.EXP
|
||||||
order.save()
|
order.save()
|
||||||
|
# Reward taker with part of the maker bond
|
||||||
|
cls.add_slashed_rewards(order.maker_bond, order.taker.profile)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# If maker is buyer, settle the taker's bond order goes back to public
|
# If maker is buyer, settle the taker's bond order goes back to public
|
||||||
@ -254,10 +256,13 @@ class Logics:
|
|||||||
cls.cancel_escrow(order)
|
cls.cancel_escrow(order)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
taker_bond = order.taker_bond
|
||||||
order.taker = None
|
order.taker = None
|
||||||
order.taker_bond = None
|
order.taker_bond = None
|
||||||
order.trade_escrow = None
|
order.trade_escrow = None
|
||||||
cls.publish_order(order)
|
cls.publish_order(order)
|
||||||
|
# Reward maker with part of the taker bond
|
||||||
|
cls.add_slashed_rewards(taker_bond, order.maker.profile)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif order.status == Order.Status.WFI:
|
elif order.status == Order.Status.WFI:
|
||||||
@ -272,16 +277,21 @@ class Logics:
|
|||||||
cls.return_escrow(order)
|
cls.return_escrow(order)
|
||||||
order.status = Order.Status.EXP
|
order.status = Order.Status.EXP
|
||||||
order.save()
|
order.save()
|
||||||
|
# Reward taker with part of the maker bond
|
||||||
|
cls.add_slashed_rewards(order.maker_bond, order.taker.profile)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# If maker is seller settle the taker's bond, order goes back to public
|
# If maker is seller settle the taker's bond, order goes back to public
|
||||||
else:
|
else:
|
||||||
cls.settle_bond(order.taker_bond)
|
cls.settle_bond(order.taker_bond)
|
||||||
cls.return_escrow(order)
|
cls.return_escrow(order)
|
||||||
|
taker_bond = order.taker_bond
|
||||||
order.taker = None
|
order.taker = None
|
||||||
order.taker_bond = None
|
order.taker_bond = None
|
||||||
order.trade_escrow = None
|
order.trade_escrow = None
|
||||||
cls.publish_order(order)
|
cls.publish_order(order)
|
||||||
|
# Reward maker with part of the taker bond
|
||||||
|
cls.add_slashed_rewards(taker_bond, order.maker.profile)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif order.status in [Order.Status.CHA, Order.Status.FSE]:
|
elif order.status in [Order.Status.CHA, Order.Status.FSE]:
|
||||||
@ -310,9 +320,9 @@ class Logics:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def open_dispute(cls, order, user=None):
|
def open_dispute(cls, order, user=None):
|
||||||
|
|
||||||
# Always settle escro and bonds during a dispute. Disputes
|
# Always settle escrow and bonds during a dispute. Disputes
|
||||||
# can take long to resolve, it might trigger force closure
|
# can take long to resolve, it might trigger force closure
|
||||||
# for unresolve HTLCs) Dispute winner will have to submit a
|
# for unresolved HTLCs) Dispute winner will have to submit a
|
||||||
# new invoice for value of escrow + bond.
|
# new invoice for value of escrow + bond.
|
||||||
|
|
||||||
if not order.trade_escrow.status == LNPayment.Status.SETLED:
|
if not order.trade_escrow.status == LNPayment.Status.SETLED:
|
||||||
@ -578,16 +588,15 @@ class Logics:
|
|||||||
|
|
||||||
# 4.a) When maker cancel after bond (before escrow)
|
# 4.a) When maker cancel after bond (before escrow)
|
||||||
"""The order into cancelled status if maker cancels."""
|
"""The order into cancelled status if maker cancels."""
|
||||||
elif (order.status in [
|
elif (order.status in [Order.Status.TAK, Order.Status.WF2,Order.Status.WFE] and order.maker == user):
|
||||||
Order.Status.PUB, Order.Status.TAK, Order.Status.WF2,
|
|
||||||
Order.Status.WFE
|
|
||||||
] and order.maker == user):
|
|
||||||
# Settle the maker bond (Maker loses the bond for canceling an ongoing trade)
|
# Settle the maker bond (Maker loses the bond for canceling an ongoing trade)
|
||||||
valid = cls.settle_bond(order.maker_bond)
|
valid = cls.settle_bond(order.maker_bond)
|
||||||
cls.return_bond(order.taker_bond) # returns taker bond
|
cls.return_bond(order.taker_bond) # returns taker bond
|
||||||
if valid:
|
if valid:
|
||||||
order.status = Order.Status.UCA
|
order.status = Order.Status.UCA
|
||||||
order.save()
|
order.save()
|
||||||
|
# Reward taker with part of the maker bond
|
||||||
|
cls.add_slashed_rewards(order.maker_bond, order.taker.profile)
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
# 4.b) When taker cancel after bond (before escrow)
|
# 4.b) When taker cancel after bond (before escrow)
|
||||||
@ -599,6 +608,8 @@ class Logics:
|
|||||||
if valid:
|
if valid:
|
||||||
order.taker = None
|
order.taker = None
|
||||||
cls.publish_order(order)
|
cls.publish_order(order)
|
||||||
|
# Reward maker with part of the taker bond
|
||||||
|
cls.add_slashed_rewards(order.taker_bond, order.maker.profile)
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
# 5) When trade collateral has been posted (after escrow)
|
# 5) When trade collateral has been posted (after escrow)
|
||||||
@ -1042,7 +1053,7 @@ class Logics:
|
|||||||
|
|
||||||
# Add referral rewards (safe)
|
# Add referral rewards (safe)
|
||||||
try:
|
try:
|
||||||
Logics.add_rewards(order)
|
cls.add_rewards(order)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -1112,6 +1123,19 @@ class Logics:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def add_slashed_rewards(cls, bond, profile):
|
||||||
|
'''
|
||||||
|
When a bond is slashed due to overtime, rewards the user that was waiting.
|
||||||
|
If participants of the order were referred, the reward is given to the referees.
|
||||||
|
'''
|
||||||
|
reward_fraction = float(config('SLASHED_BOND_REWARD_SPLIT'))
|
||||||
|
reward = int(bond.num_satoshis*reward_fraction)
|
||||||
|
profile.earned_rewards += reward
|
||||||
|
profile.save()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def withdraw_rewards(cls, user, invoice):
|
def withdraw_rewards(cls, user, invoice):
|
||||||
|
|
||||||
|
@ -634,12 +634,24 @@ bottomBarDesktop =()=>{
|
|||||||
<ListItemIcon size="small">
|
<ListItemIcon size="small">
|
||||||
<PercentIcon/>
|
<PercentIcon/>
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText
|
<Grid container xs={12}>
|
||||||
primaryTypographyProps={{fontSize: '14px'}}
|
<Grid item xs={6}>
|
||||||
secondaryTypographyProps={{fontSize: '12px'}}
|
<ListItemText
|
||||||
secondary="Trading fees">
|
primaryTypographyProps={{fontSize: '14px'}}
|
||||||
{(this.state.maker_fee*100).toFixed(3)}% <small>(maker)</small> | {(this.state.taker_fee*100).toFixed(3)}% <small>(taker)</small>
|
secondaryTypographyProps={{fontSize: '12px'}}
|
||||||
</ListItemText>
|
secondary="Maker fee">
|
||||||
|
{(this.state.maker_fee*100).toFixed(3)}%
|
||||||
|
</ListItemText>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
<ListItemText
|
||||||
|
primaryTypographyProps={{fontSize: '14px'}}
|
||||||
|
secondaryTypographyProps={{fontSize: '12px'}}
|
||||||
|
secondary="Taker fee">
|
||||||
|
{(this.state.taker_fee*100).toFixed(3)}%
|
||||||
|
</ListItemText>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export default class InfoDialog extends Component {
|
|||||||
<Typography component="h4" variant="h4">What is <i>RoboSats</i>?</Typography>
|
<Typography component="h4" variant="h4">What is <i>RoboSats</i>?</Typography>
|
||||||
<Typography component="body2" variant="body2">
|
<Typography component="body2" variant="body2">
|
||||||
<p>It is a BTC/FIAT peer-to-peer exchange over lightning. It simplifies
|
<p>It is a BTC/FIAT peer-to-peer exchange over lightning. It simplifies
|
||||||
matchmaking and minimizes the need of trust. RoboSats focuses in privacy and speed.</p>
|
matchmaking and minimizes the need for entrust. RoboSats focuses in privacy and speed.</p>
|
||||||
<img
|
<img
|
||||||
width='100%'
|
width='100%'
|
||||||
src={window.location.origin +'/static/assets/images/robosats_0.1.0_banner.png'}
|
src={window.location.origin +'/static/assets/images/robosats_0.1.0_banner.png'}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user