Skip to content

Commit

Permalink
Merge pull request #19 from balancer/fix-swap-fee
Browse files Browse the repository at this point in the history
fix swap fee percentage
  • Loading branch information
mendesfabio authored Feb 11, 2025
2 parents ae83cfc + 11a9eae commit 829b102
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions subgraphs/v3-vault/src/mappings/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,13 @@ export function handleSwap(event: SwapEvent): void {
swapFeeToken.decimals
);

let swapFeePercentage = scaleDown(event.params.swapFeePercentage, 18);

let hasDynamicSwapFee = pool.swapFee != swap.swapFeePercentage;
let swapFeeBaseAmount = swapFeeAmount;
let swapFeeDeltaAmount = ZERO_BD;
if (hasDynamicSwapFee) {
let swapFeeDelta = swap.swapFeePercentage.minus(pool.swapFee);
let swapFeeDelta = swapFeePercentage.minus(pool.swapFee);
swapFeeBaseAmount = tokenAmountIn.times(pool.swapFee);
swapFeeDeltaAmount = tokenAmountIn.times(swapFeeDelta);
}
Expand All @@ -330,7 +332,7 @@ export function handleSwap(event: SwapEvent): void {
swap.swapFeeBaseAmount = swapFeeBaseAmount;
swap.swapFeeDeltaAmount = swapFeeDeltaAmount;
swap.swapFeeToken = event.params.tokenIn;
swap.swapFeePercentage = scaleDown(event.params.swapFeePercentage, 18);
swap.swapFeePercentage = swapFeePercentage;
swap.hasDynamicSwapFee = hasDynamicSwapFee;
swap.user = event.transaction.from;
swap.logIndex = event.logIndex;
Expand Down

0 comments on commit 829b102

Please sign in to comment.