Skip to content

Commit

Permalink
hotfix: issue when integration contract has 0 shares
Browse files Browse the repository at this point in the history
  • Loading branch information
mortimr committed Dec 6, 2023
1 parent 62c79ae commit 198fdbf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/ERC20.mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,20 @@ export function _recomputeERC20TotalUnderlyingSupply(erc20Address: Address): Big
while (multipool != null) {
const pool = vPool.load(multipool.pool);
const poolBalance = PoolBalance.load(multipool.shares);
if (poolBalance == null) {
++idx;
multipool = MultiPool.load(externalEntityUUID(erc20Address, [idx.toString()]));
continue;
}
totalUnderlyingSupply = totalUnderlyingSupply.plus(
_computeEthAfterCommission(
poolBalance!.amount,
poolBalance.amount,
pool!.totalSupply,
pool!.totalUnderlyingSupply,
multipool.injectedEth,
multipool.exitedEth,
multipool.fees,
multipool.commissionPaid
multipool!.injectedEth,
multipool!.exitedEth,
multipool!.fees,
multipool!.commissionPaid
)
);
++idx;
Expand All @@ -237,7 +242,7 @@ export function handleSetFee(event: SetFee): void {

if (multiPool != null) {
const poolBalance = PoolBalance.load(multiPool.shares);
if (poolBalance!.amount.gt(BigInt.zero())) {
if (poolBalance != null && poolBalance!.amount.gt(BigInt.zero())) {
const earnedBeforeFeeUpdate = _computeIntegratorCommissionEarned(
poolBalance!.amount,
pool!.totalSupply,
Expand Down
2 changes: 1 addition & 1 deletion src/vPool.mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export function handleTransfer(event: Transfer): void {
toBalance.amount = toBalance.amount.plus(event.params.value);

saveOrEraseBalance(fromBalance, event);
if (toBalance.address != Address.zero()) {
if (toBalance.address.notEqual(Address.zero())) {
saveOrEraseBalance(toBalance, event);
}

Expand Down

0 comments on commit 198fdbf

Please sign in to comment.