Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locked fund in reward calculator #40

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions stakingreward/stakingreward.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func (calc *Calculator) simulateStakingReward(numberOfDays float64, startingDCRB

simulationTable[len(simulationTable)-1].TicketPrice = TicketPrice
simulationTable[len(simulationTable)-1].TicketsPurchased = ticketsPurchased
simulationTable[len(simulationTable)-1].LockedFund = ticketsPurchased * TicketPrice

DCRBalance -= (TicketPrice * ticketsPurchased)

Expand All @@ -219,12 +220,11 @@ func (calc *Calculator) simulateStakingReward(numberOfDays float64, startingDCRB
daysPassed := blocksPassed / blocksPerDay
day := simulationTable[len(simulationTable)-1].SimDay + int(daysPassed)
simulationTable = append(simulationTable, simulationRow{
SimBlock: simblock,
SimDay: day,
DCRBalance: DCRBalance,
Reward: (StakeRewardAtBlock(simblock) * ticketsPurchased),
ReturnedFund: (TicketPrice * ticketsPurchased),
TicketPrice: TheoreticalTicketPrice(simblock) * TicketAdjustmentFactor,
SimBlock: simblock,
SimDay: day,
DCRBalance: DCRBalance,
Reward: (StakeRewardAtBlock(simblock) * ticketsPurchased),
TicketPrice: TheoreticalTicketPrice(simblock) * TicketAdjustmentFactor,
})

// Move forward to coinbase maturity
Expand Down
2 changes: 1 addition & 1 deletion stakingreward/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ type simulationRow struct {
DCRBalance float64 `json:"dcr_balance"`
TicketsPurchased float64 `json:"tickets_purchased"`
Reward float64 `json:"reward"`
ReturnedFund float64 `json:"returned_fund"`
LockedFund float64 `json:"locked_fund"`
}
3 changes: 3 additions & 0 deletions views/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
{{ end }}

{{ end }}

<hr>
<p>Get the source from <a href="https://github.com/planetdecred/pdanalytics">Github</a></p>
</div>

{{end}}
Expand Down
2 changes: 1 addition & 1 deletion views/stakingreward.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<th style="padding: 10px 8px;">Date</th>
<th style="padding: 10px 8px;">Height</th>
<th style="padding: 10px 8px; max-width: 77px;">Tickets Price Avg <small>(<span class="text-secondary">DCR</span>)</small></th>
<th style="padding: 10px 8px; max-width: 66px;">Returned Fund <small>(<span class="text-secondary">DCR</span>)</small></th>
<th style="padding: 10px 8px; max-width: 66px;">Locked Fund <small>(<span class="text-secondary">DCR</span>)</small></th>
<th style="padding: 10px 8px; max-width: 64px;">Reward <small>(<span class="text-secondary">DCR</span>)</small></th>
<th style="padding: 10px 8px; max-width: 77px;">Total Balance <small>(<span class="text-secondary">DCR</span>)</small></th>
<th style="padding: 10px 8px; max-width: 51px;">% Gained</th>
Expand Down
2 changes: 1 addition & 1 deletion web/public/js/controllers/stakingreward_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default class extends Controller {
fields[0].innerText = date.format('YYYY-MM-DD')
fields[1].innerText = item.height
fields[2].innerText = item.ticket_price.toFixed(2)
fields[3].innerText = item.returned_fund.toFixed(2)
fields[3].innerText = item.locked_fund.toFixed(2)
fields[4].innerText = item.reward.toFixed(2)
fields[5].innerText = item.dcr_balance.toFixed(2)
fields[6].innerText = (100 * (item.dcr_balance - amount) / amount).toFixed(2)
Expand Down