MetaMorpho Markets High Utilization Rate
This iterates over a specific MetaMorpho markets and looks for markets with a high utilization rate (users can define a threshold)
use Call, Aggregate, Average, Len, Range, Zip from hexagate;
source morphoBlue: address = 0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb;
param metamorphoVault: address; /* supply a metamorpho vault address here */
source noMarkets: integer = Call {
contract: metamorphoVault,
signature: "function supplyQueueLength() returns (uint256)"
};
source marketIds: list<bytes> = [
Call {
contract: metamorphoVault,
signature: "function supplyQueue(uint256) returns (bytes32)",
params: tuple(id)
}
for id in Range { start: 0, stop: noMarkets }
];
source marketStates: list<tuple<integer, integer, integer, integer, integer, integer > > = [
Call {
contract: morphoBlue,
signature: "function market(bytes32) view returns (uint128, uint128, uint128, uint128, uint128, uint128)",
params: tuple(marketId)
}
for marketId in marketIds
];
source totalSupplyAssetsAll: list<integer> = [
marketState[0] for marketState in marketStates
];
source totalBorrowAssetsAll: list<integer> = [
marketState[2] for marketState in marketStates
];
source utilizationRates: list<integer> = [
(assets[0] * 10000) / assets[1]
for assets in Zip { first: totalBorrowAssetsAll, second: totalSupplyAssetsAll }
];
source highUtilization: list<bytes> = [
marketIds[i]
for i in Range { start: 0, stop: noMarkets }
if utilizationRates[i] >= 8500
];
/* Check if the Utilization Rate is higher than 85% */
rule {
description: "Utilization Rate is lower 85% for these market ids: $highUtilization",
condition: Len { sequence: highUtilization } == 0
};Last updated