@morpho-org/midnight-sdk
Version:
Viem-based package for Morpho Midnight that exports protocol utilities, fetch helpers, and Midnight API utilities under a dedicated API subpath.
221 lines (220 loc) • 5.21 kB
JavaScript
import { maxUint128 } from "viem";
/**
* Centibip scale used by settlement fees.
*
* @example
* ```ts
* import { CBP } from "@morpho-org/midnight-sdk";
*
* console.log(CBP);
* ```
*/
export const CBP = 1000000000000n;
/**
* Settlement-fee time-to-maturity breakpoints in seconds.
*
* Midnight linearly interpolates each market's seven settlement-fee cbp
* buckets across these breakpoints.
*
* @example
* ```ts
* import { SETTLEMENT_FEE_BREAKPOINTS } from "@morpho-org/midnight-sdk";
*
* console.log(SETTLEMENT_FEE_BREAKPOINTS[1]);
* ```
*/
export const SETTLEMENT_FEE_BREAKPOINTS = [
0n,
1n * 24n * 60n * 60n,
7n * 24n * 60n * 60n,
30n * 24n * 60n * 60n,
90n * 24n * 60n * 60n,
180n * 24n * 60n * 60n,
360n * 24n * 60n * 60n,
];
/**
* Maximum Midnight tick.
*
* @example
* ```ts
* import { MAX_TICK } from "@morpho-org/midnight-sdk";
*
* console.log(MAX_TICK);
* ```
*/
export const MAX_TICK = 6744n;
/**
* WAD price quantum used by Midnight tick prices.
*
* @example
* ```ts
* import { PRICE_ROUNDING_STEP } from "@morpho-org/midnight-sdk";
*
* console.log(PRICE_ROUNDING_STEP);
* ```
*/
export const PRICE_ROUNDING_STEP = 100000000000n;
/**
* Default Midnight tick spacing.
*
* @example
* ```ts
* import { DEFAULT_TICK_SPACING } from "@morpho-org/midnight-sdk";
*
* console.log(DEFAULT_TICK_SPACING);
* ```
*/
export const DEFAULT_TICK_SPACING = 4n;
/**
* Maximum collateral entries in a Midnight market.
*
* @example
* ```ts
* import { MAX_COLLATERALS } from "@morpho-org/midnight-sdk";
*
* console.log(MAX_COLLATERALS);
* ```
*/
export const MAX_COLLATERALS = 128n;
/**
* Maximum active collateral entries per borrower.
*
* @example
* ```ts
* import { MAX_COLLATERALS_PER_BORROWER } from "@morpho-org/midnight-sdk";
*
* console.log(MAX_COLLATERALS_PER_BORROWER);
* ```
*/
export const MAX_COLLATERALS_PER_BORROWER = 16n;
/**
* Maximum settlement-fee values by Midnight fee index.
*
* @example
* ```ts
* import { MAX_SETTLEMENT_FEES } from "@morpho-org/midnight-sdk";
*
* console.log(MAX_SETTLEMENT_FEES[0]);
* ```
*/
export const MAX_SETTLEMENT_FEES = [
14000000000000n,
14000000000000n,
98000000000000n,
417000000000000n,
1250000000000000n,
2500000000000000n,
5000000000000000n,
];
/**
* Maximum continuous fee per second.
*
* @example
* ```ts
* import { MAX_CONTINUOUS_FEE } from "@morpho-org/midnight-sdk";
*
* console.log(MAX_CONTINUOUS_FEE);
* ```
*/
export const MAX_CONTINUOUS_FEE = 317097919n;
/**
* Maximum value accepted by the uint128 offer cap fields.
*
* @example
* ```ts
* import { MAX_OFFER_CAP } from "@morpho-org/midnight-sdk";
*
* console.log(MAX_OFFER_CAP);
* ```
*/
export const MAX_OFFER_CAP = maxUint128;
/**
* Maximum Merkle tree height supported by the Midnight offer-tree typehash
* tables, enforced by every ratifier tree helper (Ecrecover, Setter, and V1).
*
* @example
* ```ts
* import { MAX_TREE_HEIGHT } from "@morpho-org/midnight-sdk";
*
* console.log(MAX_TREE_HEIGHT);
* ```
*/
export const MAX_TREE_HEIGHT = 20;
/**
* Seconds after maturity over which post-maturity LIF reaches the computed
* maximum liquidation incentive factor.
*
* @example
* ```ts
* import { TIME_TO_MAX_LIF } from "@morpho-org/midnight-sdk";
*
* console.log(TIME_TO_MAX_LIF);
* ```
*/
export const TIME_TO_MAX_LIF = 60n * 60n;
/**
* HashLib collateral params typehash.
*
* @example
* ```ts
* import { COLLATERAL_PARAMS_TYPEHASH } from "@morpho-org/midnight-sdk";
*
* console.log(COLLATERAL_PARAMS_TYPEHASH);
* ```
*/
export const COLLATERAL_PARAMS_TYPEHASH = "0x39ed3f928d24fd00574b1a02aba9c2483abcf5d9a3a366118c9a5aa29885b841";
/**
* HashLib market typehash.
*
* @example
* ```ts
* import { MARKET_TYPEHASH } from "@morpho-org/midnight-sdk";
*
* console.log(MARKET_TYPEHASH);
* ```
*/
export const MARKET_TYPEHASH = "0x510b3862f3816a109c9340b76972e8a30984246be06e034ae12ed2934220391a";
/**
* HashLib offer typehash.
*
* @example
* ```ts
* import { OFFER_TYPEHASH } from "@morpho-org/midnight-sdk";
*
* console.log(OFFER_TYPEHASH);
* ```
*/
export const OFFER_TYPEHASH = "0x9905214264a9fb7b6cc1b0e33db7a04687c6e4185a84755d29914314aa9d8906";
/**
* HashLib PriceRatifierV1 offer typehash.
*
* @example
* ```ts
* import { PRICE_RATIFIER_V1_OFFER_TYPEHASH } from "@morpho-org/midnight-sdk";
*
* console.log(PRICE_RATIFIER_V1_OFFER_TYPEHASH);
* ```
*/
export const PRICE_RATIFIER_V1_OFFER_TYPEHASH = "0x62a94097fbcb9b56e3cf7b4f7bb075b49540b1364815434ff4b16bc4decb303d";
/**
* HashLib RateRatifierV1 offer typehash.
*
* @example
* ```ts
* import { RATE_RATIFIER_V1_OFFER_TYPEHASH } from "@morpho-org/midnight-sdk";
*
* console.log(RATE_RATIFIER_V1_OFFER_TYPEHASH);
* ```
*/
export const RATE_RATIFIER_V1_OFFER_TYPEHASH = "0x8e0f9c17bf7e919b5f22e8c6c4e787905f45864a4be441067bbd2e65b35c3de1";
/**
* EcrecoverRatifier EIP-712 domain typehash.
*
* @example
* ```ts
* import { EIP712_DOMAIN_TYPEHASH } from "@morpho-org/midnight-sdk";
*
* console.log(EIP712_DOMAIN_TYPEHASH);
* ```
*/
export const EIP712_DOMAIN_TYPEHASH = "0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218";