Fix missing stackedMsats update + wrong sybil fee (#1256)

* Fix 'stackedMsats' not updated

* Fix 1% fee instead of 10%
This commit is contained in:
ekzyis 2024-07-08 16:07:35 +02:00 committed by GitHub
parent 3710840167
commit 02472bb81f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -11,7 +11,7 @@ export async function getCost ({ sats }) {
} }
export async function perform ({ invoiceId, sats, id: itemId, ...args }, { me, cost, tx }) { export async function perform ({ invoiceId, sats, id: itemId, ...args }, { me, cost, tx }) {
const feeMsats = cost / BigInt(100) const feeMsats = cost / BigInt(10) // 10% fee
const zapMsats = cost - feeMsats const zapMsats = cost - feeMsats
itemId = parseInt(itemId) itemId = parseInt(itemId)
@ -84,7 +84,9 @@ export async function onPaid ({ invoice, actIds }, { models, tx }) {
WHERE users.id = forwardees."userId" WHERE users.id = forwardees."userId"
) )
UPDATE users UPDATE users
SET msats = msats + ${itemAct.msats}::BIGINT - (SELECT msats FROM total_forwarded)::BIGINT SET
msats = msats + ${itemAct.msats}::BIGINT - (SELECT msats FROM total_forwarded)::BIGINT,
"stackedMsats" = "stackedMsats" + ${itemAct.msats}::BIGINT - (SELECT msats FROM total_forwarded)::BIGINT
WHERE id = ${itemAct.item.userId}::INTEGER` WHERE id = ${itemAct.item.userId}::INTEGER`
// perform denomormalized aggregates: weighted votes, upvotes, msats, lastZapAt // perform denomormalized aggregates: weighted votes, upvotes, msats, lastZapAt