@morpho-dev/router 0.9.0 → 0.11.0

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 (34) hide show
  1. package/dist/cli.js +5926 -3770
  2. package/dist/drizzle/migrations/0027_debt-to-transfers.sql +239 -0
  3. package/dist/drizzle/migrations/0028_obligation_id_and_keys.sql +247 -0
  4. package/dist/drizzle/migrations/0029_collateral-positions.sql +248 -0
  5. package/dist/drizzle/migrations/0030_remove_chain_id_from_offer.sql +37 -0
  6. package/dist/drizzle/migrations/0031_sell-takeable-reindex.sql +254 -0
  7. package/dist/drizzle/migrations/0032_callback-type.sql +3 -0
  8. package/dist/drizzle/migrations/0033_obligation-id-bytes20.sql +255 -0
  9. package/dist/drizzle/migrations/meta/0027_snapshot.json +1581 -0
  10. package/dist/drizzle/migrations/meta/0028_snapshot.json +1632 -0
  11. package/dist/drizzle/migrations/meta/0029_snapshot.json +1619 -0
  12. package/dist/drizzle/migrations/meta/0030_snapshot.json +1652 -0
  13. package/dist/drizzle/migrations/meta/0031_snapshot.json +1652 -0
  14. package/dist/drizzle/migrations/meta/0033_snapshot.json +1658 -0
  15. package/dist/drizzle/migrations/meta/_journal.json +49 -0
  16. package/dist/evm/bytecode/morpho.txt +1 -1
  17. package/dist/index.browser.d.mts +820 -449
  18. package/dist/index.browser.d.mts.map +1 -1
  19. package/dist/index.browser.mjs +4913 -4195
  20. package/dist/index.browser.mjs.map +1 -1
  21. package/dist/index.node.d.mts +1248 -534
  22. package/dist/index.node.d.mts.map +1 -1
  23. package/dist/index.node.mjs +3803 -1842
  24. package/dist/index.node.mjs.map +1 -1
  25. package/dist/register-otel-hook.js +7 -0
  26. package/package.json +32 -28
  27. package/dist/index.browser.d.ts +0 -4822
  28. package/dist/index.browser.d.ts.map +0 -1
  29. package/dist/index.browser.js +0 -5705
  30. package/dist/index.browser.js.map +0 -1
  31. package/dist/index.node.d.ts +0 -7752
  32. package/dist/index.node.d.ts.map +0 -1
  33. package/dist/index.node.js +0 -11633
  34. package/dist/index.node.js.map +0 -1
@@ -3,6 +3,7 @@ import { Chain } from "viem/chains";
3
3
  import * as z$1 from "zod";
4
4
  import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
5
5
  import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
6
+ import { Hono } from "hono";
6
7
  import { z } from "zod/v4";
7
8
  import "reflect-metadata";
8
9
  import { OpenAPIDocument } from "openapi-metadata";
