Skip to content

Commit

Permalink
feat(liquidity-sdk-ethers): add public allocator options
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Feb 3, 2025
1 parent 93802eb commit 093b233
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions packages/liquidity-sdk-ethers/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MarketId, bigint>;
}

export class LiquidityLoader {
Expand Down Expand Up @@ -199,7 +213,7 @@ export class LiquidityLoader {
),
});

const maxWithdrawalUtilization = fromEntries(
parameters.maxWithdrawalUtilization ??= fromEntries(
allVaultsMarkets.flatMap(([, markets]) =>
markets.map((market) => [
market.uniqueKey,
Expand All @@ -212,9 +226,8 @@ export class LiquidityLoader {
try {
const { data: endState, withdrawals } =
startState.getMarketPublicReallocations(uniqueKey, {
...parameters,
enabled: true,
maxWithdrawalUtilization,
delay: parameters.delay,
});

return {
Expand Down

0 comments on commit 093b233

Please sign in to comment.