Skip to content

Commit

Permalink
Merge pull request #407 from ericpp/fix-boost-share-splits
Browse files Browse the repository at this point in the history
Non-fee splits should be calculated from sum of splits rather than from 100
  • Loading branch information
daveajones authored Oct 2, 2024
2 parents 1c496ca + 8bfb047 commit 7e0f1f4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ui/src/components/Boostagram/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export default class Boostagram extends React.PureComponent<IProps> {

if (webln) {
this.throwConfetti()

// fee destinations are calculated as percentages of the donation amount
// i.e. (split / 100) * satAmount
for (const dest of feesDestinations) {
let feeRecord = getBaseRecord()

Expand Down Expand Up @@ -121,9 +124,13 @@ export default class Boostagram extends React.PureComponent<IProps> {
}
}

// non-fee destinations are calculated as shares of the remaining amount after fees are taken out
// i.e. (split / sum(all splits)) * runningTotal
let splitsTotal = splitsDestinations.reduce((sum, dest) => sum + dest.split, 0)

for (const dest of splitsDestinations) {
let record = getBaseRecord()
let amount = Math.round((dest.split / 100) * runningTotal)
let amount = Math.round((dest.split / splitsTotal) * runningTotal)
record.name = dest.name
record.value_msat = amount * 1000
if (amount >= 1) {
Expand Down

0 comments on commit 7e0f1f4

Please sign in to comment.