@@ -6,8 +6,11 @@ import {
66 LiquidityAddedToBuffer ,
77 LiquidityRemoved ,
88 LiquidityRemovedFromBuffer ,
9+ PoolPausedStateChanged ,
10+ PoolRecoveryModeStateChanged ,
911 PoolRegistered ,
1012 Swap as SwapEvent ,
13+ SwapFeePercentageChanged ,
1114 Unwrap ,
1215 Wrap ,
1316} from "../types/Vault/Vault" ;
@@ -37,7 +40,7 @@ import { BPT } from "../types/templates";
3740import { ERC20 } from "../types/Vault/ERC20" ;
3841import { VaultExtension } from "../types/Vault/VaultExtension" ;
3942import { ERC4626 } from "../types/Vault/ERC4626" ;
40- import { computeAggregateSwapFee } from "../helpers/math" ;
43+ import { mulDownSwapFee } from "../helpers/math" ;
4144
4245/************************************
4346 ******* POOLS REGISTRATIONS ********
@@ -54,6 +57,8 @@ export function handlePoolRegistered(event: PoolRegistered): void {
5457 pool . pauseWindowEndTime = event . params . pauseWindowEndTime ;
5558 pool . totalShares = ZERO_BD ;
5659 pool . isInitialized = false ;
60+ pool . isInRecoveryMode = false ;
61+ pool . isPaused = false ;
5762 pool . swapsCount = ZERO_BI ;
5863 pool . holdersCount = ZERO_BI ;
5964 pool . protocolSwapFee = vault . protocolSwapFee ;
@@ -189,10 +194,7 @@ export function handleLiquidityAdded(event: LiquidityAdded): void {
189194 ) ;
190195
191196 let aggregateSwapFeeAmount = scaleDown (
192- computeAggregateSwapFee (
193- event . params . swapFeeAmountsRaw [ i ] ,
194- pool . protocolSwapFee
195- ) ,
197+ mulDownSwapFee ( event . params . swapFeeAmountsRaw [ i ] , pool . protocolSwapFee ) ,
196198 poolToken . decimals
197199 ) ;
198200
@@ -259,10 +261,7 @@ export function handleLiquidityRemoved(event: LiquidityRemoved): void {
259261 ) ;
260262
261263 let aggregateSwapFeeAmount = scaleDown (
262- computeAggregateSwapFee (
263- event . params . swapFeeAmountsRaw [ i ] ,
264- pool . protocolSwapFee
265- ) ,
264+ mulDownSwapFee ( event . params . swapFeeAmountsRaw [ i ] , pool . protocolSwapFee ) ,
266265 poolToken . decimals
267266 ) ;
268267
@@ -369,7 +368,7 @@ export function handleSwap(event: SwapEvent): void {
369368 }
370369
371370 let aggregateSwapFeeAmount = scaleDown (
372- computeAggregateSwapFee ( event . params . swapFeeAmount , pool . protocolSwapFee ) ,
371+ mulDownSwapFee ( event . params . swapFeeAmount , pool . protocolSwapFee ) ,
373372 poolTokenIn . decimals
374373 ) ;
375374
@@ -594,3 +593,31 @@ export function handleWrap(event: Wrap): void {
594593 ) ;
595594 buffer . save ( ) ;
596595}
596+
597+ /************************************
598+ ********** POOLS STATE *************
599+ ************************************/
600+
601+ export function handleSwapFeePercentageChanged (
602+ event : SwapFeePercentageChanged
603+ ) : void {
604+ let pool = Pool . load ( event . params . pool ) as Pool ;
605+ pool . swapFee = scaleDown ( event . params . swapFeePercentage , 18 ) ;
606+ pool . save ( ) ;
607+ }
608+
609+ export function handlePoolRecoveryModeStateChanged (
610+ event : PoolRecoveryModeStateChanged
611+ ) : void {
612+ let pool = Pool . load ( event . params . pool ) as Pool ;
613+ pool . isInRecoveryMode = event . params . recoveryMode ;
614+ pool . save ( ) ;
615+ }
616+
617+ export function handlePoolPausedStateChanged (
618+ event : PoolPausedStateChanged
619+ ) : void {
620+ let pool = Pool . load ( event . params . pool ) as Pool ;
621+ pool . isPaused = event . params . paused ;
622+ pool . save ( ) ;
623+ }
0 commit comments