Skip to content

Commit

Permalink
fix: update pool fee upon first liquidity add (#159)
Browse files Browse the repository at this point in the history
* fix: update pool fee upon first liquidity add

* fix: type

* fix: comment added

---------

Co-authored-by: matstyler <[email protected]>
  • Loading branch information
Ulydev and matstyler authored Sep 12, 2024
1 parent ffc66b7 commit 230c848
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/mappings/amm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import { getAccount } from "../entities/Account"
import { updateAccountAssetBalance } from "../entities/AccountAsset"
import { getAsset } from "../entities/Asset"
import { getAssetAmount } from "../entities/AssetAmount"
import { getPoolLastPrices, getPoolLPToken } from "../entities/CurvePool"
import {
getPoolFee,
getPoolLastPrices,
getPoolLPToken,
} from "../entities/CurvePool"
import { getERC20Decimals, getERC20TotalSupply } from "../entities/ERC20"
import { updateFutureDailyStats } from "../entities/FutureDailyStats"
import { createTransaction } from "../entities/Transaction"
Expand Down Expand Up @@ -138,6 +142,14 @@ export function handleAddLiquidity(event: AddLiquidity): void {
pool.totalFees = pool.totalFees.plus(fee)
pool.totalAdminFees = pool.totalAdminFees.plus(adminFee)

// In case of no liquidity, the fee() will revert on the "CurvePoolDeployed" event so we have to set the fee rate here
if (
poolIBTAssetAmount.amount.equals(ZERO_BI) &&
poolPTAssetAmount.amount.equals(ZERO_BI)
) {
pool.feeRate = getPoolFee(Address.fromBytes(pool.address))
}

pool.save()

poolIBTAssetAmount.amount = poolIBTAssetAmount.amount.plus(
Expand Down

0 comments on commit 230c848

Please sign in to comment.