@morpho-org/midnight-sdk 2.4.0-next.0 → 2.4.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 (37) hide show
  1. package/lib/cjs/abis.d.ts +382 -0
  2. package/lib/cjs/abis.js +488 -1
  3. package/lib/cjs/api/MidnightApi.d.ts +14 -12
  4. package/lib/cjs/api/MidnightApi.js +35 -25
  5. package/lib/cjs/api/helpers.d.ts +10 -0
  6. package/lib/cjs/api/helpers.js +97 -10
  7. package/lib/cjs/api/types.d.ts +5 -0
  8. package/lib/cjs/api/version.generated.d.ts +1 -1
  9. package/lib/cjs/api/version.generated.js +1 -1
  10. package/lib/cjs/errors.d.ts +27 -13
  11. package/lib/cjs/errors.js +39 -8
  12. package/lib/cjs/offers/Offer.d.ts +3 -0
  13. package/lib/cjs/offers/Offer.js +3 -0
  14. package/lib/cjs/offers/OfferUtils.d.ts +6 -0
  15. package/lib/cjs/offers/OfferUtils.js +14 -0
  16. package/lib/cjs/position/Position.d.ts +3 -0
  17. package/lib/cjs/position/Position.js +13 -0
  18. package/lib/cjs/position/PositionUtils.js +35 -11
  19. package/lib/esm/abis.d.ts +382 -0
  20. package/lib/esm/abis.js +487 -0
  21. package/lib/esm/api/MidnightApi.d.ts +14 -12
  22. package/lib/esm/api/MidnightApi.js +36 -26
  23. package/lib/esm/api/helpers.d.ts +10 -0
  24. package/lib/esm/api/helpers.js +91 -8
  25. package/lib/esm/api/types.d.ts +5 -0
  26. package/lib/esm/api/version.generated.d.ts +1 -1
  27. package/lib/esm/api/version.generated.js +1 -1
  28. package/lib/esm/errors.d.ts +27 -13
  29. package/lib/esm/errors.js +36 -8
  30. package/lib/esm/offers/Offer.d.ts +3 -0
  31. package/lib/esm/offers/Offer.js +3 -0
  32. package/lib/esm/offers/OfferUtils.d.ts +6 -0
  33. package/lib/esm/offers/OfferUtils.js +15 -1
  34. package/lib/esm/position/Position.d.ts +3 -0
  35. package/lib/esm/position/Position.js +14 -1
  36. package/lib/esm/position/PositionUtils.js +36 -12
  37. package/package.json +4 -4
package/lib/esm/abis.js CHANGED
@@ -6348,3 +6348,490 @@ export const midnightEventsAbi = [
6348
6348
  anonymous: false,
6349
6349
  },
6350
6350
  ];
