Skip to content

Commit

Permalink
feat(subgraph): handle morpho on base
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-devatom committed Jun 25, 2024
1 parent 57c6b06 commit 7554767
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
22 changes: 15 additions & 7 deletions networks.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
"mainnet": {
"MorphoBlue": {
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 0
"address": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
"startBlock": 18883124

},
"Contract": {
"address": "0x38989BBA00BDF8181F4082995b3DEAe96163aC5D"
"MetaMorphoFactory": {
"address": "0xa9c3d3a366466fa809d1ae982fb2c46e5fc41101",
"startBlock": 18925584
}
},
"goerli": {
"Contract": {
"address": "0x0000000000000000000000000000000000000000"
"base": {
"MorphoBlue": {
"address": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
"startBlock": 13977148

},
"MetaMorphoFactory": {
"address": "0xa9c3d3a366466fa809d1ae982fb2c46e5fc41101",
"startBlock": 13978134
}
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"license": "MIT",
"scripts": {
"codegen": "graph codegen",
"build": "graph build",
"build:mainnet": "graph build --network mainnet",
"build:base": "graph build --network base",
"deploy:studio:base": "graph deploy --studio morpho-blue-base --network base",
"deploy:studio:mainnet": "graph deploy --studio morpho-blue-base --network mainnet",
"create-local": "graph create --node http://localhost:8020/ morpho-org/morpho-blue",
"remove-local": "graph remove --node http://localhost:8020/ morpho-org/morpho-blue",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 morpho-org/morpho-blue",
Expand Down
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum Network {
MATIC # aka Polygon
GNOSIS
GOERLI
BASE
}

enum ProtocolType {
Expand Down
14 changes: 4 additions & 10 deletions src/initializers/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,21 @@ import {
INT_ZERO,
} from "../sdk/constants";

const MORPHO_BLUE_ADDRESS = new Map<string, Address>();
MORPHO_BLUE_ADDRESS.set(
"mainnet",
Address.fromString("0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb")
const MORPHO_BLUE_ADDRESS = Address.fromString(
"0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb"
);

let protocol: LendingProtocol | null = null;
export function getProtocol(): LendingProtocol {
if (protocol !== null) return protocol!;
protocol = LendingProtocol.load(
MORPHO_BLUE_ADDRESS.get(dataSource.network())
);
protocol = LendingProtocol.load(MORPHO_BLUE_ADDRESS);
if (protocol) return protocol!;
protocol = initBlue();
return protocol!;
}

function initBlue(): LendingProtocol {
const protocol = new LendingProtocol(
MORPHO_BLUE_ADDRESS.get(dataSource.network())
);
const protocol = new LendingProtocol(MORPHO_BLUE_ADDRESS);
protocol.protocol = "Morpho";
protocol.name = "Morpho Blue";
protocol.slug = "morpho-blue";
Expand Down
1 change: 1 addition & 0 deletions src/sdk/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { _ActiveAccount } from "../../generated/schema";
// https://thegraph.com/docs/en/hosted-service/what-is-hosted-service/#supported-networks-on-the-hosted-service
export namespace Network {
export const ARBITRUM_ONE = "ARBITRUM_ONE";
export const BASE = "BASE";
export const ARWEAVE_MAINNET = "ARWEAVE_MAINNET";
export const AURORA = "AURORA";
export const AVALANCHE = "AVALANCHE";
Expand Down

0 comments on commit 7554767

Please sign in to comment.