Skip to content

Commit 10ff691

Browse files
buy fractional tickets during stake reward simulation
1 parent 6d9aabe commit 10ff691

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

cmd/dcrdata/internal/explorer/explorerroutes.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,12 +2936,6 @@ func (exp *explorerUI) CalculateStakeReward(w http.ResponseWriter, r *http.Reque
29362936
}
29372937

29382938
amountInDCR := float64(amount) / exchangeRate.Value
2939-
if amountInDCR < currentTicketPrice {
2940-
displayPage(fmt.Sprintf("%s (%s) cannot buy a single ticket, need at least %.2f (%s)",
2941-
amountStr, exchangeRate.Index, (currentTicketPrice * exchangeRate.Value), exchangeRate.Index))
2942-
return
2943-
}
2944-
29452939
durationInDays = endDate.Sub(startDate).Hours() / 24
29462940
minimumRewardDurationInDays := ((float64(exp.ChainParams.TicketMaturity) +
29472941
float64(exp.MeanVotingBlocks) +

cmd/dcrdata/views/stake_reward.tmpl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<input
2828
type="number" name="amount"
2929
class="bg-transparent border-0 ps-0 color-inherit form-control shadow-none mono"
30-
id="amount" required min={{with .ExchangeRate}}{{printf "%.f" (float64Multiply $.CurrentTicketPrice .Value)}}{{end}}
31-
placeholder="Enter an amount you want to stake" autocomplete="off"
30+
id="amount" required min=1
31+
placeholder="Enter the amount you want to stake" autocomplete="off"
3232
value="{{with .StakeReward}}{{.Amount}}{{end}}">
3333
</div>
3434
</div>
@@ -99,7 +99,7 @@
9999
Reward
100100
<span
101101
class="dcricon-info fs14 ms-2 mt-2"
102-
title="This is an estimated reward for the duration specified, a ticket receives a reward of {{printf "%.2f" $.TicketReward}}% ususally after {{$.MinimumRewardPeriod}}."
102+
title="This is an estimated reward for the duration specified, even if your stake amount cannot purchase a single ticket. A ticket receives a reward of ~{{printf "%.2f" $.TicketReward}}% usually after ~{{$.MinimumRewardPeriod}}."
103103
>
104104
</span>
105105
</div>
@@ -122,7 +122,7 @@
122122
{{$nTickets := divideFloat .TotalTicketsCost $.CurrentTicketPrice}}
123123
<div class="fs16 text-secondary">
124124
Total Cost
125-
<span class="dcricon-info fs14 ms-2 mt-2" title="Cost of purchasing {{$nTickets}} Ticket(s), excluding network and VSP fees."></span>
125+
<span class="dcricon-info fs14 ms-2 mt-2" title="Cost of purchasing {{printf "%.f" $nTickets}} Ticket(s), excluding network and VSP fees."></span>
126126
</div>
127127
<div class="mono lh1rem fs14-decimal fs24 pt-1 pb-1 d-flex align-items-baseline">
128128
<span>
@@ -136,7 +136,13 @@
136136
</div>
137137
{{- end}}
138138
<div class="fs12 lh1rem text-black-50">
139-
<span>{{printf "%.f" $nTickets}} {{if gt $nTickets 1.0}}Tickets{{else}}Ticket{{end}}</span>
139+
<span>
140+
{{if lt $nTickets 1.0}}
141+
Note: Stake amount is not sufficient to buy a single ticket.
142+
{{else}}
143+
{{printf "%.f" $nTickets}} {{if gt $nTickets 1.0}}Tickets{{else}}Ticket{{end}}
144+
{{end}}
145+
</span>
140146
</div>
141147
</div>
142148
</div>

0 commit comments

Comments
 (0)