diff --git a/packages/liquidity-sdk-ethers/src/loader.ts b/packages/liquidity-sdk-ethers/src/loader.ts index b3259a2f..d1178710 100644 --- a/packages/liquidity-sdk-ethers/src/loader.ts +++ b/packages/liquidity-sdk-ethers/src/loader.ts @@ -17,8 +17,22 @@ import type { Provider } from "ethers"; import { apiSdk } from "./api"; export interface LiquidityParameters { - /* The delay to consider between the moment reallocations are calculated and the moment they are committed onchain. Defaults to 1h. */ + /** + * The delay to consider between the moment reallocations are calculated and the moment they are committed onchain. + * Defaults to 1h. + */ delay?: bigint; + + /** + * The default maximum utilization allowed to reach to find shared liquidity (scaled by WAD). + */ + defaultMaxWithdrawalUtilization?: bigint; + + /** + * If provided, defines the maximum utilization allowed to reach for each market, defaulting to `defaultMaxWithdrawalUtilization`. + * If not, these values are fetched from Morpho API. + */ + maxWithdrawalUtilization?: Record; } export class LiquidityLoader { @@ -199,7 +213,7 @@ export class LiquidityLoader { ), }); - const maxWithdrawalUtilization = fromEntries( + parameters.maxWithdrawalUtilization ??= fromEntries( allVaultsMarkets.flatMap(([, markets]) => markets.map((market) => [ market.uniqueKey, @@ -212,9 +226,8 @@ export class LiquidityLoader { try { const { data: endState, withdrawals } = startState.getMarketPublicReallocations(uniqueKey, { + ...parameters, enabled: true, - maxWithdrawalUtilization, - delay: parameters.delay, }); return {