@morpho-dev/router 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +67 -71
  2. package/dist/cli.js +3209 -1252
  3. package/dist/drizzle/migrations/0017_dusty_the_hunter.sql +1 -0
  4. package/dist/drizzle/migrations/0018_add_chain_collector_constraints.sql +3 -0
  5. package/dist/drizzle/migrations/0019_add-obligation-units-shares.sql +2 -0
  6. package/dist/drizzle/migrations/0020_add-session.sql +1 -0
  7. package/dist/drizzle/migrations/0021_drop_chain_collector_epoch_indexes.sql +2 -0
  8. package/dist/drizzle/migrations/0021_migrate-rate-to-price.sql +15 -0
  9. package/dist/drizzle/migrations/0022_consolidate-price.sql +15 -0
  10. package/dist/drizzle/migrations/meta/0017_snapshot.json +1525 -0
  11. package/dist/drizzle/migrations/meta/0018_snapshot.json +1572 -0
  12. package/dist/drizzle/migrations/meta/0019_snapshot.json +1586 -0
  13. package/dist/drizzle/migrations/meta/_journal.json +42 -0
  14. package/dist/evm/bytecode/erc20.txt +1 -0
  15. package/dist/evm/bytecode/factory.txt +1 -0
  16. package/dist/evm/bytecode/mempool.txt +1 -0
  17. package/dist/evm/bytecode/morpho.txt +1 -0
  18. package/dist/evm/bytecode/multicall3.txt +1 -0
  19. package/dist/evm/bytecode/oracle.txt +1 -0
  20. package/dist/evm/bytecode/terms.txt +1 -0
  21. package/dist/evm/bytecode/vault.txt +1 -0
  22. package/dist/evm/bytecode/vaultV1.txt +1 -0
  23. package/dist/index.browser.d.mts +1327 -816
  24. package/dist/index.browser.d.mts.map +1 -1
  25. package/dist/index.browser.d.ts +1358 -847
  26. package/dist/index.browser.d.ts.map +1 -1
  27. package/dist/index.browser.js +2209 -1668
  28. package/dist/index.browser.js.map +1 -1
  29. package/dist/index.browser.mjs +2173 -1632
  30. package/dist/index.browser.mjs.map +1 -1
  31. package/dist/index.node.d.mts +1885 -1222
  32. package/dist/index.node.d.mts.map +1 -1
  33. package/dist/index.node.d.ts +1885 -1222
  34. package/dist/index.node.d.ts.map +1 -1
  35. package/dist/index.node.js +1984 -1016
  36. package/dist/index.node.js.map +1 -1
  37. package/dist/index.node.mjs +1963 -1014
  38. package/dist/index.node.mjs.map +1 -1
  39. package/docs/integrator.md +78 -0
  40. package/package.json +11 -5
@@ -8,15 +8,15 @@ import { Client } from "openapi-fetch";
8
8
 
9
9
  //#region rolldown:runtime
10
10
  declare namespace BookResponse_d_exports {
11
- export { BookLevelResponse, from$13 as from };
11
+ export { BookLevelResponse, from$14 as from };
12
12
  }
13
13
  type BookLevelResponse = {
14
- rate: string;
14
+ price: string;
15
15
  assets: string;
16
16
  count: number;
17
17
  };