6351
+ /**
6352
+ * ABI JSON for a per-owner BlueBuyCallback, which parks Midnight buy-offer funds as Morpho Blue
6353
+ * supply. Its constructor authorizes `OWNER` on Morpho Blue to manage the callback position.
6354
+ *
6355
+ * Source: `morpho-org/midnight` commit `4603969e80d6f911c33586c6b971e8edd7821bbc`,
6356
+ * `src/periphery/blue-buy-callback/BlueBuyCallback.sol` (compiled with `forge inspect ... abi`).
6357
+ *
6358
+ * @example
6359
+ * ```ts
6360
+ * import { blueBuyCallbackAbi } from "@morpho-org/midnight-sdk";
6361
+ *
6362
+ * console.log(blueBuyCallbackAbi.length);
6363
+ * ```
6364
+ */
6365
+ export const blueBuyCallbackAbi = [
6366
+ {
6367
+ type: "constructor",
6368
+ inputs: [
6369
+ {
6370
+ name: "_owner",
6371
+ type: "address",
6372
+ internalType: "address",
6373
+ },
6374
+ {
6375
+ name: "_midnight",
6376
+ type: "address",
6377
+ internalType: "address",
6378
+ },
6379
+ {
6380
+ name: "_blue",
6381
+ type: "address",
6382
+ internalType: "address",
6383
+ },
6384
+ ],
6385
+ stateMutability: "nonpayable",
6386
+ },
6387
+ {
6388
+ type: "function",
6389
+ name: "BLUE",
6390
+ inputs: [],
6391
+ outputs: [
6392
+ {
6393
+ name: "",
6394
+ type: "address",
6395
+ internalType: "address",
6396
+ },
6397
+ ],
6398
+ stateMutability: "view",
6399
+ },
6400
+ {
6401
+ type: "function",
6402
+ name: "MIDNIGHT",
6403
+ inputs: [],
6404
+ outputs: [
6405
+ {
6406
+ name: "",
6407
+ type: "address",
6408
+ internalType: "address",
6409
+ },
6410
+ ],
6411
+ stateMutability: "view",
6412
+ },
6413
+ {
6414
+ type: "function",
6415
+ name: "OWNER",
6416
+ inputs: [],
6417
+ outputs: [
6418
+ {
6419
+ name: "",
6420
+ type: "address",
6421
+ internalType: "address",
6422
+ },
6423
+ ],
6424
+ stateMutability: "view",
6425
+ },
6426
+ {
6427
+ type: "function",
6428
+ name: "buyerAssetsBound",
6429
+ inputs: [
6430
+ {
6431
+ name: "",
6432
+ type: "bytes32",
6433
+ internalType: "bytes32",
6434
+ },
6435
+ {
6436
+ name: "",
6437
+ type: "tuple",
6438
+ internalType: "struct Market",
6439
+ components: [
6440
+ {
6441
+ name: "chainId",
6442
+ type: "uint256",
6443
+ internalType: "uint256",
6444
+ },
6445
+ {
6446
+ name: "midnight",
6447
+ type: "address",
6448
+ internalType: "address",
6449
+ },
6450
+ {
6451
+ name: "loanToken",
6452
+ type: "address",
6453
+ internalType: "address",
6454
+ },
6455
+ {
6456
+ name: "collateralParams",
6457
+ type: "tuple[]",
6458
+ internalType: "struct CollateralParams[]",
6459
+ components: [
6460
+ {
6461
+ name: "token",
6462
+ type: "address",
6463
+ internalType: "address",
6464
+ },
6465
+ {
6466
+ name: "lltv",
6467
+ type: "uint256",
6468
+ internalType: "uint256",
6469
+ },
6470
+ {
6471
+ name: "liquidationCursor",
6472
+ type: "uint256",
6473
+ internalType: "uint256",
6474
+ },
6475
+ {
6476
+ name: "oracle",
6477
+ type: "address",
6478
+ internalType: "address",
6479
+ },
6480
+ ],
6481
+ },
6482
+ {
6483
+ name: "maturity",
6484
+ type: "uint256",
6485
+ internalType: "uint256",
6486
+ },
6487
+ {
6488
+ name: "rcfThreshold",
6489
+ type: "uint256",
6490
+ internalType: "uint256",
6491
+ },
6492
+ {
6493
+ name: "enterGate",
6494
+ type: "address",
6495
+ internalType: "address",
6496
+ },
6497
+ {
6498
+ name: "liquidatorGate",
6499
+ type: "address",
6500
+ internalType: "address",
6501
+ },
6502
+ ],
6503
+ },
6504
+ {
6505
+ name: "",
6506
+ type: "address",
6507
+ internalType: "address",
6508
+ },
6509
+ {
6510
+ name: "data",
6511
+ type: "bytes",
6512
+ internalType: "bytes",
6513
+ },
6514
+ ],
6515
+ outputs: [
6516
+ {
6517
+ name: "",
6518
+ type: "uint256",
6519
+ internalType: "uint256",
6520
+ },
6521
+ ],
6522
+ stateMutability: "view",
6523
+ },
6524
+ {
6525
+ type: "function",
6526
+ name: "nonce",
6527
+ inputs: [],
6528
+ outputs: [
6529
+ {
6530
+ name: "",
6531
+ type: "uint256",
6532
+ internalType: "uint256",
6533
+ },
6534
+ ],
6535
+ stateMutability: "view",
6536
+ },
6537
+ {
6538
+ type: "function",
6539
+ name: "onBuy",
6540
+ inputs: [
6541
+ {
6542
+ name: "",
6543
+ type: "bytes32",
6544
+ internalType: "bytes32",
6545
+ },
6546
+ {
6547
+ name: "market",
6548
+ type: "tuple",
6549
+ internalType: "struct Market",
6550
+ components: [
6551
+ {
6552
+ name: "chainId",
6553
+ type: "uint256",
6554
+ internalType: "uint256",
6555
+ },
6556
+ {
6557
+ name: "midnight",
6558
+ type: "address",
6559
+ internalType: "address",
6560
+ },
6561
+ {
6562
+ name: "loanToken",
6563
+ type: "address",
6564
+ internalType: "address",
6565
+ },
6566
+ {
6567
+ name: "collateralParams",
6568
+ type: "tuple[]",
6569
+ internalType: "struct CollateralParams[]",
6570
+ components: [
6571
+ {
6572
+ name: "token",
6573
+ type: "address",
6574
+ internalType: "address",
6575
+ },
6576
+ {
6577
+ name: "lltv",
6578
+ type: "uint256",
6579
+ internalType: "uint256",
6580
+ },
6581
+ {
6582
+ name: "liquidationCursor",
6583
+ type: "uint256",
6584
+ internalType: "uint256",
6585
+ },
6586
+ {
6587
+ name: "oracle",
6588
+ type: "address",
6589
+ internalType: "address",
6590
+ },
6591
+ ],
6592
+ },
6593
+ {
6594
+ name: "maturity",
6595
+ type: "uint256",
6596
+ internalType: "uint256",
6597
+ },
6598
+ {
6599
+ name: "rcfThreshold",
6600
+ type: "uint256",
6601
+ internalType: "uint256",
6602
+ },
6603
+ {
6604
+ name: "enterGate",
6605
+ type: "address",
6606
+ internalType: "address",
6607
+ },
6608
+ {
6609
+ name: "liquidatorGate",
6610
+ type: "address",
6611
+ internalType: "address",
6612
+ },
6613
+ ],
6614
+ },
6615
+ {
6616
+ name: "buyerAssets",
6617
+ type: "uint256",
6618
+ internalType: "uint256",
6619
+ },
6620
+ {
6621
+ name: "",
6622
+ type: "uint256",
6623
+ internalType: "uint256",
6624
+ },
6625
+ {
6626
+ name: "",
6627
+ type: "uint256",
6628
+ internalType: "uint256",
6629
+ },
6630
+ {
6631
+ name: "buyer",
6632
+ type: "address",
6633
+ internalType: "address",
6634
+ },
6635
+ {
6636
+ name: "data",
6637
+ type: "bytes",
6638
+ internalType: "bytes",
6639
+ },
6640
+ ],
6641
+ outputs: [
6642
+ {
6643
+ name: "",
6644
+ type: "bytes32",
6645
+ internalType: "bytes32",
6646
+ },
6647
+ ],
6648
+ stateMutability: "nonpayable",
6649
+ },
6650
+ {
6651
+ type: "function",
6652
+ name: "setAuthorization",
6653
+ inputs: [
6654
+ {
6655
+ name: "authorized",
6656
+ type: "address",
6657
+ internalType: "address",
6658
+ },
6659
+ {
6660
+ name: "newIsAuthorized",
6661
+ type: "bool",
6662
+ internalType: "bool",
6663
+ },
6664
+ ],
6665
+ outputs: [],
6666
+ stateMutability: "nonpayable",
6667
+ },
6668
+ {
6669
+ type: "function",
6670
+ name: "setAuthorizationWithSig",
6671
+ inputs: [
6672
+ {
6673
+ name: "authorization",
6674
+ type: "tuple",
6675
+ internalType: "struct Authorization",
6676
+ components: [
6677
+ {
6678
+ name: "authorizer",
6679
+ type: "address",
6680
+ internalType: "address",
6681
+ },
6682
+ {
6683
+ name: "authorized",
6684
+ type: "address",
6685
+ internalType: "address",
6686
+ },
6687
+ {
6688
+ name: "isAuthorized",
6689
+ type: "bool",
6690
+ internalType: "bool",
6691
+ },
6692
+ {
6693
+ name: "nonce",
6694
+ type: "uint256",
6695
+ internalType: "uint256",
6696
+ },
6697
+ {
6698
+ name: "deadline",
6699
+ type: "uint256",
6700
+ internalType: "uint256",
6701
+ },
6702
+ ],
6703
+ },
6704
+ {
6705
+ name: "signature",
6706
+ type: "tuple",
6707
+ internalType: "struct Signature",
6708
+ components: [
6709
+ {
6710
+ name: "v",
6711
+ type: "uint8",
6712
+ internalType: "uint8",
6713
+ },
6714
+ {
6715
+ name: "r",
6716
+ type: "bytes32",
6717
+ internalType: "bytes32",
6718
+ },
6719
+ {
6720
+ name: "s",
6721
+ type: "bytes32",
6722
+ internalType: "bytes32",
6723
+ },
6724
+ ],
6725
+ },
6726
+ ],
6727
+ outputs: [],
6728
+ stateMutability: "nonpayable",
6729
+ },
6730
+ {
6731
+ type: "function",
6732
+ name: "skim",
6733
+ inputs: [
6734
+ {
6735
+ name: "token",
6736
+ type: "address",
6737
+ internalType: "address",
6738
+ },
6739
+ ],
6740
+ outputs: [],
6741
+ stateMutability: "nonpayable",
6742
+ },
6743
+ {
6744
+ type: "event",
6745
+ name: "SetAuthorizationWithSig",
6746
+ inputs: [
6747
+ {
6748
+ name: "caller",
6749
+ type: "address",
6750
+ indexed: true,
6751
+ internalType: "address",
6752
+ },
6753
+ {
6754
+ name: "nonce",
6755
+ type: "uint256",
6756
+ indexed: false,
6757
+ internalType: "uint256",
6758
+ },
6759
+ ],
6760
+ anonymous: false,
6761
+ },
6762
+ {
6763
+ type: "event",
6764
+ name: "Skim",
6765
+ inputs: [
6766
+ {
6767
+ name: "caller",
6768
+ type: "address",
6769
+ indexed: true,
6770
+ internalType: "address",
6771
+ },
6772
+ {
6773
+ name: "token",
6774
+ type: "address",
6775
+ indexed: true,
6776
+ internalType: "address",
6777
+ },
6778
+ {
6779
+ name: "assets",
6780
+ type: "uint256",
6781
+ indexed: false,
6782
+ internalType: "uint256",
6783
+ },
6784
+ ],
6785
+ anonymous: false,
6786
+ },
6787
+ {
6788
+ type: "error",
6789
+ name: "ApproveReturnedFalse",
6790
+ inputs: [],
6791
+ },
6792
+ {
6793
+ type: "error",
6794
+ name: "AuthorizationExpired",
6795
+ inputs: [],
6796
+ },
6797
+ {
6798
+ type: "error",
6799
+ name: "InconsistentLoanToken",
6800
+ inputs: [],
6801
+ },
6802
+ {
6803
+ type: "error",
6804
+ name: "InvalidNonce",
6805
+ inputs: [],
6806
+ },
6807
+ {
6808
+ type: "error",
6809
+ name: "InvalidSignature",
6810
+ inputs: [],
6811
+ },
6812
+ {
6813
+ type: "error",
6814
+ name: "NoCode",
6815
+ inputs: [],
6816
+ },
6817
+ {
6818
+ type: "error",
6819
+ name: "NotMidnight",
6820
+ inputs: [],
6821
+ },
6822
+ {
6823
+ type: "error",
6824
+ name: "NotOwner",
6825
+ inputs: [],
6826
+ },
6827
+ {
6828
+ type: "error",
6829
+ name: "NotOwnerBuyer",
6830
+ inputs: [],
6831
+ },
6832
+ {
6833
+ type: "error",
6834
+ name: "TransferReturnedFalse",
6835
+ inputs: [],
6836
+ },
6837
+ ];
@@ -67,7 +67,7 @@ export declare class MidnightApi {
67
67
  * @param params.request - Optional fetch options forwarded to this request.
68
68
  * @returns Paginated books mapped to SDK camelCase fields, with each book's price levels sorted best first (asks ascending tick, bids descending tick).
69
69
  * @throws {MidnightApiError} when the API returns a non-2xx response.
70
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned book's `market_id` does not match, or cannot be derived from, its own market params, or when a returned book falls outside the supplied `marketIds`, `chainIds`, `loanTokens`, `collateralTokens`, or `maturities` filters.
70
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope, cursor or price levels are malformed, when a returned book's `market_id` does not match, or cannot be derived from, its own market params, or when a returned book falls outside the supplied `marketIds`, `chainIds`, `loanTokens`, `collateralTokens`, or `maturities` filters.
71
71
  * @example
72
72
  * ```ts
73
73
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";
@@ -92,7 +92,7 @@ export declare class MidnightApi {
92
92
  * @param params.request - Optional fetch options forwarded to this request.
93
93
  * @returns Book snapshot mapped to SDK camelCase fields, with price levels sorted best first (asks ascending tick, bids descending tick).
94
94
  * @throws {MidnightApiError} when the API returns a non-2xx response.
95
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when the returned book's `market_id` does not match, or cannot be derived from, its own market params, or when it differs from the requested `marketId`.
95
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope or price levels are malformed, when the returned book's `market_id` does not match, or cannot be derived from, its own market params, or when it differs from the requested `marketId`.
96
96
  * @example
97
97
  * ```ts
98
98
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";
@@ -117,7 +117,7 @@ export declare class MidnightApi {
117
117
  * @param params.request - Optional fetch options forwarded to this request.
118
118
  * @returns Price levels mapped to SDK camelCase fields, sorted best first (asks ascending tick, bids descending tick).
119
119
  * @throws {MidnightApiError} when the API returns a non-2xx response.
120
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON.
120
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope or price levels are malformed.
121
121
  * @example
122
122
  * ```ts
123
123
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";
@@ -142,7 +142,7 @@ export declare class MidnightApi {
142
142
  * @param params.request - Optional fetch options forwarded to this request.
143
143
  * @returns ABI-ready take objects mapped from the API response.
144
144
  * @throws {MidnightApiError} when the API returns a non-2xx response.
145
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, or when its units exceed its offer `maxUnits`.
145
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope or takeable offers are malformed, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, or when its units exceed its offer `maxUnits`.
146
146
  * @example
147
147
  * ```ts
148
148
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";
@@ -168,6 +168,7 @@ export declare class MidnightApi {
168
168
  * @param params.slippage - Optional slippage percentage used to derive the guard. Mutually exclusive with `params.averageWorstPrice`.
169
169
  * @param params.taker - Account that will execute the take (the `taker` passed to Midnight `take`).
170
170
  * The API leaves out offers made by this account, since Midnight rejects self-takes.
171
+ * @param params.limit - Optional maximum number of offers the API walks to build the quote (1 to 10,000, API default 10,000).
171
172
  * @param params.settlementFee - Optional current WAD-scaled settlement fee used for local guard validation. Defaults to zero.
172
173
  * @param params.baseUrl - Optional Midnight API base URL override.
173
174
  * @param params.fetch - Optional fetch implementation override.
@@ -182,7 +183,7 @@ export declare class MidnightApi {
182
183
  * @throws {InvalidMidnightApiQuoteTargetError} when the runtime input does not set exactly one of `units` or `assets`.
183
184
  * @throws {NegativeValueError} when `settlementFee` is negative.
184
185
  * @throws {MidnightApiError} when the API returns a non-2xx response.
185
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when an offer's maker matches the requested `taker`, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
186
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope or quote aggregates are malformed, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when an offer's maker matches the requested `taker`, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
186
187
  * @throws {SettlementFeeExceedsPriceError} when a bid's settlement fee exceeds its offer price.
187
188
  * @example
188
189
  * ```ts
@@ -213,7 +214,7 @@ export declare class MidnightApi {
213
214
  * @param params.request - Optional fetch options forwarded to this request.
214
215
  * @returns Paginated ABI-ready take objects mapped from the API response.
215
216
  * @throws {MidnightApiError} when the API returns a non-2xx response.
216
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, or when its units exceed its offer `maxUnits`.
217
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope, cursor or takeable offers are malformed, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, or when its units exceed its offer `maxUnits`.
217
218
  * @example
218
219
  * ```ts
219
220
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";
@@ -332,7 +333,7 @@ export declare class MidnightApi {
332
333
  * @param params.cursor - Optional opaque pagination cursor from a previous response.
333
334
  * @returns Paginated books mapped to SDK camelCase fields, with each book's price levels sorted best first (asks ascending tick, bids descending tick).
334
335
  * @throws {MidnightApiError} when the API returns a non-2xx response.
335
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned book's `market_id` does not match, or cannot be derived from, its own market params, or when a returned book falls outside the supplied `marketIds`, `chainIds`, `loanTokens`, `collateralTokens`, or `maturities` filters.
336
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope, cursor or price levels are malformed, when a returned book's `market_id` does not match, or cannot be derived from, its own market params, or when a returned book falls outside the supplied `marketIds`, `chainIds`, `loanTokens`, `collateralTokens`, or `maturities` filters.
336
337
  * @example
337
338
  * ```ts
338
339
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";
@@ -352,7 +353,7 @@ export declare class MidnightApi {
352
353
  * @param params.depth - Optional maximum levels returned per side.
353
354
  * @returns Book snapshot mapped to SDK camelCase fields, with price levels sorted best first (asks ascending tick, bids descending tick).
354
355
  * @throws {MidnightApiError} when the API returns a non-2xx response.
355
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when the returned book's `market_id` does not match, or cannot be derived from, its own market params, or when it differs from the requested `marketId`.
356
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope or price levels are malformed, when the returned book's `market_id` does not match, or cannot be derived from, its own market params, or when it differs from the requested `marketId`.
356
357
  * @example
357
358
  * ```ts
358
359
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";
@@ -375,7 +376,7 @@ export declare class MidnightApi {
375
376
  * @param params.depth - Optional maximum levels returned.
376
377
  * @returns Price levels mapped to SDK camelCase fields, sorted best first (asks ascending tick, bids descending tick).
377
378
  * @throws {MidnightApiError} when the API returns a non-2xx response.
378
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON.
379
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope or price levels are malformed.
379
380
  * @example
380
381
  * ```ts
381
382
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";
@@ -398,7 +399,7 @@ export declare class MidnightApi {
398
399
  * @param params.side - Book side to query.
399
400
  * @returns ABI-ready take objects mapped from the API response.
400
401
  * @throws {MidnightApiError} when the API returns a non-2xx response.
401
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, or when its units exceed its offer `maxUnits`.
402
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope or takeable offers are malformed, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, or when its units exceed its offer `maxUnits`.
402
403
  * @example
403
404
  * ```ts
404
405
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";
@@ -425,6 +426,7 @@ export declare class MidnightApi {
425
426
  * @param params.slippage - Optional slippage percentage used to derive the guard. Mutually exclusive with `params.averageWorstPrice`.
426
427
  * @param params.taker - Account that will execute the take (the `taker` passed to Midnight `take`).
427
428
  * The API leaves out offers made by this account, since Midnight rejects self-takes.
429
+ * @param params.limit - Optional maximum number of offers the API walks to build the quote (1 to 10,000, API default 10,000).
428
430
  * @param params.settlementFee - Optional current WAD-scaled settlement fee used for local guard validation. Defaults to zero.
429
431
  * @returns Quote and ABI-ready take caps. `averageWorstPrice` equals the caller's guard when provided,
430
432
  * otherwise the API's guard. Offers are returned as the API sends them. An `asks` quote by
@@ -436,7 +438,7 @@ export declare class MidnightApi {
436
438
  * @throws {InvalidMidnightApiQuoteTargetError} when the runtime input does not set exactly one of `units` or `assets`.
437
439
  * @throws {NegativeValueError} when `settlementFee` is negative.
438
440
  * @throws {MidnightApiError} when the API returns a non-2xx response.
439
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when an offer's maker matches the requested `taker`, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
441
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope or quote aggregates are malformed, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when an offer's maker matches the requested `taker`, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, when its units exceed its offer `maxUnits`, or when the returned offers imply a rounded aggregate settlement price outside the effective average-worst-price guard.
440
442
  * @throws {SettlementFeeExceedsPriceError} when a bid's settlement fee exceeds its offer price.
441
443
  * @example
442
444
  * ```ts
@@ -464,7 +466,7 @@ export declare class MidnightApi {
464
466
  * @param params.cursor - Optional opaque pagination cursor from a previous response.
465
467
  * @returns Paginated ABI-ready take objects mapped from the API response.
466
468
  * @throws {MidnightApiError} when the API returns a non-2xx response.
467
- * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, or when its units exceed its offer `maxUnits`.
469
+ * @throws {InvalidMidnightApiResponseError} when the API success response is not JSON or its envelope, cursor or takeable offers are malformed, when a returned offer cannot be mapped (malformed numeric or hex fields), when its `market_id` does not match, or cannot be derived from, its embedded market, when it falls outside the requested filters, when its `receiverIfMakerIsSeller` is not a well-formed address or is the zero address on a sell offer, when its caps or buy-side receiver are not executable, or when its units exceed its offer `maxUnits`.
468
470
  * @example
469
471
  * ```ts
470
472
  * import { MidnightApi } from "@morpho-org/midnight-sdk/api";