-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(metamorpho): handle metamorpho v1.1
- Loading branch information
1 parent
6c9ad74
commit cb8747e
Showing
7 changed files
with
232 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; | ||
|
||
import { CreateMetaMorpho as CreateMetaMorphoEvent } from "../generated/MetaMorphoFactory/MetaMorphoFactory"; | ||
import { InterestRate, MetaMorpho } from "../generated/schema"; | ||
import { MetaMorpho as MetaMorphoTemplate } from "../generated/templates"; | ||
|
||
import { getZeroMarket } from "./initializers/markets"; | ||
import { AccountManager } from "./sdk/account"; | ||
import { InterestRateSide, InterestRateType } from "./sdk/constants"; | ||
import { TokenManager } from "./sdk/token"; | ||
|
||
export function handleCreateMetaMorpho(event: CreateMetaMorphoEvent): void { | ||
MetaMorphoTemplate.create(event.params.metaMorpho); | ||
const metaMorpho = new MetaMorpho(event.params.metaMorpho); | ||
|
||
metaMorpho.name = event.params.name; | ||
metaMorpho.symbol = event.params.symbol; | ||
metaMorpho.decimals = 18; | ||
metaMorpho.version = "1.1"; | ||
metaMorpho.asset = new TokenManager(event.params.asset, event).getToken().id; | ||
|
||
metaMorpho.owner = new AccountManager( | ||
event.params.initialOwner | ||
).getAccount().id; | ||
|
||
metaMorpho.timelock = event.params.initialTimelock; | ||
|
||
metaMorpho.fee = BigInt.zero(); | ||
metaMorpho.feeAccrued = BigInt.zero(); | ||
metaMorpho.feeAccruedAssets = BigInt.zero(); | ||
|
||
metaMorpho.lastTotalAssets = BigInt.zero(); | ||
metaMorpho.totalShares = BigInt.zero(); | ||
metaMorpho.idle = BigInt.zero(); | ||
|
||
metaMorpho.supplyQueue = []; | ||
metaMorpho.withdrawQueue = []; | ||
|
||
const rate = new InterestRate(metaMorpho.id.toHexString() + "-supply"); | ||
rate.rate = BigDecimal.zero(); | ||
rate.market = getZeroMarket(event).id; | ||
rate.type = InterestRateType.VARIABLE; | ||
rate.side = InterestRateSide.LENDER; | ||
rate.save(); | ||
|
||
metaMorpho.rate = rate.id; | ||
|
||
metaMorpho.account = new AccountManager( | ||
event.params.metaMorpho | ||
).getAccount().id; | ||
|
||
metaMorpho.hasPublicAllocator = false; | ||
|
||
metaMorpho.save(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.