18
- declare function from$13(level: {
19
- rate: bigint;
18
+ declare function from$14(level: {
19
+ price: bigint;
20
20
  assets: bigint;
21
21
  count: number;
22
22
  }): BookLevelResponse;
@@ -29,10 +29,11 @@ declare const CollectorHealth: z.ZodObject<{
29
29
  updated_at: z.ZodNullable<z.ZodString>;
30
30
  lag: z.ZodNullable<z.ZodNumber>;
31
31
  status: z.ZodEnum<{
32
+ unknown: "unknown";
32
33
  live: "live";
33
34
  lagging: "lagging";
34
- unknown: "unknown";
35
35
  }>;
36
+ initialized: z.ZodBoolean;
36
37
  }, z.core.$strip>;
37
38
  declare const CollectorsHealthResponse: z.ZodArray<z.ZodObject<{
38
39
  name: z.ZodString;
@@ -41,28 +42,37 @@ declare const CollectorsHealthResponse: z.ZodArray<z.ZodObject<{
41
42
  updated_at: z.ZodNullable<z.ZodString>;
42
43
  lag: z.ZodNullable<z.ZodNumber>;
43
44
  status: z.ZodEnum<{
45
+ unknown: "unknown";
44
46
  live: "live";
45
47
  lagging: "lagging";
46
- unknown: "unknown";
47
48
  }>;
49
+ initialized: z.ZodBoolean;
48
50
  }, z.core.$strip>>;
49
51
  declare const ChainHealth: z.ZodObject<{
50
52
  chain_id: z.ZodNumber;
51
- local_block_number: z.ZodNumber;
53
+ local_block_number: z.ZodNullable<z.ZodNumber>;
52
54
  remote_block_number: z.ZodNullable<z.ZodNumber>;
53
- updated_at: z.ZodString;
55
+ updated_at: z.ZodNullable<z.ZodString>;
56
+ initialized: z.ZodBoolean;
54
57
  }, z.core.$strip>;
55
58
  declare const ChainsHealthResponse: z.ZodArray<z.ZodObject<{
56
59
  chain_id: z.ZodNumber;
57
- local_block_number: z.ZodNumber;
60
+ local_block_number: z.ZodNullable<z.ZodNumber>;
58
61
  remote_block_number: z.ZodNullable<z.ZodNumber>;
59
- updated_at: z.ZodString;
62
+ updated_at: z.ZodNullable<z.ZodString>;
63
+ initialized: z.ZodBoolean;
60
64
  }, z.core.$strip>>;
61
65
  declare const RouterStatusResponse: z.ZodObject<{
62
66
  status: z.ZodEnum<{
63
67
  live: "live";
64
68
  syncing: "syncing";
65
69
  }>;
70
+ initialized: z.ZodBoolean;
71
+ missing_chains: z.ZodArray<z.ZodNumber>;
72
+ missing_collectors: z.ZodArray<z.ZodObject<{
73
+ chain_id: z.ZodNumber;
74
+ name: z.ZodString;
75
+ }, z.core.$strip>>;
66
76
  }, z.core.$strip>;
67
77
  type CollectorsHealthResponse = z.infer<typeof CollectorsHealthResponse>;
68
78
  type ChainsHealthResponse = z.infer<typeof ChainsHealthResponse>;
@@ -330,7 +340,7 @@ declare const Morpho: readonly [{
330
340
  readonly stateMutability: "view";
331
341
  }];
332
342
  declare namespace Callback_d_exports {
333
- export { BuyVaultV1CallbackData, CallbackType, SellERC20CallbackData, decode$3 as decode, decodeBuyVaultV1Callback, decodeSellERC20Callback, encode$3 as encode, encodeBuyVaultV1Callback, encodeSellERC20Callback, isEmptyCallback };
343
+ export { BuyVaultV1CallbackData, CallbackType, SellERC20CallbackData, decode$2 as decode, decodeBuyVaultV1Callback, decodeSellERC20Callback, encode$2 as encode, encodeBuyVaultV1Callback, encodeSellERC20Callback, isEmptyCallback };
334
344
  }
335
345
  declare enum CallbackType {
336
346
  BuyWithEmptyCallback = "buy_with_empty_callback",
@@ -338,7 +348,7 @@ declare enum CallbackType {
338
348
  SellERC20Callback = "sell_erc20_callback",
339
349
  }
340
350
  declare const isEmptyCallback: (offer: Offer) => boolean;
341
- declare function decode$3(type: CallbackType, data: Hex): {
351
+ declare function decode$2(type: CallbackType, data: Hex): {
342
352
  contract: Address;
343
353
  amount: bigint;
344
354
  }[];
@@ -350,8 +360,8 @@ type SellERC20CallbackData = {
350
360
  collaterals: Address[];
351
361
  amounts: bigint[];
352
362
  };
353
- declare function encode$3(type: CallbackType.BuyVaultV1Callback, data: BuyVaultV1CallbackData): Hex;
354
- declare function encode$3(type: CallbackType.SellERC20Callback, data: SellERC20CallbackData): Hex;
363
+ declare function encode$2(type: CallbackType.BuyVaultV1Callback, data: BuyVaultV1CallbackData): Hex;
364
+ declare function encode$2(type: CallbackType.SellERC20Callback, data: SellERC20CallbackData): Hex;
355
365
  declare function decodeBuyVaultV1Callback(data: Hex): Array<{
356
366
  contract: Address;
357
367
  amount: bigint;
@@ -403,7 +413,7 @@ declare class ReorgError extends BaseError {
403
413
  declare namespace Chain_d_exports {
404
414
  export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name, chainIds, chainNames, chains$1 as chains, getChain, getWhitelistedChains, streamLogs };
405
415
  }
406
- type Chain$1 = Compute<Chain<ChainFormatters, {
416
+ type Chain$1 = Compute<Omit<Chain<ChainFormatters, {
407
417
  morpho: ChainContract;
408
418
  morphoBlue: ChainContract;
409
419
  mempool: ChainContract;
@@ -413,9 +423,20 @@ type Chain$1 = Compute<Chain<ChainFormatters, {
413
423
  v1_1: ChainContract;
414
424
  };
415
425
  };
416
- }> & {
426
+ }>, "custom"> & {
417
427
  id: Id;
418
428
  name: Name;
429
+ custom: {
430
+ morpho: ChainContract;
431
+ morphoBlue: ChainContract;
432
+ mempool: ChainContract;
433
+ vaults: {
434
+ factories: {
435
+ v1_0: ChainContract;
436
+ v1_1: ChainContract;
437
+ };
438
+ };
439
+ };
419
440
  }>;
420
441
  declare const ChainId: {
421
442
  readonly ETHEREUM: 1;
@@ -461,6 +482,14 @@ declare class MissingBlockNumberError extends BaseError {
461
482
  name: string;
462
483
  constructor();
463
484
  }
485
+ declare namespace ChainRegistry_d_exports {
486
+ export { ChainRegistry, create$1 as create };
487
+ }
488
+ type ChainRegistry = {
489
+ getById: (chainId: Id) => Chain$1 | undefined;
490
+ list: () => Chain$1[];
491
+ };
492
+ declare function create$1(chains: Chain$1[]): ChainRegistry;
464
493
  //#endregion
465
494
  //#region src/core/types.d.ts
466
495
  /** Combines members of an intersection into a readable type. */
@@ -470,7 +499,7 @@ type Brand<in out ID extends string | symbol> = {
470
499
  readonly [BrandTypeId]: { readonly [id in ID]: ID };
471
500
  };
472
501
  declare namespace LLTV_d_exports {
473
- export { InvalidLLTVError, InvalidOptionError$1 as InvalidOptionError, LLTV, LLTVSchema, Options, from$12 as from };
502
+ export { InvalidLLTVError, InvalidOptionError$1 as InvalidOptionError, LLTV, LLTVSchema, Options, from$13 as from };
474
503
  }
475
504
  type LLTV = bigint & Brand<"LLTV">;
476
505
  declare const Options: readonly [0.385, 0.5, 0.625, 0.77, 0.86, 0.915, 0.945, 0.965, 0.98];
@@ -480,8 +509,8 @@ type Options = (typeof Options)[number];
480
509
  * @param lltv - The LLTV option or the scaled LLTV.
481
510
  * @returns The LLTV.
482
511
  */
483
- declare function from$12(lltv: Options | bigint): LLTV;
484
- declare namespace from$12 {
512
+ declare function from$13(lltv: Options | bigint): LLTV;
513
+ declare namespace from$13 {
485
514
  type ErrorType = InvalidOptionError$1 | InvalidLLTVError;
486
515
  }
487
516
  declare class InvalidOptionError$1 extends BaseError {
@@ -494,7 +523,7 @@ declare class InvalidLLTVError extends BaseError {
494
523
  }
495
524
  declare const LLTVSchema: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
496
525
  declare namespace Collateral_d_exports {
497
- export { Collateral, CollateralSchema, CollateralsSchema, from$11 as from, random$3 as random };
526
+ export { Collateral, CollateralSchema, CollateralsSchema, from$12 as from, random$3 as random };
498
527
  }
499
528
  type Collateral = {
500
529
  /** Asset being used as collateral. */
@@ -514,8 +543,8 @@ declare const CollateralsSchema: z$1.ZodArray<z$1.ZodObject<{
514
543
  oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
515
544
  lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
516
545
  }, z$1.core.$strip>>;
517
- declare const from$11: (parameters: from$11.Parameters) => from$11.ReturnType;
518
- declare namespace from$11 {
546
+ declare const from$12: (parameters: from$12.Parameters) => from$12.ReturnType;
547
+ declare namespace from$12 {
519
548
  type Parameters = {
520
549
  asset: Address;
521
550
  lltv: Options | bigint;
@@ -624,35 +653,127 @@ declare class DenominatorIsZeroError extends BaseError {
624
653
  readonly name = "ERC4626.DenominatorIsZeroError";
625
654
  constructor();
626
655
  }
627
- declare namespace Format_d_exports {
628
- export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
656
+ declare namespace Liquidity_d_exports {
657
+ export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateBuyVaultCallbackPoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateSellERC20CallbackPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
629
658
  }
630
- /** The snake case representation of a type with bigint values stringified. */
631
- type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
632
- /** Make arrays/tuples and object props mutable, deeply. */
633
- type DeepMutable<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends number | string | boolean | symbol | bigint | null | undefined ? T : T extends readonly [...infer R] ? { -readonly [K in keyof R]: DeepMutable<R[K]> } : T extends ReadonlyArray<infer U> ? Array<DeepMutable<U>> : T extends object ? { -readonly [K in keyof T]: DeepMutable<T[K]> } : T;
634
- /** Stringifies bigint values to strings and preserves branded primitives. */
635
- type StringifiedBigint<T> = [T] extends [bigint] ? string : [T] extends [`0x${string}`] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? { [K in keyof T]: StringifiedBigint<T[K]> } : T;
636
- /** Key remapping that also preserves branded primitives. */
637
- type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? { [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]> } : T;
638
- type ToSnakeCase<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${ToSnakeCase<Tail>}` : `${Lowercase<Head>}_${ToSnakeCase<Uncapitalize<Tail>>}` : S;
639
659
  /**
640
- * Formats object keys to snake case.
641
- * Preserves ethereum addresses as is.
642
- * Converts ethereum addresses to checksummed if used as values.
643
- * Stringifies bigint values to strings.
660
+ * Represents a liquidity pool with a unique ID and amount.
644
661
  */
645
- declare function toSnakeCase$1<T>(obj: T): Snake<T>;
662
+ type LiquidityPool = {
663
+ id: string;
664
+ amount: bigint;
665
+ };
646
666
  /**
647
- * Formats a snake case object to its camel case type.
648
- * Preserves ethereum addresses as is.
649
- * Converts checksummed ethereum addresses to lowercase if used as values.
650
- * @warning Does not unstringify bigint values.
667
+ * Represents a hierarchical relationship between two liquidity pools.
651
668
  */
652
- declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
653
- declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
669
+ type LiquidityLink = {
670
+ parentPoolId: string;
671
+ childPoolId: string;
672
+ priority: number;
673
+ };
674
+ /**
675
+ * Represents the connection between an offer and its liquidity pools.
676
+ */
677
+ type OfferLiquidityPool = {
678
+ offerHash: Hex;
679
+ poolId: string;
680
+ /**
681
+ * The available capacity/liquidity from this pool for this offer.
682
+ * Meaning varies by pool type:
683
+ * - BuyWithEmptyCallback: Matches allowance amount from pool bellow
684
+ * - SellERC20Callback: Sell Callback/Predeposited -> Maximum debt capacity calculated from collateral (collateralAmount * oraclePrice * lltv)
685
+ * - SellERC20Callback: Existing debt as negative value (reduces available capacity)
686
+ */
687
+ amount: bigint;
688
+ };
689
+ /**
690
+ * Calculate maximum debt capacity from collateral amount.
691
+ * @param amount - Collateral amount
692
+ * @param oraclePrice - Oracle price (scaled to 36 decimals)
693
+ * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
694
+ * @returns Maximum debt capacity
695
+ */
696
+ declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
697
+ /**
698
+ * Generate pool ID for balance pools.
699
+ */
700
+ declare function generateBalancePoolId(parameters: {
701
+ user: Address;
702
+ chainId: Id;
703
+ token: Address;
704
+ }): string;
705
+ /**
706
+ * Generate pool ID for allowance pools.
707
+ */
708
+ declare function generateAllowancePoolId(parameters: {
709
+ user: Address;
710
+ chainId: Id;
711
+ token: Address;
712
+ }): string;
713
+ /**
714
+ * Generate pool ID for sell ERC20 callback pools.
715
+ * Each offer has its own callback pool to prevent liquidity conflicts.
716
+ */
717
+ declare function generateSellERC20CallbackPoolId(parameters: {
718
+ user: Address;
719
+ chainId: Id;
720
+ obligationId: Hex;
721
+ token: Address;
722
+ offerHash: Hex;
723
+ }): string;
724
+ /**
725
+ * Generate pool ID for obligation collateral pools.
726
+ * Obligation collateral pools represent collateral already deposited in the obligation.
727
+ * These pools are shared across all offers with the same obligation.
728
+ */
729
+ declare function generateObligationCollateralPoolId(parameters: {
730
+ user: Address;
731
+ chainId: Id;
732
+ obligationId: Hex;
733
+ token: Address;
734
+ }): string;
735
+ /**
736
+ * Generate pool ID for buy vault callback pools.
737
+ */
738
+ declare function generateBuyVaultCallbackPoolId(parameters: {
739
+ user: Address;
740
+ chainId: Id;
741
+ vault: Address;
742
+ offerHash: Hex;
743
+ }): string;
744
+ /**
745
+ * Generate pool ID for debt pools.
746
+ */
747
+ declare function generateDebtPoolId(parameters: {
748
+ user: Address;
749
+ chainId: Id;
750
+ obligationId: Hex;
751
+ }): string;
752
+ /**
753
+ * Generate pool ID for user position in a vault.
754
+ */
755
+ declare function generateUserVaultPositionPoolId(parameters: {
756
+ user: Address;
757
+ chainId: Id;
758
+ vault: Address;
759
+ }): string;
760
+ /**
761
+ * Generate pool ID for vault position in a market.
762
+ */
763
+ declare function generateVaultPositionPoolId(parameters: {
764
+ vault: Address;
765
+ chainId: Id;
766
+ marketId: string;
767
+ }): string;
768
+ /**
769
+ * Generate pool ID for market total liquidity.
770
+ */
771
+ declare function generateMarketLiquidityPoolId(parameters: {
772
+ chainId: Id;
773
+ marketId: string;
774
+ }): string;
654
775
  declare namespace Maturity_d_exports {
655
- export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$10 as from };
776
+ export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$11 as from };
656
777
  }
657
778
  /**
658
779
  * Maturity is a number that represents a date in seconds.
@@ -682,8 +803,8 @@ type MaturityOptions = keyof typeof MaturityOptions;
682
803
  * @throws {InvalidDateError} If the maturity is in seconds but not a valid date.
683
804
  * @throws {InvalidOptionError} If the maturity is not a valid option.
684
805
  */
685
- declare function from$10(ts: from$10.Parameters): Maturity;
686
- declare namespace from$10 {
806
+ declare function from$11(ts: from$11.Parameters): Maturity;
807
+ declare namespace from$11 {
687
808
  type Parameters = number | MaturityOptions;
688
809
  type ErrorType = InvalidFormatError | InvalidDateError | InvalidOptionError;
689
810
  }
@@ -699,72 +820,47 @@ declare class InvalidOptionError extends BaseError {
699
820
  readonly name = "Maturity.InvalidOptionError";
700
821
  constructor(input: string);
701
822
  }
702
- declare namespace Offer_d_exports {
703
- export { AccountNotSetError, InvalidOfferError, Offer, OfferConsumed, OfferHashSchema, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$2 as decode, domain, encode$2 as encode, from$9 as from, fromSnakeCase$2 as fromSnakeCase, hash, obligationId, random$2 as random, serialize, sign, signatureMsg, toSnakeCase, types };
823
+ declare namespace Format_d_exports {
824
+ export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
704
825
  }
705
- type Offer = {
706
- /** The address that made the offer. */
707
- readonly offering: Address;
708
- /** The amount of assets offered. */
709
- readonly assets: bigint;
710
- /**
711
- * The amount of assets that can be taken from the offer. takeable = min(max - consumed, available)
712
- * Where available is the total amount of assets retrievable from offering positions.
713
- */
714
- readonly takeable: bigint;
715
- /** The interest rate (with 18 decimals). */
716
- readonly rate: bigint;
717
- /** The date at which all interests will be paid. */
718
- readonly maturity: Maturity;
719
- /** The date at which the offer will expire. */
720
- readonly expiry: number;
721
- /** The date at which the offer will start. */
722
- readonly start: number;
723
- /** The nonce. Used for OCO (One-Cancelled-Other) mechanism. */
724
- readonly nonce: bigint;
725
- /** The side of the offer. `true` for buy, `false` for sell. */
726
- readonly buy: boolean;
727
- /** The chain id where the liquidity for this offer is located. */
728
- readonly chainId: Id;
729
- /** The token that is being borrowed. */
730
- readonly loanToken: Address;
731
- /** The exact set of collaterals required to borrow the loan token. */
732
- readonly collaterals: readonly Collateral[];
733
- /** The optional callback data to retrieve the maker funds. */
734
- readonly callback: {
735
- readonly address: Address;
736
- readonly data: Hex;
737
- readonly gasLimit: bigint;
738
- };
739
- /** The amount of assets consumed from the offer. */
740
- consumed: bigint;
741
- /** The hash of the offer. */
742
- readonly hash: Hex;
743
- /** The block number at which the offer was created. */
744
- readonly blockNumber: number;
745
- /** The signature of the offer. */
746
- signature?: Hex;
747
- };
748
- declare enum Status {
749
- VALID = "VALID",
750
- SIMULATION_ERROR = "SIMULATION_ERROR",
826
+ /** The snake case representation of a type with bigint values stringified. */
827
+ type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
828
+ /** Make arrays/tuples and object props mutable, deeply. */
829
+ type DeepMutable<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends number | string | boolean | symbol | bigint | null | undefined ? T : T extends readonly [...infer R] ? { -readonly [K in keyof R]: DeepMutable<R[K]> } : T extends ReadonlyArray<infer U> ? Array<DeepMutable<U>> : T extends object ? { -readonly [K in keyof T]: DeepMutable<T[K]> } : T;
830
+ /** Stringifies bigint values to strings and preserves branded primitives. */
831
+ type StringifiedBigint<T> = [T] extends [bigint] ? string : [T] extends [`0x${string}`] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? { [K in keyof T]: StringifiedBigint<T[K]> } : T;
832
+ /** Key remapping that also preserves branded primitives. */
833
+ type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? { [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]> } : T;
834
+ type ToSnakeCase<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${ToSnakeCase<Tail>}` : `${Lowercase<Head>}_${ToSnakeCase<Uncapitalize<Tail>>}` : S;
835
+ /**
836
+ * Formats object keys to snake case.
837
+ * Preserves ethereum addresses as is.
838
+ * Converts ethereum addresses to checksummed if used as values.
839
+ * Stringifies bigint values to strings.
840
+ */
841
+ declare function toSnakeCase$1<T>(obj: T): Snake<T>;
842
+ /**
843
+ * Formats a snake case object to its camel case type.
844
+ * Preserves ethereum addresses as is.
845
+ * Converts checksummed ethereum addresses to lowercase if used as values.
846
+ * @warning Does not unstringify bigint values.
847
+ */
848
+ declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
849
+ declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
850
+ declare namespace Obligation_d_exports {
851
+ export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$10 as from, fromSnakeCase$2 as fromSnakeCase, id, random$2 as random };
751
852
  }
752
- type Validation = {
753
- offerHash: Hex;
754
- status: Status;
853
+ type Obligation = {
854
+ /** The chain id where the liquidity for this obligation is located. */
855
+ chainId: Id;
856
+ /** The token that is being borrowed for this obligation. */
857
+ loanToken: Address;
858
+ /** The exact set of collaterals required to borrow the loan token. */
859
+ collaterals: Collateral[];
860
+ /** The maturity of the obligation. */
861
+ maturity: Maturity;
755
862
  };
756
- declare const OfferHashSchema: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
757
- declare const OfferSchema: (parameters?: {
758
- omitHash?: boolean;
759
- }) => z$1.ZodObject<{
760
- offering: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
761
- assets: z$1.ZodBigInt;
762
- rate: z$1.ZodBigInt;
763
- maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
764
- expiry: z$1.ZodNumber;
765
- start: z$1.ZodNumber;
766
- nonce: z$1.ZodBigInt;
767
- buy: z$1.ZodBoolean;
863
+ declare const ObligationSchema: z$1.ZodObject<{
768
864
  chainId: z$1.ZodNumber;
769
865
  loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
770
866
  collaterals: z$1.ZodArray<z$1.ZodObject<{
@@ -772,44 +868,228 @@ declare const OfferSchema: (parameters?: {
772
868
  oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
773
869
  lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
774
870
  }, z$1.core.$strip>>;
775
- callback: z$1.ZodObject<{
776
- address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
777
- data: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
778
- gasLimit: z$1.ZodBigInt;
779
- }, z$1.core.$strip>;
780
- signature: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
781
- consumed: z$1.ZodOptional<z$1.ZodBigInt>;
782
- takeable: z$1.ZodOptional<z$1.ZodBigInt>;
783
- blockNumber: z$1.ZodOptional<z$1.ZodNumber>;
871
+ maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
784
872
  }, z$1.core.$strip>;
785
873
  /**
786
- * Creates an offer from a plain object.
787
- * @throws {InvalidOfferError} If the offer is invalid.
788
- * @param input - The offer to create.
789
- * @returns The created offer with its hash.
790
- */
791
- declare function from$9(input: Compute<Omit<Offer, "chainId" | "hash"> & {
792
- chainId: number;
793
- }>): Offer;
794
- declare namespace from$9 {
795
- type ErrorType = InvalidOfferError;
796
- }
797
- /**
798
- * Creates an offer from a snake case object.
799
- * @throws {InvalidOfferError} If the offer is invalid.
800
- * @param input - The offer to create.
801
- * @returns The created offer with its hash.
802
- */
803
- declare function fromSnakeCase$2(input: Snake<Omit<Offer, "chainId" | "hash"> & {
804
- chainId: number;
805
- }>): Offer;
806
- /**
807
- * Converts an offer to a snake case object.
808
- * @param offer - The offer to convert.
809
- * @returns The converted offer.
810
- */
811
- declare function toSnakeCase(offer: Offer): Snake<Offer>;
812
- /**
874
+ * Creates an obligation from the given parameters.
875
+ * @constructor
876
+ * @param parameters - {@link from.Parameters}
877
+ * @returns The created obligation. {@link Obligation}
878
+ * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
879
+ *
880
+ * @example
881
+ * ```ts
882
+ * const obligation = Obligation.from({
883
+ * chainId: 1,
884
+ * loanToken: privateKeyToAccount(generatePrivateKey()).address,
885
+ * collaterals: [
886
+ * Collateral.from({
887
+ * asset: privateKeyToAccount(generatePrivateKey()).address,
888
+ * oracle: privateKeyToAccount(generatePrivateKey()).address,
889
+ * lltv: 0.965
890
+ * }),
891
+ * ],
892
+ * maturity: Maturity.from("end_of_next_quarter"),
893
+ * });
894
+ * ```
895
+ */
896
+ declare function from$10(parameters: from$10.Parameters): from$10.ReturnType;
897
+ declare namespace from$10 {
898
+ type Parameters = {
899
+ /** The chain id where the liquidity for this obligation is located. */
900
+ chainId: number;
901
+ /** The token that is being borrowed for this obligation. */
902
+ loanToken: Address;
903
+ /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
904
+ collaterals: from$12.Parameters[] | readonly from$12.Parameters[];
905
+ /** The maturity of the obligation. */
906
+ maturity: from$11.Parameters;
907
+ };
908
+ type ReturnType = Obligation;
909
+ type ErrorType = InvalidObligationError;
910
+ }
911
+ /**
912
+ * Creates an obligation from a snake case object.
913
+ * @throws If the obligation is invalid. {@link fromSnakeCase.ErrorType}
914
+ * @param input - {@link fromSnakeCase.Parameters}
915
+ * @returns The created obligation. {@link fromSnakeCase.ReturnType}
916
+ */
917
+ declare function fromSnakeCase$2(input: fromSnakeCase$2.Parameters): fromSnakeCase$2.ReturnType;
918
+ declare namespace fromSnakeCase$2 {
919
+ type Parameters = Snake<Omit<Obligation, "chainId"> & {
920
+ chainId: number;
921
+ }>;
922
+ type ReturnType = Obligation;
923
+ type ErrorType = InvalidObligationError;
924
+ }
925
+ /**
926
+ * Calculates the obligation id based on the smart contract's Obligation struct.
927
+ * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals, maturity)).
928
+ * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
929
+ * @param parameters - {@link id.Parameters}
930
+ * @returns The obligation id as a 32-byte hex string. {@link id.ReturnType}
931
+ *
932
+ * @example
933
+ * ```ts
934
+ * const obligation = Obligation.random();
935
+ * const id = Obligation.id(obligation);
936
+ * console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
937
+ * ```
938
+ */
939
+ declare function id(parameters: id.Parameters): id.ReturnType;
940
+ declare namespace id {
941
+ type Parameters = {
942
+ chainId: number;
943
+ loanToken: Address;
944
+ collaterals: {
945
+ asset: Address;
946
+ lltv: bigint;
947
+ oracle: Address;
948
+ }[];
949
+ maturity: number;
950
+ };
951
+ type ReturnType = Hex;
952
+ type ErrorType = CollateralsAreNotSortedError;
953
+ }
954
+ /**
955
+ * Generates a random obligation.
956
+ * @returns A randomly generated obligation. {@link random.ReturnType}
957
+ *
958
+ * @example
959
+ * ```ts
960
+ * const obligation = Obligation.random();
961
+ * ```
962
+ */
963
+ declare function random$2(): random$2.ReturnType;
964
+ declare namespace random$2 {
965
+ type ReturnType = Obligation;
966
+ }
967
+ declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
968
+ readonly name = "Obligation.InvalidObligationError";
969
+ constructor(error: z$1.ZodError | Error);
970
+ }
971
+ declare class CollateralsAreNotSortedError extends BaseError {
972
+ readonly name = "Obligation.CollateralsAreNotSortedError";
973
+ constructor();
974
+ }
975
+ declare namespace Offer_d_exports {
976
+ export { AccountNotSetError, InvalidOfferError, Offer, OfferConsumed, OfferInput, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$1 as decode, domain, encode$1 as encode, from$9 as from, fromSnakeCase$1 as fromSnakeCase, hash, obligationId, random$1 as random, serialize, sign, signatureMsg, toSnakeCase, types };
977
+ }
978
+ type Offer = {
979
+ /** The address that made the offer. */
980
+ readonly maker: Address;
981
+ /** The amount of assets offered. Mutually exclusive with obligationUnits and obligationShares. */
982
+ readonly assets: bigint;
983
+ /** The max debt units to trade. Mutually exclusive with assets and obligationShares. */
984
+ readonly obligationUnits: bigint;
985
+ /** The max lending shares to trade. Mutually exclusive with assets and obligationUnits. */
986
+ readonly obligationShares: bigint;
987
+ /** The price (18 decimals). */
988
+ readonly price: bigint;
989
+ /** The date at which all interests will be paid. */
990
+ readonly maturity: Maturity;
991
+ /** The date at which the offer will expire. */
992
+ readonly expiry: number;
993
+ /** The date at which the offer will start. */
994
+ readonly start: number;
995
+ /** The group. Used for OCO (One-Cancelled-Other) mechanism. */
996
+ readonly group: Hex;
997
+ /** The session. Used for session-based offer management. */
998
+ readonly session: Hex;
999
+ /** The side of the offer. `true` for buy, `false` for sell. */
1000
+ readonly buy: boolean;
1001
+ /** The chain id where the liquidity for this offer is located. */
1002
+ readonly chainId: Id;
1003
+ /** The token that is being borrowed. */
1004
+ readonly loanToken: Address;
1005
+ /** The exact set of collaterals required to borrow the loan token. */
1006
+ readonly collaterals: readonly Collateral[];
1007
+ /** The optional callback data to retrieve the maker funds. */
1008
+ readonly callback: {
1009
+ readonly address: Address;
1010
+ readonly data: Hex;
1011
+ };
1012
+ };
1013
+ declare enum Status {
1014
+ VALID = "VALID",
1015
+ SIMULATION_ERROR = "SIMULATION_ERROR",
1016
+ }
1017
+ type Validation = {
1018
+ offerHash: Hex;
1019
+ status: Status;
1020
+ };
1021
+ declare const OfferSchema: () => z$1.ZodObject<{
1022
+ maker: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1023
+ assets: z$1.ZodBigInt;
1024
+ obligationUnits: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBigInt>>;
1025
+ obligationShares: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBigInt>>;
1026
+ price: z$1.ZodBigInt;
1027
+ maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
1028
+ expiry: z$1.ZodNumber;
1029
+ start: z$1.ZodNumber;
1030
+ group: z$1.ZodPipe<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber, z$1.ZodBigInt]>, z$1.ZodTransform<`0x${string}`, string | number | bigint>>;
1031
+ session: z$1.ZodPipe<z$1.ZodDefault<z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber, z$1.ZodBigInt]>>>, z$1.ZodTransform<`0x${string}`, string | number | bigint>>;
1032
+ buy: z$1.ZodBoolean;
1033
+ chainId: z$1.ZodNumber;
1034
+ loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1035
+ collaterals: z$1.ZodArray<z$1.ZodObject<{
1036
+ asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1037
+ oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1038
+ lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
1039
+ }, z$1.core.$strip>>;
1040
+ callback: z$1.ZodObject<{
1041
+ address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1042
+ data: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1043
+ }, z$1.core.$strip>;
1044
+ }, z$1.core.$strip>;
1045
+ /**
1046
+ * Input type for creating offers. Accepts flexible group types that will be coerced to Hex.
1047
+ *
1048
+ * The `group` field accepts multiple input formats:
1049
+ * - **Hex string** (`0x...`): Padded to 32 bytes if needed
1050
+ * - **Numeric string**: Converted to hex (e.g., `"123"` -> `"0x...7b"`)
1051
+ * - **Number**: Non-negative safe integer, converted to hex
1052
+ * - **BigInt**: Non-negative, must fit in bytes32
1053
+ *
1054
+ * All values validated to be non-negative and within bytes32 range.
1055
+ */
1056
+ type OfferInput = Compute<Omit<Offer, "chainId" | "group" | "session" | "obligationUnits" | "obligationShares"> & {
1057
+ chainId: number;
1058
+ group: Hex | bigint | number | string;
1059
+ /** Optional: defaults to zero bytes32. */
1060
+ session?: Hex | bigint | number | string;
1061
+ /** Optional: defaults to 0n. Mutually exclusive with assets and obligationShares. */
1062
+ obligationUnits?: bigint;
1063
+ /** Optional: defaults to 0n. Mutually exclusive with assets and obligationUnits. */
1064
+ obligationShares?: bigint;
1065
+ }>;
1066
+ /**
1067
+ * Creates an offer from a plain object.
1068
+ * @throws {InvalidOfferError} If the offer is invalid.
1069
+ * @param input - The offer to create.
1070
+ * @returns The created offer.
1071
+ */
1072
+ declare function from$9(input: OfferInput): Offer;
1073
+ declare namespace from$9 {
1074
+ type ErrorType = InvalidOfferError;
1075
+ }
1076
+ /**
1077
+ * Creates an offer from a snake case object.
1078
+ * @throws {InvalidOfferError} If the offer is invalid.
1079
+ * @param input - The offer to create.
1080
+ * @returns The created offer.
1081
+ */
1082
+ declare function fromSnakeCase$1(input: Snake<Omit<Offer, "chainId" | "session"> & {
1083
+ chainId: number;
1084
+ session: string;
1085
+ }>): Offer;
1086
+ /**
1087
+ * Converts an offer to a snake case object.
1088
+ * @param offer - The offer to convert.
1089
+ * @returns The converted offer.
1090
+ */
1091
+ declare function toSnakeCase(offer: Offer): Snake<Offer>;
1092
+ /**
813
1093
  * Serializes an offer for merkle tree encoding.
814
1094
  * Converts BigInt fields to strings for JSON compatibility.
815
1095
  *
@@ -817,13 +1097,16 @@ declare function toSnakeCase(offer: Offer): Snake<Offer>;
817
1097
  * @returns JSON-serializable offer object
818
1098
  */
819
1099
  declare const serialize: (offer: Offer) => {
820
- offering: `0x${string}`;
1100
+ maker: `0x${string}`;
821
1101
  assets: string;
822
- rate: string;
1102
+ obligationUnits: string;
1103
+ obligationShares: string;
1104
+ price: string;
823
1105
  maturity: number;
824
1106
  expiry: number;
825
1107
  start: number;
826
- nonce: string;
1108
+ group: `0x${string}`;
1109
+ session: `0x${string}`;
827
1110
  buy: boolean;
828
1111
  chainId: Id;
829
1112
  loanToken: `0x${string}`;
@@ -835,9 +1118,7 @@ declare const serialize: (offer: Offer) => {
835
1118
  callback: {
836
1119
  address: `0x${string}`;
837
1120
  data: `0x${string}`;
838
- gasLimit: string;
839
1121
  };
840
- signature: `0x${string}` | undefined;
841
1122
  hash: `0x${string}`;
842
1123
  };
843
1124
  type RandomConfig = {
@@ -847,22 +1128,20 @@ type RandomConfig = {
847
1128
  assetsDecimals?: Record<Address, number>;
848
1129
  buy?: boolean;
849
1130
  assets?: bigint;
850
- consumed?: bigint;
851
- takeable?: bigint;
852
- offering?: Address;
1131
+ obligationUnits?: bigint;
1132
+ obligationShares?: bigint;
1133
+ maker?: Address;
853
1134
  maturity?: Maturity;
854
1135
  start?: number;
855
1136
  expiry?: number;
856
- nonce?: bigint;
857
- rate?: bigint;
1137
+ group?: Hex | bigint | number | string;
1138
+ session?: Hex | bigint | number | string;
1139
+ price?: bigint;
858
1140
  callback?: {
859
1141
  address: Address;
860
1142
  data: Hex;
861
- gasLimit: bigint;
862
1143
  };
863
1144
  collaterals?: readonly Collateral[];
864
- signature?: Hex;
865
- blockNumber?: number;
866
1145
  };
867
1146
  /**
868
1147
  * Generates a random Offer.
@@ -870,7 +1149,7 @@ type RandomConfig = {
870
1149
  * @warning The generated Offer should not be used for production usage.
871
1150
  * @returns {Offer} A randomly generated Offer object.
872
1151
  */
873
- declare function random$2(config?: RandomConfig): Offer;
1152
+ declare function random$1(config?: RandomConfig): Offer;
874
1153
  /**
875
1154
  * Creates an EIP-712 domain object.
876
1155
  * @param chainId - The chain ID.
@@ -894,13 +1173,19 @@ declare const types: {
894
1173
  readonly type: "address";
895
1174
  }];
896
1175
  readonly Offer: readonly [{
897
- readonly name: "offering";
1176
+ readonly name: "maker";
898
1177
  readonly type: "address";
899
1178
  }, {
900
1179
  readonly name: "assets";
901
1180
  readonly type: "uint256";
902
1181
  }, {
903
- readonly name: "rate";
1182
+ readonly name: "obligationUnits";
1183
+ readonly type: "uint256";
1184
+ }, {
1185
+ readonly name: "obligationShares";
1186
+ readonly type: "uint256";
1187
+ }, {
1188
+ readonly name: "price";
904
1189
  readonly type: "uint256";
905
1190
  }, {
906
1191
  readonly name: "maturity";
@@ -909,8 +1194,11 @@ declare const types: {
909
1194
  readonly name: "expiry";
910
1195
  readonly type: "uint256";
911
1196
  }, {
912
- readonly name: "nonce";
913
- readonly type: "uint256";
1197
+ readonly name: "group";
1198
+ readonly type: "bytes32";
1199
+ }, {
1200
+ readonly name: "session";
1201
+ readonly type: "bytes32";
914
1202
  }, {
915
1203
  readonly name: "buy";
916
1204
  readonly type: "bool";
@@ -940,9 +1228,6 @@ declare const types: {
940
1228
  }, {
941
1229
  readonly name: "data";
942
1230
  readonly type: "bytes";
943
- }, {
944
- readonly name: "gasLimit";
945
- readonly type: "uint256";
946
1231
  }];
947
1232
  };
948
1233
  /**
@@ -954,7 +1239,7 @@ declare const types: {
954
1239
  */
955
1240
  declare function sign(offers: Offer[], wallet: WalletClient): Promise<Hex>;
956
1241
  declare function signatureMsg(offers: Offer[]): Hex;
957
- declare function hash(offer: Omit<Offer, "hash">): Hex;
1242
+ declare function hash(offer: Offer): Hex;
958
1243
  /**
959
1244
  * Calculates the obligation id for an offer based on the smart contract's Obligation struct.
960
1245
  * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals (sorted by token address), maturity)).
@@ -962,32 +1247,32 @@ declare function hash(offer: Omit<Offer, "hash">): Hex;
962
1247
  * @returns The obligation id as a 32-byte hex string.
963
1248
  */
964
1249
  declare function obligationId(offer: Offer): Hex;
965
- declare function encode$2(offer: Offer): `0x${string}`;
966
- declare function decode$2(data: Hex, blockNumber: number | bigint): Offer;
1250
+ declare function encode$1(offer: Offer): `0x${string}`;
1251
+ declare function decode$1(data: Hex): Offer;
967
1252
  type OfferConsumed = {
968
1253
  id: string;
969
1254
  chainId: Id;
970
- offering: Address;
971
- nonce: bigint;
1255
+ maker: Address;
1256
+ group: Hex;
972
1257
  amount: bigint;
973
1258
  blockNumber: number;
974
1259
  };
975
1260
  /**
976
- * ABI for the Consumed event emitted by the Obligation contract.
1261
+ * ABI for the Consume event emitted by the Obligation contract.
977
1262
  */
978
1263
  declare const consumedEvent: {
979
1264
  readonly type: "event";
980
- readonly name: "Consumed";
1265
+ readonly name: "Consume";
981
1266
  readonly inputs: readonly [{
982
1267
  readonly name: "user";
983
1268
  readonly type: "address";
984
1269
  readonly indexed: true;
985
1270
  readonly internalType: "address";
986
1271
  }, {
987
- readonly name: "nonce";
988
- readonly type: "uint256";
1272
+ readonly name: "group";
1273
+ readonly type: "bytes32";
989
1274
  readonly indexed: true;
990
- readonly internalType: "uint256";
1275
+ readonly internalType: "bytes32";
991
1276
  }, {
992
1277
  readonly name: "amount";
993
1278
  readonly type: "uint256";
@@ -1015,284 +1300,49 @@ declare class AccountNotSetError extends BaseError {
1015
1300
  readonly name = "Offer.AccountNotSetError";
1016
1301
  constructor();
1017
1302
  }
1018
- declare namespace Liquidity_d_exports {
1019
- export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateBuyVaultCallbackPoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateSellERC20CallbackPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
1303
+ declare namespace Oracle_d_exports {
1304
+ export { Conversion, Oracle, from$8 as from };
1020
1305
  }
1021
1306
  /**
1022
- * Represents a liquidity pool with a unique ID and amount.
1307
+ * An oracle contract that provides price information for assets.
1023
1308
  */
1024
- type LiquidityPool = {
1025
- id: string;
1026
- amount: bigint;
1309
+ type Oracle = {
1310
+ /** The chain id where the oracle is deployed. */
1311
+ readonly chainId: Id;
1312
+ /** The address of the oracle contract. */
1313
+ readonly address: Address;
1314
+ /** The price returned by the oracle (in the oracle's native units), null if no price available. */
1315
+ readonly price: bigint | null;
1316
+ /** The block number at which the price was fetched. */
1317
+ readonly blockNumber: number;
1027
1318
  };
1028
1319
  /**
1029
- * Represents a hierarchical relationship between two liquidity pools.
1320
+ * Create an Oracle from a plain object.
1321
+ * @param data - The data to create the oracle from.
1322
+ * @returns The created oracle.
1030
1323
  */
1031
- type LiquidityLink = {
1032
- parentPoolId: string;
1033
- childPoolId: string;
1034
- priority: number;
1035
- };
1324
+ declare function from$8(data: from$8.Parameters): from$8.ReturnType;
1325
+ declare namespace from$8 {
1326
+ type Parameters = {
1327
+ chainId: Id;
1328
+ address: Address;
1329
+ price: string | null;
1330
+ blockNumber: number;
1331
+ };
1332
+ type ReturnType = Oracle;
1333
+ }
1036
1334
  /**
1037
- * Represents the connection between an offer and its liquidity pools.
1335
+ * Conversion utilities for converting between collateral and loan token amounts
1336
+ * using oracle prices and LLTV
1038
1337
  */
1039
- type OfferLiquidityPool = {
1040
- offerHash: Offer["hash"];
1041
- poolId: string;
1338
+ declare namespace Conversion {
1042
1339
  /**
1043
- * The available capacity/liquidity from this pool for this offer.
1044
- * Meaning varies by pool type:
1045
- * - BuyWithEmptyCallback: Matches allowance amount from pool bellow
1046
- * - SellERC20Callback: Sell Callback/Predeposited -> Maximum debt capacity calculated from collateral (collateralAmount * oraclePrice * lltv)
1047
- * - SellERC20Callback: Existing debt as negative value (reduces available capacity)
1048
- */
1049
- amount: bigint;
1050
- };
1051
- /**
1052
- * Calculate maximum debt capacity from collateral amount.
1053
- * @param amount - Collateral amount
1054
- * @param oraclePrice - Oracle price (scaled to 36 decimals)
1055
- * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
1056
- * @returns Maximum debt capacity
1057
- */
1058
- declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
1059
- /**
1060
- * Generate pool ID for balance pools.
1061
- */
1062
- declare function generateBalancePoolId(parameters: {
1063
- user: Address;
1064
- chainId: Id;
1065
- token: Address;
1066
- }): string;
1067
- /**
1068
- * Generate pool ID for allowance pools.
1069
- */
1070
- declare function generateAllowancePoolId(parameters: {
1071
- user: Address;
1072
- chainId: Id;
1073
- token: Address;
1074
- }): string;
1075
- /**
1076
- * Generate pool ID for sell ERC20 callback pools.
1077
- * Each offer has its own callback pool to prevent liquidity conflicts.
1078
- */
1079
- declare function generateSellERC20CallbackPoolId(parameters: {
1080
- user: Address;
1081
- chainId: Id;
1082
- obligationId: Hex;
1083
- token: Address;
1084
- offerHash: Hex;
1085
- }): string;
1086
- /**
1087
- * Generate pool ID for obligation collateral pools.
1088
- * Obligation collateral pools represent collateral already deposited in the obligation.
1089
- * These pools are shared across all offers with the same obligation.
1090
- */
1091
- declare function generateObligationCollateralPoolId(parameters: {
1092
- user: Address;
1093
- chainId: Id;
1094
- obligationId: Hex;
1095
- token: Address;
1096
- }): string;
1097
- /**
1098
- * Generate pool ID for buy vault callback pools.
1099
- */
1100
- declare function generateBuyVaultCallbackPoolId(parameters: {
1101
- user: Address;
1102
- chainId: Id;
1103
- vault: Address;
1104
- offerHash: Hex;
1105
- }): string;
1106
- /**
1107
- * Generate pool ID for debt pools.
1108
- */
1109
- declare function generateDebtPoolId(parameters: {
1110
- user: Address;
1111
- chainId: Id;
1112
- obligationId: Hex;
1113
- }): string;
1114
- /**
1115
- * Generate pool ID for user position in a vault.
1116
- */
1117
- declare function generateUserVaultPositionPoolId(parameters: {
1118
- user: Address;
1119
- chainId: Id;
1120
- vault: Address;
1121
- }): string;
1122
- /**
1123
- * Generate pool ID for vault position in a market.
1124
- */
1125
- declare function generateVaultPositionPoolId(parameters: {
1126
- vault: Address;
1127
- chainId: Id;
1128
- marketId: string;
1129
- }): string;
1130
- /**
1131
- * Generate pool ID for market total liquidity.
1132
- */
1133
- declare function generateMarketLiquidityPoolId(parameters: {
1134
- chainId: Id;
1135
- marketId: string;
1136
- }): string;
1137
- declare namespace Obligation_d_exports {
1138
- export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$8 as from, fromSnakeCase$1 as fromSnakeCase, id, random$1 as random };
1139
- }
1140
- type Obligation = {
1141
- /** The chain id where the liquidity for this obligation is located. */
1142
- chainId: Id;
1143
- /** The token that is being borrowed for this obligation. */
1144
- loanToken: Address;
1145
- /** The exact set of collaterals required to borrow the loan token. */
1146
- collaterals: Collateral[];
1147
- /** The maturity of the obligation. */
1148
- maturity: Maturity;
1149
- };
1150
- declare const ObligationSchema: z$1.ZodObject<{
1151
- chainId: z$1.ZodNumber;
1152
- loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1153
- collaterals: z$1.ZodArray<z$1.ZodObject<{
1154
- asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1155
- oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1156
- lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
1157
- }, z$1.core.$strip>>;
1158
- maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
1159
- }, z$1.core.$strip>;
1160
- /**
1161
- * Creates an obligation from the given parameters.
1162
- * @constructor
1163
- * @param parameters - {@link from.Parameters}
1164
- * @returns The created obligation. {@link Obligation}
1165
- * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
1166
- *
1167
- * @example
1168
- * ```ts
1169
- * const obligation = Obligation.from({
1170
- * chainId: 1,
1171
- * loanToken: privateKeyToAccount(generatePrivateKey()).address,
1172
- * collaterals: [
1173
- * Collateral.from({
1174
- * asset: privateKeyToAccount(generatePrivateKey()).address,
1175
- * oracle: privateKeyToAccount(generatePrivateKey()).address,
1176
- * lltv: 0.965
1177
- * }),
1178
- * ],
1179
- * maturity: Maturity.from("end_of_next_quarter"),
1180
- * });
1181
- * ```
1182
- */
1183
- declare function from$8(parameters: from$8.Parameters): from$8.ReturnType;
1184
- declare namespace from$8 {
1185
- type Parameters = {
1186
- /** The chain id where the liquidity for this obligation is located. */
1187
- chainId: number;
1188
- /** The token that is being borrowed for this obligation. */
1189
- loanToken: Address;
1190
- /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
1191
- collaterals: from$11.Parameters[] | readonly from$11.Parameters[];
1192
- /** The maturity of the obligation. */
1193
- maturity: from$10.Parameters;
1194
- };
1195
- type ReturnType = Obligation;
1196
- type ErrorType = InvalidObligationError;
1197
- }
1198
- /**
1199
- * Creates an obligation from a snake case object.
1200
- * @throws If the obligation is invalid. {@link fromSnakeCase.ErrorType}
1201
- * @param input - {@link fromSnakeCase.Parameters}
1202
- * @returns The created obligation. {@link fromSnakeCase.ReturnType}
1203
- */
1204
- declare function fromSnakeCase$1(input: fromSnakeCase$1.Parameters): fromSnakeCase$1.ReturnType;
1205
- declare namespace fromSnakeCase$1 {
1206
- type Parameters = Snake<Omit<Obligation, "chainId"> & {
1207
- chainId: number;
1208
- }>;
1209
- type ReturnType = Obligation;
1210
- type ErrorType = InvalidObligationError;
1211
- }
1212
- /**
1213
- * Calculates the obligation id based on the smart contract's Obligation struct.
1214
- * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals, maturity)).
1215
- * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
1216
- * @param obligation - {@link id.Parameters}
1217
- * @returns The obligation id as a 32-byte hex string. {@link id.ReturnType}
1218
- *
1219
- * @example
1220
- * ```ts
1221
- * const obligation = Obligation.random();
1222
- * const id = Obligation.id(obligation);
1223
- * console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
1224
- * ```
1225
- */
1226
- declare function id(obligation: id.Parameters): id.ReturnType;
1227
- declare namespace id {
1228
- type Parameters = Obligation;
1229
- type ReturnType = Hex;
1230
- type ErrorType = CollateralsAreNotSortedError;
1231
- }
1232
- /**
1233
- * Generates a random obligation.
1234
- * @returns A randomly generated obligation. {@link random.ReturnType}
1235
- *
1236
- * @example
1237
- * ```ts
1238
- * const obligation = Obligation.random();
1239
- * ```
1240
- */
1241
- declare function random$1(): random$1.ReturnType;
1242
- declare namespace random$1 {
1243
- type ReturnType = Obligation;
1244
- }
1245
- declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
1246
- readonly name = "Obligation.InvalidObligationError";
1247
- constructor(error: z$1.ZodError | Error);
1248
- }
1249
- declare class CollateralsAreNotSortedError extends BaseError {
1250
- readonly name = "Obligation.CollateralsAreNotSortedError";
1251
- constructor();
1252
- }
1253
- declare namespace Oracle_d_exports {
1254
- export { Conversion, Oracle, from$7 as from };
1255
- }
1256
- /**
1257
- * An oracle contract that provides price information for assets.
1258
- */
1259
- type Oracle = {
1260
- /** The chain id where the oracle is deployed. */
1261
- readonly chainId: Id;
1262
- /** The address of the oracle contract. */
1263
- readonly address: Address;
1264
- /** The price returned by the oracle (in the oracle's native units), null if no price available. */
1265
- readonly price: bigint | null;
1266
- /** The block number at which the price was fetched. */
1267
- readonly blockNumber: number;
1268
- };
1269
- /**
1270
- * Create an Oracle from a plain object.
1271
- * @param data - The data to create the oracle from.
1272
- * @returns The created oracle.
1273
- */
1274
- declare function from$7(data: from$7.Parameters): from$7.ReturnType;
1275
- declare namespace from$7 {
1276
- type Parameters = {
1277
- chainId: Id;
1278
- address: Address;
1279
- price: string | null;
1280
- blockNumber: number;
1281
- };
1282
- type ReturnType = Oracle;
1283
- }
1284
- /**
1285
- * Conversion utilities for converting between collateral and loan token amounts
1286
- * using oracle prices and LLTV
1287
- */
1288
- declare namespace Conversion {
1289
- /**
1290
- * Converts a collateral amount to loan token
1291
- * Uses the formula: (amount * price / 10^36) * lltv / 10^18
1292
- *
1293
- * @param amount - The collateral amount to convert
1294
- * @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
1295
- * @returns The equivalent loan token amount
1340
+ * Converts a collateral amount to loan token
1341
+ * Uses the formula: (amount * price / 10^36) * lltv / 10^18
1342
+ *
1343
+ * @param amount - The collateral amount to convert
1344
+ * @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
1345
+ * @returns The equivalent loan token amount
1296
1346
  */
1297
1347
  function collateralToLoan(amount: bigint, params: {
1298
1348
  price: bigint;
@@ -1313,7 +1363,7 @@ declare namespace Conversion {
1313
1363
  }): bigint;
1314
1364
  }
1315
1365
  declare namespace Position_d_exports {
1316
- export { Position, Type, from$6 as from };
1366
+ export { Position, Type, from$7 as from };
1317
1367
  }
1318
1368
  type Position = {
1319
1369
  /** The chain id. */
@@ -1347,8 +1397,8 @@ declare enum Type {
1347
1397
  * @param parameters - {@link from.Parameters}
1348
1398
  * @returns The created Position. {@link from.ReturnType}
1349
1399
  */
1350
- declare function from$6(parameters: from$6.Parameters): from$6.ReturnType;
1351
- declare namespace from$6 {
1400
+ declare function from$7(parameters: from$7.Parameters): from$7.ReturnType;
1401
+ declare namespace from$7 {
1352
1402
  type Parameters = {
1353
1403
  chainId: Id;
1354
1404
  contract: Address;
@@ -1361,27 +1411,27 @@ declare namespace from$6 {
1361
1411
  type ReturnType = Position;
1362
1412
  }
1363
1413
  declare namespace Quote_d_exports {
1364
- export { InvalidQuoteError, Quote, QuoteSchema, from$5 as from, fromSnakeCase, random };
1414
+ export { InvalidQuoteError, Quote, QuoteSchema, from$6 as from, fromSnakeCase, random };
1365
1415
  }
1366
1416
  type Quote = {
1367
1417
  /** The obligation id. */
1368
1418
  obligationId: Hex;
1369
1419
  ask: {
1370
- /** The highest interest rate the seller will accept to pay for the obligation. (18 decimals). */
1371
- rate: bigint;
1420
+ /** The ask price for the obligation. (18 decimals). */
1421
+ price: bigint;
1372
1422
  };
1373
1423
  bid: {
1374
- /** The lowest interest rate a buyer is willing to be paid for the obligation. (18 decimals). */
1375
- rate: bigint;
1424
+ /** The bid price for the obligation. (18 decimals). */
1425
+ price: bigint;
1376
1426
  };
1377
1427
  };
1378
1428
  declare const QuoteSchema: z$1.ZodObject<{
1379
1429
  obligationId: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1380
1430
  ask: z$1.ZodObject<{
1381
- rate: z$1.ZodBigInt;
1431
+ price: z$1.ZodBigInt;
1382
1432
  }, z$1.core.$strip>;
1383
1433
  bid: z$1.ZodObject<{
1384
- rate: z$1.ZodBigInt;
1434
+ price: z$1.ZodBigInt;
1385
1435
  }, z$1.core.$strip>;
1386
1436
  }, z$1.core.$strip>;
1387
1437
  /**
@@ -1393,11 +1443,11 @@ declare const QuoteSchema: z$1.ZodObject<{
1393
1443
  *
1394
1444
  * @example
1395
1445
  * ```ts
1396
- * const quote = Quote.from({ obligationId: "0x123", ask: { assets: 100n, rate: 100n }, bid: { assets: 100n, rate: 100n } });
1446
+ * const quote = Quote.from({ obligationId: "0x123", ask: { price: 100n }, bid: { price: 100n } });
1397
1447
  * ```
1398
1448
  */
1399
- declare function from$5(parameters: from$5.Parameters): from$5.ReturnType;
1400
- declare namespace from$5 {
1449
+ declare function from$6(parameters: from$6.Parameters): from$6.ReturnType;
1450
+ declare namespace from$6 {
1401
1451
  type Parameters = Quote;
1402
1452
  type ReturnType = Quote;
1403
1453
  type ErrorType = InvalidQuoteError;
@@ -1412,7 +1462,7 @@ declare function fromSnakeCase(snake: fromSnakeCase.Parameters): fromSnakeCase.R
1412
1462
  declare namespace fromSnakeCase {
1413
1463
  type Parameters = Snake<Quote>;
1414
1464
  type ReturnType = Quote;
1415
- type ErrorType = from$5.ErrorType;
1465
+ type ErrorType = from$6.ErrorType;
1416
1466
  }
1417
1467
  /**
1418
1468
  * Generates a random quote.
@@ -1427,14 +1477,14 @@ declare function random(): random.ReturnType;
1427
1477
  declare namespace random {
1428
1478
  type Parameters = never;
1429
1479
  type ReturnType = Quote;
1430
- type ErrorType = from$5.ErrorType;
1480
+ type ErrorType = from$6.ErrorType;
1431
1481
  }
1432
1482
  declare class InvalidQuoteError extends BaseError<z$1.ZodError | Error> {
1433
1483
  readonly name = "Quote.InvalidQuoteError";
1434
1484
  constructor(error: z$1.ZodError | Error);
1435
1485
  }
1436
1486
  declare namespace Transfer_d_exports {
1437
- export { Transfer, from$4 as from };
1487
+ export { Transfer, from$5 as from };
1438
1488
  }
1439
1489
  type Transfer = {
1440
1490
  id: string;
@@ -1457,8 +1507,8 @@ type Transfer = {
1457
1507
  * const transfer = Transfer.from({ id: "1", chainId: 1, contract: "0x123", from: "0x456", to: "0x789", value: 100n, blockNumber: 100n });
1458
1508
  * ```
1459
1509
  */
1460
- declare function from$4(parameters: from$4.Parameters): from$4.ReturnType;
1461
- declare namespace from$4 {
1510
+ declare function from$5(parameters: from$5.Parameters): from$5.ReturnType;
1511
+ declare namespace from$5 {
1462
1512
  type Parameters = {
1463
1513
  id: string;
1464
1514
  chainId: Id;
@@ -1471,7 +1521,7 @@ declare namespace from$4 {
1471
1521
  type ReturnType = Transfer;
1472
1522
  }
1473
1523
  declare namespace Tree_d_exports {
1474
- export { DecodeError, EncodeError, Proof, Tree, TreeError, VERSION, decode$1 as decode, encode$1 as encode, encodeUnsigned, from$3 as from, proofs };
1524
+ export { DecodeError, EncodeError, Proof, Tree, TreeError, VERSION, decode, encode, encodeUnsigned, from$4 as from, proofs };
1475
1525
  }
1476
1526
  /**
1477
1527
  * A merkle tree of offers built from offer hashes.
@@ -1501,7 +1551,7 @@ declare const VERSION = 1;
1501
1551
  * @returns A `StandardMerkleTree` of `bytes32` leaves representing the offers.
1502
1552
  * @throws {TreeError} If tree building fails due to offer inconsistencies.
1503
1553
  */
1504
- declare const from$3: (offers: Offer[]) => Tree;
1554
+ declare const from$4: (offers: Offer[]) => Tree;
1505
1555
  /**
1506
1556
  * Generates merkle proofs for all offers in a tree.
1507
1557
  *
@@ -1546,7 +1596,7 @@ declare const proofs: (tree: Tree) => Proof[];
1546
1596
  * @returns Hex-encoded calldata ready for onchain broadcast
1547
1597
  * @throws {EncodeError} If signature verification fails or root mismatch
1548
1598
  */
1549
- declare const encode$1: (tree: Tree, signature: Hex) => Promise<Hex>;
1599
+ declare const encode: (tree: Tree, signature: Hex) => Promise<Hex>;
1550
1600
  /**
1551
1601
  * Encodes a merkle tree without a signature into hex payload for client-side signing.
1552
1602
  *
@@ -1584,7 +1634,7 @@ declare const encodeUnsigned: (tree: Tree) => Hex;
1584
1634
  * @returns Validated tree, signature, and recovered signer address
1585
1635
  * @throws {DecodeError} If version invalid, signature invalid, or root mismatch
1586
1636
  */
1587
- declare const decode$1: (encoded: Hex) => Promise<{
1637
+ declare const decode: (encoded: Hex) => Promise<{
1588
1638
  tree: Tree;
1589
1639
  signature: Hex;
1590
1640
  signer: Address;
@@ -1630,13 +1680,13 @@ interface paths {
1630
1680
  };
1631
1681
  /**
1632
1682
  * Get aggregated book
1633
- * @description Returns aggregated book data for a given obligation and side. Offers are grouped by rate with summed takeable amounts. Book levels are sorted by rate (ascending for buy side, descending for sell side).
1683
+ * @description Returns aggregated book data for a given obligation and side. Offers are grouped by computed price with summed takeable amounts. Book levels are sorted by price (ascending for buy side, descending for sell side).
1634
1684
  */
1635
1685
  get: {
1636
1686
  parameters: {
1637
1687
  query?: {
1638
1688
  /**
1639
- * @description Maximum number of rate levels to return.
1689
+ * @description Maximum number of price levels to return.
1640
1690
  * @example 10
1641
1691
  */
1642
1692
  limit?: number;
@@ -1647,7 +1697,18 @@ interface paths {
1647
1697
  cursor?: string;
1648
1698
  };
1649
1699
  header?: never;
1650
- path?: never;
1700
+ path: {
1701
+ /**
1702
+ * @description Book side (buy or sell).
1703
+ * @example buy
1704
+ */
1705
+ side: "buy" | "sell";
1706
+ /**
1707
+ * @description Obligation id.
1708
+ * @example 0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67
1709
+ */
1710
+ obligationId: string;
1711
+ };
1651
1712
  cookie?: never;
1652
1713
  };
1653
1714
  requestBody?: never;
@@ -1680,7 +1741,7 @@ interface paths {
1680
1741
  patch?: never;
1681
1742
  trace?: never;
1682
1743
  };
1683
- "/v1/offers": {
1744
+ "/v1/config": {
1684
1745
  parameters: {
1685
1746
  query?: never;
1686
1747
  header?: never;
@@ -1688,38 +1749,12 @@ interface paths {
1688
1749
  cookie?: never;
1689
1750
  };
1690
1751
  /**
1691
- * List all offers
1692
- * @description Returns offers. Provide either `obligation_id` + `side` (order book) or `offering` (by maker).
1752
+ * Get router configuration
1753
+ * @description Returns chain configurations including contract addresses and supported maturity timestamps.
1693
1754
  */
1694
1755
  get: {
1695
1756
  parameters: {
1696
- query?: {
1697
- /**
1698
- * @description Maximum number of offers to return.
1699
- * @example 10
1700
- */
1701
- limit?: number;
1702
- /**
1703
- * @description Pagination cursor in base64url-encoded format.
1704
- * @example eyJvZmZzZXQiOjEwMH0
1705
- */
1706
- cursor?: string;
1707
- /**
1708
- * @description Maker address to filter offers by. Alternative to obligation_id + side.
1709
- * @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401
1710
- */
1711
- offering?: string;
1712
- /**
1713
- * @description Obligation id used to filter offers. Required when not using offering.
1714
- * @example 0x1234567890123456789012345678901234567890123456789012345678901234
1715
- */
1716
- obligation_id?: string;
1717
- /**
1718
- * @description Side of the offer. Required when using obligation_id.
1719
- * @example buy
1720
- */
1721
- side?: "buy" | "sell";
1722
- };
1757
+ query?: never;
1723
1758
  header?: never;
1724
1759
  path?: never;
1725
1760
  cookie?: never;
@@ -1732,7 +1767,72 @@ interface paths {
1732
1767
  [name: string]: unknown;
1733
1768
  };
1734
1769
  content: {
1735
- "application/json": components["schemas"]["OfferListResponse"];
1770
+ "application/json": components["schemas"]["ConfigSuccessResponse"];
1771
+ };
1772
+ };
1773
+ };
1774
+ };
1775
+ put?: never;
1776
+ post?: never;
1777
+ delete?: never;
1778
+ options?: never;
1779
+ head?: never;
1780
+ patch?: never;
1781
+ trace?: never;
1782
+ };
1783
+ "/v1/offers": {
1784
+ parameters: {
1785
+ query?: never;
1786
+ header?: never;
1787
+ path?: never;
1788
+ cookie?: never;
1789
+ };
1790
+ /**
1791
+ * List all offers
1792
+ * @description Returns offers. Provide either `obligation_id` + `side` (order book) or `maker` (by maker address).
1793
+ */
1794
+ get: {
1795
+ parameters: {
1796
+ query?: {
1797
+ /**
1798
+ * @description Maximum number of offers to return.
1799
+ * @example 10
1800
+ */
1801
+ limit?: number;
1802
+ /**
1803
+ * @description Pagination cursor in base64url-encoded format.
1804
+ * @example eyJvZmZzZXQiOjEwMH0
1805
+ */
1806
+ cursor?: string;
1807
+ /**
1808
+ * @description Maker address to filter offers by. Alternative to obligation_id + side.
1809
+ * @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401
1810
+ */
1811
+ maker?: string;
1812
+ /**
1813
+ * @description Obligation id used to filter offers. Required when not using maker.
1814
+ * @example 0x1234567890123456789012345678901234567890123456789012345678901234
1815
+ */
1816
+ obligation_id?: string;
1817
+ /**
1818
+ * @description Side of the offer. Required when using obligation_id.
1819
+ * @example buy
1820
+ */
1821
+ side?: "buy" | "sell";
1822
+ };
1823
+ header?: never;
1824
+ path?: never;
1825
+ cookie?: never;
1826
+ };
1827
+ requestBody?: never;
1828
+ responses: {
1829
+ /** @description Success */
1830
+ 200: {
1831
+ headers: {
1832
+ [name: string]: unknown;
1833
+ };
1834
+ content: {
1835
+ "application/json": components["schemas"]["OfferListResponse"];
1736
1836
  };
1737
1837
  };
1738
1838
  /** @description Bad Request */
@@ -1768,9 +1868,35 @@ interface paths {
1768
1868
  get: {
1769
1869
  parameters: {
1770
1870
  query?: {
1771
- /** @example 10 */
1871
+ /**
1872
+ * @description Filter by exact maturity timestamp (unix seconds).
1873
+ * @example 1761922800
1874
+ */
1875
+ maturity?: number;
1876
+ /**
1877
+ * @description Filter by collateral token (matches any collateral in the obligation).
1878
+ * @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751
1879
+ */
1880
+ collateral_token?: string;
1881
+ /**
1882
+ * @description Filter by loan token address.
1883
+ * @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078
1884
+ */
1885
+ loan_token?: string;
1886
+ /**
1887
+ * @description Filter by chain ID.
1888
+ * @example 1
1889
+ */
1890
+ chain?: number;
1891
+ /**
1892
+ * @description Maximum number of obligations to return.
1893
+ * @example 10
1894
+ */
1772
1895
  limit?: number;
1773
- /** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
1896
+ /**
1897
+ * @description Obligation id cursor for pagination.
1898
+ * @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc
1899
+ */
1774
1900
  cursor?: string;
1775
1901
  };
1776
1902
  header?: never;
@@ -1822,7 +1948,13 @@ interface paths {
1822
1948
  parameters: {
1823
1949
  query?: never;
1824
1950
  header?: never;
1825
- path?: never;
1951
+ path: {
1952
+ /**
1953
+ * @description Obligation id.
1954
+ * @example 0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67
1955
+ */
1956
+ obligationId: string;
1957
+ };
1826
1958
  cookie?: never;
1827
1959
  };
1828
1960
  requestBody?: never;
@@ -1868,7 +2000,13 @@ interface paths {
1868
2000
  */
1869
2001
  get: {
1870
2002
  parameters: {
1871
- query?: never;
2003
+ query?: {
2004
+ /**
2005
+ * @description Fail the request if initialization is incomplete.
2006
+ * @example true
2007
+ */
2008
+ strict?: boolean;
2009
+ };
1872
2010
  header?: never;
1873
2011
  path?: never;
1874
2012
  cookie?: never;
@@ -1907,7 +2045,13 @@ interface paths {
1907
2045
  */
1908
2046
  get: {
1909
2047
  parameters: {
1910
- query?: never;
2048
+ query?: {
2049
+ /**
2050
+ * @description Fail the request if initialization is incomplete.
2051
+ * @example true
2052
+ */
2053
+ strict?: boolean;
2054
+ };
1911
2055
  header?: never;
1912
2056
  path?: never;
1913
2057
  cookie?: never;
@@ -1946,7 +2090,13 @@ interface paths {
1946
2090
  */
1947
2091
  get: {
1948
2092
  parameters: {
1949
- query?: never;
2093
+ query?: {
2094
+ /**
2095
+ * @description Fail the request if initialization is incomplete.
2096
+ * @example true
2097
+ */
2098
+ strict?: boolean;
2099
+ };
1950
2100
  header?: never;
1951
2101
  path?: never;
1952
2102
  cookie?: never;
@@ -1972,6 +2122,71 @@ interface paths {
1972
2122
  patch?: never;
1973
2123
  trace?: never;
1974
2124
  };
2125
+ "/v1/users/{userAddress}/positions": {
2126
+ parameters: {
2127
+ query?: never;
2128
+ header?: never;
2129
+ path?: never;
2130
+ cookie?: never;
2131
+ };
2132
+ /**
2133
+ * Get user positions
2134
+ * @description Returns positions for a user with reserved balance. The reserved balance is the amount locked by active offers (max lot upper - offset - consumed).
2135
+ */
2136
+ get: {
2137
+ parameters: {
2138
+ query?: {
2139
+ /**
2140
+ * @description Maximum number of positions to return.
2141
+ * @example 10
2142
+ */
2143
+ limit?: number;
2144
+ /**
2145
+ * @description Pagination cursor in base64url-encoded format.
2146
+ * @example eyJvZmZzZXQiOjEwMH0
2147
+ */
2148
+ cursor?: string;
2149
+ };
2150
+ header?: never;
2151
+ path: {
2152
+ /**
2153
+ * @description User address to get positions for.
2154
+ * @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401
2155
+ */
2156
+ userAddress: string;
2157
+ };
2158
+ cookie?: never;
2159
+ };
2160
+ requestBody?: never;
2161
+ responses: {
2162
+ /** @description Success */
2163
+ 200: {
2164
+ headers: {
2165
+ [name: string]: unknown;
2166
+ };
2167
+ content: {
2168
+ "application/json": components["schemas"]["PositionListResponse"];
2169
+ };
2170
+ };
2171
+ /** @description Bad Request */
2172
+ 400: {
2173
+ headers: {
2174
+ [name: string]: unknown;
2175
+ };
2176
+ content: {
2177
+ "application/json": components["schemas"]["BadRequestResponse"];
2178
+ };
2179
+ };
2180
+ };
2181
+ };
2182
+ put?: never;
2183
+ post?: never;
2184
+ delete?: never;
2185
+ options?: never;
2186
+ head?: never;
2187
+ patch?: never;
2188
+ trace?: never;
2189
+ };
1975
2190
  "/v1/validate": {
1976
2191
  parameters: {
1977
2192
  query?: never;
@@ -1987,11 +2202,12 @@ interface paths {
1987
2202
  *
1988
2203
  * **Available validation rules:**
1989
2204
  * - **parse_error**: Returns when an offer fails to parse due to invalid format or missing required fields
1990
- * - **mixed_maker**: Validates that all offers in a batch have the same maker (offering address)
2205
+ * - **mixed_maker**: Validates that all offers in a batch have the same maker address
2206
+ * - **amount_mutual_exclusivity**: Validates that at most one of (assets, obligationUnits, obligationShares) is non-zero
1991
2207
  * - **chain_ids**: Validates that offer chain is one of: [109111114]
1992
2208
  * - **maturity**: Validates that offer maturity is one of: [end_of_month, end_of_next_month]
1993
2209
  * - **callback**: Validates callbacks: buy empty callback is allowed; sell offers must use a non-empty callback; non-empty callbacks must target one of [0x3333333333333333333333333333333333333333, 0x4444444444444444444444444444444444444444, 0x1111111111111111111111111111111111111111, 0x2222222222222222222222222222222222222222]
1994
- * - **token**: Validates that offer loan token and collateral tokens are in the allowed assets list
2210
+ * - **token**: Validates that offer loan token and collateral tokens are in the allowed assets list for the offer chain
1995
2211
  */
1996
2212
  post: {
1997
2213
  parameters: {
@@ -2039,7 +2255,7 @@ interface components {
2039
2255
  meta: components["schemas"]["Meta"];
2040
2256
  /** @example eyJvZmZzZXQiOjEwMH0 */
2041
2257
  cursor: string | null;
2042
- /** @description Aggregated book levels grouped by rate. */
2258
+ /** @description Aggregated book levels grouped by computed price. */
2043
2259
  data: components["schemas"]["BookLevelResponse"][];
2044
2260
  };
2045
2261
  Meta: {
@@ -2048,7 +2264,7 @@ interface components {
2048
2264
  };
2049
2265
  BookLevelResponse: {
2050
2266
  /** @example 2750000000000000000 */
2051
- rate: string;
2267
+ price: string;
2052
2268
  /** @example 369216000000000000000000 */
2053
2269
  assets: string;
2054
2270
  /** @example 5 */
@@ -2076,6 +2292,56 @@ interface components {
2076
2292
  */
2077
2293
  details: Record<string, never>;
2078
2294
  };
2295
+ ConfigSuccessResponse: {
2296
+ meta: components["schemas"]["Meta"];
2297
+ /** @example null */
2298
+ cursor: string | null;
2299
+ /**
2300
+ * @description Array of chain configurations for all indexed chains.
2301
+ * @example [
2302
+ * {
2303
+ * "chain_id": 505050505,
2304
+ * "contracts": {
2305
+ * "mempool": "0xD946246695A9259F3B33a78629026F61B3Ab40aF"
2306
+ * },
2307
+ * "maturities": {
2308
+ * "end_of_month": 1738335600,
2309
+ * "end_of_next_month": 1740754800
2310
+ * }
2311
+ * }
2312
+ * ]
2313
+ */
2314
+ data: components["schemas"]["ConfigDataResponse"][];
2315
+ };
2316
+ ConfigDataResponse: {
2317
+ /** @example 505050505 */
2318
+ chain_id: number;
2319
+ contracts: components["schemas"]["ConfigContractsResponse"];
2320
+ /**
2321
+ * @description Supported maturity timestamps. Offers must use one of these values.
2322
+ * @example {
2323
+ * "end_of_month": 1738335600,
2324
+ * "end_of_next_month": 1740754800
2325
+ * }
2326
+ */
2327
+ maturities: components["schemas"]["MaturitiesResponse"];
2328
+ };
2329
+ ConfigContractsResponse: {
2330
+ /** @example 0xD946246695A9259F3B33a78629026F61B3Ab40aF */
2331
+ mempool: string;
2332
+ };
2333
+ MaturitiesResponse: {
2334
+ /**
2335
+ * @description Unix timestamp for end of current month maturity (last Friday 15:00 UTC).
2336
+ * @example 1738335600
2337
+ */
2338
+ end_of_month: number;
2339
+ /**
2340
+ * @description Unix timestamp for end of next month maturity (last Friday 15:00 UTC).
2341
+ * @example 1740754800
2342
+ */
2343
+ end_of_next_month: number;
2344
+ };
2079
2345
  OfferListResponse: {
2080
2346
  meta: components["schemas"]["Meta"];
2081
2347
  /** @example eyJvZmZzZXQiOjEwMH0 */
@@ -2084,29 +2350,34 @@ interface components {
2084
2350
  * @description Offers matching the provided filters.
2085
2351
  * @example [
2086
2352
  * {
2087
- * "hash": "0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427",
2088
- * "offering": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
2089
- * "assets": "369216000000000000000000",
2090
- * "rate": "2750000000000000000",
2091
- * "maturity": 1761922799,
2092
- * "expiry": 1761922799,
2093
- * "start": 1761922790,
2094
- * "nonce": "571380",
2095
- * "buy": false,
2096
- * "chain_id": 1,
2097
- * "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
2098
- * "collaterals": [
2099
- * {
2100
- * "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2101
- * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
2102
- * "lltv": "860000000000000000"
2103
- * }
2104
- * ],
2105
- * "callback": {
2106
- * "address": "0x1111111111111111111111111111111111111111",
2107
- * "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
2108
- * "gas_limit": "500000"
2353
+ * "offer": {
2354
+ * "obligation": {
2355
+ * "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
2356
+ * "collaterals": [
2357
+ * {
2358
+ * "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2359
+ * "lltv": "860000000000000000",
2360
+ * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401"
2361
+ * }
2362
+ * ],
2363
+ * "maturity": 1761922799
2364
+ * },
2365
+ * "buy": false,
2366
+ * "maker": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
2367
+ * "assets": "369216000000000000000000",
2368
+ * "obligation_units": "0",
2369
+ * "obligation_shares": "0",
2370
+ * "start": 1761922790,
2371
+ * "expiry": 1761922799,
2372
+ * "price": "2750000000000000000",
2373
+ * "group": "0x000000000000000000000000000000000000000000000000000000000008b8f4",
2374
+ * "session": "0x0000000000000000000000000000000000000000000000000000000000000000",
2375
+ * "callback": "0x1111111111111111111111111111111111111111",
2376
+ * "callback_data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000"
2109
2377
  * },
2378
+ * "offer_hash": "0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427",
2379
+ * "obligation_id": "0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc",
2380
+ * "chain_id": 1,
2110
2381
  * "consumed": "0",
2111
2382
  * "takeable": "369216000000000000000000",
2112
2383
  * "block_number": 2942933377146801,
@@ -2122,50 +2393,44 @@ interface components {
2122
2393
  data: components["schemas"]["OfferListItemResponse"][];
2123
2394
  };
2124
2395
  OfferListItemResponse: {
2125
- /** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
2126
- hash: string;
2127
- /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
2128
- offering: string;
2129
- /** @example 369216000000000000000000 */
2130
- assets: string;
2131
- /** @example 2750000000000000000 */
2132
- rate: string;
2133
- /** @example 1761922799 */
2134
- maturity: number;
2135
- /** @example 1761922799 */
2136
- expiry: number;
2137
- /** @example 1761922790 */
2138
- start: number;
2139
- /** @example 571380 */
2140
- nonce: string;
2141
- /** @example false */
2142
- buy: boolean;
2143
- /** @example 1 */
2144
- chain_id: number;
2145
- /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
2146
- loan_token: string;
2147
- /**
2148
- * @example [
2149
- * {
2150
- * "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2151
- * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
2152
- * "lltv": "860000000000000000"
2153
- * }
2154
- * ]
2155
- */
2156
- collaterals: components["schemas"]["CollateralResponse"][];
2157
2396
  /**
2158
2397
  * @example {
2159
- * "address": "0x1111111111111111111111111111111111111111",
2160
- * "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
2161
- * "gas_limit": "500000"
2398
+ * "obligation": {
2399
+ * "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
2400
+ * "collaterals": [
2401
+ * {
2402
+ * "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2403
+ * "lltv": "860000000000000000",
2404
+ * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401"
2405
+ * }
2406
+ * ],
2407
+ * "maturity": 1761922799
2408
+ * },
2409
+ * "buy": false,
2410
+ * "maker": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
2411
+ * "assets": "369216000000000000000000",
2412
+ * "obligation_units": "0",
2413
+ * "obligation_shares": "0",
2414
+ * "start": 1761922790,
2415
+ * "expiry": 1761922799,
2416
+ * "price": "2750000000000000000",
2417
+ * "group": "0x000000000000000000000000000000000000000000000000000000000008b8f4",
2418
+ * "session": "0x0000000000000000000000000000000000000000000000000000000000000000",
2419
+ * "callback": "0x1111111111111111111111111111111111111111",
2420
+ * "callback_data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000"
2162
2421
  * }
2163
2422
  */
2164
- callback: components["schemas"]["OfferCallbackResponse"];
2165
- /** @example 369216000000000000000000 */
2166
- takeable: string;
2423
+ offer: components["schemas"]["OfferDataResponse"];
2424
+ /** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
2425
+ offer_hash: string;
2426
+ /** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
2427
+ obligation_id: string;
2428
+ /** @example 1 */
2429
+ chain_id: number;
2167
2430
  /** @example 0 */
2168
2431
  consumed: string;
2432
+ /** @example 369216000000000000000000 */
2433
+ takeable: string;
2169
2434
  /** @example 2942933377146801 */
2170
2435
  block_number: number;
2171
2436
  /** @example 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef */
@@ -2180,21 +2445,69 @@ interface components {
2180
2445
  /** @example 0x1234567890123456789012345678901234567890123456789012345678901234123456789012345678901234567890123456789012345678901234567890123400 */
2181
2446
  signature: string | null;
2182
2447
  };
2448
+ OfferDataResponse: {
2449
+ /**
2450
+ * @example {
2451
+ * "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
2452
+ * "collaterals": [
2453
+ * {
2454
+ * "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2455
+ * "lltv": "860000000000000000",
2456
+ * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401"
2457
+ * }
2458
+ * ],
2459
+ * "maturity": 1761922799
2460
+ * }
2461
+ */
2462
+ obligation: components["schemas"]["ObligationOfferResponse"];
2463
+ /** @example false */
2464
+ buy: boolean;
2465
+ /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
2466
+ maker: string;
2467
+ /** @example 369216000000000000000000 */
2468
+ assets: string;
2469
+ /** @example 0 */
2470
+ obligation_units: string;
2471
+ /** @example 0 */
2472
+ obligation_shares: string;
2473
+ /** @example 1761922790 */
2474
+ start: number;
2475
+ /** @example 1761922799 */
2476
+ expiry: number;
2477
+ /** @example 2750000000000000000 */
2478
+ price: string;
2479
+ /** @example 0x000000000000000000000000000000000000000000000000000000000008b8f4 */
2480
+ group: string;
2481
+ /** @example 0x0000000000000000000000000000000000000000000000000000000000000000 */
2482
+ session: string;
2483
+ /** @example 0x1111111111111111111111111111111111111111 */
2484
+ callback: string;
2485
+ /** @example 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000 */
2486
+ callback_data: string;
2487
+ };
2488
+ ObligationOfferResponse: {
2489
+ /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
2490
+ loan_token: string;
2491
+ /**
2492
+ * @example [
2493
+ * {
2494
+ * "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
2495
+ * "lltv": "860000000000000000",
2496
+ * "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401"
2497
+ * }
2498
+ * ]
2499
+ */
2500
+ collaterals: components["schemas"]["CollateralResponse"][];
2501
+ /** @example 1761922799 */
2502
+ maturity: number;
2503
+ };
2183
2504
  CollateralResponse: {
2184
2505
  /** @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751 */
2185
- asset: string;
2186
- /** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
2187
- oracle: string;
2506
+ token: string;
2188
2507
  /** @example 860000000000000000 */
2189
2508
  lltv: string;
2190
- };
2191
- OfferCallbackResponse: {
2192
- /** @example 0x1111111111111111111111111111111111111111 */
2193
- address: string;
2194
- /** @example 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000 */
2195
- data: string;
2196
- /** @example 500000 */
2197
- gas_limit: string;
2509
+ /** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
2510
+ oracle: string;
2198
2511
  };
2199
2512
  ObligationListResponse: {
2200
2513
  meta: components["schemas"]["Meta"];
@@ -2218,11 +2531,11 @@ interface components {
2218
2531
  };
2219
2532
  AskResponse: {
2220
2533
  /** @example 1000000000000000000 */
2221
- rate: string;
2534
+ price: string;
2222
2535
  };
2223
2536
  BidResponse: {
2224
2537
  /** @example 1000000000000000000 */
2225
- rate: string;
2538
+ price: string;
2226
2539
  };
2227
2540
  ObligationSingleSuccessResponse: {
2228
2541
  meta: components["schemas"]["Meta"];
@@ -2236,7 +2549,10 @@ interface components {
2236
2549
  /**
2237
2550
  * @description Aggregated router status.
2238
2551
  * @example {
2239
- * "status": "live"
2552
+ * "status": "live",
2553
+ * "initialized": true,
2554
+ * "missing_chains": [],
2555
+ * "missing_collectors": []
2240
2556
  * }
2241
2557
  */
2242
2558
  data: components["schemas"]["RouterStatusDataResponse"];
@@ -2247,6 +2563,24 @@ interface components {
2247
2563
  * @enum {string}
2248
2564
  */
2249
2565
  status: "live" | "syncing";
2566
+ /** @example true */
2567
+ initialized: boolean;
2568
+ /**
2569
+ * @description Configured chain ids missing initialization rows.
2570
+ * @example []
2571
+ */
2572
+ missing_chains: number[];
2573
+ /**
2574
+ * @description Collectors missing initialization rows.
2575
+ * @example []
2576
+ */
2577
+ missing_collectors: components["schemas"]["MissingCollectorResponse"][];
2578
+ };
2579
+ MissingCollectorResponse: {
2580
+ /** @example 1 */
2581
+ chain_id: number;
2582
+ /** @example offers */
2583
+ name: string;
2250
2584
  };
2251
2585
  CollectorsHealthSuccessResponse: {
2252
2586
  meta: components["schemas"]["Meta"];
@@ -2259,7 +2593,8 @@ interface components {
2259
2593
  * "block_number": 21345678,
2260
2594
  * "updated_at": "2024-01-01T12:00:00.000Z",
2261
2595
  * "lag": 0,
2262
- * "status": "live"
2596
+ * "status": "live",
2597
+ * "initialized": true
2263
2598
  * }
2264
2599
  * ]
2265
2600
  */
@@ -2281,6 +2616,8 @@ interface components {
2281
2616
  * @enum {string}
2282
2617
  */
2283
2618
  status: "live" | "lagging" | "unknown";
2619
+ /** @example true */
2620
+ initialized: boolean;
2284
2621
  };
2285
2622
  ChainsHealthSuccessResponse: {
2286
2623
  meta: components["schemas"]["Meta"];
@@ -2291,7 +2628,8 @@ interface components {
2291
2628
  * "chain_id": 1,
2292
2629
  * "local_block_number": 21345678,
2293
2630
  * "remote_block_number": 21345690,
2294
- * "updated_at": "2024-01-01T12:00:00.000Z"
2631
+ * "updated_at": "2024-01-01T12:00:00.000Z",
2632
+ * "initialized": true
2295
2633
  * }
2296
2634
  * ]
2297
2635
  */
@@ -2301,11 +2639,43 @@ interface components {
2301
2639
  /** @example 1 */
2302
2640
  chain_id: number;
2303
2641
  /** @example 21345678 */
2304
- local_block_number: number;
2642
+ local_block_number: number | null;
2305
2643
  /** @example 21345690 */
2306
2644
  remote_block_number: number | null;
2307
2645
  /** @example 2024-01-01T12:00:00.000Z */
2308
- updated_at: string;
2646
+ updated_at: string | null;
2647
+ /** @example true */
2648
+ initialized: boolean;
2649
+ };
2650
+ PositionListResponse: {
2651
+ meta: components["schemas"]["Meta"];
2652
+ /** @example eyJvZmZzZXQiOjEwMH0 */
2653
+ cursor: string | null;
2654
+ /**
2655
+ * @description User positions with reserved balances from active offers.
2656
+ * @example [
2657
+ * {
2658
+ * "chain_id": 1,
2659
+ * "contract": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
2660
+ * "user": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
2661
+ * "reserved": "200000000000000000000",
2662
+ * "block_number": 21345678
2663
+ * }
2664
+ * ]
2665
+ */
2666
+ data: components["schemas"]["PositionListItemResponse"][];
2667
+ };
2668
+ PositionListItemResponse: {
2669
+ /** @example 1 */
2670
+ chain_id: number;
2671
+ /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
2672
+ contract: string;
2673
+ /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
2674
+ user: string;
2675
+ /** @example 200000000000000000000 */
2676
+ reserved: string;
2677
+ /** @example 21345678 */
2678
+ block_number: number;
2309
2679
  };
2310
2680
  ValidateOffersRequest: {
2311
2681
  /** @description Array of offers in snake_case format. Required, non-empty. */
@@ -2313,19 +2683,25 @@ interface components {
2313
2683
  };
2314
2684
  ValidateOfferRequest: {
2315
2685
  /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
2316
- offering: string;
2686
+ maker: string;
2317
2687
  /** @example 369216000000000000000000 */
2318
2688
  assets: string;
2689
+ /** @example 0 */
2690
+ obligation_units?: string;
2691
+ /** @example 0 */
2692
+ obligation_shares?: string;
2319
2693
  /** @example 2750000000000000000 */
2320
- rate: string;
2694
+ price: string;
2321
2695
  /** @example 1761922799 */
2322
2696
  maturity: number;
2323
2697
  /** @example 1761922799 */
2324
2698
  expiry: number;
2325
2699
  /** @example 1761922790 */
2326
2700
  start: number;
2327
- /** @example 571380 */
2328
- nonce: string;
2701
+ /** @example 0x000000000000000000000000000000000000000000000000000000000008b8f4 */
2702
+ group: string;
2703
+ /** @example 0x0000000000000000000000000000000000000000000000000000000000000000 */
2704
+ session: string;
2329
2705
  /** @example false */
2330
2706
  buy: boolean;
2331
2707
  /** @example 1 */
@@ -2341,15 +2717,28 @@ interface components {
2341
2717
  * }
2342
2718
  * ]
2343
2719
  */
2344
- collaterals: components["schemas"]["CollateralResponse"][];
2720
+ collaterals: components["schemas"]["ValidateCollateralRequest"][];
2345
2721
  /**
2346
2722
  * @example {
2347
2723
  * "address": "0x1111111111111111111111111111111111111111",
2348
- * "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000",
2349
- * "gas_limit": "500000"
2724
+ * "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000"
2350
2725
  * }
2351
2726
  */
2352
- callback: components["schemas"]["OfferCallbackResponse"];
2727
+ callback: components["schemas"]["ValidateCallbackRequest"];
2728
+ };
2729
+ ValidateCollateralRequest: {
2730
+ /** @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751 */
2731
+ asset: string;
2732
+ /** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
2733
+ oracle: string;
2734
+ /** @example 860000000000000000 */
2735
+ lltv: string;
2736
+ };
2737
+ ValidateCallbackRequest: {
2738
+ /** @example 0x1111111111111111111111111111111111111111 */
2739
+ address: string;
2740
+ /** @example 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000 */
2741
+ data: string;
2353
2742
  };
2354
2743
  ValidationSuccessResponse: {
2355
2744
  meta: components["schemas"]["Meta"];
@@ -2357,245 +2746,79 @@ interface components {
2357
2746
  cursor: string | null;
2358
2747
  /** @description Payload and root for client-side signing. */
2359
2748
  data: components["schemas"]["ValidationSuccessDataResponse"];
2360
- };
2361
- ValidationSuccessDataResponse: {
2362
- /**
2363
- * @description Unsigned payload: version (1B) + gzip(offers) + root (32B).
2364
- * @example 0x01789c...
2365
- */
2366
- payload: string;
2367
- /**
2368
- * @description Merkle tree root to sign with EIP-191.
2369
- * @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427
2370
- */
2371
- root: string;
2372
- };
2373
- };
2374
- responses: never;
2375
- parameters: never;
2376
- requestBodies: never;
2377
- headers: never;
2378
- pathItems: never;
2379
- }
2380
- declare namespace ObligationResponse_d_exports {
2381
- export { ObligationResponse, from$2 as from };
2382
- }
2383
- type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
2384
- /**
2385
- * Creates an `ObligationResponse` from a `Obligation`.
2386
- * @constructor
2387
- * @param obligation - {@link Obligation}
2388
- * @returns The created `ObligationResponse`. {@link ObligationResponse}
2389
- */
2390
- declare function from$2(obligation: Obligation, quote: Quote): ObligationResponse;
2391
- declare namespace Gate_d_exports {
2392
- export { Batch, Issue, Result, Rule, RuleNames, Single, batch$1 as batch, run, single };
2393
- }
2394
- /**
2395
- * A validation rule.
2396
- */
2397
- type Rule<T, Name$1 extends string = string> = {
2398
- kind: "single";
2399
- name: Name$1;
2400
- description: string;
2401
- run: Single<T, Name$1>;
2402
- } | {
2403
- kind: "batch";
2404
- name: Name$1;
2405
- description: string;
2406
- run: Batch<T, Name$1>;
2407
- };
2408
- type RuleNames<Rules$1 extends readonly {
2409
- name: string;
2410
- }[]> = Rules$1[number]["name"];
2411
- /**
2412
- * A single item validation rule.
2413
- * @param item - The item to validate.
2414
- * @returns The issue that was found. If the item is valid, this will be undefined.
2415
- */
2416
- type Single<T, RuleName extends string> = (item: T) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
2417
- /**
2418
- * A batch item validation rule.
2419
- * @param items - The items to validate.
2420
- * @returns A map of the items to the issue that was found.
2421
- */
2422
- type Batch<T, RuleName extends string> = (items: T[]) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
2423
- /**
2424
- * Create a validation rule iterating over a single item at a time.
2425
- * @param name - The name of the rule.
2426
- * @param description - A human-readable description of the rule.
2427
- * @param run - The function that validates the rule.
2428
- * @returns The created rule.
2429
- */
2430
- declare function single<Name$1 extends string, T>(name: Name$1, description: string, run: Single<T, Name$1>): Rule<T, Name$1>;
2431
- /**
2432
- * Create a validation rule iterating over a batch of items at a time.
2433
- * @param name - The name of the rule.
2434
- * @param description - A human-readable description of the rule.
2435
- * @param run - The function that validates the rule.
2436
- * @returns The created rule.
2437
- */
2438
- declare function batch$1<Name$1 extends string, T>(name: Name$1, description: string, run: Batch<T, Name$1>): Rule<T, Name$1>;
2439
- /**
2440
- * A validation issue.
2441
- */
2442
- type Issue<T, RuleName extends string = string> = {
2443
- /** The name of the rule that caused the issue. */
2444
- ruleName: RuleName;
2445
- /** The message of the issue. */
2446
- message: string;
2447
- /** The item that was not valid. */
2448
- item: T;
2449
- };
2450
- /**
2451
- * The result of a validation.
2452
- */
2453
- type Result<T, RuleName extends string = string> = {
2454
- /** The items that were valid. */
2455
- valid: T[];
2456
- /** The reports of the failed validations. */
2457
- issues: Issue<T, RuleName>[];
2458
- };
2459
- declare function run<T, Name$1 extends string, Rules$1 extends readonly Rule<T, Name$1>[]>(parameters: {
2460
- items: T[];
2461
- rules: Rules$1;
2462
- chunkSize?: number;
2463
- }): Promise<Result<T, RuleNames<Rules$1>>>;
2464
- declare namespace Gatekeeper_d_exports {
2465
- export { Gatekeeper, Rules, create };
2466
- }
2467
- type Rules = readonly Rule<Offer, string>[];
2468
- type Gatekeeper = {
2469
- rules: Rules;
2470
- isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
2471
- };
2472
- type GatekeeperParameters = {
2473
- rules: Rules;
2474
- };
2475
- declare function create(parameters: GatekeeperParameters): Gatekeeper;
2476
- declare namespace GateConfig_d_exports {
2477
- export { CallbackConfig, GateConfig, assets$1 as assets, configs, getCallback, getCallbackAddresses, getCallbackType, getCallbackTypeAddresses };
2478
- }
2479
- type GateConfig = {
2480
- callbacks?: CallbackConfig[];
2481
- maturities?: MaturityType[];
2482
- };
2483
- type CallbackConfig = {
2484
- type: CallbackType.BuyVaultV1Callback;
2485
- addresses: Address[];
2486
- vaultFactories: Address[];
2487
- } | {
2488
- type: CallbackType.SellERC20Callback;
2489
- addresses: Address[];
2490
- } | {
2491
- type: CallbackType.BuyWithEmptyCallback;
2492
- };
2493
- declare function getCallback(chain: Name, type: CallbackType.BuyVaultV1Callback): Extract<CallbackConfig, {
2494
- type: CallbackType.BuyVaultV1Callback;
2495
- }> | undefined;
2496
- declare function getCallback(chain: Name, type: CallbackType.SellERC20Callback): Extract<CallbackConfig, {
2497
- type: CallbackType.SellERC20Callback;
2498
- }> | undefined;
2499
- declare function getCallback(chain: Name, type: CallbackType.BuyWithEmptyCallback): Extract<CallbackConfig, {
2500
- type: CallbackType.BuyWithEmptyCallback;
2501
- }> | undefined;
2502
- declare function getCallback(chain: Name, type: CallbackType): CallbackConfig | undefined;
2503
- /**
2504
- * Attempts to infer the configured callback type from a callback address on a chain.
2505
- * Skips the empty callback type as it does not carry addresses.
2506
- *
2507
- * @param chain - Chain name for which to infer the callback type
2508
- * @param address - Callback contract address
2509
- * @returns The callback type when found, otherwise undefined
2510
- */
2511
- declare function getCallbackType(chain: Name, address: Address): CallbackType | undefined;
2512
- /**
2513
- * Returns the callback addresses for a given chain and callback type, if it exists.
2514
- * @param chain - Chain name for which to read the validation configuration
2515
- * @param type - Callback type to retrieve
2516
- * @returns The matching callback addresses or an empty array if not configured
2517
- */
2518
- declare function getCallbackTypeAddresses(chain: Name, type: CallbackType): Address[];
2519
- /**
2520
- * Returns the list of allowed non-empty callback addresses for a chain.
2521
- *
2522
- * @param chain - Chain name
2523
- * @returns Array of allowed callback addresses (lowercased). Empty when none configured
2524
- */
2525
- declare const getCallbackAddresses: (chain: Name) => Address[];
2526
- declare const assets$1: Record<string, Address[]>;
2527
- declare const configs: Record<Name, GateConfig>;
2528
- //#endregion
2529
- //#region src/gatekeeper/morphoRules.d.ts
2530
- declare const morphoRules: (chains: Chain$1[]) => (Rule<Offer, "mixed_maker"> | Rule<Offer, "chain_ids"> | Rule<Offer, "maturity"> | Rule<Offer, "callback"> | Rule<Offer, "token">)[];
2531
- declare namespace Rules_d_exports {
2532
- export { ValidityParameters, callback, chains, maturity, sameMaker, token, validity };
2533
- }
2534
- type ValidityParameters = {
2535
- client: PublicClient<Transport, Chain$1>;
2536
- };
2537
- /**
2538
- * set of rules to validate offers.
2539
- *
2540
- * @param parameters - Validity parameters with chain and client
2541
- * @returns Array of validation rules to evaluate against offers
2542
- */
2543
- declare function validity(parameters: ValidityParameters): (Rule<Offer, "expiry"> | Rule<Offer, "sell_erc20_callback_invalid"> | Rule<Offer, "buy_offers_callback_vault_invalid">)[];
2544
- declare const chains: ({
2545
- chains
2546
- }: {
2547
- chains: Chain$1[];
2548
- }) => Rule<Offer, "chain_ids">;
2549
- declare const maturity: ({
2550
- maturities
2551
- }: {
2552
- maturities: MaturityType[];
2553
- }) => Rule<Offer, "maturity">;
2554
- declare const callback: ({
2555
- callbacks,
2556
- allowedAddresses
2557
- }: {
2558
- callbacks: CallbackType[];
2559
- allowedAddresses: Address[];
2560
- }) => Rule<Offer, "callback">;
2561
- /**
2562
- * A validation rule that checks if the offer's token is allowed.
2563
- * @param offer - The offer to validate.
2564
- * @returns The issue that was found. If the offer is valid, this will be undefined.
2565
- */
2566
- declare const token: ({
2567
- assets
2568
- }: {
2569
- assets: Address[];
2570
- }) => Rule<Offer, "token">;
2571
- /**
2572
- * A batch validation rule that ensures all offers in a tree have the same maker (offering address).
2573
- * Returns an issue only for the first non-conforming offer.
2574
- * This rule is signing-agnostic; signer verification is handled at the collector level.
2575
- */
2576
- declare const sameMaker: () => Rule<Offer, "mixed_maker">;
2577
- //#endregion
2578
- //#region src/database/domains/Trees.d.ts
2749
+ };
2750
+ ValidationSuccessDataResponse: {
2751
+ /**
2752
+ * @description Unsigned payload: version (1B) + gzip(offers) + root (32B).
2753
+ * @example 0x01789c...
2754
+ */
2755
+ payload: string;
2756
+ /**
2757
+ * @description Merkle tree root to sign with EIP-191.
2758
+ * @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427
2759
+ */
2760
+ root: string;
2761
+ };
2762
+ };
2763
+ responses: never;
2764
+ parameters: never;
2765
+ requestBodies: never;
2766
+ headers: never;
2767
+ pathItems: never;
2768
+ }
2769
+ declare namespace ObligationResponse_d_exports {
2770
+ export { ObligationResponse, from$3 as from };
2771
+ }
2772
+ type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
2579
2773
  /**
2580
- * Attestation data for a single offer, containing the merkle root, signature, and proof.
2774
+ * Creates an `ObligationResponse` from a `Obligation`.
2775
+ * @constructor
2776
+ * @param obligation - {@link Obligation}
2777
+ * @returns The created `ObligationResponse`. {@link ObligationResponse}
2581
2778
  */
2582
- type Attestation = {
2583
- root: Hex;
2584
- signature: Hex;
2585
- proof: Hex[];
2586
- };
2779
+ declare function from$3(obligation: Obligation, quote: Quote): ObligationResponse;
2587
2780
  declare namespace OfferResponse_d_exports {
2588
- export { OfferResponse, from$1 as from };
2781
+ export { Input, OfferResponse, from$2 as from };
2589
2782
  }
2590
2783
  type OfferResponse = paths["/v1/offers"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
2784
+ type Input = Readonly<{
2785
+ hash: Hex;
2786
+ maker: Address;
2787
+ assets: bigint;
2788
+ obligationUnits: bigint;
2789
+ obligationShares: bigint;
2790
+ price: bigint;
2791
+ maturity: number;
2792
+ expiry: number;
2793
+ start: number;
2794
+ group: Hex;
2795
+ session: Hex;
2796
+ buy: boolean;
2797
+ chainId: number;
2798
+ loanToken: Address;
2799
+ collaterals: Readonly<{
2800
+ asset: Address;
2801
+ lltv: bigint;
2802
+ oracle: Address;
2803
+ }[]>;
2804
+ callback: {
2805
+ address: Address;
2806
+ data: Hex;
2807
+ };
2808
+ root?: Hex | undefined;
2809
+ proof?: Hex[] | undefined;
2810
+ signature?: Hex | undefined;
2811
+ consumed: bigint;
2812
+ takeable: bigint;
2813
+ blockNumber: number;
2814
+ }>;
2591
2815
  /**
2592
- * Creates an `OfferResponse` from an `Offer`.
2816
+ * Creates an `OfferResponse` matching the Solidity Offer struct layout.
2593
2817
  * @constructor
2594
- * @param offer - {@link Offer}
2595
- * @param attestation - {@link Attestation}
2818
+ * @param input - {@link Input}
2596
2819
  * @returns The created `OfferResponse`. {@link OfferResponse}
2597
2820
  */
2598
- declare function from$1(offer: Offer, attestation?: Attestation): OfferResponse;
2821
+ declare function from$2(input: Input): OfferResponse;
2599
2822
  //#endregion
2600
2823
  //#region src/api/Schema/openapi.d.ts
2601
2824
  declare class BooksController {
@@ -2612,10 +2835,16 @@ declare class HealthController {
2612
2835
  getCollectorsHealth(): Promise<void>;
2613
2836
  getChainsHealth(): Promise<void>;
2614
2837
  }
2838
+ declare class ConfigController {
2839
+ getConfig(): Promise<void>;
2840
+ }
2615
2841
  declare class ObligationsController {
2616
2842
  getObligations(): Promise<void>;
2617
2843
  getObligation(): Promise<void>;
2618
2844
  }
2845
+ declare class UsersController {
2846
+ getUserPositions(): Promise<void>;
2847
+ }
2619
2848
  type RuleInfo = {
2620
2849
  name: string;
2621
2850
  description: string;
@@ -2625,20 +2854,91 @@ type OpenApiOptions = {
2625
2854
  };
2626
2855
  declare const OpenApi: (options?: OpenApiOptions) => Promise<OpenAPIDocument>;
2627
2856
  //#endregion
2857
+ //#region src/database/domains/Positions.d.ts
2858
+ type PaginationParams = {
2859
+ /** Cursor string returned by a previous call, for pagination */
2860
+ cursor?: string;
2861
+ /** Page size; defaults to {@link DEFAULT_LIMIT} */
2862
+ limit?: number;
2863
+ };
2864
+ declare namespace getByUser {
2865
+ type Parameters = PaginationParams & {
2866
+ /** The user address to get positions for. */
2867
+ user: Address;
2868
+ };
2869
+ type PositionWithReserved = {
2870
+ chainId: Id;
2871
+ contract: Address;
2872
+ user: Address;
2873
+ blockNumber: number;
2874
+ /** The amount reserved by active offers: max(lot.upper) - offset - consumed */
2875
+ reserved: bigint;
2876
+ };
2877
+ type ReturnType = {
2878
+ positions: PositionWithReserved[];
2879
+ nextCursor: string | null;
2880
+ };
2881
+ }
2882
+ declare namespace PositionResponse_d_exports {
2883
+ export { PositionResponse, PositionWithReserved$1 as PositionWithReserved, from$1 as from };
2884
+ }
2885
+ type PositionResponse = {
2886
+ chain_id: Id;
2887
+ contract: Address;
2888
+ user: Address;
2889
+ reserved: string;
2890
+ block_number: number;
2891
+ };
2892
+ type PositionWithReserved$1 = getByUser.PositionWithReserved;
2893
+ /**
2894
+ * Creates a `PositionResponse` from a `PositionWithReserved`.
2895
+ * @param position - {@link PositionWithReserved}
2896
+ * @returns The created `PositionResponse`. {@link PositionResponse}
2897
+ */
2898
+ declare function from$1(position: PositionWithReserved$1): PositionResponse;
2899
+ //#endregion
2628
2900
  //#region src/api/Schema/requests.d.ts
2629
2901
  declare const schemas: {
2902
+ readonly get_health: z$1.ZodObject<{
2903
+ strict: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodEnum<{
2904
+ 0: "0";
2905
+ 1: "1";
2906
+ true: "true";
2907
+ false: "false";
2908
+ }>, z$1.ZodTransform<boolean, "0" | "1" | "true" | "false">>>;
2909
+ }, z$1.core.$strip>;
2910
+ readonly get_health_collectors: z$1.ZodObject<{
2911
+ strict: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodEnum<{
2912
+ 0: "0";
2913
+ 1: "1";
2914
+ true: "true";
2915
+ false: "false";
2916
+ }>, z$1.ZodTransform<boolean, "0" | "1" | "true" | "false">>>;
2917
+ }, z$1.core.$strip>;
2918
+ readonly get_health_chains: z$1.ZodObject<{
2919
+ strict: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodEnum<{
2920
+ 0: "0";
2921
+ 1: "1";
2922
+ true: "true";
2923
+ false: "false";
2924
+ }>, z$1.ZodTransform<boolean, "0" | "1" | "true" | "false">>>;
2925
+ }, z$1.core.$strip>;
2630
2926
  readonly get_offers: z$1.ZodObject<{
2631
2927
  side: z$1.ZodOptional<z$1.ZodEnum<{
2632
2928
  buy: "buy";
2633
2929
  sell: "sell";
2634
2930
  }>>;
2635
2931
  obligation_id: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
2636
- offering: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
2932
+ maker: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
2637
2933
  cursor: z$1.ZodOptional<z$1.ZodString>;
2638
2934
  limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
2639
2935
  }, z$1.core.$strip>;
2640
2936
  readonly get_obligations: z$1.ZodObject<{
2641
2937
  cursor: z$1.ZodOptional<z$1.ZodString>;
2938
+ chain: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>>;
2939
+ loan_token: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
2940
+ collateral_token: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
2941
+ maturity: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>>;
2642
2942
  limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
2643
2943
  }, z$1.core.$strip>;
2644
2944
  readonly get_obligation: z$1.ZodObject<{
@@ -2656,12 +2956,17 @@ declare const schemas: {
2656
2956
  readonly validate_offers: z$1.ZodObject<{
2657
2957
  offers: z$1.ZodArray<z$1.ZodUnknown>;
2658
2958
  }, z$1.core.$strict>;
2959
+ readonly get_user_positions: z$1.ZodObject<{
2960
+ user_address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
2961
+ cursor: z$1.ZodOptional<z$1.ZodString>;
2962
+ limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
2963
+ }, z$1.core.$strip>;
2659
2964
  };
2660
2965
  type Action = keyof typeof schemas;
2661
2966
  declare function parse<A extends Action>(action: A, query: unknown): z$1.infer<(typeof schemas)[A]>;
2662
2967
  declare function safeParse<A extends Action>(action: A, query: unknown, error?: z$1.core.$ZodErrorMap<z$1.core.$ZodIssue>): z$1.ZodSafeParseResult<z$1.infer<(typeof schemas)[A]>>;
2663
2968
  declare namespace index_d_exports$1 {
2664
- export { BookResponse_d_exports as BookResponse, BooksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, OpenApiOptions, RouterStatusResponse, RuleInfo, ValidateController, parse, safeParse };
2969
+ export { BookResponse_d_exports as BookResponse, BooksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, ConfigController, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, OpenApiOptions, PositionResponse_d_exports as PositionResponse, RouterStatusResponse, RuleInfo, UsersController, ValidateController, parse, safeParse };
2665
2970
  }
2666
2971
  declare namespace Client_d_exports {
2667
2972
  export { Client$2 as Client, ConnectOptions, HttpForbiddenError, HttpGetApiFailedError, HttpRateLimitError, HttpUnauthorizedError, InvalidUrlError, connect$1 as connect, getObligations, getOffers };
@@ -2743,10 +3048,17 @@ declare namespace getOffers {
2743
3048
  };
2744
3049
  type ReturnType = {
2745
3050
  offers: Compute<Offer & {
3051
+ hash: Hex;
3052
+ blockNumber: number;
3053
+ consumed: bigint;
3054
+ takeable: bigint;
3055
+ } & {
2746
3056
  /** 32-byte merkle root. */
2747
3057
  root?: Hex;
2748
3058
  /** Sibling hashes for the merkle proof. */
2749
3059
  proof?: Hex[];
3060
+ /** Offer signature from the Merkle tree. */
3061
+ signature?: Hex;
2750
3062
  }>[];
2751
3063
  /** The pagination cursor. */
2752
3064
  cursor: string | null;
@@ -2760,6 +3072,14 @@ declare namespace getObligations {
2760
3072
  cursor?: Hex;
2761
3073
  /** Maximum number of obligations to return. @default 20 */
2762
3074
  limit?: number;
3075
+ /** Filter by chain ID. */
3076
+ chainId?: number;
3077
+ /** Filter by loan token address. */
3078
+ loanToken?: Address;
3079
+ /** Filter by collateral token (matches any collateral in the obligation). */
3080
+ collateralToken?: Address;
3081
+ /** Filter by exact maturity timestamp (unix seconds). */
3082
+ maturity?: number;
2763
3083
  };
2764
3084
  type ReturnType = {
2765
3085
  obligations: Compute<{
@@ -2796,22 +3116,198 @@ declare class HttpGetApiFailedError extends BaseError {
2796
3116
  details?: string;
2797
3117
  });
2798
3118
  }
2799
- declare namespace Cursor_d_exports {
2800
- export { Cursor, decode, encode, validate };
3119
+ declare namespace Gate_d_exports {
3120
+ export { Batch, Issue, Result, Rule, RuleNames, Single, batch$1 as batch, run, single };
2801
3121
  }
2802
- type Cursor = {
2803
- sort: "rate" | "maturity" | "expiry" | "amount";
2804
- dir: "asc" | "desc";
2805
- rate?: string;
2806
- maturity?: number;
2807
- expiry?: number;
2808
- assets?: string;
2809
- hash: string;
2810
- page?: number;
3122
+ /**
3123
+ * A validation rule.
3124
+ */
3125
+ type Rule<T, Name$1 extends string = string> = {
3126
+ kind: "single";
3127
+ name: Name$1;
3128
+ description: string;
3129
+ run: Single<T, Name$1>;
3130
+ } | {
3131
+ kind: "batch";
3132
+ name: Name$1;
3133
+ description: string;
3134
+ run: Batch<T, Name$1>;
3135
+ };
3136
+ type RuleNames<Rules$1 extends readonly {
3137
+ name: string;
3138
+ }[]> = Rules$1[number]["name"];
3139
+ /**
3140
+ * A single item validation rule.
3141
+ * @param item - The item to validate.
3142
+ * @returns The issue that was found. If the item is valid, this will be undefined.
3143
+ */
3144
+ type Single<T, RuleName extends string> = (item: T) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
3145
+ /**
3146
+ * A batch item validation rule.
3147
+ * @param items - The items to validate.
3148
+ * @returns A map of the items to the issue that was found.
3149
+ */
3150
+ type Batch<T, RuleName extends string> = (items: T[]) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
3151
+ /**
3152
+ * Create a validation rule iterating over a single item at a time.
3153
+ * @param name - The name of the rule.
3154
+ * @param description - A human-readable description of the rule.
3155
+ * @param run - The function that validates the rule.
3156
+ * @returns The created rule.
3157
+ */
3158
+ declare function single<Name$1 extends string, T>(name: Name$1, description: string, run: Single<T, Name$1>): Rule<T, Name$1>;
3159
+ /**
3160
+ * Create a validation rule iterating over a batch of items at a time.
3161
+ * @param name - The name of the rule.
3162
+ * @param description - A human-readable description of the rule.
3163
+ * @param run - The function that validates the rule.
3164
+ * @returns The created rule.
3165
+ */
3166
+ declare function batch$1<Name$1 extends string, T>(name: Name$1, description: string, run: Batch<T, Name$1>): Rule<T, Name$1>;
3167
+ /**
3168
+ * A validation issue.
3169
+ */
3170
+ type Issue<T, RuleName extends string = string> = {
3171
+ /** The name of the rule that caused the issue. */
3172
+ ruleName: RuleName;
3173
+ /** The message of the issue. */
3174
+ message: string;
3175
+ /** The item that was not valid. */
3176
+ item: T;
3177
+ };
3178
+ /**
3179
+ * The result of a validation.
3180
+ */
3181
+ type Result<T, RuleName extends string = string> = {
3182
+ /** The items that were valid. */
3183
+ valid: T[];
3184
+ /** The reports of the failed validations. */
3185
+ issues: Issue<T, RuleName>[];
3186
+ };
3187
+ declare function run<T, Name$1 extends string, Rules$1 extends readonly Rule<T, Name$1>[]>(parameters: {
3188
+ items: T[];
3189
+ rules: Rules$1;
3190
+ chunkSize?: number;
3191
+ }): Promise<Result<T, RuleNames<Rules$1>>>;
3192
+ declare namespace GateConfig_d_exports {
3193
+ export { CallbackConfig, GateConfig, assets, configs, getCallback, getCallbackAddresses, getCallbackType, getCallbackTypeAddresses };
3194
+ }
3195
+ type GateConfig = {
3196
+ callbacks?: CallbackConfig[];
3197
+ maturities?: MaturityType[];
3198
+ };
3199
+ type CallbackConfig = {
3200
+ type: CallbackType.BuyVaultV1Callback;
3201
+ addresses: Address[];
3202
+ vaultFactories: Address[];
3203
+ } | {
3204
+ type: CallbackType.SellERC20Callback;
3205
+ addresses: Address[];
3206
+ } | {
3207
+ type: CallbackType.BuyWithEmptyCallback;
3208
+ };
3209
+ declare function getCallback(chain: Name, type: CallbackType.BuyVaultV1Callback): Extract<CallbackConfig, {
3210
+ type: CallbackType.BuyVaultV1Callback;
3211
+ }> | undefined;
3212
+ declare function getCallback(chain: Name, type: CallbackType.SellERC20Callback): Extract<CallbackConfig, {
3213
+ type: CallbackType.SellERC20Callback;
3214
+ }> | undefined;
3215
+ declare function getCallback(chain: Name, type: CallbackType.BuyWithEmptyCallback): Extract<CallbackConfig, {
3216
+ type: CallbackType.BuyWithEmptyCallback;
3217
+ }> | undefined;
3218
+ declare function getCallback(chain: Name, type: CallbackType): CallbackConfig | undefined;
3219
+ /**
3220
+ * Attempts to infer the configured callback type from a callback address on a chain.
3221
+ * Skips the empty callback type as it does not carry addresses.
3222
+ *
3223
+ * @param chain - Chain name for which to infer the callback type
3224
+ * @param address - Callback contract address
3225
+ * @returns The callback type when found, otherwise undefined
3226
+ */
3227
+ declare function getCallbackType(chain: Name, address: Address): CallbackType | undefined;
3228
+ /**
3229
+ * Returns the callback addresses for a given chain and callback type, if it exists.
3230
+ * @param chain - Chain name for which to read the validation configuration
3231
+ * @param type - Callback type to retrieve
3232
+ * @returns The matching callback addresses or an empty array if not configured
3233
+ */
3234
+ declare function getCallbackTypeAddresses(chain: Name, type: CallbackType): Address[];
3235
+ /**
3236
+ * Returns the list of allowed non-empty callback addresses for a chain.
3237
+ *
3238
+ * @param chain - Chain name
3239
+ * @returns Array of allowed callback addresses (lowercased). Empty when none configured
3240
+ */
3241
+ declare const getCallbackAddresses: (chain: Name) => Address[];
3242
+ declare const assets: Record<string, Address[]>;
3243
+ declare const configs: Record<Name, GateConfig>;
3244
+ declare namespace Gatekeeper_d_exports {
3245
+ export { Gatekeeper, Rules, create };
3246
+ }
3247
+ type Rules = readonly Rule<Offer, string>[];
3248
+ type Gatekeeper = {
3249
+ rules: Rules;
3250
+ isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
3251
+ };
3252
+ type GatekeeperParameters = {
3253
+ rules: Rules;
3254
+ };
3255
+ declare function create(parameters: GatekeeperParameters): Gatekeeper;
3256
+ //#endregion
3257
+ //#region src/gatekeeper/morphoRules.d.ts
3258
+ declare const morphoRules: (chains: Chain$1[]) => (Rule<Offer, "mixed_maker"> | Rule<Offer, "amount_mutual_exclusivity"> | Rule<Offer, "chain_ids"> | Rule<Offer, "maturity"> | Rule<Offer, "callback"> | Rule<Offer, "token">)[];
3259
+ declare namespace Rules_d_exports {
3260
+ export { ValidityParameters, amountMutualExclusivity, callback, chains, maturity, sameMaker, token, validity };
3261
+ }
3262
+ type ValidityParameters = {
3263
+ client: PublicClient<Transport, Chain$1>;
2811
3264
  };
2812
- declare function validate(cursor: unknown): cursor is Cursor;
2813
- declare function encode(c: Cursor): string;
2814
- declare function decode(token?: string): Cursor | null;
3265
+ /**
3266
+ * set of rules to validate offers.
3267
+ *
3268
+ * @param parameters - Validity parameters with chain and client
3269
+ * @returns Array of validation rules to evaluate against offers
3270
+ */
3271
+ declare function validity(parameters: ValidityParameters): (Rule<Offer, "expiry"> | Rule<Offer, "sell_erc20_callback_invalid"> | Rule<Offer, "buy_offers_callback_vault_invalid">)[];
3272
+ declare const chains: ({
3273
+ chains
3274
+ }: {
3275
+ chains: Chain$1[];
3276
+ }) => Rule<Offer, "chain_ids">;
3277
+ declare const maturity: ({
3278
+ maturities
3279
+ }: {
3280
+ maturities: MaturityType[];
3281
+ }) => Rule<Offer, "maturity">;
3282
+ declare const callback: ({
3283
+ callbacks,
3284
+ allowedAddresses
3285
+ }: {
3286
+ callbacks: CallbackType[];
3287
+ allowedAddresses: Address[];
3288
+ }) => Rule<Offer, "callback">;
3289
+ /**
3290
+ * A validation rule that checks if the offer's tokens are allowed for its chain.
3291
+ * @param assetsByChainId - Allowed assets indexed by chain id.
3292
+ * @returns The issue that was found. If the offer is valid, this will be undefined.
3293
+ */
3294
+ declare const token: ({
3295
+ assetsByChainId
3296
+ }: {
3297
+ assetsByChainId: Partial<Record<Id, Address[]>>;
3298
+ }) => Rule<Offer, "token">;
3299
+ /**
3300
+ * A batch validation rule that ensures all offers in a tree have the same maker address.
3301
+ * Returns an issue only for the first non-conforming offer.
3302
+ * This rule is signing-agnostic; signer verification is handled at the collector level.
3303
+ */
3304
+ declare const sameMaker: () => Rule<Offer, "mixed_maker">;
3305
+ /**
3306
+ * A validation rule that ensures mutual exclusivity of offer amount fields.
3307
+ * At most one of (assets, obligationUnits, obligationShares) can be non-zero.
3308
+ * Matches contract requirement: `atMostOneNonZero(offer.assets, offer.obligationUnits, offer.obligationShares)`.
3309
+ */
3310
+ declare const amountMutualExclusivity: () => Rule<Offer, "amount_mutual_exclusivity">;
2815
3311
  //#endregion
2816
3312
  //#region src/mempool/MempoolEVMClient.d.ts
2817
3313
  declare function from(parameters: from.Parameters): from.ReturnType;
@@ -2830,7 +3326,7 @@ declare namespace from {
2830
3326
  declare namespace MempoolClient_d_exports {
2831
3327
  export { AddParameters, Client$1 as Client, GetParameters, connect };
2832
3328
  }
2833
- type AddParameters = Compute<Omit<Offer, "hash" | "createdAt">[]>;
3329
+ type AddParameters = Compute<Omit<Offer, "createdAt">[]>;
2834
3330
  type GetParameters = {
2835
3331
  /** The block number to get offers from. */
2836
3332
  blockNumberGte?: number;
@@ -2885,6 +3381,12 @@ declare namespace connect {
2885
3381
  //#region src/utils/BigMath.d.ts
2886
3382
  declare function max$1(a: bigint, b: bigint): bigint;
2887
3383
  declare function min(a: bigint, b: bigint): bigint;
3384
+ /**
3385
+ * Checks if at most one of the given values is non-zero.
3386
+ * @param values - The bigint values to check.
3387
+ * @returns True if zero or one value is non-zero, false if two or more are non-zero.
3388
+ */
3389
+ declare function atMostOneNonZero(...values: bigint[]): boolean;
2888
3390
  //#endregion
2889
3391
  //#region src/utils/batch.d.ts
2890
3392
  /**
@@ -2922,6 +3424,15 @@ declare function batchMulticall<TResult>(parameters: {
2922
3424
  retryDelayMs: number;
2923
3425
  blockNumber?: bigint;
2924
3426
  }): Promise<TResult[]>;
3427
+ declare namespace Group_d_exports {
3428
+ export { fromNumber };
3429
+ }
3430
+ /**
3431
+ * Creates a bytes32 group identifier from a number.
3432
+ * @param n - A non-negative integer.
3433
+ * @throws {Error} If n is negative or not an integer.
3434
+ */
3435
+ declare const fromNumber: (n: number) => Hex;
2925
3436
  //#endregion
2926
3437
  //#region src/utils/lazy.d.ts
2927
3438
  /**
@@ -2996,8 +3507,8 @@ declare function max(): number;
2996
3507
  //#region src/utils/wait.d.ts
2997
3508
  declare function wait(time: number): Promise<unknown>;
2998
3509
  declare namespace index_d_exports$2 {
2999
- export { BaseError, GlobalErrorType, Random_d_exports as Random, ReorgError, Snake, time_d_exports as Time, batch, batchMulticall, fromSnakeCase$3 as fromSnakeCase, lazy, max$1 as max, min, poll, retry, stringifyBigint, toSnakeCase$1 as toSnakeCase, wait };
3510
+ export { BaseError, GlobalErrorType, Group_d_exports as Group, Random_d_exports as Random, ReorgError, Snake, time_d_exports as Time, atMostOneNonZero, batch, batchMulticall, fromSnakeCase$3 as fromSnakeCase, lazy, max$1 as max, min, poll, retry, stringifyBigint, toSnakeCase$1 as toSnakeCase, wait };
3000
3511
  }
3001
3512
  //#endregion
3002
- export { index_d_exports as Abi, Brand, BrandTypeId, Callback_d_exports as Callback, Chain_d_exports as Chain, Collateral_d_exports as Collateral, Compute, Cursor_d_exports as Cursor, ERC4626_d_exports as ERC4626, Errors_d_exports as Errors, Format_d_exports as Format, GateConfig_d_exports as GateConfig, Gatekeeper_d_exports as Gatekeeper, LLTV_d_exports as LLTV, Liquidity_d_exports as Liquidity, Maturity_d_exports as Maturity, MempoolClient_d_exports as Mempool, Obligation_d_exports as Obligation, Offer_d_exports as Offer, Oracle_d_exports as Oracle, Position_d_exports as Position, Quote_d_exports as Quote, index_d_exports$1 as RouterApi, Client_d_exports as RouterClient, Rules_d_exports as Rules, time_d_exports as Time, Transfer_d_exports as Transfer, Tree_d_exports as Tree, index_d_exports$2 as Utils, Gate_d_exports as Validation, morphoRules };
3513
+ export { index_d_exports as Abi, Brand, BrandTypeId, Callback_d_exports as Callback, Chain_d_exports as Chain, ChainRegistry_d_exports as ChainRegistry, Collateral_d_exports as Collateral, Compute, ERC4626_d_exports as ERC4626, Errors_d_exports as Errors, Format_d_exports as Format, GateConfig_d_exports as GateConfig, Gatekeeper_d_exports as Gatekeeper, LLTV_d_exports as LLTV, Liquidity_d_exports as Liquidity, Maturity_d_exports as Maturity, MempoolClient_d_exports as Mempool, Obligation_d_exports as Obligation, Offer_d_exports as Offer, Oracle_d_exports as Oracle, Position_d_exports as Position, Quote_d_exports as Quote, index_d_exports$1 as RouterApi, Client_d_exports as RouterClient, Rules_d_exports as Rules, time_d_exports as Time, Transfer_d_exports as Transfer, Tree_d_exports as Tree, index_d_exports$2 as Utils, Gate_d_exports as Validation, morphoRules };
3003
3514
  //# sourceMappingURL=index.browser.d.ts.map