@morpho-org/liquidity-sdk-viem
v1.3.4
Published
Viem-based package that helps seamlessly calculate the liquidity available through the PublicAllocator.
Downloads
316
Keywords
Readme
@morpho-org/liquidity-sdk-viem
Viem-based package that provides utilities to build viem-based liquidity bots on Morpho and examples using Flashbots and Morpho's GraphQL API.
Installation
npm install @morpho-org/liquidity-sdk-viemyarn add @morpho-org/liquidity-sdk-viemGetting Started
Fetch from API or RPC
import { LiquidityLoader } from "@morpho-org/liquidity-sdk-viem";
const loader = new LiquidityLoader(
client // viem client.
);
const [withdrawals1, withdrawals2] = await Promise.all([
loader.fetch(
"0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc" as MarketId,
"api"
),
loader.fetch(
"0xe475337d11be1db07f7c5a156e511f05d1844308e66e17d2ba5da0839d3b34d9" as MarketId,
"rpc"
),
]);Fetch only from API
import { ChainId } from "@morpho-org/blue-sdk";
import { LiquidityLoader } from "@morpho-org/liquidity-sdk-viem";
const loader = new LiquidityLoader({ chainId: ChainId.EthMainnet });
const [withdrawals1, withdrawals2] = await Promise.all([
loader.fetch(
"0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc" as MarketId
),
loader.fetch(
"0xe475337d11be1db07f7c5a156e511f05d1844308e66e17d2ba5da0839d3b34d9" as MarketId
),
]);