From 0d72d5d3dedf7390e7ade520ad94ff16ca41f429 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 17 Dec 2024 10:49:38 +0100 Subject: [PATCH 1/2] fix(public-allocator): allow set flow cap to 0 for a non-listed vault market --- src/public-allocator.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/public-allocator.ts b/src/public-allocator.ts index 1ac8414..61e53c5 100644 --- a/src/public-allocator.ts +++ b/src/public-allocator.ts @@ -12,7 +12,7 @@ import { Account, MarketFlowCapsSet, MetaMorpho, - MetaMorphoAllocator, + MetaMorphoAllocator, MetaMorphoMarket, MetaMorphoPublicAllocator, MetaMorphoPublicAllocatorMarket, PublicAllocatorReallocationToEvent, @@ -238,8 +238,26 @@ export function handleSetFlowCaps(event: SetFlowCaps): void { setFlowCapsEvent.save(); for (let i = 0; i < event.params.config.length; i++) { + + + const config = event.params.config[i]; + const mmMarket = MetaMorphoMarket.load( + event.params.vault.concat(config.id) + ); + + if ( + !mmMarket && + config.caps.maxIn.isZero() && + config.caps.maxOut.isZero() + ) { + // because of the following line on the PA contract, you can set a flow cap to 0 for a non-listed market + // If the mmMarket doesn't exist at all, we just skip the cap configuration + // https://github.com/morpho-org/public-allocator/blob/main/src/PublicAllocator.sol#L85 + continue; + } + const paMarket = loadPublicAllocatorMarket(event.params.vault, config.id); const marketFlowCapsSet = new MarketFlowCapsSet(eventId.concat(config.id)); From ff8d19e4458965f3cb928f9d8f5717c41d8d404f Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 17 Dec 2024 10:56:26 +0100 Subject: [PATCH 2/2] chore: lint --- src/public-allocator.ts | 6 ++---- subgraph.yaml | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/public-allocator.ts b/src/public-allocator.ts index 61e53c5..d53fcd4 100644 --- a/src/public-allocator.ts +++ b/src/public-allocator.ts @@ -12,7 +12,8 @@ import { Account, MarketFlowCapsSet, MetaMorpho, - MetaMorphoAllocator, MetaMorphoMarket, + MetaMorphoAllocator, + MetaMorphoMarket, MetaMorphoPublicAllocator, MetaMorphoPublicAllocatorMarket, PublicAllocatorReallocationToEvent, @@ -238,9 +239,6 @@ export function handleSetFlowCaps(event: SetFlowCaps): void { setFlowCapsEvent.save(); for (let i = 0; i < event.params.config.length; i++) { - - - const config = event.params.config[i]; const mmMarket = MetaMorphoMarket.load( diff --git a/subgraph.yaml b/subgraph.yaml index ff02f9d..3ab1457 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -137,8 +137,8 @@ dataSources: name: PublicAllocator network: mainnet source: - address: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D" abi: PublicAllocator + address: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D" startBlock: 19375099 mapping: kind: ethereum/events