@@ -160,17 +161,17 @@ declare const MorphoV2: readonly [{
160
161
  readonly type: "function";
161
162
  readonly stateMutability: "view";
162
163
  readonly inputs: readonly [{
163
- readonly type: "bytes32";
164
+ readonly type: "bytes20";
164
165
  readonly name: "id";
165
166
  }, {
166
167
  readonly type: "address";
167
168
  readonly name: "user";
168
169
  }, {
169
- readonly type: "address";
170
- readonly name: "collateralToken";
170
+ readonly type: "uint256";
171
+ readonly name: "collateralIndex";
171
172
  }];
172
173
  readonly outputs: readonly [{
173
- readonly type: "uint256";
174
+ readonly type: "uint128";
174
175
  }];
175
176
  }, {
176
177
  readonly name: "consume";
@@ -203,7 +204,7 @@ declare const MorphoV2: readonly [{
203
204
  readonly type: "function";
204
205
  readonly stateMutability: "view";
205
206
  readonly inputs: readonly [{
206
- readonly type: "bytes32";
207
+ readonly type: "bytes20";
207
208
  readonly name: "id";
208
209
  }, {
209
210
  readonly type: "address";
@@ -239,7 +240,7 @@ declare const MorphoV2: readonly [{
239
240
  readonly type: "function";
240
241
  readonly stateMutability: "view";
241
242
  readonly inputs: readonly [{
242
- readonly type: "bytes32";
243
+ readonly type: "bytes20";
243
244
  readonly name: "id";
244
245
  }];
245
246
  readonly outputs: readonly [{
@@ -288,10 +289,13 @@ declare const MorphoV2: readonly [{
288
289
  }, {
289
290
  readonly type: "uint256";
290
291
  readonly name: "maturity";
292
+ }, {
293
+ readonly type: "uint256";
294
+ readonly name: "minCollatValue";
291
295
  }];
292
296
  readonly name: "obligation";
293
297
  }, {
294
- readonly type: "bytes32";
298
+ readonly type: "bytes20";
295
299
  readonly name: "id";
296
300
  }, {
297
301
  readonly type: "address";
@@ -325,21 +329,20 @@ declare const MorphoV2: readonly [{
325
329
  }, {
326
330
  readonly type: "uint256";
327
331
  readonly name: "maturity";
328
- }];
329
- readonly name: "obligation";
330
- }, {
331
- readonly type: "tuple[]";
332
- readonly components: readonly [{
333
- readonly type: "uint256";
334
- readonly name: "collateralIndex";
335
332
  }, {
336
333
  readonly type: "uint256";
337
- readonly name: "repaid";
338
- }, {
339
- readonly type: "uint256";
340
- readonly name: "seized";
334
+ readonly name: "minCollatValue";
341
335
  }];
342
- readonly name: "seizures";
336
+ readonly name: "obligation";
337
+ }, {
338
+ readonly type: "uint256";
339
+ readonly name: "collateralIndex";
340
+ }, {
341
+ readonly type: "uint256";
342
+ readonly name: "seizedAssets";
343
+ }, {
344
+ readonly type: "uint256";
345
+ readonly name: "repaidUnits";
343
346
  }, {
344
347
  readonly type: "address";
345
348
  readonly name: "borrower";
@@ -348,17 +351,9 @@ declare const MorphoV2: readonly [{
348
351
  readonly name: "data";
349
352
  }];
350
353
  readonly outputs: readonly [{
351
- readonly type: "tuple[]";
352
- readonly components: readonly [{
353
- readonly type: "uint256";
354
- readonly name: "collateralIndex";
355
- }, {
356
- readonly type: "uint256";
357
- readonly name: "repaid";
358
- }, {
359
- readonly type: "uint256";
360
- readonly name: "seized";
361
- }];
354
+ readonly type: "uint256";
355
+ }, {
356
+ readonly type: "uint256";
362
357
  }];
363
358
  }, {
364
359
  readonly name: "multicall";
@@ -374,7 +369,7 @@ declare const MorphoV2: readonly [{
374
369
  readonly type: "function";
375
370
  readonly stateMutability: "view";
376
371
  readonly inputs: readonly [{
377
- readonly type: "bytes32";
372
+ readonly type: "bytes20";
378
373
  readonly name: "id";
379
374
  }];
380
375
  readonly outputs: readonly [{
@@ -385,7 +380,7 @@ declare const MorphoV2: readonly [{
385
380
  readonly type: "function";
386
381
  readonly stateMutability: "view";
387
382
  readonly inputs: readonly [{
388
- readonly type: "bytes32";
383
+ readonly type: "bytes20";
389
384
  readonly name: "id";
390
385
  }];
391
386
  readonly outputs: readonly [{
@@ -400,6 +395,9 @@ declare const MorphoV2: readonly [{
400
395
  }, {
401
396
  readonly type: "bool";
402
397
  readonly name: "created";
398
+ }, {
399
+ readonly type: "uint16[6]";
400
+ readonly name: "fees";
403
401
  }];
404
402
  }, {
405
403
  readonly name: "owner";
@@ -434,6 +432,9 @@ declare const MorphoV2: readonly [{
434
432
  }, {
435
433
  readonly type: "uint256";
436
434
  readonly name: "maturity";
435
+ }, {
436
+ readonly type: "uint256";
437
+ readonly name: "minCollatValue";
437
438
  }];
438
439
  readonly name: "obligation";
439
440
  }, {
@@ -484,7 +485,7 @@ declare const MorphoV2: readonly [{
484
485
  readonly type: "function";
485
486
  readonly stateMutability: "nonpayable";
486
487
  readonly inputs: readonly [{
487
- readonly type: "bytes32";
488
+ readonly type: "bytes20";
488
489
  readonly name: "id";
489
490
  }, {
490
491
  readonly type: "uint256";
@@ -517,7 +518,7 @@ declare const MorphoV2: readonly [{
517
518
  readonly type: "function";
518
519
  readonly stateMutability: "view";
519
520
  readonly inputs: readonly [{
520
- readonly type: "bytes32";
521
+ readonly type: "bytes20";
521
522
  readonly name: "id";
522
523
  }, {
523
524
  readonly type: "address";
@@ -557,11 +558,14 @@ declare const MorphoV2: readonly [{
557
558
  }, {
558
559
  readonly type: "uint256";
559
560
  readonly name: "maturity";
561
+ }, {
562
+ readonly type: "uint256";
563
+ readonly name: "minCollatValue";
560
564
  }];
561
565
  readonly name: "obligation";
562
566
  }, {
563
- readonly type: "address";
564
- readonly name: "collateral";
567
+ readonly type: "uint256";
568
+ readonly name: "collateralIndex";
565
569
  }, {
566
570
  readonly type: "uint256";
567
571
  readonly name: "assets";
@@ -621,6 +625,9 @@ declare const MorphoV2: readonly [{
621
625
  }, {
622
626
  readonly type: "uint256";
623
627
  readonly name: "maturity";
628
+ }, {
629
+ readonly type: "uint256";
630
+ readonly name: "minCollatValue";
624
631
  }];
625
632
  readonly name: "obligation";
626
633
  }, {
@@ -693,12 +700,80 @@ declare const MorphoV2: readonly [{
693
700
  }, {
694
701
  readonly type: "uint256";
695
702
  }];
703
+ }, {
704
+ readonly name: "toId";
705
+ readonly type: "function";
706
+ readonly stateMutability: "view";
707
+ readonly inputs: readonly [{
708
+ readonly type: "tuple";
709
+ readonly components: readonly [{
710
+ readonly type: "address";
711
+ readonly name: "loanToken";
712
+ }, {
713
+ readonly type: "tuple[]";
714
+ readonly components: readonly [{
715
+ readonly type: "address";
716
+ readonly name: "token";
717
+ }, {
718
+ readonly type: "uint256";
719
+ readonly name: "lltv";
720
+ }, {
721
+ readonly type: "address";
722
+ readonly name: "oracle";
723
+ }];
724
+ readonly name: "collaterals";
725
+ }, {
726
+ readonly type: "uint256";
727
+ readonly name: "maturity";
728
+ }, {
729
+ readonly type: "uint256";
730
+ readonly name: "minCollatValue";
731
+ }];
732
+ readonly name: "obligation";
733
+ }];
734
+ readonly outputs: readonly [{
735
+ readonly type: "bytes20";
736
+ }];
737
+ }, {
738
+ readonly name: "toObligation";
739
+ readonly type: "function";
740
+ readonly stateMutability: "view";
741
+ readonly inputs: readonly [{
742
+ readonly type: "bytes20";
743
+ readonly name: "id";
744
+ }];
745
+ readonly outputs: readonly [{
746
+ readonly type: "tuple";
747
+ readonly components: readonly [{
748
+ readonly type: "address";
749
+ readonly name: "loanToken";
750
+ }, {
751
+ readonly type: "tuple[]";
752
+ readonly components: readonly [{
753
+ readonly type: "address";
754
+ readonly name: "token";
755
+ }, {
756
+ readonly type: "uint256";
757
+ readonly name: "lltv";
758
+ }, {
759
+ readonly type: "address";
760
+ readonly name: "oracle";
761
+ }];
762
+ readonly name: "collaterals";
763
+ }, {
764
+ readonly type: "uint256";
765
+ readonly name: "maturity";
766
+ }, {
767
+ readonly type: "uint256";
768
+ readonly name: "minCollatValue";
769
+ }];
770
+ }];
696
771
  }, {
697
772
  readonly name: "totalShares";
698
773
  readonly type: "function";
699
774
  readonly stateMutability: "view";
700
775
  readonly inputs: readonly [{
701
- readonly type: "bytes32";
776
+ readonly type: "bytes20";
702
777
  readonly name: "id";
703
778
  }];
704
779
  readonly outputs: readonly [{
@@ -709,7 +784,7 @@ declare const MorphoV2: readonly [{
709
784
  readonly type: "function";
710
785
  readonly stateMutability: "view";
711
786
  readonly inputs: readonly [{
712
- readonly type: "bytes32";
787
+ readonly type: "bytes20";
713
788
  readonly name: "id";
714
789
  }];
715
790
  readonly outputs: readonly [{
@@ -740,18 +815,21 @@ declare const MorphoV2: readonly [{
740
815
  }, {
741
816
  readonly type: "uint256";
742
817
  readonly name: "maturity";
818
+ }, {
819
+ readonly type: "uint256";
820
+ readonly name: "minCollatValue";
743
821
  }];
744
822
  readonly name: "obligation";
745
823
  }];
746
824
  readonly outputs: readonly [{
747
- readonly type: "bytes32";
825
+ readonly type: "bytes20";
748
826
  }];
749
827
  }, {
750
828
  readonly name: "tradingFee";
751
829
  readonly type: "function";
752
830
  readonly stateMutability: "view";
753
831
  readonly inputs: readonly [{
754
- readonly type: "bytes32";
832
+ readonly type: "bytes20";
755
833
  readonly name: "id";
756
834
  }, {
757
835
  readonly type: "uint256";
@@ -793,6 +871,9 @@ declare const MorphoV2: readonly [{
793
871
  }, {
794
872
  readonly type: "uint256";
795
873
  readonly name: "maturity";
874
+ }, {
875
+ readonly type: "uint256";
876
+ readonly name: "minCollatValue";
796
877
  }];
797
878
  readonly name: "obligation";
798
879
  }, {
@@ -838,11 +919,14 @@ declare const MorphoV2: readonly [{
838
919
  }, {
839
920
  readonly type: "uint256";
840
921
  readonly name: "maturity";
922
+ }, {
923
+ readonly type: "uint256";
924
+ readonly name: "minCollatValue";
841
925
  }];
842
926
  readonly name: "obligation";
843
927
  }, {
844
- readonly type: "address";
845
- readonly name: "collateral";
928
+ readonly type: "uint256";
929
+ readonly name: "collateralIndex";
846
930
  }, {
847
931
  readonly type: "uint256";
848
932
  readonly name: "assets";
@@ -859,7 +943,7 @@ declare const MorphoV2: readonly [{
859
943
  readonly type: "function";
860
944
  readonly stateMutability: "view";
861
945
  readonly inputs: readonly [{
862
- readonly type: "bytes32";
946
+ readonly type: "bytes20";
863
947
  readonly name: "id";
864
948
  }];
865
949
  readonly outputs: readonly [{
@@ -911,29 +995,22 @@ declare const MorphoV2: readonly [{
911
995
  readonly name: "caller";
912
996
  readonly indexed: true;
913
997
  }, {
914
- readonly type: "bytes32";
915
- readonly name: "id";
998
+ readonly type: "bytes20";
999
+ readonly name: "id_";
916
1000
  readonly indexed: true;
917
1001
  }, {
918
- readonly type: "tuple[]";
919
- readonly components: readonly [{
920
- readonly type: "uint256";
921
- readonly name: "collateralIndex";
922
- }, {
923
- readonly type: "uint256";
924
- readonly name: "repaid";
925
- }, {
926
- readonly type: "uint256";
927
- readonly name: "seized";
928
- }];
929
- readonly name: "seizures";
1002
+ readonly type: "uint256";
1003
+ readonly name: "collateralIndex";
1004
+ }, {
1005
+ readonly type: "uint256";
1006
+ readonly name: "seizedAssets";
1007
+ }, {
1008
+ readonly type: "uint256";
1009
+ readonly name: "repaidUnits";
930
1010
  }, {
931
1011
  readonly type: "address";
932
1012
  readonly name: "borrower";
933
1013
  readonly indexed: true;
934
- }, {
935
- readonly type: "uint256";
936
- readonly name: "totalRepaid";
937
1014
  }, {
938
1015
  readonly type: "uint256";
939
1016
  readonly name: "badDebt";
@@ -942,8 +1019,8 @@ declare const MorphoV2: readonly [{
942
1019
  readonly name: "ObligationCreated";
943
1020
  readonly type: "event";
944
1021
  readonly inputs: readonly [{
945
- readonly type: "bytes32";
946
- readonly name: "id";
1022
+ readonly type: "bytes20";
1023
+ readonly name: "id_";
947
1024
  readonly indexed: true;
948
1025
  }, {
949
1026
  readonly type: "tuple";
@@ -966,6 +1043,9 @@ declare const MorphoV2: readonly [{
966
1043
  }, {
967
1044
  readonly type: "uint256";
968
1045
  readonly name: "maturity";
1046
+ }, {
1047
+ readonly type: "uint256";
1048
+ readonly name: "minCollatValue";
969
1049
  }];
970
1050
  readonly name: "obligation";
971
1051
  }];
@@ -977,8 +1057,8 @@ declare const MorphoV2: readonly [{
977
1057
  readonly name: "caller";
978
1058
  readonly indexed: true;
979
1059
  }, {
980
- readonly type: "bytes32";
981
- readonly name: "id";
1060
+ readonly type: "bytes20";
1061
+ readonly name: "id_";
982
1062
  readonly indexed: true;
983
1063
  }, {
984
1064
  readonly type: "uint256";
@@ -1015,8 +1095,8 @@ declare const MorphoV2: readonly [{
1015
1095
  readonly name: "SetObligationTradingFee";
1016
1096
  readonly type: "event";
1017
1097
  readonly inputs: readonly [{
1018
- readonly type: "bytes32";
1019
- readonly name: "id";
1098
+ readonly type: "bytes20";
1099
+ readonly name: "id_";
1020
1100
  readonly indexed: true;
1021
1101
  }, {
1022
1102
  readonly type: "uint256";
@@ -1060,8 +1140,8 @@ declare const MorphoV2: readonly [{
1060
1140
  readonly type: "address";
1061
1141
  readonly name: "caller";
1062
1142
  }, {
1063
- readonly type: "bytes32";
1064
- readonly name: "id";
1143
+ readonly type: "bytes20";
1144
+ readonly name: "id_";
1065
1145
  readonly indexed: true;
1066
1146
  }, {
1067
1147
  readonly type: "address";
@@ -1082,8 +1162,8 @@ declare const MorphoV2: readonly [{
1082
1162
  readonly type: "address";
1083
1163
  readonly name: "caller";
1084
1164
  }, {
1085
- readonly type: "bytes32";
1086
- readonly name: "id";
1165
+ readonly type: "bytes20";
1166
+ readonly name: "id_";
1087
1167
  readonly indexed: true;
1088
1168
  }, {
1089
1169
  readonly type: "address";
@@ -1131,8 +1211,8 @@ declare const MorphoV2: readonly [{
1131
1211
  readonly type: "address";
1132
1212
  readonly name: "caller";
1133
1213
  }, {
1134
- readonly type: "bytes32";
1135
- readonly name: "id";
1214
+ readonly type: "bytes20";
1215
+ readonly name: "id_";
1136
1216
  readonly indexed: true;
1137
1217
  }, {
1138
1218
  readonly type: "uint256";
@@ -1156,8 +1236,8 @@ declare const MorphoV2: readonly [{
1156
1236
  readonly type: "address";
1157
1237
  readonly name: "caller";
1158
1238
  }, {
1159
- readonly type: "bytes32";
1160
- readonly name: "id";
1239
+ readonly type: "bytes20";
1240
+ readonly name: "id_";
1161
1241
  readonly indexed: true;
1162
1242
  }, {
1163
1243
  readonly type: "address";
@@ -1301,7 +1381,7 @@ declare const Morpho: readonly [{
1301
1381
  readonly stateMutability: "view";
1302
1382
  }];
1303
1383
  declare namespace Callback_d_exports {
1304
- export { Callback, Type$1 as Type, isEmptyCallback };
1384
+ export { Callback, CallbackType, Type$1 as Type, isEmptyCallback };
1305
1385
  }
1306
1386
  type Callback = {
1307
1387
  type: Type$1.BuyWithEmptyCallback;
@@ -1312,6 +1392,9 @@ declare enum Type$1 {
1312
1392
  BuyWithEmptyCallback = "buy_with_empty_callback",
1313
1393
  SellWithEmptyCallback = "sell_with_empty_callback"
1314
1394
  }
1395
+ declare enum CallbackType {
1396
+ Empty = "empty"
1397
+ }
1315
1398
  declare const isEmptyCallback: (offer: Offer) => boolean;
1316
1399
  declare namespace Errors_d_exports {
1317
1400
  export { BaseError, GlobalErrorType, ReorgError };
@@ -1346,7 +1429,7 @@ declare class ReorgError extends BaseError {
1346
1429
  constructor(blockNumber: number);
1347
1430
  }
1348
1431
  declare namespace Chain_d_exports {
1349
- export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name$1 as Name, chainIds, chainNames, chains$2 as chains, getChain, getWhitelistedChains, streamLogs };
1432
+ export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name$1 as Name, UnrecoverableLogsResponseSizeError, chainIds, chainNames, chains$1 as chains, getChain, getWhitelistedChains, streamLogs };
1350
1433
  }
1351
1434
  type Chain$1 = Compute<Omit<Chain<ChainFormatters, {
1352
1435
  morpho: ChainContract;
@@ -1387,7 +1470,7 @@ type Id = (typeof ChainId)[Uppercase<Name$1>];
1387
1470
  declare const chainIds: readonly Id[];
1388
1471
  declare function getChain(chainId: Id): Chain$1 | undefined;
1389
1472
  declare const getWhitelistedChains: () => Chain$1[];
1390
- declare const chains$2: Record<Lowercase<Name$1>, Chain$1>;
1473
+ declare const chains$1: Record<Lowercase<Name$1>, Chain$1>;
1391
1474
  declare function streamLogs<abiEvent extends AbiEvent | undefined = undefined>(parameters: {
1392
1475
  client: PublicClient;
1393
1476
  contractAddress?: Address;
@@ -1405,6 +1488,8 @@ declare function streamLogs<abiEvent extends AbiEvent | undefined = undefined>(p
1405
1488
  }, void, void>;
1406
1489
  declare class InvalidBlockRangeError extends BaseError {
1407
1490
  name: string;
1491
+ readonly fromBlock: bigint;
1492
+ readonly toBlock: bigint;
1408
1493
  constructor(fromBlock: bigint, toBlock: bigint);
1409
1494
  }
1410
1495
  declare class InvalidBlockWindowError extends BaseError {
@@ -1419,8 +1504,12 @@ declare class MissingBlockNumberError extends BaseError {
1419
1504
  name: string;
1420
1505
  constructor();
1421
1506
  }
1507
+ declare class UnrecoverableLogsResponseSizeError extends BaseError<Error> {
1508
+ name: string;
1509
+ constructor(blockNumber: bigint, cause?: unknown);
1510
+ }
1422
1511
  declare namespace ChainRegistry_d_exports {
1423
- export { ChainRegistry, create$6 as create };
1512
+ export { ChainRegistry, create$8 as create };
1424
1513
  }
1425
1514
  type ChainRegistry = {
1426
1515
  getById: (chainId: Id) => Chain$1 | undefined;
@@ -1431,7 +1520,7 @@ type ChainRegistry = {
1431
1520
  * @param chains - Array of chain objects to register.
1432
1521
  * @returns A registry for looking up chains by ID. {@link ChainRegistry}
1433
1522
  */
1434
- declare function create$6(chains: Chain$1[]): ChainRegistry;
1523
+ declare function create$8(chains: Chain$1[]): ChainRegistry;
1435
1524
  //#endregion
1436
1525
  //#region src/core/types.d.ts
1437
1526
  /** Combines members of an intersection into a readable type. */
@@ -1465,13 +1554,23 @@ declare class InvalidLLTVError extends BaseError {
1465
1554
  }
1466
1555
  declare const LLTVSchema: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
1467
1556
  declare namespace Collateral_d_exports {
1468
- export { Collateral, CollateralSchema, CollateralsSchema, from$16 as from, random$3 as random };
1557
+ export { Collateral, CollateralSchema, CollateralsSchema, abi$1 as abi, from$16 as from, random$3 as random };
1469
1558
  }
1470
1559
  type Collateral = {
1471
1560
  /** Asset being used as collateral. */asset: Address; /** Liquidation Loan-to-Value of the collateral. */
1472
1561
  lltv: LLTV; /** Oracle contract used to price the collateral. */
1473
1562
  oracle: Address;
1474
1563
  };
1564
+ declare const abi$1: readonly [{
1565
+ readonly type: "address";
1566
+ readonly name: "token";
1567
+ }, {
1568
+ readonly type: "uint256";
1569
+ readonly name: "lltv";
1570
+ }, {
1571
+ readonly type: "address";
1572
+ readonly name: "oracle";
1573
+ }];
1475
1574
  declare const CollateralSchema: z$1.ZodObject<{
1476
1575
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1477
1576
  oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1585,132 +1684,63 @@ declare class DenominatorIsZeroError extends BaseError {
1585
1684
  readonly name = "ERC4626.DenominatorIsZeroError";
1586
1685
  constructor();
1587
1686
  }
1588
- declare namespace Liquidity_d_exports {
1589
- export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
1687
+ declare namespace Format_d_exports {
1688
+ export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
1590
1689
  }
1690
+ /** The snake case representation of a type with bigint values stringified. */
1691
+ type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
1692
+ /** Make arrays/tuples and object props mutable, deeply. */
1693
+ 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;
1694
+ /** Stringifies bigint values to strings and preserves branded primitives. */
1695
+ 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;
1696
+ /** Key remapping that also preserves branded primitives. */
1697
+ 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;
1698
+ 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;
1591
1699
  /**
1592
- * Represents a liquidity pool with a unique ID and amount.
1700
+ * Formats object keys to snake case.
1701
+ * Preserves ethereum addresses as is.
1702
+ * Converts ethereum addresses to checksummed if used as values.
1703
+ * Stringifies bigint values to strings.
1593
1704
  */
1594
- type LiquidityPool = {
1595
- id: string;
1596
- amount: bigint;
1597
- };
1705
+ declare function toSnakeCase$1<T>(obj: T): Snake<T>;
1598
1706
  /**
1599
- * Represents a hierarchical relationship between two liquidity pools.
1707
+ * Formats a snake case object to its camel case type.
1708
+ * Preserves ethereum addresses as is.
1709
+ * Converts checksummed ethereum addresses to lowercase if used as values.
1710
+ * @warning Does not unstringify bigint values.
1600
1711
  */
1601
- type LiquidityLink = {
1602
- parentPoolId: string;
1603
- childPoolId: string;
1604
- priority: number;
1605
- };
1712
+ declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
1713
+ declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
1714
+ declare namespace Maturity_d_exports {
1715
+ export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$15 as from };
1716
+ }
1606
1717
  /**
1607
- * Represents the connection between an offer and its liquidity pools.
1718
+ * Maturity is a number that represents a date in seconds.
1608
1719
  */
1609
- type OfferLiquidityPool = {
1610
- offerHash: Hex;
1611
- poolId: string;
1612
- /**
1613
- * The available capacity/liquidity from this pool for this offer.
1614
- * Matches allowance amount from pool below.
1615
- */
1616
- amount: bigint;
1720
+ type Maturity = number & Brand<"Maturity">;
1721
+ declare const MaturitySchema: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
1722
+ declare enum MaturityType {
1723
+ EndOfWeek = "end_of_week",
1724
+ EndOfNextWeek = "end_of_next_week",
1725
+ EndOfMonth = "end_of_month",
1726
+ EndOfNextMonth = "end_of_next_month",
1727
+ EndOfQuarter = "end_of_quarter",
1728
+ EndOfNextQuarter = "end_of_next_quarter"
1729
+ }
1730
+ declare const MaturityOptions: {
1731
+ readonly end_of_week: () => Maturity;
1732
+ readonly end_of_next_week: () => Maturity;
1733
+ readonly end_of_month: () => Maturity;
1734
+ readonly end_of_next_month: () => Maturity;
1735
+ readonly end_of_quarter: () => Maturity;
1736
+ readonly end_of_next_quarter: () => Maturity;
1617
1737
  };
1738
+ type MaturityOptions = keyof typeof MaturityOptions;
1618
1739
  /**
1619
- * Calculate maximum debt capacity from collateral amount.
1620
- * @param amount - Collateral amount
1621
- * @param oraclePrice - Oracle price (scaled to 36 decimals)
1622
- * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
1623
- * @returns Maximum debt capacity
1624
- */
1625
- declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
1626
- /**
1627
- * Generate pool ID for balance pools.
1628
- */
1629
- declare function generateBalancePoolId(parameters: {
1630
- user: Address;
1631
- chainId: Id;
1632
- token: Address;
1633
- }): string;
1634
- /**
1635
- * Generate pool ID for allowance pools.
1636
- */
1637
- declare function generateAllowancePoolId(parameters: {
1638
- user: Address;
1639
- chainId: Id;
1640
- token: Address;
1641
- }): string;
1642
- /**
1643
- * Generate pool ID for obligation collateral pools.
1644
- * Obligation collateral pools represent collateral already deposited in the obligation.
1645
- * These pools are shared across all offers with the same obligation.
1646
- */
1647
- declare function generateObligationCollateralPoolId(parameters: {
1648
- user: Address;
1649
- chainId: Id;
1650
- obligationId: Hex;
1651
- token: Address;
1652
- }): string;
1653
- /**
1654
- * Generate pool ID for debt pools.
1655
- */
1656
- declare function generateDebtPoolId(parameters: {
1657
- user: Address;
1658
- chainId: Id;
1659
- obligationId: Hex;
1660
- }): string;
1661
- /**
1662
- * Generate pool ID for user position in a vault.
1663
- */
1664
- declare function generateUserVaultPositionPoolId(parameters: {
1665
- user: Address;
1666
- chainId: Id;
1667
- vault: Address;
1668
- }): string;
1669
- /**
1670
- * Generate pool ID for vault position in a market.
1671
- */
1672
- declare function generateVaultPositionPoolId(parameters: {
1673
- vault: Address;
1674
- chainId: Id;
1675
- marketId: string;
1676
- }): string;
1677
- /**
1678
- * Generate pool ID for market total liquidity.
1679
- */
1680
- declare function generateMarketLiquidityPoolId(parameters: {
1681
- chainId: Id;
1682
- marketId: string;
1683
- }): string;
1684
- declare namespace Maturity_d_exports {
1685
- export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$15 as from };
1686
- }
1687
- /**
1688
- * Maturity is a number that represents a date in seconds.
1689
- */
1690
- type Maturity = number & Brand<"Maturity">;
1691
- declare const MaturitySchema: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
1692
- declare enum MaturityType {
1693
- EndOfWeek = "end_of_week",
1694
- EndOfNextWeek = "end_of_next_week",
1695
- EndOfMonth = "end_of_month",
1696
- EndOfNextMonth = "end_of_next_month",
1697
- EndOfQuarter = "end_of_quarter",
1698
- EndOfNextQuarter = "end_of_next_quarter"
1699
- }
1700
- declare const MaturityOptions: {
1701
- readonly end_of_week: () => Maturity;
1702
- readonly end_of_next_week: () => Maturity;
1703
- readonly end_of_month: () => Maturity;
1704
- readonly end_of_next_month: () => Maturity;
1705
- readonly end_of_quarter: () => Maturity;
1706
- readonly end_of_next_quarter: () => Maturity;
1707
- };
1708
- type MaturityOptions = keyof typeof MaturityOptions;
1709
- /**
1710
- * Creates a maturity from a timestamp in seconds or a maturity option.
1711
- * @throws {InvalidFormatError} If the maturity is in milliseconds.
1712
- * @throws {InvalidDateError} If the maturity is in seconds but not a valid date.
1713
- * @throws {InvalidOptionError} If the maturity is not a valid option.
1740
+ * Creates a maturity from a timestamp in seconds or a maturity option.
1741
+ * @throws {InvalidFormatError} If the maturity is in milliseconds.
1742
+ * @throws {InvalidDateError} If the maturity is in seconds but not a valid date.
1743
+ * @throws {InvalidOptionError} If the maturity is not a valid option.
1714
1744
  */
1715
1745
  declare function from$15(ts: from$15.Parameters): Maturity;
1716
1746
  declare namespace from$15 {
@@ -1729,44 +1759,16 @@ declare class InvalidOptionError extends BaseError {
1729
1759
  readonly name = "Maturity.InvalidOptionError";
1730
1760
  constructor(input: string);
1731
1761
  }
1732
- declare namespace Format_d_exports {
1733
- export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
1734
- }
1735
- /** The snake case representation of a type with bigint values stringified. */
1736
- type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
1737
- /** Make arrays/tuples and object props mutable, deeply. */
1738
- 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;
1739
- /** Stringifies bigint values to strings and preserves branded primitives. */
1740
- 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;
1741
- /** Key remapping that also preserves branded primitives. */
1742
- 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;
1743
- 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;
1744
- /**
1745
- * Formats object keys to snake case.
1746
- * Preserves ethereum addresses as is.
1747
- * Converts ethereum addresses to checksummed if used as values.
1748
- * Stringifies bigint values to strings.
1749
- */
1750
- declare function toSnakeCase$1<T>(obj: T): Snake<T>;
1751
- /**
1752
- * Formats a snake case object to its camel case type.
1753
- * Preserves ethereum addresses as is.
1754
- * Converts checksummed ethereum addresses to lowercase if used as values.
1755
- * @warning Does not unstringify bigint values.
1756
- */
1757
- declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
1758
- declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
1759
1762
  declare namespace Obligation_d_exports {
1760
- export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$14 as from, fromOffer$1 as fromOffer, fromSnakeCase$2 as fromSnakeCase, id, random$2 as random };
1763
+ export { CollateralsAreNotSortedError, InvalidObligationError, Obligation$1 as Obligation, ObligationSchema, abi, from$14 as from, fromOffer$1 as fromOffer, fromSnakeCase$2 as fromSnakeCase, key$1 as key, random$2 as random, tupleAbi };
1761
1764
  }
1762
- type Obligation = {
1763
- /** The chain id where the liquidity for this obligation is located. */chainId: Id; /** The token that is being borrowed for this obligation. */
1764
- loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1765
+ type Obligation$1 = {
1766
+ /** The token that is being borrowed for this obligation. */loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1765
1767
  collaterals: Collateral[]; /** The maturity of the obligation. */
1766
- maturity: Maturity;
1768
+ maturity: Maturity; /** Minimum collateral value (quoted in loan token) to maintain on collateral updates. */
1769
+ minCollatValue: bigint;
1767
1770
  };
1768
1771
  declare const ObligationSchema: z$1.ZodObject<{
1769
- chainId: z$1.ZodNumber;
1770
1772
  loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1771
1773
  collaterals: z$1.ZodArray<z$1.ZodObject<{
1772
1774
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1774,7 +1776,57 @@ declare const ObligationSchema: z$1.ZodObject<{
1774
1776
  lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
1775
1777
  }, z$1.core.$strip>>;
1776
1778
  maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
1779
+ minCollatValue: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBigInt>>;
1777
1780
  }, z$1.core.$strip>;
1781
+ declare const abi: readonly [{
1782
+ readonly type: "address";
1783
+ readonly name: "loanToken";
1784
+ }, {
1785
+ readonly type: "tuple[]";
1786
+ readonly name: "collaterals";
1787
+ readonly components: readonly [{
1788
+ readonly type: "address";
1789
+ readonly name: "token";
1790
+ }, {
1791
+ readonly type: "uint256";
1792
+ readonly name: "lltv";
1793
+ }, {
1794
+ readonly type: "address";
1795
+ readonly name: "oracle";
1796
+ }];
1797
+ }, {
1798
+ readonly type: "uint256";
1799
+ readonly name: "maturity";
1800
+ }, {
1801
+ readonly type: "uint256";
1802
+ readonly name: "minCollatValue";
1803
+ }];
1804
+ declare const tupleAbi: readonly [{
1805
+ readonly type: "tuple";
1806
+ readonly components: readonly [{
1807
+ readonly type: "address";
1808
+ readonly name: "loanToken";
1809
+ }, {
1810
+ readonly type: "tuple[]";
1811
+ readonly name: "collaterals";
1812
+ readonly components: readonly [{
1813
+ readonly type: "address";
1814
+ readonly name: "token";
1815
+ }, {
1816
+ readonly type: "uint256";
1817
+ readonly name: "lltv";
1818
+ }, {
1819
+ readonly type: "address";
1820
+ readonly name: "oracle";
1821
+ }];
1822
+ }, {
1823
+ readonly type: "uint256";
1824
+ readonly name: "maturity";
1825
+ }, {
1826
+ readonly type: "uint256";
1827
+ readonly name: "minCollatValue";
1828
+ }];
1829
+ }];
1778
1830
  /**
1779
1831
  * Creates an obligation from the given parameters.
1780
1832
  * @constructor
@@ -1785,7 +1837,6 @@ declare const ObligationSchema: z$1.ZodObject<{
1785
1837
  * @example
1786
1838
  * ```ts
1787
1839
  * const obligation = Obligation.from({
1788
- * chainId: 1,
1789
1840
  * loanToken: privateKeyToAccount(generatePrivateKey()).address,
1790
1841
  * collaterals: [
1791
1842
  * Collateral.from({
@@ -1801,12 +1852,12 @@ declare const ObligationSchema: z$1.ZodObject<{
1801
1852
  declare function from$14(parameters: from$14.Parameters): from$14.ReturnType;
1802
1853
  declare namespace from$14 {
1803
1854
  type Parameters = {
1804
- /** The chain id where the liquidity for this obligation is located. */chainId: number; /** The token that is being borrowed for this obligation. */
1805
- loanToken: Address; /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
1855
+ /** The token that is being borrowed for this obligation. */loanToken: Address; /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
1806
1856
  collaterals: from$16.Parameters[] | readonly from$16.Parameters[]; /** The maturity of the obligation. */
1807
- maturity: from$15.Parameters;
1857
+ maturity: from$15.Parameters; /** Minimum collateral value (quoted in loan token). @default 0 */
1858
+ minCollatValue?: bigint;
1808
1859
  };
1809
- type ReturnType = Obligation;
1860
+ type ReturnType = Obligation$1;
1810
1861
  type ErrorType = InvalidObligationError;
1811
1862
  }
1812
1863
  /**
@@ -1817,30 +1868,31 @@ declare namespace from$14 {
1817
1868
  */
1818
1869
  declare function fromSnakeCase$2(input: fromSnakeCase$2.Parameters): fromSnakeCase$2.ReturnType;
1819
1870
  declare namespace fromSnakeCase$2 {
1820
- type Parameters = Snake<Omit<Obligation, "chainId"> & {
1821
- chainId: number;
1822
- }>;
1823
- type ReturnType = Obligation;
1871
+ type SnakeCaseParameters = Omit<Obligation$1, "minCollatValue"> & {
1872
+ minCollatValue?: bigint;
1873
+ };
1874
+ type Parameters = Snake<SnakeCaseParameters>;
1875
+ type ReturnType = Obligation$1;
1824
1876
  type ErrorType = InvalidObligationError;
1825
1877
  }
1826
1878
  /**
1827
- * Calculates the obligation id based on the smart contract's Obligation struct.
1828
- * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals, maturity)).
1879
+ * Calculates a canonical key for an obligation payload.
1880
+ * The key is computed as keccak256(abi.encode(loanToken, collaterals, maturity, minCollatValue)).
1881
+ * If omitted, `minCollatValue` defaults to `0`.
1829
1882
  * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
1830
- * @param parameters - {@link id.Parameters}
1831
- * @returns The obligation id as a 32-byte hex string. {@link id.ReturnType}
1883
+ * @param parameters - {@link key.Parameters}
1884
+ * @returns The obligation key as a 32-byte hex string. {@link key.ReturnType}
1832
1885
  *
1833
1886
  * @example
1834
1887
  * ```ts
1835
1888
  * const obligation = Obligation.random();
1836
- * const id = Obligation.id(obligation);
1837
- * console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
1889
+ * const key = Obligation.key(obligation);
1890
+ * console.log(key); // 0x1234567890123456789012345678901234567890123456789012345678901234
1838
1891
  * ```
1839
1892
  */
1840
- declare function id(parameters: id.Parameters): id.ReturnType;
1841
- declare namespace id {
1893
+ declare function key$1(parameters: key$1.Parameters): key$1.ReturnType;
1894
+ declare namespace key$1 {
1842
1895
  type Parameters = {
1843
- chainId: number;
1844
1896
  loanToken: Address;
1845
1897
  collaterals: {
1846
1898
  asset: Address;
@@ -1848,6 +1900,7 @@ declare namespace id {
1848
1900
  oracle: Address;
1849
1901
  }[];
1850
1902
  maturity: number;
1903
+ minCollatValue?: bigint;
1851
1904
  };
1852
1905
  type ReturnType = Hex;
1853
1906
  type ErrorType = CollateralsAreNotSortedError;
@@ -1863,7 +1916,7 @@ declare namespace id {
1863
1916
  */
1864
1917
  declare function random$2(): random$2.ReturnType;
1865
1918
  declare namespace random$2 {
1866
- type ReturnType = Obligation;
1919
+ type ReturnType = Obligation$1;
1867
1920
  }
1868
1921
  /**
1869
1922
  * Creates an obligation from an offer.
@@ -1875,7 +1928,7 @@ declare namespace random$2 {
1875
1928
  declare function fromOffer$1(offer: Offer): fromOffer$1.ReturnType;
1876
1929
  declare namespace fromOffer$1 {
1877
1930
  type Parameters = Offer;
1878
- type ReturnType = Obligation;
1931
+ type ReturnType = Obligation$1;
1879
1932
  }
1880
1933
  declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
1881
1934
  readonly name = "Obligation.InvalidObligationError";
@@ -1885,8 +1938,138 @@ declare class CollateralsAreNotSortedError extends BaseError {
1885
1938
  readonly name = "Obligation.CollateralsAreNotSortedError";
1886
1939
  constructor();
1887
1940
  }
1941
+ declare namespace Id_d_exports {
1942
+ export { Obligation, creationCode, toId };
1943
+ }
1944
+ type Obligation = Obligation$1;
1945
+ /**
1946
+ * Builds the same creation code as `IdLib.creationCode` in Solidity.
1947
+ *
1948
+ * Layout: `prefix (11 bytes) + abi.encode(obligation)`.
1949
+ *
1950
+ * @param parameters - {@link creationCode.Parameters}
1951
+ * @returns The CREATE2 init code bytes. {@link creationCode.ReturnType}
1952
+ */
1953
+ declare function creationCode(parameters: creationCode.Parameters): creationCode.ReturnType;
1954
+ declare namespace creationCode {
1955
+ type Parameters = {
1956
+ obligation: Obligation;
1957
+ chainId: Id;
1958
+ morphoV2: Address;
1959
+ };
1960
+ type ReturnType = Hex;
1961
+ }
1962
+ /**
1963
+ * Computes the same id as `IdLib.toId` in Solidity using the CREATE2 preimage:
1964
+ * `keccak256(0xff ++ morphoV2 ++ chainId ++ keccak256(creationCode))`,
1965
+ * then truncates to the lower 20 bytes.
1966
+ *
1967
+ * @param parameters - {@link toId.Parameters}
1968
+ * @returns The obligation id. {@link toId.ReturnType}
1969
+ */
1970
+ declare function toId(parameters: toId.Parameters): toId.ReturnType;
1971
+ declare namespace toId {
1972
+ type Parameters = creationCode.Parameters;
1973
+ type ReturnType = Hex;
1974
+ }
1975
+ declare namespace Liquidity_d_exports {
1976
+ export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
1977
+ }
1978
+ /**
1979
+ * Represents a liquidity pool with a unique ID and amount.
1980
+ */
1981
+ type LiquidityPool = {
1982
+ id: string;
1983
+ amount: bigint;
1984
+ };
1985
+ /**
1986
+ * Represents a hierarchical relationship between two liquidity pools.
1987
+ */
1988
+ type LiquidityLink = {
1989
+ parentPoolId: string;
1990
+ childPoolId: string;
1991
+ priority: number;
1992
+ };
1993
+ /**
1994
+ * Represents the connection between an offer and its liquidity pools.
1995
+ */
1996
+ type OfferLiquidityPool = {
1997
+ offerHash: Hex;
1998
+ poolId: string;
1999
+ /**
2000
+ * The available capacity/liquidity from this pool for this offer.
2001
+ * Matches allowance amount from pool below.
2002
+ */
2003
+ amount: bigint;
2004
+ };
2005
+ /**
2006
+ * Calculate maximum debt capacity from collateral amount.
2007
+ * @param amount - Collateral amount
2008
+ * @param oraclePrice - Oracle price (scaled to 36 decimals)
2009
+ * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
2010
+ * @returns Maximum debt capacity
2011
+ */
2012
+ declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
2013
+ /**
2014
+ * Generate pool ID for balance pools.
2015
+ */
2016
+ declare function generateBalancePoolId(parameters: {
2017
+ user: Address;
2018
+ chainId: Id;
2019
+ token: Address;
2020
+ }): string;
2021
+ /**
2022
+ * Generate pool ID for allowance pools.
2023
+ */
2024
+ declare function generateAllowancePoolId(parameters: {
2025
+ user: Address;
2026
+ chainId: Id;
2027
+ token: Address;
2028
+ }): string;
2029
+ /**
2030
+ * Generate pool ID for obligation collateral pools.
2031
+ * Obligation collateral pools represent collateral already deposited in the obligation.
2032
+ * These pools are shared across all offers with the same obligation.
2033
+ */
2034
+ declare function generateObligationCollateralPoolId(parameters: {
2035
+ user: Address;
2036
+ chainId: Id;
2037
+ obligationId: Hex;
2038
+ token: Address;
2039
+ }): string;
2040
+ /**
2041
+ * Generate pool ID for debt pools.
2042
+ */
2043
+ declare function generateDebtPoolId(parameters: {
2044
+ user: Address;
2045
+ chainId: Id;
2046
+ obligationId: Hex;
2047
+ }): string;
2048
+ /**
2049
+ * Generate pool ID for user position in a vault.
2050
+ */
2051
+ declare function generateUserVaultPositionPoolId(parameters: {
2052
+ user: Address;
2053
+ chainId: Id;
2054
+ vault: Address;
2055
+ }): string;
2056
+ /**
2057
+ * Generate pool ID for vault position in a market.
2058
+ */
2059
+ declare function generateVaultPositionPoolId(parameters: {
2060
+ vault: Address;
2061
+ chainId: Id;
2062
+ marketId: string;
2063
+ }): string;
2064
+ /**
2065
+ * Generate pool ID for market total liquidity.
2066
+ */
2067
+ declare function generateMarketLiquidityPoolId(parameters: {
2068
+ chainId: Id;
2069
+ marketId: string;
2070
+ }): string;
1888
2071
  declare namespace Offer_d_exports {
1889
- export { InvalidOfferError, Offer, OfferConsumed, OfferInput, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$1 as decode, domain, encode$1 as encode, from$13 as from, fromSnakeCase$1 as fromSnakeCase, hash, obligationId, random$1 as random, serialize, takeEvent, toSnakeCase, types };
2072
+ export { InvalidOfferError, Offer, OfferConsumed, OfferInput, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$1 as decode, encode$1 as encode, from$13 as from, fromSnakeCase$1 as fromSnakeCase, hash, liquidateEvent, obligationId, random$1 as random, repayEvent, serialize, supplyCollateralEvent, takeEvent, toSnakeCase, withdrawCollateralEvent };
1890
2073
  }
1891
2074
  type Offer = {
1892
2075
  /** The address that made the offer. */readonly maker: Address; /** The amount of assets offered. Mutually exclusive with obligationUnits and obligationShares. */
@@ -1899,8 +2082,7 @@ type Offer = {
1899
2082
  readonly start: number; /** The group. Used for OCO (One-Cancelled-Other) mechanism. */
1900
2083
  readonly group: Hex; /** The session. Used for session-based offer management. */
1901
2084
  readonly session: Hex; /** The side of the offer. `true` for buy, `false` for sell. */
1902
- readonly buy: boolean; /** The chain id where the liquidity for this offer is located. */
1903
- readonly chainId: Id; /** The token that is being borrowed. */
2085
+ readonly buy: boolean; /** The token that is being borrowed. */
1904
2086
  readonly loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1905
2087
  readonly collaterals: readonly Collateral[]; /** The optional callback data to retrieve the maker funds. */
1906
2088
  readonly callback: {
@@ -1915,6 +2097,7 @@ declare enum Status {
1915
2097
  }
1916
2098
  type Validation = {
1917
2099
  offerHash: Hex;
2100
+ obligationId: Hex;
1918
2101
  status: Status;
1919
2102
  };
1920
2103
  declare const OfferSchema: () => z$1.ZodObject<{
@@ -1929,7 +2112,6 @@ declare const OfferSchema: () => z$1.ZodObject<{
1929
2112
  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>>;
1930
2113
  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>>;
1931
2114
  buy: z$1.ZodBoolean;
1932
- chainId: z$1.ZodNumber;
1933
2115
  loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1934
2116
  collaterals: z$1.ZodArray<z$1.ZodObject<{
1935
2117
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1953,8 +2135,7 @@ declare const OfferSchema: () => z$1.ZodObject<{
1953
2135
  *
1954
2136
  * All values validated to be non-negative and within bytes32 range.
1955
2137
  */
1956
- type OfferInput = Compute<Omit<Offer, "chainId" | "group" | "session" | "obligationUnits" | "obligationShares" | "receiverIfMakerIsSeller"> & {
1957
- chainId: number;
2138
+ type OfferInput = Compute<Omit<Offer, "group" | "session" | "obligationUnits" | "obligationShares" | "receiverIfMakerIsSeller"> & {
1958
2139
  group: Hex | bigint | number | string; /** Optional: defaults to zero bytes32. */
1959
2140
  session?: Hex | bigint | number | string; /** Optional: defaults to 0n. Mutually exclusive with assets and obligationShares. */
1960
2141
  obligationUnits?: bigint; /** Optional: defaults to 0n. Mutually exclusive with assets and obligationUnits. */
@@ -2006,7 +2187,6 @@ declare const serialize: (offer: Offer) => {
2006
2187
  group: `0x${string}`;
2007
2188
  session: `0x${string}`;
2008
2189
  buy: boolean;
2009
- chainId: Id;
2010
2190
  loanToken: `0x${string}`;
2011
2191
  collaterals: {
2012
2192
  asset: `0x${string}`;
@@ -2021,7 +2201,6 @@ declare const serialize: (offer: Offer) => {
2021
2201
  hash: `0x${string}`;
2022
2202
  };
2023
2203
  type RandomConfig = {
2024
- chains?: Chain$1[];
2025
2204
  loanTokens?: Address[];
2026
2205
  collateralTokens?: Address[];
2027
2206
  assetsDecimals?: Record<Address, number>;
@@ -2051,96 +2230,28 @@ type RandomConfig = {
2051
2230
  */
2052
2231
  declare function random$1(config?: RandomConfig): Offer;
2053
2232
  /**
2054
- * Creates an EIP-712 domain object.
2055
- * @param chainId - The chain ID.
2056
- * @returns The EIP-712 domain object.
2057
- */
2058
- declare const domain: (chainId: number) => {
2059
- chainId: bigint;
2060
- verifyingContract: "0x0000000000000000000000000000000000000000";
2061
- };
2062
- /**
2063
- * The EIP-712 types for the offer.
2064
- * @warning The ordering of the types should NEVER be changed. The offer hash is computed based on the order of the types.
2065
- * @returns The EIP-712 types.
2233
+ * Computes the canonical chain-agnostic offer hash.
2234
+ * The hash is `keccak256(abi.encode(offer))` using {@link encode}.
2235
+ *
2236
+ * @param offer - Offer payload to hash.
2237
+ * @returns 32-byte offer hash.
2066
2238
  */
2067
- declare const types: {
2068
- readonly EIP712Domain: readonly [{
2069
- readonly name: "chainId";
2070
- readonly type: "uint256";
2071
- }, {
2072
- readonly name: "verifyingContract";
2073
- readonly type: "address";
2074
- }];
2075
- readonly Offer: readonly [{
2076
- readonly name: "maker";
2077
- readonly type: "address";
2078
- }, {
2079
- readonly name: "assets";
2080
- readonly type: "uint256";
2081
- }, {
2082
- readonly name: "obligationUnits";
2083
- readonly type: "uint256";
2084
- }, {
2085
- readonly name: "obligationShares";
2086
- readonly type: "uint256";
2087
- }, {
2088
- readonly name: "tick";
2089
- readonly type: "uint256";
2090
- }, {
2091
- readonly name: "maturity";
2092
- readonly type: "uint256";
2093
- }, {
2094
- readonly name: "expiry";
2095
- readonly type: "uint256";
2096
- }, {
2097
- readonly name: "group";
2098
- readonly type: "bytes32";
2099
- }, {
2100
- readonly name: "session";
2101
- readonly type: "bytes32";
2102
- }, {
2103
- readonly name: "buy";
2104
- readonly type: "bool";
2105
- }, {
2106
- readonly name: "loanToken";
2107
- readonly type: "address";
2108
- }, {
2109
- readonly name: "collaterals";
2110
- readonly type: "Collateral[]";
2111
- }, {
2112
- readonly name: "callback";
2113
- readonly type: "Callback";
2114
- }, {
2115
- readonly name: "receiverIfMakerIsSeller";
2116
- readonly type: "address";
2117
- }];
2118
- readonly Collateral: readonly [{
2119
- readonly name: "asset";
2120
- readonly type: "address";
2121
- }, {
2122
- readonly name: "oracle";
2123
- readonly type: "address";
2124
- }, {
2125
- readonly name: "lltv";
2126
- readonly type: "uint256";
2127
- }];
2128
- readonly Callback: readonly [{
2129
- readonly name: "address";
2130
- readonly type: "address";
2131
- }, {
2132
- readonly name: "data";
2133
- readonly type: "bytes";
2134
- }];
2135
- };
2136
2239
  declare function hash(offer: Offer): Hex;
2137
2240
  /**
2138
- * Calculates the obligation id for an offer based on the smart contract's Obligation struct.
2139
- * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals (sorted by token address), maturity)).
2241
+ * Calculates the onchain obligation id for an offer.
2242
+ * The id is computed with {@link Id.toId}.
2140
2243
  * @param offer - The offer to calculate the obligation id for.
2141
- * @returns The obligation id as a 32-byte hex string.
2244
+ * @param parameters - The chain context used by the onchain id function.
2245
+ * @returns The obligation id as a 20-byte hex string.
2142
2246
  */
2143
- declare function obligationId(offer: Offer): Hex;
2247
+ declare function obligationId(offer: Offer, parameters: obligationId.Parameters): obligationId.ReturnType;
2248
+ declare namespace obligationId {
2249
+ type Parameters = {
2250
+ chainId: Id;
2251
+ morphoV2: Address;
2252
+ };
2253
+ type ReturnType = Hex;
2254
+ }
2144
2255
  declare function encode$1(offer: Offer): `0x${string}`;
2145
2256
  declare function decode$1(data: Hex): Offer;
2146
2257
  type OfferConsumed = {
@@ -2163,10 +2274,10 @@ declare const takeEvent: {
2163
2274
  readonly indexed: false;
2164
2275
  readonly internalType: "address";
2165
2276
  }, {
2166
- readonly name: "id";
2167
- readonly type: "bytes32";
2277
+ readonly name: "id_";
2278
+ readonly type: "bytes20";
2168
2279
  readonly indexed: true;
2169
- readonly internalType: "bytes32";
2280
+ readonly internalType: "bytes20";
2170
2281
  }, {
2171
2282
  readonly name: "maker";
2172
2283
  readonly type: "address";
@@ -2206,51 +2317,197 @@ declare const takeEvent: {
2206
2317
  readonly name: "buyerIsLender";
2207
2318
  readonly type: "bool";
2208
2319
  readonly indexed: false;
2209
- readonly internalType: "bool";
2320
+ readonly internalType: "bool";
2321
+ }, {
2322
+ readonly name: "sellerIsBorrower";
2323
+ readonly type: "bool";
2324
+ readonly indexed: false;
2325
+ readonly internalType: "bool";
2326
+ }, {
2327
+ readonly name: "sellerReceiver";
2328
+ readonly type: "address";
2329
+ readonly indexed: false;
2330
+ readonly internalType: "address";
2331
+ }, {
2332
+ readonly name: "group";
2333
+ readonly type: "bytes32";
2334
+ readonly indexed: false;
2335
+ readonly internalType: "bytes32";
2336
+ }, {
2337
+ readonly name: "consumed";
2338
+ readonly type: "uint256";
2339
+ readonly indexed: false;
2340
+ readonly internalType: "uint256";
2341
+ }];
2342
+ readonly anonymous: false;
2343
+ };
2344
+ /**
2345
+ * ABI for the Consume event emitted by the Obligation contract.
2346
+ */
2347
+ declare const consumedEvent: {
2348
+ readonly type: "event";
2349
+ readonly name: "Consume";
2350
+ readonly inputs: readonly [{
2351
+ readonly name: "user";
2352
+ readonly type: "address";
2353
+ readonly indexed: true;
2354
+ readonly internalType: "address";
2355
+ }, {
2356
+ readonly name: "group";
2357
+ readonly type: "bytes32";
2358
+ readonly indexed: true;
2359
+ readonly internalType: "bytes32";
2360
+ }, {
2361
+ readonly name: "amount";
2362
+ readonly type: "uint256";
2363
+ readonly indexed: false;
2364
+ readonly internalType: "uint256";
2365
+ }];
2366
+ readonly anonymous: false;
2367
+ };
2368
+ /**
2369
+ * ABI for the Repay event emitted by the MorphoV2 contract.
2370
+ */
2371
+ declare const repayEvent: {
2372
+ readonly type: "event";
2373
+ readonly name: "Repay";
2374
+ readonly inputs: readonly [{
2375
+ readonly name: "caller";
2376
+ readonly type: "address";
2377
+ readonly indexed: true;
2378
+ readonly internalType: "address";
2379
+ }, {
2380
+ readonly name: "id_";
2381
+ readonly type: "bytes20";
2382
+ readonly indexed: true;
2383
+ readonly internalType: "bytes20";
2384
+ }, {
2385
+ readonly name: "obligationUnits";
2386
+ readonly type: "uint256";
2387
+ readonly indexed: false;
2388
+ readonly internalType: "uint256";
2389
+ }, {
2390
+ readonly name: "onBehalf";
2391
+ readonly type: "address";
2392
+ readonly indexed: true;
2393
+ readonly internalType: "address";
2394
+ }];
2395
+ readonly anonymous: false;
2396
+ };
2397
+ /**
2398
+ * ABI for the Liquidate event emitted by the MorphoV2 contract.
2399
+ */
2400
+ declare const liquidateEvent: {
2401
+ readonly type: "event";
2402
+ readonly name: "Liquidate";
2403
+ readonly inputs: readonly [{
2404
+ readonly name: "caller";
2405
+ readonly type: "address";
2406
+ readonly indexed: true;
2407
+ readonly internalType: "address";
2408
+ }, {
2409
+ readonly name: "id_";
2410
+ readonly type: "bytes20";
2411
+ readonly indexed: true;
2412
+ readonly internalType: "bytes20";
2413
+ }, {
2414
+ readonly name: "collateralIndex";
2415
+ readonly type: "uint256";
2416
+ readonly indexed: false;
2417
+ readonly internalType: "uint256";
2418
+ }, {
2419
+ readonly name: "seizedAssets";
2420
+ readonly type: "uint256";
2421
+ readonly indexed: false;
2422
+ readonly internalType: "uint256";
2423
+ }, {
2424
+ readonly name: "repaidUnits";
2425
+ readonly type: "uint256";
2426
+ readonly indexed: false;
2427
+ readonly internalType: "uint256";
2428
+ }, {
2429
+ readonly name: "borrower";
2430
+ readonly type: "address";
2431
+ readonly indexed: true;
2432
+ readonly internalType: "address";
2433
+ }, {
2434
+ readonly name: "badDebt";
2435
+ readonly type: "uint256";
2436
+ readonly indexed: false;
2437
+ readonly internalType: "uint256";
2438
+ }];
2439
+ readonly anonymous: false;
2440
+ };
2441
+ /**
2442
+ * ABI for the SupplyCollateral event emitted by the MorphoV2 contract.
2443
+ */
2444
+ declare const supplyCollateralEvent: {
2445
+ readonly type: "event";
2446
+ readonly name: "SupplyCollateral";
2447
+ readonly inputs: readonly [{
2448
+ readonly name: "caller";
2449
+ readonly type: "address";
2450
+ readonly indexed: false;
2451
+ readonly internalType: "address";
2210
2452
  }, {
2211
- readonly name: "sellerIsBorrower";
2212
- readonly type: "bool";
2213
- readonly indexed: false;
2214
- readonly internalType: "bool";
2453
+ readonly name: "id_";
2454
+ readonly type: "bytes20";
2455
+ readonly indexed: true;
2456
+ readonly internalType: "bytes20";
2215
2457
  }, {
2216
- readonly name: "sellerReceiver";
2458
+ readonly name: "collateral";
2217
2459
  readonly type: "address";
2218
- readonly indexed: false;
2460
+ readonly indexed: true;
2219
2461
  readonly internalType: "address";
2220
2462
  }, {
2221
- readonly name: "group";
2222
- readonly type: "bytes32";
2223
- readonly indexed: false;
2224
- readonly internalType: "bytes32";
2225
- }, {
2226
- readonly name: "consumed";
2463
+ readonly name: "assets";
2227
2464
  readonly type: "uint256";
2228
2465
  readonly indexed: false;
2229
2466
  readonly internalType: "uint256";
2467
+ }, {
2468
+ readonly name: "onBehalf";
2469
+ readonly type: "address";
2470
+ readonly indexed: true;
2471
+ readonly internalType: "address";
2230
2472
  }];
2231
2473
  readonly anonymous: false;
2232
2474
  };
2233
2475
  /**
2234
- * ABI for the Consume event emitted by the Obligation contract.
2476
+ * ABI for the WithdrawCollateral event emitted by the MorphoV2 contract.
2235
2477
  */
2236
- declare const consumedEvent: {
2478
+ declare const withdrawCollateralEvent: {
2237
2479
  readonly type: "event";
2238
- readonly name: "Consume";
2480
+ readonly name: "WithdrawCollateral";
2239
2481
  readonly inputs: readonly [{
2240
- readonly name: "user";
2482
+ readonly name: "caller";
2241
2483
  readonly type: "address";
2242
- readonly indexed: true;
2484
+ readonly indexed: false;
2243
2485
  readonly internalType: "address";
2244
2486
  }, {
2245
- readonly name: "group";
2246
- readonly type: "bytes32";
2487
+ readonly name: "id_";
2488
+ readonly type: "bytes20";
2247
2489
  readonly indexed: true;
2248
- readonly internalType: "bytes32";
2490
+ readonly internalType: "bytes20";
2249
2491
  }, {
2250
- readonly name: "amount";
2492
+ readonly name: "collateral";
2493
+ readonly type: "address";
2494
+ readonly indexed: true;
2495
+ readonly internalType: "address";
2496
+ }, {
2497
+ readonly name: "assets";
2251
2498
  readonly type: "uint256";
2252
2499
  readonly indexed: false;
2253
2500
  readonly internalType: "uint256";
2501
+ }, {
2502
+ readonly name: "onBehalf";
2503
+ readonly type: "address";
2504
+ readonly indexed: true;
2505
+ readonly internalType: "address";
2506
+ }, {
2507
+ readonly name: "receiver";
2508
+ readonly type: "address";
2509
+ readonly indexed: false;
2510
+ readonly internalType: "address";
2254
2511
  }];
2255
2512
  readonly anonymous: false;
2256
2513
  };
@@ -2323,6 +2580,7 @@ declare namespace fromCollateral {
2323
2580
  declare function fromOffer(parameters: fromOffer.Parameters): fromOffer.ReturnType;
2324
2581
  declare namespace fromOffer {
2325
2582
  type Parameters = {
2583
+ chainId: Id;
2326
2584
  offer: Offer;
2327
2585
  blockNumber: number;
2328
2586
  price?: bigint | null;
@@ -2339,6 +2597,7 @@ declare namespace fromOffer {
2339
2597
  declare function fromOffers(parameters: fromOffers.Parameters): fromOffers.ReturnType;
2340
2598
  declare namespace fromOffers {
2341
2599
  type Parameters = {
2600
+ chainId: Id;
2342
2601
  offers: Offer[];
2343
2602
  blockNumber: number;
2344
2603
  price?: bigint | null;
@@ -2377,7 +2636,7 @@ declare namespace Conversion {
2377
2636
  }): bigint;
2378
2637
  }
2379
2638
  declare namespace Position_d_exports {
2380
- export { Position, Type, from$11 as from };
2639
+ export { Position, Type, from$11 as from, positionTypeId };
2381
2640
  }
2382
2641
  type Position = {
2383
2642
  /** The chain id. */chainId: Id;
@@ -2392,13 +2651,17 @@ type Position = {
2392
2651
  /** The underlying asset of the position.
2393
2652
  * For ERC20 positions, this equals the contract address.
2394
2653
  * For vault positions, this is the vault's underlying asset.
2654
+ * For debt positions, this is the zero address (sentinel).
2655
+ * For collateral positions, this is the collateral token address.
2395
2656
  */
2396
- asset?: Address; /** The block number at which the position was last updated. */
2657
+ asset: Address; /** The block number at which the position was last updated. */
2397
2658
  blockNumber: number;
2398
2659
  };
2399
2660
  declare enum Type {
2400
2661
  ERC20 = "erc20",
2401
- VAULT_V1 = "vault_v1"
2662
+ VAULT_V1 = "vault_v1",
2663
+ DEBT_OF = "debtOf",
2664
+ COLLATERAL_OF = "collateralOf"
2402
2665
  }
2403
2666
  /**
2404
2667
  * @constructor
@@ -2414,11 +2677,17 @@ declare namespace from$11 {
2414
2677
  user: Address;
2415
2678
  type: Type;
2416
2679
  balance?: bigint;
2417
- asset?: Address;
2680
+ asset: Address;
2418
2681
  blockNumber: number;
2419
2682
  };
2420
2683
  type ReturnType = Position;
2421
2684
  }
2685
+ /**
2686
+ * Maps a {@link Type} enum value to its 1-based integer ID used in the database.
2687
+ * @param type - The position type.
2688
+ * @returns The 1-based integer ID.
2689
+ */
2690
+ declare const positionTypeId: (type: Type) => number;
2422
2691
  declare namespace Quote_d_exports {
2423
2692
  export { InvalidQuoteError, Quote, QuoteInput, Side, from$10 as from, fromSnakeCase, random };
2424
2693
  }
@@ -2607,6 +2876,8 @@ type Transfer = {
2607
2876
  from: Address;
2608
2877
  to: Address;
2609
2878
  value: bigint;
2879
+ type: Type; /** The underlying asset of the transfer's position. */
2880
+ asset: Address;
2610
2881
  blockNumber: number;
2611
2882
  };
2612
2883
  /**
@@ -2630,6 +2901,8 @@ declare namespace from$8 {
2630
2901
  from: Address;
2631
2902
  to: Address;
2632
2903
  value: bigint;
2904
+ type: Type;
2905
+ asset: Address;
2633
2906
  blockNumber: number;
2634
2907
  };
2635
2908
  type ReturnType = Transfer;
@@ -2826,7 +3099,7 @@ declare class SignatureDomainError extends BaseError {
2826
3099
  }
2827
3100
  //#endregion
2828
3101
  //#region src/indexer/collectors/Collector.d.ts
2829
- declare const names: readonly ["offers", "consumed_events", "positions", "prices"];
3102
+ declare const names: readonly ["offers", "morpho_v2", "positions", "prices"];
2830
3103
  type Name = (typeof names)[number];
2831
3104
  /** A general collector interface. */
2832
3105
  type Collector<name extends Name = Name, client extends PublicClient<Transport, Chain$1> = PublicClient<Transport, Chain$1>> = {
@@ -2901,7 +3174,7 @@ type BlocksDomain = {
2901
3174
  handleReorg: (parameters: HandleReorgParameters) => Promise<void>;
2902
3175
  };
2903
3176
  declare namespace Logger_d_exports {
2904
- export { LogEntry, LogFn, LogLevel, LogLevelValues, Logger, defaultLogger, getLogger, runWithLogger, silentLogger };
3177
+ export { LogContext, LogEntry, LogFn, LogLevel, LogLevelValues, Logger, defaultLogger, getLogger, runWithLogContext, runWithLogger, silentLogger };
2905
3178
  }
2906
3179
  declare const LogLevelValues: readonly ["trace", "debug", "info", "warn", "error", "fatal", "silent"];
2907
3180
  type LogLevel = (typeof LogLevelValues)[number];
@@ -2909,6 +3182,7 @@ type LogEntry = Compute<{
2909
3182
  msg: string;
2910
3183
  } & Record<string, unknown>>;
2911
3184
  type LogFn = (entry: LogEntry) => void;
3185
+ type LogContext = Readonly<Record<string, unknown>>;
2912
3186
  type Logger = {
2913
3187
  trace: LogFn;
2914
3188
  debug: LogFn;
@@ -2920,12 +3194,20 @@ type Logger = {
2920
3194
  declare function defaultLogger(minLevel?: LogLevel, pretty?: boolean): Logger;
2921
3195
  declare function silentLogger(): Logger;
2922
3196
  declare function runWithLogger<T>(logger: Logger, fn: () => Promise<T>): Promise<T>;
3197
+ /**
3198
+ * Run a function with additional context fields attached to every log entry emitted via {@link getLogger}.
3199
+ * Nested calls merge context (inner keys override outer keys).
3200
+ * @param context - Static fields added to all log entries in this scope.
3201
+ * @param fn - Async function to run with the scoped logging context.
3202
+ * @returns The result of the function.
3203
+ */
3204
+ declare function runWithLogContext<T>(context: LogContext, fn: () => Promise<T>): Promise<T>;
2923
3205
  declare function getLogger(): Logger;
2924
3206
  //#endregion
2925
3207
  //#region src/database/domains/Offers.d.ts
2926
3208
  type CreateBatch = Readonly<{
2927
3209
  blockNumber: number;
2928
- offers: Offer[];
3210
+ offers: create$7.OfferInput[];
2929
3211
  }>;
2930
3212
  /**
2931
3213
  * Raw row returned by database queries.
@@ -2933,6 +3215,7 @@ type CreateBatch = Readonly<{
2933
3215
  */
2934
3216
  type Row = {
2935
3217
  hash: Hex;
3218
+ obligationId: Hex;
2936
3219
  maker: Address;
2937
3220
  assets: bigint;
2938
3221
  obligationUnits: bigint;
@@ -2957,8 +3240,12 @@ type Row = {
2957
3240
  takeable: bigint;
2958
3241
  blockNumber: number;
2959
3242
  };
3243
+ type OfferReference$1 = {
3244
+ hash: Hex;
3245
+ obligationId: Hex;
3246
+ };
2960
3247
  type OffersDomain = {
2961
- /** Insert offers (insert-only). */create: (batches: CreateBatch[]) => Promise<Hex[]>;
3248
+ /** Insert offers (insert-only). */create: (batches: CreateBatch[]) => Promise<OfferReference$1[]>;
2962
3249
  /** Delete multiple offers by hashes or block number greater than or equal to the given value on a given chain.
2963
3250
  * @returns the number of offers deleted.
2964
3251
  */
@@ -2983,13 +3270,23 @@ type PaginationParams$1 = {
2983
3270
  type GetOffersParams = {
2984
3271
  /** Filter by maker address */maker?: Address;
2985
3272
  } & PaginationParams$1;
3273
+ declare function create$7(config: {
3274
+ db: Core;
3275
+ }): OffersDomain;
3276
+ declare namespace create$7 {
3277
+ type OfferInput = {
3278
+ offer: Offer;
3279
+ obligationId: Hex;
3280
+ chainId: Id;
3281
+ };
3282
+ }
2986
3283
  //#endregion
2987
3284
  //#region src/database/domains/Book.d.ts
2988
3285
  type BookDomain = {
2989
- /** Get aggregated book levels for a given obligation side. */get: (parameters: get$4.Parameters) => Promise<get$4.ReturnType>; /** Get all offers for a given obligation side with cross-invalidation. */
3286
+ /** Get aggregated book levels for a given obligation side. */get: (parameters: get$5.Parameters) => Promise<get$5.ReturnType>; /** Get all offers for a given obligation side with cross-invalidation. */
2990
3287
  getOffers: (parameters: getOffers$2.Parameters) => Promise<getOffers$2.ReturnType>;
2991
3288
  };
2992
- declare namespace get$4 {
3289
+ declare namespace get$5 {
2993
3290
  type Parameters = {
2994
3291
  /** The side of the offer. */side: "buy" | "sell"; /** The obligationId of the offer. */
2995
3292
  obligationId: Hex; /** Cursor string returned by a previous call, for pagination */
@@ -3024,10 +3321,12 @@ type CallbackInput = {
3024
3321
  chainId: Id;
3025
3322
  contract: Address;
3026
3323
  user: Address;
3027
- amount: bigint;
3324
+ positionTypeId: number;
3325
+ type: CallbackType;
3028
3326
  };
3029
3327
  type OfferCallbacks = {
3030
3328
  offerHash: Hex;
3329
+ obligationId: Hex;
3031
3330
  callbacks: CallbackInput[];
3032
3331
  };
3033
3332
  type CallbacksDomain = {
@@ -3073,12 +3372,23 @@ type GroupInput = {
3073
3372
  blockNumber: number;
3074
3373
  consumed?: bigint;
3075
3374
  };
3375
+ type GroupKey = {
3376
+ chainId: Id;
3377
+ maker: Address;
3378
+ group: Hex;
3379
+ };
3076
3380
  type GroupsDomain = {
3077
3381
  /**
3078
3382
  * Insert groups (insert-only).
3079
3383
  * @param groups - Groups to insert. {@link GroupInput}
3080
3384
  */
3081
3385
  create: (groups: GroupInput[]) => Promise<void>;
3386
+ /**
3387
+ * Check which groups already exist in the database.
3388
+ * @param groups - Group keys to check. {@link GroupKey}
3389
+ * @returns The subset of input groups that exist in the database.
3390
+ */
3391
+ exists: (groups: GroupKey[]) => Promise<GroupKey[]>;
3082
3392
  };
3083
3393
  //#endregion
3084
3394
  //#region src/database/domains/Lots.d.ts
@@ -3097,18 +3407,20 @@ type LotsDomain = {
3097
3407
  * Called when offers are created to reserve liquidity on positions.
3098
3408
  * For each (position, group), keeps only the biggest offer by assets.
3099
3409
  * If lot exists and new offer is bigger, grows the lot and shifts higher lots.
3410
+ * Automatically upserts lots_positions bridge rows before inserting lots.
3100
3411
  */
3101
- create: (parameters: create$5.Parameters) => Promise<void>;
3412
+ create: (parameters: create$6.Parameters) => Promise<void>;
3102
3413
  /**
3103
3414
  * Get lots with optional filtering.
3104
3415
  */
3105
- get: (parameters?: get$3.Parameters) => Promise<Lot[]>;
3416
+ get: (parameters?: get$4.Parameters) => Promise<Lot[]>;
3106
3417
  };
3107
- declare namespace create$5 {
3418
+ declare namespace create$6 {
3108
3419
  type OfferLotInfo = {
3109
3420
  positionChainId: Id;
3110
3421
  positionContract: Address;
3111
3422
  positionUser: Address;
3423
+ positionTypeId: number;
3112
3424
  group: string;
3113
3425
  obligationId: string;
3114
3426
  size: bigint;
@@ -3116,7 +3428,7 @@ declare namespace create$5 {
3116
3428
  type Parameters = OfferLotInfo[];
3117
3429
  type ReturnType = undefined;
3118
3430
  }
3119
- declare namespace get$3 {
3431
+ declare namespace get$4 {
3120
3432
  type Parameters = {
3121
3433
  chainId?: Id;
3122
3434
  user?: Address;
@@ -3126,15 +3438,15 @@ declare namespace get$3 {
3126
3438
  };
3127
3439
  type ReturnType = Lot[];
3128
3440
  }
3129
- declare function create$5(db: Core): LotsDomain;
3441
+ declare function create$6(db: Core): LotsDomain;
3130
3442
  //#endregion
3131
3443
  //#region src/database/domains/Obligations.d.ts
3132
3444
  type ObligationsDomain = {
3133
3445
  /**
3134
- * Insert obligations (insert-only).
3135
- * @param obligations - Obligations to insert. {@link Obligation.Obligation}
3446
+ * Insert obligations and their onchain obligation id keys (insert-only).
3447
+ * @param obligations - Obligations to insert.
3136
3448
  */
3137
- create: (obligations: Obligation[]) => Promise<void>;
3449
+ create: (obligations: create$5.Input[]) => Promise<void>;
3138
3450
  /**
3139
3451
  * Get active obligations with optional chain filters.
3140
3452
  * @param parameters - Optional chain filters.
@@ -3142,8 +3454,30 @@ type ObligationsDomain = {
3142
3454
  */
3143
3455
  get: (parameters?: {
3144
3456
  chainId?: Id[];
3145
- }) => Promise<Obligation[]>;
3457
+ }) => Promise<get$3.Output[]>;
3146
3458
  };
3459
+ /**
3460
+ * Create an obligations domain instance.
3461
+ * @param db - Database core instance.
3462
+ * @returns Obligations domain. {@link ObligationsDomain}
3463
+ */
3464
+ declare function create$5(db: Core): ObligationsDomain;
3465
+ declare namespace create$5 {
3466
+ type Input = {
3467
+ obligationId: Hex;
3468
+ chainId: Id;
3469
+ morphoV2: Address;
3470
+ obligation: Obligation$1;
3471
+ };
3472
+ }
3473
+ declare namespace get$3 {
3474
+ type Output = {
3475
+ obligationId: Hex;
3476
+ chainId: Id;
3477
+ morphoV2: Address;
3478
+ obligation: Obligation$1;
3479
+ };
3480
+ }
3147
3481
  //#endregion
3148
3482
  //#region src/database/domains/Offsets.d.ts
3149
3483
  type Offset = {
@@ -3216,7 +3550,7 @@ type PositionsDomain = {
3216
3550
  */
3217
3551
  getByUser: (parameters: getByUser.Parameters) => Promise<getByUser.ReturnType>;
3218
3552
  /**
3219
- * Set all positions to empty after a given block number (inclusive), deletes all transfers linked to the positions.
3553
+ * Set all positions of a given type to empty after a given block number (inclusive), deletes all transfers linked to the positions.
3220
3554
  * @param parameters - {@link setEmptyAfter.Parameters}
3221
3555
  * @returns The number of positions set to empty. {@link setEmptyAfter.ReturnType}
3222
3556
  */
@@ -3239,7 +3573,8 @@ declare namespace get$1 {
3239
3573
  }
3240
3574
  declare namespace getByUser {
3241
3575
  type Parameters = PaginationParams & {
3242
- /** The user address to get positions for. */user: Address;
3576
+ /** The user address to get positions for. */user: Address; /** The type of position to get. Default is all types. */
3577
+ type?: Type;
3243
3578
  };
3244
3579
  type PositionWithReserved = {
3245
3580
  chainId: Id;
@@ -3256,8 +3591,9 @@ declare namespace getByUser {
3256
3591
  }
3257
3592
  declare namespace setEmptyAfter {
3258
3593
  type Parameters = {
3259
- /** The chain id . */chainId: Id; /** The block number after which all positions should be set to empty. (inclusive) */
3260
- blockNumber: number;
3594
+ /** The chain id. */chainId: Id; /** The block number after which all positions should be set to empty. (inclusive) */
3595
+ blockNumber: number; /** The position type to target. */
3596
+ type: Type;
3261
3597
  };
3262
3598
  type ReturnType = number;
3263
3599
  }
@@ -3270,11 +3606,26 @@ type TransfersDomain = {
3270
3606
  * @returns The number of transfers created. {@link create.ReturnType}
3271
3607
  */
3272
3608
  create: (transfers: create$4.Parameters) => Promise<create$4.ReturnType>;
3609
+ /**
3610
+ * Delete transfers by chain, position type, and block number >= given value (for reorg rollback).
3611
+ * Reverses balance deltas on affected positions and cleans up orphan positions.
3612
+ * @param parameters - {@link del.Parameters}
3613
+ * @returns The number of transfers deleted. {@link del.ReturnType}
3614
+ */
3615
+ delete: (parameters: del.Parameters) => Promise<del.ReturnType>;
3273
3616
  };
3274
3617
  declare namespace create$4 {
3275
3618
  type Parameters = Transfer[];
3276
3619
  type ReturnType = number;
3277
3620
  }
3621
+ declare namespace del {
3622
+ type Parameters = {
3623
+ chainId: Id;
3624
+ blockNumberGte: number;
3625
+ positionTypeId: number;
3626
+ };
3627
+ type ReturnType = number;
3628
+ }
3278
3629
  declare const create$4: (db: Core) => TransfersDomain;
3279
3630
  //#endregion
3280
3631
  //#region src/database/domains/Trees.d.ts
@@ -3289,25 +3640,41 @@ type Attestation = {
3289
3640
  /**
3290
3641
  * Input for creating trees with their signatures.
3291
3642
  */
3292
- type CreateInput = {
3293
- tree: Tree;
3643
+ type UpsertInput = {
3644
+ root: Hex;
3294
3645
  signature: Hex;
3295
3646
  };
3647
+ type UpsertPathsInput = {
3648
+ offerHash: Hex;
3649
+ obligationId: Hex;
3650
+ treeRoot: Hex;
3651
+ proof: Hex[];
3652
+ };
3653
+ type OfferReference = {
3654
+ offerHash: Hex;
3655
+ obligationId: Hex;
3656
+ };
3296
3657
  type TreesDomain = {
3297
3658
  /**
3298
- * Creates trees and attestation links in a single transaction.
3659
+ * Creates or updates merkle roots and signatures.
3660
+ *
3661
+ * @param trees - Array of merkle root attestations
3662
+ * @returns Array of tree roots that were upserted
3663
+ */
3664
+ upsert: (trees: UpsertInput[]) => Promise<Hex[]>;
3665
+ /**
3666
+ * Creates or updates merkle proofs for offers.
3299
3667
  *
3300
- * @param trees - Array of decoded trees with signatures (batch insertion)
3301
- * @returns Array of tree roots that were created/upserted
3668
+ * @param paths - Array of offer proof rows
3302
3669
  */
3303
- create: (trees: CreateInput[]) => Promise<Hex[]>;
3670
+ upsertPaths: (paths: UpsertPathsInput[]) => Promise<void>;
3304
3671
  /**
3305
3672
  * Retrieves merkle attestations for execution flow.
3306
3673
  *
3307
- * @param hashes - Array of offer hashes to look up
3308
- * @returns Map of offer hash to attestation (only entries with attestations are included)
3674
+ * @param references - Array of offer references to look up
3675
+ * @returns Map of serialized offer key (`offerHash:obligationId`) to attestation
3309
3676
  */
3310
- getAttestations: (hashes: Hex[]) => Promise<Map<Hex, Attestation>>;
3677
+ getAttestations: (references: OfferReference[]) => Promise<Map<string, Attestation>>;
3311
3678
  };
3312
3679
  //#endregion
3313
3680
  //#region src/database/domains/Validations.d.ts
@@ -3347,7 +3714,9 @@ type ListObligationsParameters = {
3347
3714
  limit?: number;
3348
3715
  };
3349
3716
  type ListedObligation = {
3350
- obligation: Obligation;
3717
+ obligationId: Hex;
3718
+ chainId: Id;
3719
+ obligation: Obligation$1;
3351
3720
  quote: Quote;
3352
3721
  };
3353
3722
  type ListObligationsResult = {
@@ -3503,6 +3872,22 @@ type ConfigRule = {
3503
3872
  type: "oracle";
3504
3873
  chain_id: Id;
3505
3874
  address: Address;
3875
+ } | {
3876
+ type: "group_consistency";
3877
+ chain_id: Id;
3878
+ description: string;
3879
+ } | {
3880
+ type: "group_immutability";
3881
+ chain_id: Id;
3882
+ description: string;
3883
+ } | {
3884
+ type: "max_collaterals";
3885
+ chain_id: Id;
3886
+ max: number;
3887
+ } | {
3888
+ type: "min_duration";
3889
+ chain_id: Id;
3890
+ min_seconds: number;
3506
3891
  };
3507
3892
  type ValidationIssue = {
3508
3893
  index: number;
@@ -3553,7 +3938,10 @@ type GatekeeperClient = {
3553
3938
  statusCode: number;
3554
3939
  body: ConfigRulesPayload;
3555
3940
  }>; /** Validate offers and return decision results. */
3556
- isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>; /** Base URL for the gatekeeper service. */
3941
+ isAllowed: (parameters: {
3942
+ offers: Offer[];
3943
+ chainId: number;
3944
+ }) => Promise<Result<Offer, string>>; /** Base URL for the gatekeeper service. */
3557
3945
  baseUrl: string;
3558
3946
  };
3559
3947
  type ClientConfig = {
@@ -3667,6 +4055,12 @@ type CreateParameters = {
3667
4055
  chainRegistry: ChainRegistry;
3668
4056
  };
3669
4057
  declare function create$1(params: CreateParameters): RouterApi;
4058
+ /**
4059
+ * Create the router API Hono app with all routes and middleware configured.
4060
+ * @param parameters - API construction parameters.
4061
+ * @returns Configured Hono app instance.
4062
+ */
4063
+ declare function createApp(parameters: CreateParameters): Hono;
3670
4064
  declare namespace BookResponse_d_exports {
3671
4065
  export { BookLevelResponse, from$4 as from };
3672
4066
  }
@@ -4534,7 +4928,7 @@ interface components {
4534
4928
  * "receiver_if_maker_is_seller": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401"
4535
4929
  * },
4536
4930
  * "offer_hash": "0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427",
4537
- * "obligation_id": "0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc",
4931
+ * "obligation_id": "0x25690ae1aee324a005be565f3bcdd16dbf8daf79",
4538
4932
  * "chain_id": 1,
4539
4933
  * "consumed": "0",
4540
4934
  * "takeable": "369216000000000000000000",
@@ -4580,7 +4974,7 @@ interface components {
4580
4974
  * }
4581
4975
  */
4582
4976
  offer: components["schemas"]["OfferDataResponse"]; /** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
4583
- offer_hash: string; /** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
4977
+ offer_hash: string; /** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf79 */
4584
4978
  obligation_id: string; /** @example 1 */
4585
4979
  chain_id: number; /** @example 0 */
4586
4980
  consumed: string; /** @example 369216000000000000000000 */
@@ -4778,7 +5172,7 @@ interface components {
4778
5172
  * "chain_id": 1,
4779
5173
  * "contract": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
4780
5174
  * "user": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
4781
- * "obligation_id": "0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",
5175
+ * "obligation_id": "0x12590ae1aee324a005be565f3bcdd16dbf8daf79",
4782
5176
  * "reserved": "200000000000000000000",
4783
5177
  * "block_number": 21345678
4784
5178
  * }
@@ -4792,14 +5186,19 @@ interface components {
4792
5186
  user: string;
4793
5187
  /**
4794
5188
  * @description Obligation id this reserved amount belongs to, or null if no lots exist.
4795
- * @example 0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67
5189
+ * @example 0x12590ae1aee324a005be565f3bcdd16dbf8daf79
4796
5190
  */
4797
5191
  obligation_id: string | null; /** @example 200000000000000000000 */
4798
5192
  reserved: string; /** @example 21345678 */
4799
5193
  block_number: number;
4800
5194
  };
4801
5195
  ValidateOffersRequest: {
4802
- /** @description Array of offers in snake_case format. Required, non-empty. */offers: components["schemas"]["ValidateOfferRequest"][];
5196
+ /**
5197
+ * @description Chain id used for chain-scoped validation rules.
5198
+ * @example 1
5199
+ */
5200
+ chain_id: number; /** @description Array of offers in snake_case format. Required, non-empty. */
5201
+ offers: components["schemas"]["ValidateOfferRequest"][];
4803
5202
  };
4804
5203
  ValidateOfferRequest: {
4805
5204
  /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */maker: string; /** @example 369216000000000000000000 */
@@ -4812,8 +5211,7 @@ interface components {
4812
5211
  start: number; /** @example 0x000000000000000000000000000000000000000000000000000000000008b8f4 */
4813
5212
  group: string; /** @example 0x0000000000000000000000000000000000000000000000000000000000000000 */
4814
5213
  session: string; /** @example false */
4815
- buy: boolean; /** @example 1 */
4816
- chain_id: number; /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
5214
+ buy: boolean; /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
4817
5215
  loan_token: string;
4818
5216
  /**
4819
5217
  * @example [
@@ -4876,15 +5274,17 @@ type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["c
4876
5274
  * @constructor
4877
5275
  * @param obligation - {@link Obligation}
4878
5276
  * @param quote - {@link Quote}
5277
+ * @param chainId - The chain id used to compute `id`.
4879
5278
  * @returns The created `ObligationResponse`. {@link ObligationResponse}
4880
5279
  */
4881
- declare function from$3(obligation: Obligation, quote: Quote): ObligationResponse;
5280
+ declare function from$3(obligation: Obligation$1, quote: Quote, chainId: Id): ObligationResponse;
4882
5281
  declare namespace OfferResponse_d_exports {
4883
5282
  export { Input, OfferResponse, from$2 as from };
4884
5283
  }
4885
5284
  type OfferResponse = paths["/v1/offers"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
4886
5285
  type Input = Readonly<{
4887
5286
  hash: Hex;
5287
+ obligationId: Hex;
4888
5288
  maker: Address;
4889
5289
  assets: bigint;
4890
5290
  obligationUnits: bigint;
@@ -5011,6 +5411,10 @@ declare const schemas: {
5011
5411
  callback: "callback";
5012
5412
  loan_token: "loan_token";
5013
5413
  collateral_token: "collateral_token";
5414
+ min_duration: "min_duration";
5415
+ max_collaterals: "max_collaterals";
5416
+ group_consistency: "group_consistency";
5417
+ group_immutability: "group_immutability";
5014
5418
  }>>>>;
5015
5419
  chains: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>>>>;
5016
5420
  }, z$1.core.$strip>;
@@ -5058,6 +5462,7 @@ declare const schemas: {
5058
5462
  limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
5059
5463
  }, z$1.core.$strip>;
5060
5464
  readonly validate_offers: z$1.ZodObject<{
5465
+ chain_id: z$1.ZodNumber;
5061
5466
  offers: z$1.ZodArray<z$1.ZodUnknown>;
5062
5467
  }, z$1.core.$strict>;
5063
5468
  readonly get_user_positions: z$1.ZodObject<{
@@ -5155,6 +5560,15 @@ declare function getHealth(query: unknown, db: Database, chainRegistry?: ChainRe
5155
5560
  declare function getHealthChains(query: unknown, db: Database, healthClients?: Map<Id, Client>, chainRegistry?: ChainRegistry): Promise<Payload<paths["/v1/health/chains"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
5156
5561
  declare function getHealthCollectors(query: unknown, db: Database, chainRegistry?: ChainRegistry): Promise<Payload<paths["/v1/health/collectors"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
5157
5562
  //#endregion
5563
+ //#region src/api/Controllers/getMetrics.d.ts
5564
+ /**
5565
+ * Get router synchronization metrics in Prometheus exposition format.
5566
+ * @param db - Database instance. {@link Database.Database}
5567
+ * @param chainRegistry - Optional chain registry used to scope expected chains.
5568
+ * @returns Prometheus exposition payload.
5569
+ */
5570
+ declare function getMetrics(db: Database, chainRegistry?: ChainRegistry): Promise<string>;
5571
+ //#endregion
5158
5572
  //#region src/api/Controllers/getObligation.d.ts
5159
5573
  declare function getObligation(params: object, db: Database): Promise<Payload<ObligationResponse>>;
5160
5574
  //#endregion
@@ -5172,12 +5586,19 @@ type OffersRowsResult = {
5172
5586
  nextCursor: string | null;
5173
5587
  };
5174
5588
  /**
5175
- * Query offers with computed consumed/available/takeable values.
5589
+ * Query offers for a maker with computed consumed/available/takeable values.
5590
+ * Uses the same CTE-based computation as Book.ts via shared OfferFormulas builders.
5176
5591
  * @param db - The database client. {@link Database.Core}
5177
5592
  * @param parameters - {@link GetOffersQueryParams}
5178
5593
  * @returns The offers with pagination cursor.
5179
5594
  */
5180
5595
  declare function getOffersQuery(db: Core, parameters?: GetOffersQueryParams): Promise<OffersRowsResult>;
5596
+ /**
5597
+ * Get offers with optional maker or obligation+side filter.
5598
+ * @param queryParameters - Raw query parameters from the API request.
5599
+ * @param db - The database client. {@link Database.Database}
5600
+ * @returns The offers response payload.
5601
+ */
5181
5602
  declare function getOffers$1(queryParameters: object, db: Database): Promise<Payload<OfferResponse[]>>;
5182
5603
  //#endregion
5183
5604
  //#region src/api/Controllers/getUserPositions.d.ts
@@ -5189,14 +5610,18 @@ declare function getOffers$1(queryParameters: object, db: Database): Promise<Pay
5189
5610
  */
5190
5611
  declare function getUserPositions(queryParameters: object, db: Database): Promise<Payload<PositionResponse[]>>;
5191
5612
  declare namespace Gatekeeper_d_exports {
5192
- export { Gatekeeper, Rules, create };
5613
+ export { Gatekeeper, Rules, RulesFactory, create };
5193
5614
  }
5194
5615
  type Rules = readonly Rule<Offer, string>[];
5616
+ type RulesFactory = (chainId: Id) => Rules;
5195
5617
  type Gatekeeper = {
5196
- isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
5618
+ isAllowed: (parameters: {
5619
+ offers: Offer[];
5620
+ chainId: Id;
5621
+ }) => Promise<Result<Offer, string>>;
5197
5622
  };
5198
5623
  type GatekeeperParameters = {
5199
- rules: Rules;
5624
+ rules: RulesFactory;
5200
5625
  };
5201
5626
  /**
5202
5627
  * Create a gatekeeper instance with the provided rules.
@@ -5221,10 +5646,10 @@ type ValidateOffersIssuesPayload = SuccessPayload$1<{
5221
5646
  type ValidateOffersResponse = ValidateOffersSuccessPayload | ValidateOffersIssuesPayload;
5222
5647
  declare function validateOffers(body: object, gatekeeper: Gatekeeper): Promise<ValidateOffersResponse | ErrorPayload$1>;
5223
5648
  declare namespace index_d_exports$4 {
5224
- export { CONFIG_CONTRACT_NAMES, ConfigContract, ConfigContractName, GetOffersQueryParams, ValidationIssue$1 as ValidationIssue, getBook, getConfigContracts, getConfigRules, getDocsHtml, getHealth, getHealthChains, getHealthCollectors, getIntegratorDocsHtml, getObligation, getObligations$1 as getObligations, getOffers$1 as getOffers, getOffersQuery, getSwaggerJson, getUserPositions, validateOffers };
5649
+ export { CONFIG_CONTRACT_NAMES, ConfigContract, ConfigContractName, GetOffersQueryParams, ValidationIssue$1 as ValidationIssue, getBook, getConfigContracts, getConfigRules, getDocsHtml, getHealth, getHealthChains, getHealthCollectors, getIntegratorDocsHtml, getMetrics, getObligation, getObligations$1 as getObligations, getOffers$1 as getOffers, getOffersQuery, getSwaggerJson, getUserPositions, validateOffers };
5225
5650
  }
5226
5651
  declare namespace RouterApi_d_exports {
5227
- export { ApiConfig, BookResponse_d_exports as BookResponse, BooksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, ConfigContractsController, ConfigRulesController, index_d_exports$4 as Controllers, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, PositionResponse_d_exports as PositionResponse, RouterApi, RouterStatusResponse, UsersController, ValidateController, create$1 as create, from$5 as from, parse, safeParse };
5652
+ export { ApiConfig, BookResponse_d_exports as BookResponse, BooksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, ConfigContractsController, ConfigRulesController, index_d_exports$4 as Controllers, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, PositionResponse_d_exports as PositionResponse, RouterApi, RouterStatusResponse, UsersController, ValidateController, create$1 as create, createApp, from$5 as from, parse, safeParse };
5228
5653
  }
5229
5654
  declare namespace Client_d_exports$1 {
5230
5655
  export { Client$3 as Client, ConnectOptions, HttpForbiddenError, HttpGetApiFailedError, HttpRateLimitError, HttpUnauthorizedError, InvalidUrlError, connect$1 as connect, getObligations, getOffers };
@@ -5326,8 +5751,9 @@ declare namespace getObligations {
5326
5751
  };
5327
5752
  type ReturnType = {
5328
5753
  obligations: Compute<{
5329
- /** The obligation id. Uses {@link Obligation.id} to calculate the id.*/id: () => Hex;
5330
- } & Obligation & Omit<Quote, "obligationId">>[]; /** The pagination cursor. */
5754
+ /** The obligation id returned by the API. */id: Hex; /** The chain id used to compute the obligation id. */
5755
+ chainId: Id;
5756
+ } & Obligation$1 & Omit<Quote, "obligationId">>[]; /** The pagination cursor. */
5331
5757
  cursor: string | null;
5332
5758
  };
5333
5759
  type ErrorType = GetApiErrorType;
@@ -5359,11 +5785,12 @@ declare class HttpGetApiFailedError extends BaseError {
5359
5785
  }
5360
5786
  //#endregion
5361
5787
  //#region src/database/drizzle/VERSION.d.ts
5362
- declare const VERSION: "router_v1.8";
5788
+ declare const VERSION: "router_v1.13";
5363
5789
  //#endregion
5364
5790
  //#region src/database/drizzle/schema.d.ts
5365
5791
  declare enum EnumTableName {
5366
5792
  OBLIGATIONS = "obligations",
5793
+ OBLIGATION_ID_KEYS = "obligation_id_keys",
5367
5794
  GROUPS = "groups",
5368
5795
  CONSUMED_EVENTS = "consumed_events",
5369
5796
  OBLIGATION_COLLATERALS_V2 = "obligation_collaterals_v2",
@@ -5377,20 +5804,21 @@ declare enum EnumTableName {
5377
5804
  COLLECTORS = "collectors",
5378
5805
  CHAINS = "chains",
5379
5806
  LOTS = "lots",
5807
+ LOTS_POSITIONS = "lots_positions",
5380
5808
  OFFSETS = "offsets",
5381
5809
  TREES = "trees",
5382
5810
  MERKLE_PATHS = "merkle_paths"
5383
5811
  }
5384
5812
  declare const TABLE_NAMES: readonly EnumTableName[];
5385
- declare const VERSIONED_TABLE_NAMES: ("\"router_v1.8\".\"obligations\"" | "\"router_v1.8\".\"groups\"" | "\"router_v1.8\".\"consumed_events\"" | "\"router_v1.8\".\"obligation_collaterals_v2\"" | "\"router_v1.8\".\"oracles\"" | "\"router_v1.8\".\"offers\"" | "\"router_v1.8\".\"offers_callbacks\"" | "\"router_v1.8\".\"callbacks\"" | "\"router_v1.8\".\"positions\"" | "\"router_v1.8\".\"transfers\"" | "\"router_v1.8\".\"validations\"" | "\"router_v1.8\".\"collectors\"" | "\"router_v1.8\".\"chains\"" | "\"router_v1.8\".\"lots\"" | "\"router_v1.8\".\"offsets\"" | "\"router_v1.8\".\"trees\"" | "\"router_v1.8\".\"merkle_paths\"")[];
5813
+ declare const VERSIONED_TABLE_NAMES: ("\"router_v1.13\".\"obligations\"" | "\"router_v1.13\".\"obligation_id_keys\"" | "\"router_v1.13\".\"groups\"" | "\"router_v1.13\".\"consumed_events\"" | "\"router_v1.13\".\"obligation_collaterals_v2\"" | "\"router_v1.13\".\"oracles\"" | "\"router_v1.13\".\"offers\"" | "\"router_v1.13\".\"offers_callbacks\"" | "\"router_v1.13\".\"callbacks\"" | "\"router_v1.13\".\"positions\"" | "\"router_v1.13\".\"transfers\"" | "\"router_v1.13\".\"validations\"" | "\"router_v1.13\".\"collectors\"" | "\"router_v1.13\".\"chains\"" | "\"router_v1.13\".\"lots\"" | "\"router_v1.13\".\"lots_positions\"" | "\"router_v1.13\".\"offsets\"" | "\"router_v1.13\".\"trees\"" | "\"router_v1.13\".\"merkle_paths\"")[];
5386
5814
  type TableName = (typeof TABLE_NAMES)[number];
5387
5815
  type VersionedTableName = `"${typeof VERSION}"."${TableName}"`;
5388
5816
  declare const obligations: drizzle_orm_pg_core0.PgTableWithColumns<{
5389
5817
  name: EnumTableName.OBLIGATIONS;
5390
- schema: "router_v1.8";
5818
+ schema: "router_v1.13";
5391
5819
  columns: {
5392
- obligationId: drizzle_orm_pg_core0.PgColumn<{
5393
- name: "obligation_id";
5820
+ obligationKey: drizzle_orm_pg_core0.PgColumn<{
5821
+ name: "obligation_key";
5394
5822
  tableName: EnumTableName.OBLIGATIONS;
5395
5823
  dataType: "string";
5396
5824
  columnType: "PgVarchar";
@@ -5408,12 +5836,31 @@ declare const obligations: drizzle_orm_pg_core0.PgTableWithColumns<{
5408
5836
  }, {}, {
5409
5837
  length: 66;
5410
5838
  }>;
5411
- chainId: drizzle_orm_pg_core0.PgColumn<{
5412
- name: "chain_id";
5839
+ loanToken: drizzle_orm_pg_core0.PgColumn<{
5840
+ name: "loan_token";
5841
+ tableName: EnumTableName.OBLIGATIONS;
5842
+ dataType: "string";
5843
+ columnType: "PgVarchar";
5844
+ data: string;
5845
+ driverParam: string;
5846
+ notNull: true;
5847
+ hasDefault: false;
5848
+ isPrimaryKey: false;
5849
+ isAutoincrement: false;
5850
+ hasRuntimeDefault: false;
5851
+ enumValues: [string, ...string[]];
5852
+ baseColumn: never;
5853
+ identity: undefined;
5854
+ generated: undefined;
5855
+ }, {}, {
5856
+ length: 42;
5857
+ }>;
5858
+ maturity: drizzle_orm_pg_core0.PgColumn<{
5859
+ name: "maturity";
5413
5860
  tableName: EnumTableName.OBLIGATIONS;
5414
5861
  dataType: "number";
5415
- columnType: "PgBigInt53";
5416
- data: Id;
5862
+ columnType: "PgInteger";
5863
+ data: number;
5417
5864
  driverParam: string | number;
5418
5865
  notNull: true;
5419
5866
  hasDefault: false;
@@ -5424,12 +5871,36 @@ declare const obligations: drizzle_orm_pg_core0.PgTableWithColumns<{
5424
5871
  baseColumn: never;
5425
5872
  identity: undefined;
5426
5873
  generated: undefined;
5874
+ }, {}, {}>;
5875
+ };
5876
+ dialect: "pg";
5877
+ }>;
5878
+ declare const obligationIdKeys: drizzle_orm_pg_core0.PgTableWithColumns<{
5879
+ name: EnumTableName.OBLIGATION_ID_KEYS;
5880
+ schema: "router_v1.13";
5881
+ columns: {
5882
+ obligationId: drizzle_orm_pg_core0.PgColumn<{
5883
+ name: "obligation_id";
5884
+ tableName: EnumTableName.OBLIGATION_ID_KEYS;
5885
+ dataType: "string";
5886
+ columnType: "PgVarchar";
5887
+ data: string;
5888
+ driverParam: string;
5889
+ notNull: true;
5890
+ hasDefault: false;
5891
+ isPrimaryKey: true;
5892
+ isAutoincrement: false;
5893
+ hasRuntimeDefault: false;
5894
+ enumValues: [string, ...string[]];
5895
+ baseColumn: never;
5896
+ identity: undefined;
5897
+ generated: undefined;
5427
5898
  }, {}, {
5428
- $type: Id;
5899
+ length: 42;
5429
5900
  }>;
5430
- loanToken: drizzle_orm_pg_core0.PgColumn<{
5431
- name: "loan_token";
5432
- tableName: EnumTableName.OBLIGATIONS;
5901
+ obligationKey: drizzle_orm_pg_core0.PgColumn<{
5902
+ name: "obligation_key";
5903
+ tableName: EnumTableName.OBLIGATION_ID_KEYS;
5433
5904
  dataType: "string";
5434
5905
  columnType: "PgVarchar";
5435
5906
  data: string;
@@ -5444,14 +5915,14 @@ declare const obligations: drizzle_orm_pg_core0.PgTableWithColumns<{
5444
5915
  identity: undefined;
5445
5916
  generated: undefined;
5446
5917
  }, {}, {
5447
- length: 42;
5918
+ length: 66;
5448
5919
  }>;
5449
- maturity: drizzle_orm_pg_core0.PgColumn<{
5450
- name: "maturity";
5451
- tableName: EnumTableName.OBLIGATIONS;
5920
+ chainId: drizzle_orm_pg_core0.PgColumn<{
5921
+ name: "chain_id";
5922
+ tableName: EnumTableName.OBLIGATION_ID_KEYS;
5452
5923
  dataType: "number";
5453
- columnType: "PgInteger";
5454
- data: number;
5924
+ columnType: "PgBigInt53";
5925
+ data: Id;
5455
5926
  driverParam: string | number;
5456
5927
  notNull: true;
5457
5928
  hasDefault: false;
@@ -5462,13 +5933,34 @@ declare const obligations: drizzle_orm_pg_core0.PgTableWithColumns<{
5462
5933
  baseColumn: never;
5463
5934
  identity: undefined;
5464
5935
  generated: undefined;
5465
- }, {}, {}>;
5936
+ }, {}, {
5937
+ $type: Id;
5938
+ }>;
5939
+ morphoV2: drizzle_orm_pg_core0.PgColumn<{
5940
+ name: "morpho_v2";
5941
+ tableName: EnumTableName.OBLIGATION_ID_KEYS;
5942
+ dataType: "string";
5943
+ columnType: "PgVarchar";
5944
+ data: string;
5945
+ driverParam: string;
5946
+ notNull: true;
5947
+ hasDefault: false;
5948
+ isPrimaryKey: false;
5949
+ isAutoincrement: false;
5950
+ hasRuntimeDefault: false;
5951
+ enumValues: [string, ...string[]];
5952
+ baseColumn: never;
5953
+ identity: undefined;
5954
+ generated: undefined;
5955
+ }, {}, {
5956
+ length: 42;
5957
+ }>;
5466
5958
  };
5467
5959
  dialect: "pg";
5468
5960
  }>;
5469
5961
  declare const groups: drizzle_orm_pg_core0.PgTableWithColumns<{
5470
5962
  name: EnumTableName.GROUPS;
5471
- schema: "router_v1.8";
5963
+ schema: "router_v1.13";
5472
5964
  columns: {
5473
5965
  chainId: drizzle_orm_pg_core0.PgColumn<{
5474
5966
  name: "chain_id";
@@ -5583,7 +6075,7 @@ declare const groups: drizzle_orm_pg_core0.PgTableWithColumns<{
5583
6075
  }>;
5584
6076
  declare const consumedEvents: drizzle_orm_pg_core0.PgTableWithColumns<{
5585
6077
  name: EnumTableName.CONSUMED_EVENTS;
5586
- schema: "router_v1.8";
6078
+ schema: "router_v1.13";
5587
6079
  columns: {
5588
6080
  eventId: drizzle_orm_pg_core0.PgColumn<{
5589
6081
  name: "event_id";
@@ -5717,10 +6209,10 @@ declare const consumedEvents: drizzle_orm_pg_core0.PgTableWithColumns<{
5717
6209
  }>;
5718
6210
  declare const obligationCollateralsV2: drizzle_orm_pg_core0.PgTableWithColumns<{
5719
6211
  name: EnumTableName.OBLIGATION_COLLATERALS_V2;
5720
- schema: "router_v1.8";
6212
+ schema: "router_v1.13";
5721
6213
  columns: {
5722
- obligationId: drizzle_orm_pg_core0.PgColumn<{
5723
- name: "obligation_id";
6214
+ obligationKey: drizzle_orm_pg_core0.PgColumn<{
6215
+ name: "obligation_key";
5724
6216
  tableName: EnumTableName.OBLIGATION_COLLATERALS_V2;
5725
6217
  dataType: "string";
5726
6218
  columnType: "PgVarchar";
@@ -5757,25 +6249,6 @@ declare const obligationCollateralsV2: drizzle_orm_pg_core0.PgTableWithColumns<{
5757
6249
  }, {}, {
5758
6250
  length: 42;
5759
6251
  }>;
5760
- oracleChainId: drizzle_orm_pg_core0.PgColumn<{
5761
- name: "oracle_chain_id";
5762
- tableName: EnumTableName.OBLIGATION_COLLATERALS_V2;
5763
- dataType: "number";
5764
- columnType: "PgBigInt53";
5765
- data: Id;
5766
- driverParam: string | number;
5767
- notNull: true;
5768
- hasDefault: false;
5769
- isPrimaryKey: false;
5770
- isAutoincrement: false;
5771
- hasRuntimeDefault: false;
5772
- enumValues: undefined;
5773
- baseColumn: never;
5774
- identity: undefined;
5775
- generated: undefined;
5776
- }, {}, {
5777
- $type: Id;
5778
- }>;
5779
6252
  oracleAddress: drizzle_orm_pg_core0.PgColumn<{
5780
6253
  name: "oracle_address";
5781
6254
  tableName: EnumTableName.OBLIGATION_COLLATERALS_V2;
@@ -5798,10 +6271,27 @@ declare const obligationCollateralsV2: drizzle_orm_pg_core0.PgTableWithColumns<{
5798
6271
  lltv: drizzle_orm_pg_core0.PgColumn<{
5799
6272
  name: "lltv";
5800
6273
  tableName: EnumTableName.OBLIGATION_COLLATERALS_V2;
5801
- dataType: "bigint";
5802
- columnType: "PgBigInt64";
5803
- data: bigint;
5804
- driverParam: string;
6274
+ dataType: "bigint";
6275
+ columnType: "PgBigInt64";
6276
+ data: bigint;
6277
+ driverParam: string;
6278
+ notNull: true;
6279
+ hasDefault: false;
6280
+ isPrimaryKey: false;
6281
+ isAutoincrement: false;
6282
+ hasRuntimeDefault: false;
6283
+ enumValues: undefined;
6284
+ baseColumn: never;
6285
+ identity: undefined;
6286
+ generated: undefined;
6287
+ }, {}, {}>;
6288
+ collateralIndex: drizzle_orm_pg_core0.PgColumn<{
6289
+ name: "collateral_index";
6290
+ tableName: EnumTableName.OBLIGATION_COLLATERALS_V2;
6291
+ dataType: "number";
6292
+ columnType: "PgInteger";
6293
+ data: number;
6294
+ driverParam: string | number;
5805
6295
  notNull: true;
5806
6296
  hasDefault: false;
5807
6297
  isPrimaryKey: false;
@@ -5834,7 +6324,7 @@ declare const obligationCollateralsV2: drizzle_orm_pg_core0.PgTableWithColumns<{
5834
6324
  }>;
5835
6325
  declare const oracles: drizzle_orm_pg_core0.PgTableWithColumns<{
5836
6326
  name: EnumTableName.ORACLES;
5837
- schema: "router_v1.8";
6327
+ schema: "router_v1.13";
5838
6328
  columns: {
5839
6329
  chainId: drizzle_orm_pg_core0.PgColumn<{
5840
6330
  name: "chain_id";
@@ -5930,7 +6420,7 @@ declare const oracles: drizzle_orm_pg_core0.PgTableWithColumns<{
5930
6420
  }>;
5931
6421
  declare const offers: drizzle_orm_pg_core0.PgTableWithColumns<{
5932
6422
  name: EnumTableName.OFFERS;
5933
- schema: "router_v1.8";
6423
+ schema: "router_v1.13";
5934
6424
  columns: {
5935
6425
  hash: drizzle_orm_pg_core0.PgColumn<{
5936
6426
  name: "hash";
@@ -5941,7 +6431,7 @@ declare const offers: drizzle_orm_pg_core0.PgTableWithColumns<{
5941
6431
  driverParam: string;
5942
6432
  notNull: true;
5943
6433
  hasDefault: false;
5944
- isPrimaryKey: true;
6434
+ isPrimaryKey: false;
5945
6435
  isAutoincrement: false;
5946
6436
  hasRuntimeDefault: false;
5947
6437
  enumValues: [string, ...string[]];
@@ -5968,7 +6458,7 @@ declare const offers: drizzle_orm_pg_core0.PgTableWithColumns<{
5968
6458
  identity: undefined;
5969
6459
  generated: undefined;
5970
6460
  }, {}, {
5971
- length: 66;
6461
+ length: 42;
5972
6462
  }>;
5973
6463
  assets: drizzle_orm_pg_core0.PgColumn<{
5974
6464
  name: "assets";
@@ -6276,7 +6766,7 @@ declare const offers: drizzle_orm_pg_core0.PgTableWithColumns<{
6276
6766
  }>;
6277
6767
  declare const offersCallbacks: drizzle_orm_pg_core0.PgTableWithColumns<{
6278
6768
  name: EnumTableName.OFFERS_CALLBACKS;
6279
- schema: "router_v1.8";
6769
+ schema: "router_v1.13";
6280
6770
  columns: {
6281
6771
  offerHash: drizzle_orm_pg_core0.PgColumn<{
6282
6772
  name: "offer_hash";
@@ -6297,6 +6787,25 @@ declare const offersCallbacks: drizzle_orm_pg_core0.PgTableWithColumns<{
6297
6787
  }, {}, {
6298
6788
  length: 66;
6299
6789
  }>;
6790
+ obligationId: drizzle_orm_pg_core0.PgColumn<{
6791
+ name: "obligation_id";
6792
+ tableName: EnumTableName.OFFERS_CALLBACKS;
6793
+ dataType: "string";
6794
+ columnType: "PgVarchar";
6795
+ data: string;
6796
+ driverParam: string;
6797
+ notNull: true;
6798
+ hasDefault: false;
6799
+ isPrimaryKey: false;
6800
+ isAutoincrement: false;
6801
+ hasRuntimeDefault: false;
6802
+ enumValues: [string, ...string[]];
6803
+ baseColumn: never;
6804
+ identity: undefined;
6805
+ generated: undefined;
6806
+ }, {}, {
6807
+ length: 42;
6808
+ }>;
6300
6809
  callbackId: drizzle_orm_pg_core0.PgColumn<{
6301
6810
  name: "callback_id";
6302
6811
  tableName: EnumTableName.OFFERS_CALLBACKS;
@@ -6319,9 +6828,10 @@ declare const offersCallbacks: drizzle_orm_pg_core0.PgTableWithColumns<{
6319
6828
  };
6320
6829
  dialect: "pg";
6321
6830
  }>;
6831
+ declare const CallbackTypes: drizzle_orm_pg_core0.PgEnum<[CallbackType, ...CallbackType[]]>;
6322
6832
  declare const callbacks$1: drizzle_orm_pg_core0.PgTableWithColumns<{
6323
6833
  name: EnumTableName.CALLBACKS;
6324
- schema: "router_v1.8";
6834
+ schema: "router_v1.13";
6325
6835
  columns: {
6326
6836
  id: drizzle_orm_pg_core0.PgColumn<{
6327
6837
  name: "id";
@@ -6378,7 +6888,7 @@ declare const callbacks$1: drizzle_orm_pg_core0.PgTableWithColumns<{
6378
6888
  identity: undefined;
6379
6889
  generated: undefined;
6380
6890
  }, {}, {
6381
- length: 42;
6891
+ length: 66;
6382
6892
  }>;
6383
6893
  positionUser: drizzle_orm_pg_core0.PgColumn<{
6384
6894
  name: "position_user";
@@ -6399,14 +6909,112 @@ declare const callbacks$1: drizzle_orm_pg_core0.PgTableWithColumns<{
6399
6909
  }, {}, {
6400
6910
  length: 42;
6401
6911
  }>;
6402
- amount: drizzle_orm_pg_core0.PgColumn<{
6403
- name: "amount";
6912
+ positionTypeId: drizzle_orm_pg_core0.PgColumn<{
6913
+ name: "position_type_id";
6914
+ tableName: EnumTableName.CALLBACKS;
6915
+ dataType: "number";
6916
+ columnType: "PgInteger";
6917
+ data: number;
6918
+ driverParam: string | number;
6919
+ notNull: true;
6920
+ hasDefault: false;
6921
+ isPrimaryKey: false;
6922
+ isAutoincrement: false;
6923
+ hasRuntimeDefault: false;
6924
+ enumValues: undefined;
6925
+ baseColumn: never;
6926
+ identity: undefined;
6927
+ generated: undefined;
6928
+ }, {}, {}>;
6929
+ type: drizzle_orm_pg_core0.PgColumn<{
6930
+ name: "type";
6404
6931
  tableName: EnumTableName.CALLBACKS;
6405
6932
  dataType: "string";
6406
- columnType: "PgNumeric";
6933
+ columnType: "PgEnumColumn";
6934
+ data: CallbackType;
6935
+ driverParam: string;
6936
+ notNull: true;
6937
+ hasDefault: false;
6938
+ isPrimaryKey: false;
6939
+ isAutoincrement: false;
6940
+ hasRuntimeDefault: false;
6941
+ enumValues: [CallbackType, ...CallbackType[]];
6942
+ baseColumn: never;
6943
+ identity: undefined;
6944
+ generated: undefined;
6945
+ }, {}, {}>;
6946
+ };
6947
+ dialect: "pg";
6948
+ }>;
6949
+ declare const lotsPositions: drizzle_orm_pg_core0.PgTableWithColumns<{
6950
+ name: EnumTableName.LOTS_POSITIONS;
6951
+ schema: "router_v1.13";
6952
+ columns: {
6953
+ chainId: drizzle_orm_pg_core0.PgColumn<{
6954
+ name: "chain_id";
6955
+ tableName: EnumTableName.LOTS_POSITIONS;
6956
+ dataType: "number";
6957
+ columnType: "PgBigInt53";
6958
+ data: Id;
6959
+ driverParam: string | number;
6960
+ notNull: true;
6961
+ hasDefault: false;
6962
+ isPrimaryKey: false;
6963
+ isAutoincrement: false;
6964
+ hasRuntimeDefault: false;
6965
+ enumValues: undefined;
6966
+ baseColumn: never;
6967
+ identity: undefined;
6968
+ generated: undefined;
6969
+ }, {}, {
6970
+ $type: Id;
6971
+ }>;
6972
+ contract: drizzle_orm_pg_core0.PgColumn<{
6973
+ name: "contract";
6974
+ tableName: EnumTableName.LOTS_POSITIONS;
6975
+ dataType: "string";
6976
+ columnType: "PgVarchar";
6407
6977
  data: string;
6408
6978
  driverParam: string;
6409
- notNull: false;
6979
+ notNull: true;
6980
+ hasDefault: false;
6981
+ isPrimaryKey: false;
6982
+ isAutoincrement: false;
6983
+ hasRuntimeDefault: false;
6984
+ enumValues: [string, ...string[]];
6985
+ baseColumn: never;
6986
+ identity: undefined;
6987
+ generated: undefined;
6988
+ }, {}, {
6989
+ length: 66;
6990
+ }>;
6991
+ user: drizzle_orm_pg_core0.PgColumn<{
6992
+ name: "user";
6993
+ tableName: EnumTableName.LOTS_POSITIONS;
6994
+ dataType: "string";
6995
+ columnType: "PgVarchar";
6996
+ data: string;
6997
+ driverParam: string;
6998
+ notNull: true;
6999
+ hasDefault: false;
7000
+ isPrimaryKey: false;
7001
+ isAutoincrement: false;
7002
+ hasRuntimeDefault: false;
7003
+ enumValues: [string, ...string[]];
7004
+ baseColumn: never;
7005
+ identity: undefined;
7006
+ generated: undefined;
7007
+ }, {}, {
7008
+ length: 42;
7009
+ }>;
7010
+ positionTypeId: drizzle_orm_pg_core0.PgColumn<{
7011
+ name: "position_type_id";
7012
+ tableName: EnumTableName.LOTS_POSITIONS;
7013
+ dataType: "number";
7014
+ columnType: "PgInteger";
7015
+ data: number;
7016
+ driverParam: string | number;
7017
+ notNull: true;
6410
7018
  hasDefault: false;
6411
7019
  isPrimaryKey: false;
6412
7020
  isAutoincrement: false;
@@ -6421,7 +7029,7 @@ declare const callbacks$1: drizzle_orm_pg_core0.PgTableWithColumns<{
6421
7029
  }>;
6422
7030
  declare const lots: drizzle_orm_pg_core0.PgTableWithColumns<{
6423
7031
  name: EnumTableName.LOTS;
6424
- schema: "router_v1.8";
7032
+ schema: "router_v1.13";
6425
7033
  columns: {
6426
7034
  chainId: drizzle_orm_pg_core0.PgColumn<{
6427
7035
  name: "chain_id";
@@ -6478,7 +7086,7 @@ declare const lots: drizzle_orm_pg_core0.PgTableWithColumns<{
6478
7086
  identity: undefined;
6479
7087
  generated: undefined;
6480
7088
  }, {}, {
6481
- length: 42;
7089
+ length: 66;
6482
7090
  }>;
6483
7091
  group: drizzle_orm_pg_core0.PgColumn<{
6484
7092
  name: "group";
@@ -6516,7 +7124,7 @@ declare const lots: drizzle_orm_pg_core0.PgTableWithColumns<{
6516
7124
  identity: undefined;
6517
7125
  generated: undefined;
6518
7126
  }, {}, {
6519
- length: 66;
7127
+ length: 42;
6520
7128
  }>;
6521
7129
  lower: drizzle_orm_pg_core0.PgColumn<{
6522
7130
  name: "lower";
@@ -6557,7 +7165,7 @@ declare const lots: drizzle_orm_pg_core0.PgTableWithColumns<{
6557
7165
  }>;
6558
7166
  declare const offsets: drizzle_orm_pg_core0.PgTableWithColumns<{
6559
7167
  name: EnumTableName.OFFSETS;
6560
- schema: "router_v1.8";
7168
+ schema: "router_v1.13";
6561
7169
  columns: {
6562
7170
  chainId: drizzle_orm_pg_core0.PgColumn<{
6563
7171
  name: "chain_id";
@@ -6614,7 +7222,7 @@ declare const offsets: drizzle_orm_pg_core0.PgTableWithColumns<{
6614
7222
  identity: undefined;
6615
7223
  generated: undefined;
6616
7224
  }, {}, {
6617
- length: 42;
7225
+ length: 66;
6618
7226
  }>;
6619
7227
  group: drizzle_orm_pg_core0.PgColumn<{
6620
7228
  name: "group";
@@ -6652,7 +7260,7 @@ declare const offsets: drizzle_orm_pg_core0.PgTableWithColumns<{
6652
7260
  identity: undefined;
6653
7261
  generated: undefined;
6654
7262
  }, {}, {
6655
- length: 66;
7263
+ length: 42;
6656
7264
  }>;
6657
7265
  value: drizzle_orm_pg_core0.PgColumn<{
6658
7266
  name: "value";
@@ -6677,7 +7285,7 @@ declare const offsets: drizzle_orm_pg_core0.PgTableWithColumns<{
6677
7285
  declare const PositionTypes: drizzle_orm_pg_core0.PgEnum<[Type, ...Type[]]>;
6678
7286
  declare const positionTypes: drizzle_orm_pg_core0.PgTableWithColumns<{
6679
7287
  name: "position_types";
6680
- schema: "router_v1.8";
7288
+ schema: "router_v1.13";
6681
7289
  columns: {
6682
7290
  id: drizzle_orm_pg_core0.PgColumn<{
6683
7291
  name: "id";
@@ -6718,7 +7326,7 @@ declare const positionTypes: drizzle_orm_pg_core0.PgTableWithColumns<{
6718
7326
  }>;
6719
7327
  declare const positions: drizzle_orm_pg_core0.PgTableWithColumns<{
6720
7328
  name: EnumTableName.POSITIONS;
6721
- schema: "router_v1.8";
7329
+ schema: "router_v1.13";
6722
7330
  columns: {
6723
7331
  chainId: drizzle_orm_pg_core0.PgColumn<{
6724
7332
  name: "chain_id";
@@ -6756,7 +7364,7 @@ declare const positions: drizzle_orm_pg_core0.PgTableWithColumns<{
6756
7364
  identity: undefined;
6757
7365
  generated: undefined;
6758
7366
  }, {}, {
6759
- length: 42;
7367
+ length: 66;
6760
7368
  }>;
6761
7369
  user: drizzle_orm_pg_core0.PgColumn<{
6762
7370
  name: "user";
@@ -6818,7 +7426,7 @@ declare const positions: drizzle_orm_pg_core0.PgTableWithColumns<{
6818
7426
  columnType: "PgVarchar";
6819
7427
  data: string;
6820
7428
  driverParam: string;
6821
- notNull: false;
7429
+ notNull: true;
6822
7430
  hasDefault: false;
6823
7431
  isPrimaryKey: false;
6824
7432
  isAutoincrement: false;
@@ -6869,7 +7477,7 @@ declare const positions: drizzle_orm_pg_core0.PgTableWithColumns<{
6869
7477
  }>;
6870
7478
  declare const transfers: drizzle_orm_pg_core0.PgTableWithColumns<{
6871
7479
  name: EnumTableName.TRANSFERS;
6872
- schema: "router_v1.8";
7480
+ schema: "router_v1.13";
6873
7481
  columns: {
6874
7482
  eventId: drizzle_orm_pg_core0.PgColumn<{
6875
7483
  name: "event_id";
@@ -6926,7 +7534,7 @@ declare const transfers: drizzle_orm_pg_core0.PgTableWithColumns<{
6926
7534
  identity: undefined;
6927
7535
  generated: undefined;
6928
7536
  }, {}, {
6929
- length: 42;
7537
+ length: 66;
6930
7538
  }>;
6931
7539
  from: drizzle_orm_pg_core0.PgColumn<{
6932
7540
  name: "from";
@@ -6983,6 +7591,42 @@ declare const transfers: drizzle_orm_pg_core0.PgTableWithColumns<{
6983
7591
  identity: undefined;
6984
7592
  generated: undefined;
6985
7593
  }, {}, {}>;
7594
+ positionTypeId: drizzle_orm_pg_core0.PgColumn<{
7595
+ name: "position_type_id";
7596
+ tableName: EnumTableName.TRANSFERS;
7597
+ dataType: "number";
7598
+ columnType: "PgInteger";
7599
+ data: number;
7600
+ driverParam: string | number;
7601
+ notNull: true;
7602
+ hasDefault: false;
7603
+ isPrimaryKey: false;
7604
+ isAutoincrement: false;
7605
+ hasRuntimeDefault: false;
7606
+ enumValues: undefined;
7607
+ baseColumn: never;
7608
+ identity: undefined;
7609
+ generated: undefined;
7610
+ }, {}, {}>;
7611
+ asset: drizzle_orm_pg_core0.PgColumn<{
7612
+ name: "asset";
7613
+ tableName: EnumTableName.TRANSFERS;
7614
+ dataType: "string";
7615
+ columnType: "PgVarchar";
7616
+ data: string;
7617
+ driverParam: string;
7618
+ notNull: true;
7619
+ hasDefault: false;
7620
+ isPrimaryKey: false;
7621
+ isAutoincrement: false;
7622
+ hasRuntimeDefault: false;
7623
+ enumValues: [string, ...string[]];
7624
+ baseColumn: never;
7625
+ identity: undefined;
7626
+ generated: undefined;
7627
+ }, {}, {
7628
+ length: 42;
7629
+ }>;
6986
7630
  blockNumber: drizzle_orm_pg_core0.PgColumn<{
6987
7631
  name: "block_number";
6988
7632
  tableName: EnumTableName.TRANSFERS;
@@ -7023,7 +7667,7 @@ declare const transfers: drizzle_orm_pg_core0.PgTableWithColumns<{
7023
7667
  declare const StatusCode: drizzle_orm_pg_core0.PgEnum<[Status, ...Status[]]>;
7024
7668
  declare const status: drizzle_orm_pg_core0.PgTableWithColumns<{
7025
7669
  name: "status";
7026
- schema: "router_v1.8";
7670
+ schema: "router_v1.13";
7027
7671
  columns: {
7028
7672
  id: drizzle_orm_pg_core0.PgColumn<{
7029
7673
  name: "id";
@@ -7064,7 +7708,7 @@ declare const status: drizzle_orm_pg_core0.PgTableWithColumns<{
7064
7708
  }>;
7065
7709
  declare const validations: drizzle_orm_pg_core0.PgTableWithColumns<{
7066
7710
  name: "validations";
7067
- schema: "router_v1.8";
7711
+ schema: "router_v1.13";
7068
7712
  columns: {
7069
7713
  offerHash: drizzle_orm_pg_core0.PgColumn<{
7070
7714
  name: "offer_hash";
@@ -7075,7 +7719,7 @@ declare const validations: drizzle_orm_pg_core0.PgTableWithColumns<{
7075
7719
  driverParam: string;
7076
7720
  notNull: true;
7077
7721
  hasDefault: false;
7078
- isPrimaryKey: true;
7722
+ isPrimaryKey: false;
7079
7723
  isAutoincrement: false;
7080
7724
  hasRuntimeDefault: false;
7081
7725
  enumValues: [string, ...string[]];
@@ -7085,6 +7729,25 @@ declare const validations: drizzle_orm_pg_core0.PgTableWithColumns<{
7085
7729
  }, {}, {
7086
7730
  length: 66;
7087
7731
  }>;
7732
+ obligationId: drizzle_orm_pg_core0.PgColumn<{
7733
+ name: "obligation_id";
7734
+ tableName: "validations";
7735
+ dataType: "string";
7736
+ columnType: "PgVarchar";
7737
+ data: string;
7738
+ driverParam: string;
7739
+ notNull: true;
7740
+ hasDefault: false;
7741
+ isPrimaryKey: false;
7742
+ isAutoincrement: false;
7743
+ hasRuntimeDefault: false;
7744
+ enumValues: [string, ...string[]];
7745
+ baseColumn: never;
7746
+ identity: undefined;
7747
+ generated: undefined;
7748
+ }, {}, {
7749
+ length: 42;
7750
+ }>;
7088
7751
  statusId: drizzle_orm_pg_core0.PgColumn<{
7089
7752
  name: "status_id";
7090
7753
  tableName: "validations";
@@ -7124,7 +7787,7 @@ declare const validations: drizzle_orm_pg_core0.PgTableWithColumns<{
7124
7787
  }>;
7125
7788
  declare const collectors: drizzle_orm_pg_core0.PgTableWithColumns<{
7126
7789
  name: EnumTableName.COLLECTORS;
7127
- schema: "router_v1.8";
7790
+ schema: "router_v1.13";
7128
7791
  columns: {
7129
7792
  chainId: drizzle_orm_pg_core0.PgColumn<{
7130
7793
  name: "chain_id";
@@ -7150,7 +7813,7 @@ declare const collectors: drizzle_orm_pg_core0.PgTableWithColumns<{
7150
7813
  tableName: EnumTableName.COLLECTORS;
7151
7814
  dataType: "string";
7152
7815
  columnType: "PgText";
7153
- data: "offers" | "consumed_events" | "positions" | "prices";
7816
+ data: "morpho_v2" | "offers" | "positions" | "prices";
7154
7817
  driverParam: string;
7155
7818
  notNull: true;
7156
7819
  hasDefault: false;
@@ -7162,7 +7825,7 @@ declare const collectors: drizzle_orm_pg_core0.PgTableWithColumns<{
7162
7825
  identity: undefined;
7163
7826
  generated: undefined;
7164
7827
  }, {}, {
7165
- $type: "offers" | "consumed_events" | "positions" | "prices";
7828
+ $type: "morpho_v2" | "offers" | "positions" | "prices";
7166
7829
  }>;
7167
7830
  blockNumber: drizzle_orm_pg_core0.PgColumn<{
7168
7831
  name: "block_number";
@@ -7218,9 +7881,9 @@ declare const collectors: drizzle_orm_pg_core0.PgTableWithColumns<{
7218
7881
  };
7219
7882
  dialect: "pg";
7220
7883
  }>;
7221
- declare const chains$1: drizzle_orm_pg_core0.PgTableWithColumns<{
7884
+ declare const chains: drizzle_orm_pg_core0.PgTableWithColumns<{
7222
7885
  name: EnumTableName.CHAINS;
7223
- schema: "router_v1.8";
7886
+ schema: "router_v1.13";
7224
7887
  columns: {
7225
7888
  chainId: drizzle_orm_pg_core0.PgColumn<{
7226
7889
  name: "chain_id";
@@ -7297,7 +7960,7 @@ declare const chains$1: drizzle_orm_pg_core0.PgTableWithColumns<{
7297
7960
  }>;
7298
7961
  declare const trees: drizzle_orm_pg_core0.PgTableWithColumns<{
7299
7962
  name: EnumTableName.TREES;
7300
- schema: "router_v1.8";
7963
+ schema: "router_v1.13";
7301
7964
  columns: {
7302
7965
  root: drizzle_orm_pg_core0.PgColumn<{
7303
7966
  name: "root";
@@ -7359,7 +8022,7 @@ declare const trees: drizzle_orm_pg_core0.PgTableWithColumns<{
7359
8022
  }>;
7360
8023
  declare const merklePaths: drizzle_orm_pg_core0.PgTableWithColumns<{
7361
8024
  name: EnumTableName.MERKLE_PATHS;
7362
- schema: "router_v1.8";
8025
+ schema: "router_v1.13";
7363
8026
  columns: {
7364
8027
  offerHash: drizzle_orm_pg_core0.PgColumn<{
7365
8028
  name: "offer_hash";
@@ -7370,7 +8033,7 @@ declare const merklePaths: drizzle_orm_pg_core0.PgTableWithColumns<{
7370
8033
  driverParam: string;
7371
8034
  notNull: true;
7372
8035
  hasDefault: false;
7373
- isPrimaryKey: true;
8036
+ isPrimaryKey: false;
7374
8037
  isAutoincrement: false;
7375
8038
  hasRuntimeDefault: false;
7376
8039
  enumValues: [string, ...string[]];
@@ -7380,6 +8043,25 @@ declare const merklePaths: drizzle_orm_pg_core0.PgTableWithColumns<{
7380
8043
  }, {}, {
7381
8044
  length: 66;
7382
8045
  }>;
8046
+ obligationId: drizzle_orm_pg_core0.PgColumn<{
8047
+ name: "obligation_id";
8048
+ tableName: EnumTableName.MERKLE_PATHS;
8049
+ dataType: "string";
8050
+ columnType: "PgVarchar";
8051
+ data: string;
8052
+ driverParam: string;
8053
+ notNull: true;
8054
+ hasDefault: false;
8055
+ isPrimaryKey: false;
8056
+ isAutoincrement: false;
8057
+ hasRuntimeDefault: false;
8058
+ enumValues: [string, ...string[]];
8059
+ baseColumn: never;
8060
+ identity: undefined;
8061
+ generated: undefined;
8062
+ }, {}, {
8063
+ length: 42;
8064
+ }>;
7383
8065
  treeRoot: drizzle_orm_pg_core0.PgColumn<{
7384
8066
  name: "tree_root";
7385
8067
  tableName: EnumTableName.MERKLE_PATHS;
@@ -7437,29 +8119,20 @@ declare const merklePaths: drizzle_orm_pg_core0.PgTableWithColumns<{
7437
8119
  dialect: "pg";
7438
8120
  }>;
7439
8121
  declare namespace index_d_exports$2 {
7440
- export { PositionTypes, StatusCode, TABLE_NAMES, TableName, VERSION, VERSIONED_TABLE_NAMES, VersionedTableName, callbacks$1 as callbacks, chains$1 as chains, collectors, consumedEvents, groups, lots, merklePaths, obligationCollateralsV2, obligations, offers, offersCallbacks, offsets, oracles, positionTypes, positions, status, transfers, trees, validations };
8122
+ export { CallbackTypes, PositionTypes, StatusCode, TABLE_NAMES, TableName, VERSION, VERSIONED_TABLE_NAMES, VersionedTableName, callbacks$1 as callbacks, chains, collectors, consumedEvents, groups, lots, lotsPositions, merklePaths, obligationCollateralsV2, obligationIdKeys, obligations, offers, offersCallbacks, offsets, oracles, positionTypes, positions, status, transfers, trees, validations };
7441
8123
  }
7442
8124
  //#endregion
7443
8125
  //#region src/gatekeeper/morphoRules.d.ts
7444
- 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, "loan_token"> | Rule<Offer, "collateral_token"> | Rule<Offer, "oracle">)[];
8126
+ declare const morphoRules: (parameters: {
8127
+ chains: Chain$1[];
8128
+ chainId: Id;
8129
+ db?: {
8130
+ groups: GroupsDomain;
8131
+ };
8132
+ }) => Rule<Offer, string>[];
7445
8133
  declare namespace Rules_d_exports {
7446
- export { ValidityParameters, amountMutualExclusivity, callback, chains, collateralToken, loanToken, maturity, oracle, sameMaker, validity };
8134
+ export { amountMutualExclusivity, callback, collateralToken, groupConsistency, groupImmutability, loanToken, maturity, maxCollaterals, minDuration, oracle, sameMaker };
7447
8135
  }
7448
- type ValidityParameters = {
7449
- client: PublicClient<Transport, Chain$1>;
7450
- };
7451
- /**
7452
- * set of rules to validate offers.
7453
- *
7454
- * @param _parameters - Validity parameters with chain and client
7455
- * @returns Array of validation rules to evaluate against offers
7456
- */
7457
- declare function validity(_parameters: ValidityParameters): Rule<Offer, "expiry">[];
7458
- declare const chains: ({
7459
- chains
7460
- }: {
7461
- chains: Chain$1[];
7462
- }) => Rule<Offer, "chain_ids">;
7463
8136
  declare const maturity: ({
7464
8137
  maturities
7465
8138
  }: {
@@ -7477,9 +8150,11 @@ declare const callback: ({
7477
8150
  * @returns The issue that was found. If the offer is valid, this will be undefined.
7478
8151
  */
7479
8152
  declare const loanToken: ({
7480
- assetsByChainId
8153
+ assetsByChainId,
8154
+ chainId
7481
8155
  }: {
7482
8156
  assetsByChainId: Partial<Record<Id, Address[]>>;
8157
+ chainId: Id;
7483
8158
  }) => Rule<Offer, "loan_token">;
7484
8159
  /**
7485
8160
  * A validation rule that checks if the offer's collateral tokens are allowed for its chain.
@@ -7487,9 +8162,11 @@ declare const loanToken: ({
7487
8162
  * @returns The issue that was found. If the offer is valid, this will be undefined.
7488
8163
  */
7489
8164
  declare const collateralToken: ({
7490
- collateralAssetsByChainId
8165
+ collateralAssetsByChainId,
8166
+ chainId
7491
8167
  }: {
7492
8168
  collateralAssetsByChainId: Partial<Record<Id, Address[]>>;
8169
+ chainId: Id;
7493
8170
  }) => Rule<Offer, "collateral_token">;
7494
8171
  /**
7495
8172
  * A validation rule that checks if the offer's oracle addresses are allowed for its chain.
@@ -7497,9 +8174,11 @@ declare const collateralToken: ({
7497
8174
  * @returns The issue that was found. If the offer is valid, this will be undefined.
7498
8175
  */
7499
8176
  declare const oracle: ({
7500
- oraclesByChainId
8177
+ oraclesByChainId,
8178
+ chainId
7501
8179
  }: {
7502
8180
  oraclesByChainId: Partial<Record<Id, Address[]>>;
8181
+ chainId: Id;
7503
8182
  }) => Rule<Offer, "oracle">;
7504
8183
  /**
7505
8184
  * A batch validation rule that ensures all offers in a tree have the same maker address.
@@ -7512,7 +8191,46 @@ declare const sameMaker: () => Rule<Offer, "mixed_maker">;
7512
8191
  * At most one of (assets, obligationUnits, obligationShares) can be non-zero.
7513
8192
  * Matches contract requirement: `atMostOneNonZero(offer.assets, offer.obligationUnits, offer.obligationShares)`.
7514
8193
  */
8194
+ /**
8195
+ * A validation rule that checks if the offer duration (expiry - start) meets a minimum threshold.
8196
+ * @param minSeconds - Minimum required duration in seconds.
8197
+ * @returns The issue that was found. If the offer is valid, this will be undefined.
8198
+ */
8199
+ declare const minDuration: ({
8200
+ minSeconds
8201
+ }: {
8202
+ minSeconds: number;
8203
+ }) => Rule<Offer, "min_duration">;
8204
+ /**
8205
+ * A validation rule that checks if an offer exceeds the maximum number of collaterals.
8206
+ * The contract enforces this limit; this rule rejects early to avoid on-chain reverts.
8207
+ * @param max - Maximum allowed collaterals per offer.
8208
+ * @returns The issue that was found. If the offer is valid, this will be undefined.
8209
+ */
8210
+ declare const maxCollaterals: ({
8211
+ max
8212
+ }: {
8213
+ max: number;
8214
+ }) => Rule<Offer, "max_collaterals">;
7515
8215
  declare const amountMutualExclusivity: () => Rule<Offer, "amount_mutual_exclusivity">;
8216
+ /**
8217
+ * A batch validation rule that ensures all offers within the same group are consistent.
8218
+ * All offers sharing the same group must have the same loan token, assets amount, and side (buy/sell).
8219
+ */
8220
+ declare const groupConsistency: () => Rule<Offer, "group_consistency">;
8221
+ /**
8222
+ * A batch validation rule that prevents adding offers to groups that already exist in the database.
8223
+ * Groups are immutable after creation — new offers cannot be added to an existing group.
8224
+ */
8225
+ declare const groupImmutability: ({
8226
+ db,
8227
+ chainId
8228
+ }: {
8229
+ db: {
8230
+ groups: GroupsDomain;
8231
+ };
8232
+ chainId: Id;
8233
+ }) => Rule<Offer, "group_immutability">;
7516
8234
  //#endregion
7517
8235
  //#region src/mempool/MempoolEVMClient.d.ts
7518
8236
  type MempoolEVMClientConfig = {
@@ -7541,7 +8259,7 @@ declare namespace from {
7541
8259
  */
7542
8260
  declare function add(config: MempoolEVMClientConfig, offers: AddParameters): Promise<Hex>;
7543
8261
  declare namespace add {
7544
- type ErrorType = WalletAccountNotSetError | ViemClientError | InvalidOfferError | ChainIdMismatchError | MissingMorphoAddressError;
8262
+ type ErrorType = WalletAccountNotSetError | ViemClientError | InvalidOfferError | MissingMorphoAddressError;
7545
8263
  }
7546
8264
  declare function get(config: MempoolEVMClientConfig, parameters?: GetParameters): AsyncGenerator<{
7547
8265
  offers: Offer[];
@@ -7550,7 +8268,7 @@ declare function get(config: MempoolEVMClientConfig, parameters?: GetParameters)
7550
8268
  declare namespace get {
7551
8269
  type ErrorType = streamOffersReturnType;
7552
8270
  }
7553
- type streamOffersReturnType = WalletAccountNotSetError | ChainIdMismatchError | MissingMorphoAddressError;
8271
+ type streamOffersReturnType = WalletAccountNotSetError | MissingMorphoAddressError;
7554
8272
  declare class WalletAccountNotSetError extends BaseError {
7555
8273
  name: string;
7556
8274
  constructor();
@@ -7558,10 +8276,6 @@ declare class WalletAccountNotSetError extends BaseError {
7558
8276
  declare class ViemClientError extends BaseError {
7559
8277
  name: string;
7560
8278
  }
7561
- declare class ChainIdMismatchError extends BaseError {
7562
- name: string;
7563
- constructor(expected: Id, actual: Id);
7564
- }
7565
8279
  declare class MissingMorphoAddressError extends BaseError {
7566
8280
  name: string;
7567
8281
  constructor();
@@ -7612,11 +8326,11 @@ declare namespace connect {
7612
8326
  type ErrorType = from.ErrorType;
7613
8327
  }
7614
8328
  declare namespace index_d_exports$1 {
7615
- export { AddParameters, ChainIdMismatchError, Client$2 as Client, GetParameters, MissingMorphoAddressError, ViemClientError, WalletAccountNotSetError, add, connect, from, get };
8329
+ export { AddParameters, Client$2 as Client, GetParameters, MissingMorphoAddressError, ViemClientError, WalletAccountNotSetError, add, connect, from, get };
7616
8330
  }
7617
8331
  //#endregion
7618
8332
  //#region src/utils/BigMath.d.ts
7619
- declare function max$1(a: bigint, b: bigint): bigint;
8333
+ declare function max$2(a: bigint, b: bigint): bigint;
7620
8334
  declare function min(a: bigint, b: bigint): bigint;
7621
8335
  /**
7622
8336
  * Checks if at most one of the given values is non-zero.
@@ -7736,16 +8450,16 @@ declare function address(): Address;
7736
8450
  //#region src/utils/retry.d.ts
7737
8451
  declare const retry: <T>(fn: () => Promise<T>, attempts?: number, delayMs?: number) => Promise<T>;
7738
8452
  declare namespace time_d_exports {
7739
- export { max, now };
8453
+ export { max$1 as max, now };
7740
8454
  }
7741
8455
  declare function now(): number;
7742
- declare function max(): number;
8456
+ declare function max$1(): number;
7743
8457
  //#endregion
7744
8458
  //#region src/utils/wait.d.ts
7745
8459
  declare function wait(time: number): Promise<unknown>;
7746
8460
  declare namespace index_d_exports$3 {
7747
- 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 };
8461
+ 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$2 as max, min, poll, retry, stringifyBigint, toSnakeCase$1 as toSnakeCase, wait };
7748
8462
  }
7749
8463
  //#endregion
7750
- export { index_d_exports as Abi, BookResponse_d_exports as BookResponse, BooksController, Brand, BrandTypeId, Callback_d_exports as Callback, Chain_d_exports as Chain, ChainHealth, ChainRegistry_d_exports as ChainRegistry, ChainsHealthResponse, Collateral_d_exports as Collateral, CollectorHealth, CollectorsHealthResponse, Compute, ConfigContractsController, ConfigRule, ConfigRulesController, ConfigRulesPayload, Database_d_exports as Database, ERC4626_d_exports as ERC4626, ErrorPayload, Errors_d_exports as Errors, Format_d_exports as Format, Gatekeeper_d_exports as Gatekeeper, Client_d_exports as GatekeeperClient, Health_d_exports as Health, HealthController, Indexer_d_exports as Indexer, LLTV_d_exports as LLTV, Liquidity_d_exports as Liquidity, Logger_d_exports as Logger, Maturity_d_exports as Maturity, index_d_exports$1 as Mempool, Obligation_d_exports as Obligation, ObligationResponse_d_exports as ObligationResponse, ObligationsController, Offer_d_exports as Offer, OfferResponse_d_exports as OfferResponse, OffersController, index_d_exports$2 as OffersSchema, OpenApi, Oracle_d_exports as Oracle, Position_d_exports as Position, PositionResponse_d_exports as PositionResponse, Quote_d_exports as Quote, RouterApi_d_exports as RouterApi, Client_d_exports$1 as RouterClient, RouterStatusResponse, Rules_d_exports as Rules, SuccessPayload, Tick_d_exports as Tick, time_d_exports as Time, TradingFee_d_exports as TradingFee, Transfer_d_exports as Transfer, Tree_d_exports as Tree, UsersController, index_d_exports$3 as Utils, ValidateController, ValidateOffersData, ValidateOffersIssues, ValidateOffersSuccess, Gate_d_exports as Validation, ValidationIssue, morphoRules, parse, safeParse };
8464
+ export { index_d_exports as Abi, BookResponse_d_exports as BookResponse, BooksController, Brand, BrandTypeId, Callback_d_exports as Callback, Chain_d_exports as Chain, ChainHealth, ChainRegistry_d_exports as ChainRegistry, ChainsHealthResponse, Collateral_d_exports as Collateral, CollectorHealth, CollectorsHealthResponse, Compute, ConfigContractsController, ConfigRule, ConfigRulesController, ConfigRulesPayload, Database_d_exports as Database, ERC4626_d_exports as ERC4626, ErrorPayload, Errors_d_exports as Errors, Format_d_exports as Format, Gatekeeper_d_exports as Gatekeeper, Client_d_exports as GatekeeperClient, Health_d_exports as Health, HealthController, Id_d_exports as Id, Indexer_d_exports as Indexer, LLTV_d_exports as LLTV, Liquidity_d_exports as Liquidity, Logger_d_exports as Logger, Maturity_d_exports as Maturity, index_d_exports$1 as Mempool, Obligation_d_exports as Obligation, ObligationResponse_d_exports as ObligationResponse, ObligationsController, Offer_d_exports as Offer, OfferResponse_d_exports as OfferResponse, OffersController, index_d_exports$2 as OffersSchema, OpenApi, Oracle_d_exports as Oracle, Position_d_exports as Position, PositionResponse_d_exports as PositionResponse, Quote_d_exports as Quote, RouterApi_d_exports as RouterApi, Client_d_exports$1 as RouterClient, RouterStatusResponse, Rules_d_exports as Rules, SuccessPayload, Tick_d_exports as Tick, time_d_exports as Time, TradingFee_d_exports as TradingFee, Transfer_d_exports as Transfer, Tree_d_exports as Tree, UsersController, index_d_exports$3 as Utils, ValidateController, ValidateOffersData, ValidateOffersIssues, ValidateOffersSuccess, Gate_d_exports as Validation, ValidationIssue, morphoRules, parse, safeParse };
7751
8465
  //# sourceMappingURL=index.node.d.mts.map