Skip to content

Commit

Permalink
fixes cm counts
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-converter committed Dec 18, 2020
1 parent 4de2573 commit ec856e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/mapping-liquidityTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ export function handleReferralAdded(event: ReferralAdded): void {
let wasBelowCm = referrer.reservationReferralActualWei < CM_REFERRER_THRESHOLD
referrer.reservationReferralActualWei = referrer.reservationReferralActualWei.plus(referral.actualWei)
referrer.reservationReferralCount = referrer.reservationReferralCount.plus(ONE)
referrer.save()
if (wasBelowCm && referrer.reservationReferralActualWei >= CM_REFERRER_THRESHOLD) {
if (wasBelowCm && referrer.reservationReferralActualWei >= CM_REFERRER_THRESHOLD && referrer.cmStatus === false) {
referrer.cmStatus = true
referrer.cmStatusInLaunch = true
global.cmStatusCount = global.cmStatusCount.plus(ONE)
global.cmStatusInLaunchCount = global.cmStatusInLaunchCount.plus(ONE)
}
referrer.save()
global.save()

transaction.referral = referral.id
Expand Down
23 changes: 17 additions & 6 deletions src/mapping-wiseToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BigInt, ethereum } from "@graphprotocol/graph-ts"
import {
getOrCreateGlobal,
createUser,
ZERO,
ONE,
} from "./shared"
import {
Expand All @@ -14,13 +15,17 @@ import {
} from "../generated/schema"

export function handleGiveStatus (call: GiveStatusCall): void {
let referrer = new User(call.inputs._referrer.toHex())
referrer.cmStatus = true
referrer.save()
let referrer = createUser(call.inputs._referrer.toHex())
if (referrer.cmStatus === false) {
referrer.cmStatus = true
referrer.cmStatusInLaunch = true
referrer.save()

let global = getOrCreateGlobal()
global.cmStatusCount = global.cmStatusCount.plus(ONE)
global.save()
let global = getOrCreateGlobal()
global.cmStatusCount = global.cmStatusCount.plus(ONE)
global.cmStatusInLaunchCount = global.cmStatusInLaunchCount.plus(ONE)
global.save()
}
}

export function handleStakeStart (event: StakeStart): void {
Expand All @@ -43,6 +48,12 @@ export function handleStakeStart (event: StakeStart): void {
referrer = createUser(referrerID)
global.userCount = global.userCount.plus(ONE)
}
if (event.params.referralShares.gt(ZERO)) {
if (referrer.cmStatus === false) {
global.cmStatusCount = global.cmStatusCount.plus(ONE)
}
referrer.cmStatus = true
}
referrer.save()
global.save()

Expand Down

0 comments on commit ec856e7

Please sign in to comment.