Skip to content

Commit

Permalink
feat(public-allocator): better entity naming
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-devatom committed Sep 23, 2024
1 parent 78b0762 commit b9ba4dc
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 51 deletions.
77 changes: 38 additions & 39 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}

Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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!
Expand Down
29 changes: 17 additions & 12 deletions src/public-allocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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();

Expand Down Expand Up @@ -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;
Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand All @@ -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;
Expand Down

0 comments on commit b9ba4dc

Please sign in to comment.