Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(public-allocator): allow set flow cap to 0 for a non-listed vault market #13

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/public-allocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
MarketFlowCapsSet,
MetaMorpho,
MetaMorphoAllocator,
MetaMorphoMarket,
MetaMorphoPublicAllocator,
MetaMorphoPublicAllocatorMarket,
PublicAllocatorReallocationToEvent,
Expand Down Expand Up @@ -240,6 +241,21 @@ export function handleSetFlowCaps(event: SetFlowCaps): void {
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));
Expand Down
2 changes: 1 addition & 1 deletion subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ dataSources:
name: PublicAllocator
network: mainnet
source:
address: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D"
abi: PublicAllocator
address: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D"
startBlock: 19375099
mapping:
kind: ethereum/events
Expand Down
Loading