Skip to content

Commit

Permalink
feat(morpho): support subtitle (#81)
Browse files Browse the repository at this point in the history
* feat(morpho): support subtitle

* feat(pt-: filtering out spectra asset
  • Loading branch information
tomrpl authored Jan 14, 2025
1 parent 3bb2a93 commit 26abb83
Show file tree
Hide file tree
Showing 2 changed files with 334 additions and 17 deletions.
167 changes: 150 additions & 17 deletions protocols/morpho/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,181 @@ category: Money Market
metadata:
pt:
- chainId: 1
address: "0x5BaE9a5D67d1CA5b09B14c91935f635CFBF3b685"
integrationUrl: https://app.morpho.org/market?id=0x8411eeb07c8e32de0b3784b6b967346a45593bfd8baeb291cc209dc195c7b3ad&network=mainnet&morphoPrice=1
address: "0x23e479ddcda990E8523494895759bD98cD2fDBF6"
subtitle: cbBTC
integrationUrl: https://app.morpho.org/market?id=0x7bf57130cf88dcfe052a4cfd6c7cce28ec7d0be7264f2a6b8a3b3f1b2fb02494&network=mainnet
description: >-
The PT-USD0++-27MAR2025 is the asset used as collateral in a Morpho
market with USDC as the loan token.
The PT-corn-SolvBTC.BBN-26DEC2024 is the asset used as collateral in a Morpho
market with cbBTC as the loan token.
- chainId: 1
address: "0x23e479ddcda990E8523494895759bD98cD2fDBF6"
subtitle: WBTC
integrationUrl: https://app.morpho.org/market?id=0xcfd9f683c6ab4b3c95e450e3faaf582c2b5fe938ef7405c4d60f2e9fd77415cc&network=mainnet
description: >-
The PT-corn-SolvBTC.BBN-26DEC2024 is the asset used as collateral in a Morpho
market with WBTC as the loan token.
- chainId: 1
address: "0x23e479ddcda990E8523494895759bD98cD2fDBF6"
subtitle: WBTC
integrationUrl: https://app.morpho.org/market?id=0x9f4d8ba585b21520f23072010bcc8f861dff2856059d785eb5b7fb00bc7c575c&network=mainnet
description: >-
The PT-corn-SolvBTC.BBN-26DEC2024 is the asset used as collateral in a Morpho
market with WBTC as the loan token.
- chainId: 1
address: "0x270d664d2Fc7D962012a787Aec8661CA83DF24EB"
integrationUrl: https://app.morpho.org/market?id=0x35669bebe1faac708df40050c4841b841e00b3b7a51fb7e091361dd0f3d3b52c&network=mainnet&morphoPrice=1
integrationUrl: https://app.morpho.org/market?id=0x35669bebe1faac708df40050c4841b841e00b3b7a51fb7e091361dd0f3d3b52c&network=mainnet
description: >-
The PT-USD0++-31OCT2024 is the asset used as collateral in a Morpho
market with USDA as the loan token.
- chainId: 1
address: "0xf7906F274c174A52d444175729E3fa98f9bde285"
integrationUrl: https://app.morpho.org/market?id=0xed9e817ac29464b3cc520bf124fb333c330021a8ae768889f414d21df35686e0&network=mainnet&morphoPrice=1
address: "0x386AE941D4262B0Ee96354499dF2ab8442734EC0"
integrationUrl: https://app.morpho.org/market?id=0x27852bb453d4fe6ec918dd27b7136bb233d210aab1758a59ed8daaeec24f7b3d&network=mainnet
description: >-
The PT-ezETH-26DEC2024 is the asset used as collateral in a Morpho
market with USDA as the loan token.
The PT-sUSDE-27FEB2025 is the asset used as collateral in a Morpho
market with USDC as the loan token.
- chainId: 1
address: "0x44A7876cA99460ef3218bf08b5f52E2dbE199566"
subtitle: LBTC
integrationUrl: https://app.morpho.org/market?id=0x17af0be1f59e3eb8e3de2ed7655ed544c9465d089f21b89c465874a6447f2590&network=mainnet
description: >-
The PT-corn-eBTC-27MAR2025 is the asset used as collateral in a Morpho
market with LBTC as the loan token.
- chainId: 1
address: "0x44A7876cA99460ef3218bf08b5f52E2dbE199566"
subtitle: WBTC
integrationUrl: https://app.morpho.org/market?id=0x9dd533d05afa8dfce6a2ed82219e1c1dcebb16fe7722fb5912b989ef69df487f&network=mainnet
description: >-
The PT-corn-eBTC-27MAR2025 is the asset used as collateral in a Morpho
market with WBTC as the loan token.
- chainId: 1
address: "0x5BaE9a5D67d1CA5b09B14c91935f635CFBF3b685"
subtitle: USDC
integrationUrl: https://app.morpho.org/market?id=0x147977320f168afc651b7e5a1849cc1b1e64e329e1bf0212fa49dcb2856074a4&network=mainnet
description: >-
The PT-USD0++-27MAR2025 is the asset used as collateral in a Morpho
market with USDC as the loan token.
- chainId: 1
address: "0x5BaE9a5D67d1CA5b09B14c91935f635CFBF3b685"
subtitle: USDC
integrationUrl: https://app.morpho.org/market?id=0x8411eeb07c8e32de0b3784b6b967346a45593bfd8baeb291cc209dc195c7b3ad&network=mainnet
description: >-
The PT-USD0++-27MAR2025 is the asset used as collateral in a Morpho
market with USDC as the loan token.
- chainId: 8453
address: "0x5d746848005507DA0b1717C137A10C30AD9ee307"
subtitle: cbBTC
integrationUrl: https://app.morpho.org/market?id=0x9a697eb760dd12aaea23699c96ea2ebbfe48b7af64138d92c4d232b9ed380024&network=base
description: >-
The PT-LBTC-29MAY2025 is the asset used as collateral in a Morpho
market with cbBTC as the loan token.
- chainId: 8453
address: "0x5d746848005507DA0b1717C137A10C30AD9ee307"
subtitle: cbBTC
integrationUrl: https://app.morpho.org/market?id=0xaa5b2464e10b40d9b9642337987eaee5e91ed4003da62c77d7ee2edfe910188e&network=base
description: >-
The PT-LBTC-29MAY2025 is the asset used as collateral in a Morpho
market with cbBTC as the loan token.
- chainId: 8453
address: "0x5d746848005507DA0b1717C137A10C30AD9ee307"
subtitle: LBTC
integrationUrl: https://app.morpho.org/market?id=0x12c37bd01e0050e15e85e37b6bfd9a9bc357e7881a4589b6873f94512af1ce66&network=base
description: >-
The PT-LBTC-29MAY2025 is the asset used as collateral in a Morpho
market with LBTC as the loan token.
- chainId: 1
address: "0x6E43F6abce001c14C7115d20908d0c272338eAf1"
integrationUrl: https://app.morpho.org/market?id=0x1260f0313a8fdf0fc1792aa8fc2545c30227e553a23b087e5abe9bd91caf39a9&network=mainnet
description: >-
The PT-agETH-26JUN2025 is the asset used as collateral in a Morpho
market with WETH as the loan token.
- chainId: 1
address: "0x8A47b431A7D947c6a3ED6E42d501803615a97EAa"
integrationUrl: https://app.morpho.org/market?id=0xab0dcab71e65c05b7f241ea79a33452c87e62db387129e4abe15e458d433e4d8&network=mainnet
description: >-
The PT-USDe-27MAR2025 is the asset used as collateral in a Morpho
market with DAI as the loan token.
- chainId: 1
address: "0xA8c8861b5ccF8CCe0ade6811CD2A7A7d3222B0B8"
integrationUrl: https://app.morpho.org/market?id=0xcc63ab57cdcd6dd24cd42db3ebe829fb1b56da89fcd17cea6202cf6b69d02393&network=mainnet
description: >-
The PT-wstUSR-27MAR2025 is the asset used as collateral in a Morpho
market with USDC as the loan token.
- chainId: 1
address: "0xAE5099C39f023C91d3dd55244CAFB36225B0850E"
integrationUrl: https://app.morpho.org/market?id=0x8f46cd82c4c44a090c3d72bd7a84baf4e69ee50331d5deae514f86fe062b0748&network=mainnet
description: >-
The PT-sUSDE-24OCT2024 is the asset used as collateral in a Morpho
market with DAI as the loan token.
- chainId: 1
address: "0xb7de5dFCb74d25c2f21841fbd6230355C50d9308"
integrationUrl: https://app.morpho.org/market?id=0x8d177cc2597296e8ff4816be51fe2482add89de82bdfaba3118c7948a6b2bc02&network=mainnet
description: >-
The PT-sUSDE-29MAY2025 is the asset used as collateral in a Morpho
market with USDC as the loan token.
- chainId: 1
address: "0xd1A1984cc5CAcbd36F6a511877d13662C950fd62"
integrationUrl: https://app.morpho.org/market?id=0x2a3fb4e86d7294ced8be46851a4e9a5b946494b4ee373ccb464227b48aa0beb3&network=mainnet
description: >-
The PT-SolvBTC.BBN-27MAR2025 is the asset used as collateral in a Morpho
market with WBTC as the loan token.
- chainId: 1
address: "0xE00bd3Df25fb187d6ABBB620b3dfd19839947b81"
subtitle: DAI
integrationUrl: https://app.morpho.org/market?id=0x5e3e6b1e01c5708055548d82d01db741e37d03b948a7ef9f3d4b962648bcbfa7&network=mainnet&morphoPrice=1
integrationUrl: https://app.morpho.org/market?id=0x5e3e6b1e01c5708055548d82d01db741e37d03b948a7ef9f3d4b962648bcbfa7&network=mainnet
description: >-
The PT-sUSDE-27MAR2025 is the asset used as collateral in a Morpho
market with DAI as the loan token.
- chainId: 1
address: "0xE00bd3Df25fb187d6ABBB620b3dfd19839947b81"
subtitle: USDC
integrationUrl: https://app.morpho.org/market?id=0x346afa2b6d528222a2f9721ded6e7e2c40ac94877a598f5dae5013c651d2a462&network=mainnet&morphoPrice=1
integrationUrl: https://app.morpho.org/market?id=0x346afa2b6d528222a2f9721ded6e7e2c40ac94877a598f5dae5013c651d2a462&network=mainnet
description: >-
The PT-sUSDE-27MAR2025 is the asset used as collateral in a Morpho
market with USDC as the loan token.
market with USDC as the loan token.
- chainId: 1
address: "0xAE5099C39f023C91d3dd55244CAFB36225B0850E"
integrationUrl: https://app.morpho.org/market?id=0x8f46cd82c4c44a090c3d72bd7a84baf4e69ee50331d5deae514f86fe062b0748&network=mainnet&morphoPrice=1
address: "0xE08C45F3cfE70f4e03668Dc6E84Af842bEE95A68"
integrationUrl: https://app.morpho.org/market?id=0xc3250fa72657f5d956a55fd7febf5bf953c18aa04bff2e4088415b1e5c2923b0&network=mainnet
description: >-
The PT-sUSDE-24OCT2024 is the asset used as collateral in a Morpho
market with DAI as the loan token.
The PT-rsETH-26JUN2025 is the asset used as collateral in a Morpho
market with WETH as the loan token.
- chainId: 1
address: "0xEc5a52C685CC3Ad79a6a347aBACe330d69e0b1eD"
subtitle: LBTC
integrationUrl: https://app.morpho.org/market?id=0x3170feb9e3c0172beb9901f6035e4e005f42177c5c14e8c0538c27078864654e&network=mainnet
description: >-
The PT-LBTC-27MAR2025 is the asset used as collateral in a Morpho
market with LBTC as the loan token.
- chainId: 1
address: "0xEc5a52C685CC3Ad79a6a347aBACe330d69e0b1eD"
subtitle: WBTC
integrationUrl: https://app.morpho.org/market?id=0x198132864e7974fb451dfebeb098b3b7e7e65566667fb1cf1116db4fb2ad23f9&network=mainnet
description: >-
The PT-LBTC-27MAR2025 is the asset used as collateral in a Morpho
market with WBTC as the loan token.
- chainId: 1
address: "0xEc5a52C685CC3Ad79a6a347aBACe330d69e0b1eD"
subtitle: WBTC
integrationUrl: https://app.morpho.org/market?id=0xa39263bf7275f772863c464ef4e9e972aaa0f1a6a1bf2a47f92bf57a542d2458&network=mainnet
description: >-
The PT-LBTC-27MAR2025 is the asset used as collateral in a Morpho
market with WBTC as the loan token.
- chainId: 1
address: "0xEe9085fC268F6727d5D4293dBABccF901ffDCC29"
integrationUrl: https://app.morpho.org/market?id=0xe37784e5ff9c2795395c5a41a0cb7ae1da4a93d67bfdd8654b9ff86b3065941c&network=mainnet&morphoPrice=1
integrationUrl: https://app.morpho.org/market?id=0xe37784e5ff9c2795395c5a41a0cb7ae1da4a93d67bfdd8654b9ff86b3065941c&network=mainnet
description: >-
The PT-sUSDE-26DEC2024 is the asset used as collateral in a Morpho
market with DAI as the loan token.
- chainId: 1
address: "0xf696FE29Ef85E892b5926313897D178288faA07e"
integrationUrl: https://app.morpho.org/market?id=0x19ab5f7fa9a014d6e5c07384ac34f56e517f449c75f3c9cdc1e0ccd06313419b&network=mainnet
description: >-
The PT-USD0++-26JUN2025 is the asset used as collateral in a Morpho
market with USDC as the loan token.
- chainId: 1
address: "0xf7906F274c174A52d444175729E3fa98f9bde285"
integrationUrl: https://app.morpho.org/market?id=0xed9e817ac29464b3cc520bf124fb333c330021a8ae768889f414d21df35686e0&network=mainnet
description: >-
The PT-ezETH-26DEC2024 is the asset used as collateral in a Morpho
market with USDA as the loan token.
yt: []
lp: []
184 changes: 184 additions & 0 deletions protocols/morpho/script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// run this basic .ts script in a script.ts file with ts-node script.ts. the logs will correspond to the config.yaml file.

// run this basic .ts script in a script.ts file with ts-node script.ts. the logs will correspond to the config.yaml file.

interface Market {
uniqueKey: string;
whitelisted: boolean;
collateralAsset: {
address: string;
symbol: string;
priceUsd: number | null;
chain: { network: string };
} | null;
loanAsset: {
address: string;
symbol: string;
priceUsd: number | null;
chain: { network: string };
} | null;
state: {
supplyAssetsUsd: number;
collateralAssetsUsd: number;
};
}

interface GraphQLMarketsResponse {
data: {
markets: {
items: Market[];
};
};
}

function isGraphQLMarketsResponse(
value: unknown
): value is GraphQLMarketsResponse {
return (
typeof value === "object" &&
value !== null &&
"data" in value &&
typeof (value as any).data === "object" &&
"markets" in (value as any).data &&
typeof (value as any).data.markets === "object" &&
"items" in (value as any).data.markets &&
Array.isArray((value as any).data.markets.items)
);
}

export async function fetchPTData(): Promise<void> {
let skip = 0;
let hasMore = true;
const collateralMarkets = new Map<string, string[]>();
let allFilteredMarkets: Market[] = [];

console.log("name: Morpho");
console.log("icon: logo.png");
console.log("category: Money Market");
console.log("metadata:");
console.log(" pt:");

// First pass: collect all markets
while (hasMore) {
const query = ` query {
markets(first: 100, skip: ${skip}, where: { chainId_in: [1, 8453] }, orderBy: BorrowAssetsUsd, orderDirection: Desc) {
items {
uniqueKey
whitelisted
collateralAsset {
address
symbol
priceUsd
chain {
network
}
}
loanAsset {
symbol
}
}
}
}
`;

try {
const response = await fetch("https://blue-api.morpho.org/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ query }),
});

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

const responseData: unknown = await response.json();
if (!isGraphQLMarketsResponse(responseData)) {
throw new Error("Unexpected API response structure");
}

const markets = responseData.data.markets.items;
const filteredMarkets = markets.filter(
(market) =>
market.whitelisted &&
market.loanAsset &&
market.collateralAsset?.symbol?.toLowerCase().startsWith("pt-") &&
market.collateralAsset?.address.toLowerCase() !==
"0xd0097149aa4cc0d0e1fc99b8bd73fc17dc32c1e9"
);

// Store filtered markets and update collateralMarkets map
filteredMarkets.forEach((market) => {
if (!market.collateralAsset || !market.loanAsset) return;

const collateralAddress = market.collateralAsset.address.toLowerCase();
if (!collateralMarkets.has(collateralAddress)) {
collateralMarkets.set(collateralAddress, []);
}
collateralMarkets.get(collateralAddress)?.push(market.uniqueKey);
});

allFilteredMarkets.push(...filteredMarkets);
skip += 100;
hasMore = markets.length === 100;
} catch (error) {
console.error("Error fetching markets:", error);
break;
}

}

// Sort all markets by collateral asset address and output
allFilteredMarkets
.sort((a, b) => {
const addressA = a.collateralAsset?.address.toLowerCase() || "";
const addressB = b.collateralAsset?.address.toLowerCase() || "";
return addressA.localeCompare(addressB);
})
.forEach((market) => {
if (!market.collateralAsset || !market.loanAsset) return;

if (
market.collateralAsset.address.toLowerCase() ===
"0xd0097149aa4cc0d0e1fc99b8bd73fc17dc32c1e9"
)
return;

const chainId =
market.collateralAsset.chain.network.toLowerCase() === "ethereum"
? 1
: 8453;

console.log(` - chainId: ${chainId}`);
console.log(` address: "${market.collateralAsset.address}"`);

const collateralAddress = market.collateralAsset.address.toLowerCase();
const marketsCount =
collateralMarkets.get(collateralAddress)?.length || 0;
if (marketsCount > 1) {
console.log(` subtitle: ${market.loanAsset.symbol}`);
}

console.log(
` integrationUrl: https://app.morpho.org/market?id=${
market.uniqueKey
}&network=${chainId === 1 ? "mainnet" : "base"}`
);
console.log(` description: >-`);
console.log(
` The ${market.collateralAsset.symbol} is the asset used as collateral in a Morpho`
);
console.log(
` market with ${market.loanAsset.symbol} as the loan token.`
);
});

console.log(" yt: []");
console.log(" lp: []");
}

fetchPTData().then(() => {
// Done
});

0 comments on commit 26abb83

Please sign in to comment.