This commit is contained in:
Maria Carmina 2023-03-15 15:49:40 +02:00
parent 080d44fbc7
commit b19740389d
2 changed files with 10 additions and 3 deletions

View File

@ -9,7 +9,10 @@ export function handleAllocated(event: Allocated): void {
// loop all allocations
const token = getToken(event.params.tokenAddress, false)
for (let i = 0; i < event.params.tos.length; i++) {
const reward = getDFReward(event.params.tos[i], event.transaction.hash.toHex())
const reward = getDFReward(
event.params.tos[i],
event.transaction.hash.toHex()
)
const history = new DFHistory(
event.params.tos[i].toHexString() +
@ -61,7 +64,11 @@ export function handleClaimed(event: Claimed): void {
history.save()
// update available claims
const claim = getDFAvailableClaim(event.params.to, event.params.tokenAddress, event.transaction.hash.toHex())
const claim = getDFAvailableClaim(
event.params.to,
event.params.tokenAddress,
event.transaction.hash.toHex()
)
claim.amount = claim.amount.minus(history.amount)
claim.save()
}

View File

@ -22,7 +22,7 @@ export function getDFReward(address: Address, txId: String): DFReward {
export function getDFAvailableClaim(
user: Address,
token: Address,
txId: String,
txId: String
): DFAvailableClaim {
const id = user.toHexString() + '-' + token.toHexString()
let dfClaim = DFAvailableClaim.load(id)