Skip to content

Commit

Permalink
calculate both fees
Browse files Browse the repository at this point in the history
  • Loading branch information
YouStillAlive committed Sep 2, 2024
1 parent 780379c commit dc249b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions scripts/curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ async function getTokenBalances(lpAddress: string, token: any) {
])

const lpPool = await ethers.getContractAt("UniswapV3Pool", lpAddress)
const token0 = await lpPool.token0()
const isPartyPool = await bnbPartyFactory.isTokenOnPartyLP(token0 === wethAddress ? await token.getAddress() : token0)
const [feeGrowthGlobal0X128, feeGrowthGlobal1X128, liquidity, getFeeGlobal] = await Promise.all([
lpPool.feeGrowthGlobal0X128(),
lpPool.feeGrowthGlobal1X128(),
lpPool.liquidity(),
bnbPartyFactory.getFeeGrowthInsideLastX128(lpAddress, BNBPositionManager),
bnbPartyFactory.getFeeGrowthInsideLastX128(lpAddress, isPartyPool ? BNBPositionManager : positionManager),
])
const token0 = await lpPool.token0()
let wbnbFee, memeFee

if (token0 === wethAddress) {
wbnbFee = await bnbPartyFactory.calculateFees(liquidity, feeGrowthGlobal0X128 - getFeeGlobal.feeGrowthInside0LastX128)
memeFee = await bnbPartyFactory.calculateFees(liquidity, feeGrowthGlobal1X128 - getFeeGlobal.feeGrowthInside1LastX128)
Expand Down
2 changes: 1 addition & 1 deletion test/SwapRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("Smart Router", function () {

it("user should receive meme token after join party", async () => {
const amountIn = ethers.parseUnits("5", 17)

const balanceBefore = await MEMEToken.balanceOf(await signers[0].getAddress())
await bnbPartyFactory.joinParty(MEME, 0, { value: amountIn })
const balanceAfter = await MEMEToken.balanceOf(await signers[0].getAddress())
Expand Down

0 comments on commit dc249b2

Please sign in to comment.