mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 12:11:35 +00:00
Fix delay when bad request. Fixavg premium to weighted avg premium
This commit is contained in:
parent
8e609b9e47
commit
f390a8f2f1
@ -369,7 +369,7 @@ class Logics():
|
||||
order.last_satoshis = cls.satoshis_now(order)
|
||||
bond_satoshis = int(order.last_satoshis * BOND_SIZE)
|
||||
pos_text = 'Buying' if cls.is_buyer(order, user) else 'Selling'
|
||||
description = (f"RoboSats - Taking 'Order {order.id}' {pos_text} BTC for {float(order.amount) + Order.currency_dict[str(order.currency)]}"
|
||||
description = (f"RoboSats - Taking 'Order {order.id}' {pos_text} BTC for {str(float(order.amount)) + Order.currency_dict[str(order.currency)]}"
|
||||
+ " - This is a taker bond, it will freeze in your wallet temporarily and automatically return. It will be charged if you cheat or cancel.")
|
||||
|
||||
# Gen hold Invoice
|
||||
|
12
api/views.py
12
api/views.py
@ -207,7 +207,7 @@ class OrderView(viewsets.ViewSet):
|
||||
|
||||
def take_update_confirm_dispute_cancel(self, request, format=None):
|
||||
'''
|
||||
Here takes place all of updatesto the order object.
|
||||
Here takes place all of the updates to the order object.
|
||||
That is: take, confim, cancel, dispute, update_invoice or rate.
|
||||
'''
|
||||
order_id = request.GET.get(self.lookup_url_kwarg)
|
||||
@ -430,18 +430,20 @@ class InfoView(ListAPIView):
|
||||
|
||||
queryset = MarketTick.objects.filter(timestamp__day=today.day)
|
||||
if not len(queryset) == 0:
|
||||
premiums = []
|
||||
weighted_premiums = []
|
||||
volumes = []
|
||||
for tick in queryset:
|
||||
premiums.append(tick.premium)
|
||||
weighted_premiums.append(tick.premium*tick.volume)
|
||||
volumes.append(tick.volume)
|
||||
avg_premium = sum(premiums) / len(premiums)
|
||||
|
||||
total_volume = sum(volumes)
|
||||
# Avg_premium is the weighted average of the premiums by volume
|
||||
avg_premium = sum(weighted_premiums) / total_volume
|
||||
else:
|
||||
avg_premium = 0
|
||||
total_volume = 0
|
||||
|
||||
context['today_avg_nonkyc_btc_premium'] = avg_premium
|
||||
context['today_avg_nonkyc_btc_premium'] = round(avg_premium,2)
|
||||
context['today_total_volume'] = total_volume
|
||||
context['lnd_version'] = get_lnd_version()
|
||||
context['robosats_running_commit_hash'] = get_commit_robosats()
|
||||
|
@ -25,7 +25,7 @@ export default class BottomBar extends Component {
|
||||
num_public_sell_orders: null,
|
||||
fee: null,
|
||||
today_avg_nonkyc_btc_premium: null,
|
||||
today_volume: null,
|
||||
today_total_volume: null,
|
||||
};
|
||||
this.getInfo();
|
||||
}
|
||||
@ -78,7 +78,7 @@ export default class BottomBar extends Component {
|
||||
<Divider/>
|
||||
<ListItem>
|
||||
<ListItemIcon><EqualizerIcon/></ListItemIcon>
|
||||
<ListItemText primary={this.state.today_volume} secondary="Today traded volume"/>
|
||||
<ListItemText primary={this.state.today_total_volume+" BTC"} secondary="Today traded volume"/>
|
||||
</ListItem>
|
||||
</List>
|
||||
</DialogContent>
|
||||
@ -203,8 +203,8 @@ export default class BottomBar extends Component {
|
||||
<ListItemText
|
||||
primaryTypographyProps={{fontSize: '14px'}}
|
||||
secondaryTypographyProps={{fontSize: '12px'}}
|
||||
primary={this.state.today_avg_nonkyc_btc_premium}
|
||||
secondary="Today Avg Premium" />
|
||||
primary={this.state.today_avg_nonkyc_btc_premium+"%"}
|
||||
secondary="Today Non-KYC Avg Premium" />
|
||||
</ListItem>
|
||||
</Grid>
|
||||
|
||||
|
@ -89,7 +89,7 @@ export default class InfoDialog extends Component {
|
||||
inspecting the source code </a> </p>
|
||||
</Typography>
|
||||
|
||||
<Typography component="h5" variant="h5">What happens if <i>RoboSats</i> suddently disapears?</Typography>
|
||||
<Typography component="h5" variant="h5">What happens if <i>RoboSats</i> suddenly disapears?</Typography>
|
||||
<Typography component="body2" variant="body2">
|
||||
<p> Your sats will most likely return to you. Any hold invoice that is not
|
||||
settled would be automatically returned even if <i>RoboSats</i> goes down
|
||||
|
@ -51,9 +51,9 @@ export default class OrderPage extends Component {
|
||||
this.statusToDelay = {
|
||||
"0": 3000, //'Waiting for maker bond'
|
||||
"1": 30000, //'Public'
|
||||
"2": 999999, //'Deleted'
|
||||
"2": 9999999, //'Deleted'
|
||||
"3": 3000, //'Waiting for taker bond'
|
||||
"4": 999999, //'Cancelled'
|
||||
"4": 9999999, //'Cancelled'
|
||||
"5": 999999, //'Expired'
|
||||
"6": 3000, //'Waiting for trade collateral and buyer invoice'
|
||||
"7": 3000, //'Waiting only for seller trade collateral'
|
||||
@ -61,13 +61,13 @@ export default class OrderPage extends Component {
|
||||
"9": 10000, //'Sending fiat - In chatroom'
|
||||
"10": 15000, //'Fiat sent - In chatroom'
|
||||
"11": 300000, //'In dispute'
|
||||
"12": 999999, //'Collaboratively cancelled'
|
||||
"12": 9999999,//'Collaboratively cancelled'
|
||||
"13": 120000, //'Sending satoshis to buyer'
|
||||
"14": 999999, //'Sucessful trade'
|
||||
"15": 15000, //'Failed lightning network routing'
|
||||
"16": 999999, //'Maker lost dispute'
|
||||
"17": 999999, //'Taker lost dispute'
|
||||
}
|
||||
"14": 9999999,//'Sucessful trade'
|
||||
"15": 10000, //'Failed lightning network routing'
|
||||
"16": 9999999,//'Maker lost dispute'
|
||||
"17": 9999999,//'Taker lost dispute'
|
||||
}
|
||||
}
|
||||
|
||||
getOrderDetails() {
|
||||
@ -77,7 +77,7 @@ export default class OrderPage extends Component {
|
||||
.then((data) => {console.log(data) &
|
||||
this.setState({
|
||||
loading: false,
|
||||
delay: this.statusToDelay[data.status.toString()],
|
||||
delay: this.setDelay(data.status),
|
||||
id: data.id,
|
||||
statusCode: data.status,
|
||||
statusText: data.status_message,
|
||||
@ -207,6 +207,11 @@ export default class OrderPage extends Component {
|
||||
}));
|
||||
}
|
||||
|
||||
// set delay to the one matching the order status. If no order status, set delay to 9999999
|
||||
setDelay(val){
|
||||
return val ? this.statusToDelay[val.toString()] : 99999999;
|
||||
}
|
||||
|
||||
getCurrencyCode(val){
|
||||
let code = val ? this.state.currencies_dict[val.toString()] : ""
|
||||
return code
|
||||
|
Loading…
Reference in New Issue
Block a user