From b9ba4dc827206ef38ce2ea44c1157eb49966c5cb Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 23 Sep 2024 11:34:18 +0200 Subject: [PATCH] feat(public-allocator): better entity naming --- schema.graphql | 77 ++++++++++++++++++++--------------------- src/public-allocator.ts | 29 +++++++++------- 2 files changed, 55 insertions(+), 51 deletions(-) diff --git a/schema.graphql b/schema.graphql index d8fbebc..6f17133 100644 --- a/schema.graphql +++ b/schema.graphql @@ -2401,27 +2401,26 @@ type MetaMorphoPublicAllocator @entity(immutable: true) { admin: Account - markets: [MetaMorphoPublicAllocatorMarket!]! @derivedFrom(field: "metaMorpho") - setFlowCapsEvents: [SetFlowCapsEvent!]! @derivedFrom(field: "metaMorpho") - reallocationToEvents: [PublicAllocatorReallocationToEvent!]! @derivedFrom(field: "metaMorpho") - withdrawalEvents: [PublicAllocatorWithdrawalEvent!]! @derivedFrom(field: "metaMorpho") - flowCapsChanges: [MarketFlowCapsSet!]! @derivedFrom(field: "metaMorpho") + markets: [MetaMorphoPublicAllocatorMarket!]! @derivedFrom(field: "metaMorphoPublicAllocator") + setFlowCapsEvents: [SetFlowCapsEvent!]! @derivedFrom(field: "metaMorphoPublicAllocator") + reallocationToEvents: [PublicAllocatorReallocationToEvent!]! @derivedFrom(field: "metaMorphoPublicAllocator") + withdrawalEvents: [PublicAllocatorWithdrawalEvent!]! @derivedFrom(field: "metaMorphoPublicAllocator") + flowCapsChanges: [MarketFlowCapsSet!]! @derivedFrom(field: "metaMorphoPublicAllocator") } type MetaMorphoPublicAllocatorMarket @entity(immutable: true) { id: Bytes! - metaMorpho: MetaMorphoPublicAllocator! + metaMorphoPublicAllocator: MetaMorphoPublicAllocator! market: MetaMorphoMarket! flowCapIn: BigInt! flowCapOut: BigInt! - setFlowCapsEvents: [SetFlowCapsEvent!]! @derivedFrom(field: "market") - reallocationToEvents: [PublicAllocatorReallocationToEvent!]! @derivedFrom(field: "market") - withdrawalEvents: [PublicAllocatorWithdrawalEvent!]! @derivedFrom(field: "market") - flowCapsChanges: [MarketFlowCapsSet!]! @derivedFrom(field: "market") + reallocationToEvents: [PublicAllocatorReallocationToEvent!]! @derivedFrom(field: "marketPublicAllocator") + withdrawalEvents: [PublicAllocatorWithdrawalEvent!]! @derivedFrom(field: "marketPublicAllocator") + flowCapsChanges: [MarketFlowCapsSet!]! @derivedFrom(field: "marketPublicAllocator") } @@ -2454,9 +2453,7 @@ type SetFlowCapsEvent implements Event @entity(immutable: true) @transaction { " Timestamp of this event " timestamp: BigInt! - - metaMorpho: MetaMorphoPublicAllocator! - + metaMorphoPublicAllocator: MetaMorphoPublicAllocator! flowCaps: [MarketFlowCapsSet!]! @derivedFrom(field: "setFlowCapsEvent") } @@ -2490,57 +2487,59 @@ type PublicAllocatorReallocationToEvent implements Event @entity(immutable: true " Timestamp of this event " timestamp: BigInt! - metaMorpho: MetaMorphoPublicAllocator! + metaMorphoPublicAllocator: MetaMorphoPublicAllocator! - market: MetaMorphoPublicAllocatorMarket! + marketPublicAllocator: MetaMorphoPublicAllocatorMarket! suppliedAssets: BigInt! + + flowCaps: MarketFlowCapsSet! @derivedFrom(field: "publicReallocationEvent") } type PublicAllocatorWithdrawalEvent implements Event @entity(immutable: true) @transaction { - " { Transaction hash }{ Log index } " - id: Bytes! + " { Transaction hash }{ Log index } " + id: Bytes! - " Transaction hash of the transaction that emitted this event " - hash: Bytes! + " Transaction hash of the transaction that emitted this event " + hash: Bytes! - " Nonce of the transaction that emitted this event " - nonce: BigInt! + " Nonce of the transaction that emitted this event " + nonce: BigInt! - " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " - logIndex: Int! + " Event log index. For transactions that don't emit event, create arbitrary index starting from 0 " + logIndex: Int! - " Price of gas in this transaction " - gasPrice: BigInt + " Price of gas in this transaction " + gasPrice: BigInt - " Gas used in this transaction. (Optional because not every chain will support this) " - gasUsed: BigInt + " Gas used in this transaction. (Optional because not every chain will support this) " + gasUsed: BigInt - " Gas limit of this transaction. e.g. the amount of gas the sender will pay " - gasLimit: BigInt + " Gas limit of this transaction. e.g. the amount of gas the sender will pay " + gasLimit: BigInt - " Block number of this event " - blockNumber: BigInt! + " Block number of this event " + blockNumber: BigInt! - " Timestamp of this event " - timestamp: BigInt! + " Timestamp of this event " + timestamp: BigInt! - metaMorpho: MetaMorphoPublicAllocator + metaMorphoPublicAllocator: MetaMorphoPublicAllocator - market: MetaMorphoPublicAllocatorMarket + marketPublicAllocator: MetaMorphoPublicAllocatorMarket - withdrawnAssets: BigInt! + withdrawnAssets: BigInt! - flowCaps: [MarketFlowCapsSet!]! @derivedFrom(field: "publicWithdrawalEvent") + flowCaps: MarketFlowCapsSet! @derivedFrom(field: "publicWithdrawalEvent") } type MarketFlowCapsSet @entity(immutable: true) { id: Bytes! - metaMorpho: MetaMorphoPublicAllocator! + metaMorphoPublicAllocator: MetaMorphoPublicAllocator! - market: MetaMorphoPublicAllocatorMarket! + marketPublicAllocator: MetaMorphoPublicAllocatorMarket! prevFlowCapIn: BigInt! flowCapIn: BigInt! diff --git a/src/public-allocator.ts b/src/public-allocator.ts index 782d178..4a6aa52 100644 --- a/src/public-allocator.ts +++ b/src/public-allocator.ts @@ -65,7 +65,7 @@ export function loadPublicAllocatorMarket( paMarket.market = mmMarket.id; const paVault = loadPublicAllocatorVault(metaMorpho); - paMarket.metaMorpho = paVault.id; + paMarket.metaMorphoPublicAllocator = paVault.id; paMarket.flowCapIn = BigInt.zero(); paMarket.flowCapOut = BigInt.zero(); @@ -102,8 +102,9 @@ export function handlePublicReallocateTo(event: PublicReallocateTo): void { ); const marketFlowCapsSet = new MarketFlowCapsSet(eventId); - marketFlowCapsSet.metaMorpho = paMarket.metaMorpho; - marketFlowCapsSet.market = paMarket.market; + marketFlowCapsSet.metaMorphoPublicAllocator = + paMarket.metaMorphoPublicAllocator; + marketFlowCapsSet.marketPublicAllocator = paMarket.market; marketFlowCapsSet.prevFlowCapIn = paMarket.flowCapIn; marketFlowCapsSet.flowCapIn = newFlowCapIn; @@ -121,8 +122,9 @@ export function handlePublicReallocateTo(event: PublicReallocateTo): void { reallocateToEvent.gasLimit = event.transaction.gasLimit; reallocateToEvent.blockNumber = event.block.number; reallocateToEvent.timestamp = event.block.timestamp; - reallocateToEvent.metaMorpho = paMarket.metaMorpho; - reallocateToEvent.market = paMarket.id; + reallocateToEvent.metaMorphoPublicAllocator = + paMarket.metaMorphoPublicAllocator; + reallocateToEvent.marketPublicAllocator = paMarket.id; reallocateToEvent.suppliedAssets = event.params.suppliedAssets; reallocateToEvent.save(); @@ -153,8 +155,9 @@ export function handlePublicWithdrawal(event: PublicWithdrawal): void { ); const marketFlowCapsSet = new MarketFlowCapsSet(eventId); - marketFlowCapsSet.metaMorpho = paMarket.metaMorpho; - marketFlowCapsSet.market = paMarket.market; + marketFlowCapsSet.metaMorphoPublicAllocator = + paMarket.metaMorphoPublicAllocator; + marketFlowCapsSet.marketPublicAllocator = paMarket.market; marketFlowCapsSet.prevFlowCapIn = paMarket.flowCapIn; marketFlowCapsSet.flowCapIn = paMarket.flowCapIn; @@ -172,8 +175,9 @@ export function handlePublicWithdrawal(event: PublicWithdrawal): void { withdrawalEvent.gasLimit = event.transaction.gasLimit; withdrawalEvent.blockNumber = event.block.number; withdrawalEvent.timestamp = event.block.timestamp; - withdrawalEvent.metaMorpho = paMarket.metaMorpho; - withdrawalEvent.market = paMarket.id; + withdrawalEvent.metaMorphoPublicAllocator = + paMarket.metaMorphoPublicAllocator; + withdrawalEvent.marketPublicAllocator = paMarket.id; withdrawalEvent.withdrawnAssets = event.params.withdrawnAssets; withdrawalEvent.save(); @@ -221,7 +225,7 @@ export function handleSetFlowCaps(event: SetFlowCaps): void { setFlowCapsEvent.gasLimit = event.transaction.gasLimit; setFlowCapsEvent.blockNumber = event.block.number; setFlowCapsEvent.timestamp = event.block.timestamp; - setFlowCapsEvent.metaMorpho = paVault.id; + setFlowCapsEvent.metaMorphoPublicAllocator = paVault.id; setFlowCapsEvent.save(); @@ -231,8 +235,9 @@ export function handleSetFlowCaps(event: SetFlowCaps): void { const paMarket = loadPublicAllocatorMarket(event.params.vault, config.id); const marketFlowCapsSet = new MarketFlowCapsSet(eventId.concat(config.id)); - marketFlowCapsSet.metaMorpho = paMarket.metaMorpho; - marketFlowCapsSet.market = paMarket.id; + marketFlowCapsSet.metaMorphoPublicAllocator = + paMarket.metaMorphoPublicAllocator; + marketFlowCapsSet.marketPublicAllocator = paMarket.id; marketFlowCapsSet.prevFlowCapIn = paMarket.flowCapIn; marketFlowCapsSet.flowCapIn = config.caps.maxIn; marketFlowCapsSet.prevFlowCapOut = paMarket.flowCapOut;