Skip to content

Commit 0de181f

Browse files
authored
fix decmail math (#117)
1 parent 69834d8 commit 0de181f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/mappings/pool.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,21 @@ export function _handleRebind(
101101
if (tokenAddress != OCEAN) {
102102
pool.datatokenAddress = tokenAddress
103103
}
104-
pool.tokenCount += BigInt.fromI32(1)
104+
pool.tokenCount = pool.tokenCount.plus(BigInt.fromI32(1))
105105
const address = Address.fromString(tokenAddress)
106106
const denormWeight = hexToDecimal(denormWeightStr, decimals)
107107
const poolTokenId = poolId.concat('-').concat(address.toHexString())
108108
let poolToken = PoolToken.load(poolTokenId)
109109
if (poolToken == null) {
110110
createPoolTokenEntity(poolTokenId, poolId, address.toHexString())
111111
poolToken = PoolToken.load(poolTokenId)
112-
pool.totalWeight += denormWeight
112+
pool.totalWeight = pool.totalWeight.plus(denormWeight)
113113
} else {
114114
const oldWeight = poolToken.denormWeight
115115
if (denormWeight > oldWeight) {
116-
pool.totalWeight = pool.totalWeight + (denormWeight - oldWeight)
116+
pool.totalWeight = pool.totalWeight.plus(denormWeight).minus(oldWeight)
117117
} else {
118-
pool.totalWeight = pool.totalWeight - (oldWeight - denormWeight)
118+
pool.totalWeight = pool.totalWeight.minus(oldWeight).minus(denormWeight)
119119
}
120120
}
121121

@@ -451,9 +451,9 @@ export function handleTransfer(event: Transfer): void {
451451
createPoolShareEntity(poolShareToId, poolId, event.params.to.toHex())
452452
poolShareTo = PoolShare.load(poolShareToId)
453453
}
454-
poolShareTo.balance += value
454+
poolShareTo.balance = poolShareTo.balance.plus(value)
455455
poolShareTo.save()
456-
pool.totalShares += value
456+
pool.totalShares = pool.totalShares.plus(value)
457457
if (poolTx != null) {
458458
poolTx.sharesTransferAmount = value
459459
poolTx.sharesBalance = poolShareTo.balance
@@ -474,11 +474,11 @@ export function handleTransfer(event: Transfer): void {
474474
createPoolShareEntity(poolShareFromId, poolId, event.params.from.toHex())
475475
poolShareFrom = PoolShare.load(poolShareFromId)
476476
}
477-
poolShareFrom.balance -= value
477+
poolShareFrom.balance = poolShareFrom.balance.minus(value)
478478
poolShareFrom.save()
479-
pool.totalShares -= value
479+
pool.totalShares = pool.totalShares.minus(value)
480480
if (poolTx != null) {
481-
poolTx.sharesTransferAmount = -value
481+
poolTx.sharesTransferAmount = poolTx.sharesTransferAmount.minus(value)
482482
poolTx.sharesBalance = poolShareFrom.balance
483483
}
484484
debuglog(
@@ -497,14 +497,14 @@ export function handleTransfer(event: Transfer): void {
497497
createPoolShareEntity(poolShareToId, poolId, event.params.to.toHex())
498498
poolShareTo = PoolShare.load(poolShareToId)
499499
}
500-
poolShareTo.balance.plus(value)
500+
poolShareTo.balance = poolShareTo.balance.plus(value)
501501
poolShareTo.save()
502502

503503
if (poolShareFrom == null) {
504504
createPoolShareEntity(poolShareFromId, poolId, event.params.from.toHex())
505505
poolShareFrom = PoolShare.load(poolShareFromId)
506506
}
507-
poolShareFrom.balance.minus(value)
507+
poolShareFrom.balance = poolShareFrom.balance.minus(value)
508508
poolShareFrom.save()
509509
debuglog(
510510
'pool shares transfer: ' +
@@ -527,15 +527,15 @@ export function handleTransfer(event: Transfer): void {
527527
poolShareTo.balance.notEqual(ZERO_BD) &&
528528
poolShareToBalance.equals(ZERO_BD)
529529
) {
530-
pool.holderCount.plus(BigInt.fromI32(1))
530+
pool.holderCount = pool.holderCount.plus(BigInt.fromI32(1))
531531
}
532532

533533
if (
534534
poolShareFrom != null &&
535535
poolShareFrom.balance.equals(ZERO_BD) &&
536536
poolShareFromBalance.notEqual(ZERO_BD)
537537
) {
538-
pool.holderCount.plus(BigInt.fromI32(1))
538+
pool.holderCount = pool.holderCount.plus(BigInt.fromI32(1))
539539
}
540540

541541
if (poolTx != null) {

0 commit comments

Comments
 (0)