@morpho-dev/router 0.0.15 → 0.0.16
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.
- package/dist/index.browser.d.cts +21 -17
- package/dist/index.browser.d.ts +21 -17
- package/dist/index.browser.js +24 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +24 -2
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +43 -24
- package/dist/index.node.d.ts +43 -24
- package/dist/index.node.js +35 -7
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +36 -8
- package/dist/index.node.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.browser.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _morpho_dev_mempool from '@morpho-dev/mempool';
|
|
2
|
+
import { Compute, Offer, Errors, Format } from '@morpho-dev/mempool';
|
|
2
3
|
export * from '@morpho-dev/mempool';
|
|
3
4
|
import * as viem from 'viem';
|
|
4
5
|
import { Address, PublicClient } from 'viem';
|
|
@@ -7,10 +8,6 @@ import * as zod_v4_core from 'zod/v4/core';
|
|
|
7
8
|
import * as zod_v4 from 'zod/v4';
|
|
8
9
|
import { z, ZodError } from 'zod/v4';
|
|
9
10
|
|
|
10
|
-
type Compute<type> = {
|
|
11
|
-
[key in keyof type]: type[key];
|
|
12
|
-
} & unknown;
|
|
13
|
-
|
|
14
11
|
declare const chainNames: readonly ["ethereum", "base"];
|
|
15
12
|
type ChainName = (typeof chainNames)[number];
|
|
16
13
|
declare const ChainId: {
|
|
@@ -55,7 +52,7 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
55
52
|
offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
|
|
56
53
|
assets: zod_v4.ZodBigInt;
|
|
57
54
|
rate: zod_v4.ZodBigInt;
|
|
58
|
-
maturity: zod_v4.ZodNumber
|
|
55
|
+
maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
|
|
59
56
|
expiry: zod_v4.ZodNumber;
|
|
60
57
|
start: zod_v4.ZodNumber;
|
|
61
58
|
nonce: zod_v4.ZodBigInt;
|
|
@@ -132,6 +129,13 @@ declare namespace RouterOffer$1 {
|
|
|
132
129
|
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_from as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
133
130
|
}
|
|
134
131
|
|
|
132
|
+
type OfferResponse = {
|
|
133
|
+
offer: Offer.Offer;
|
|
134
|
+
consumed: bigint;
|
|
135
|
+
status: OfferStatus;
|
|
136
|
+
metadata?: OfferMetadata;
|
|
137
|
+
};
|
|
138
|
+
|
|
135
139
|
type GetParameters = {
|
|
136
140
|
/** Filter by multiple creator addresses (comma-separated) */
|
|
137
141
|
creators?: string[];
|
|
@@ -221,11 +225,11 @@ type RouterClientConfig = {
|
|
|
221
225
|
type Client = Compute<RouterClientConfig & {
|
|
222
226
|
get: (parameters: GetParameters) => Promise<{
|
|
223
227
|
cursor: string | null;
|
|
224
|
-
offers:
|
|
228
|
+
offers: OfferResponse[];
|
|
225
229
|
}>;
|
|
226
230
|
match: (parameters: MatchParameters) => Promise<{
|
|
227
231
|
cursor: string | null;
|
|
228
|
-
offers:
|
|
232
|
+
offers: OfferResponse[];
|
|
229
233
|
}>;
|
|
230
234
|
}>;
|
|
231
235
|
declare function connect(opts?: {
|
|
@@ -241,7 +245,7 @@ declare namespace connect {
|
|
|
241
245
|
*/
|
|
242
246
|
declare function get(config: RouterClientConfig, parameters: GetParameters): Promise<{
|
|
243
247
|
cursor: string | null;
|
|
244
|
-
offers:
|
|
248
|
+
offers: OfferResponse[];
|
|
245
249
|
}>;
|
|
246
250
|
declare namespace get {
|
|
247
251
|
type ErrorType = GetApiErrorType;
|
|
@@ -252,7 +256,7 @@ declare namespace get {
|
|
|
252
256
|
*/
|
|
253
257
|
declare function match(config: RouterClientConfig, parameters: MatchParameters): Promise<{
|
|
254
258
|
cursor: string | null;
|
|
255
|
-
offers:
|
|
259
|
+
offers: OfferResponse[];
|
|
256
260
|
}>;
|
|
257
261
|
declare namespace match {
|
|
258
262
|
type ErrorType = GetApiErrorType;
|
|
@@ -433,7 +437,7 @@ declare function morpho(parameters: {
|
|
|
433
437
|
readonly offering: Address;
|
|
434
438
|
readonly assets: bigint;
|
|
435
439
|
readonly rate: bigint;
|
|
436
|
-
readonly maturity: number
|
|
440
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
437
441
|
readonly expiry: number;
|
|
438
442
|
readonly nonce: bigint;
|
|
439
443
|
readonly buy: boolean;
|
|
@@ -457,7 +461,7 @@ declare function morpho(parameters: {
|
|
|
457
461
|
readonly offering: Address;
|
|
458
462
|
readonly assets: bigint;
|
|
459
463
|
readonly rate: bigint;
|
|
460
|
-
readonly maturity: number
|
|
464
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
461
465
|
readonly expiry: number;
|
|
462
466
|
readonly nonce: bigint;
|
|
463
467
|
readonly buy: boolean;
|
|
@@ -481,7 +485,7 @@ declare function morpho(parameters: {
|
|
|
481
485
|
readonly offering: Address;
|
|
482
486
|
readonly assets: bigint;
|
|
483
487
|
readonly rate: bigint;
|
|
484
|
-
readonly maturity: number
|
|
488
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
485
489
|
readonly expiry: number;
|
|
486
490
|
readonly nonce: bigint;
|
|
487
491
|
readonly buy: boolean;
|
|
@@ -505,7 +509,7 @@ declare function morpho(parameters: {
|
|
|
505
509
|
readonly offering: Address;
|
|
506
510
|
readonly assets: bigint;
|
|
507
511
|
readonly rate: bigint;
|
|
508
|
-
readonly maturity: number
|
|
512
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
509
513
|
readonly expiry: number;
|
|
510
514
|
readonly nonce: bigint;
|
|
511
515
|
readonly buy: boolean;
|
|
@@ -529,7 +533,7 @@ declare function morpho(parameters: {
|
|
|
529
533
|
readonly offering: Address;
|
|
530
534
|
readonly assets: bigint;
|
|
531
535
|
readonly rate: bigint;
|
|
532
|
-
readonly maturity: number
|
|
536
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
533
537
|
readonly expiry: number;
|
|
534
538
|
readonly nonce: bigint;
|
|
535
539
|
readonly buy: boolean;
|
|
@@ -553,7 +557,7 @@ declare function morpho(parameters: {
|
|
|
553
557
|
readonly offering: Address;
|
|
554
558
|
readonly assets: bigint;
|
|
555
559
|
readonly rate: bigint;
|
|
556
|
-
readonly maturity: number
|
|
560
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
557
561
|
readonly expiry: number;
|
|
558
562
|
readonly nonce: bigint;
|
|
559
563
|
readonly buy: boolean;
|
|
@@ -628,4 +632,4 @@ declare namespace Validation {
|
|
|
628
632
|
export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
|
|
629
633
|
}
|
|
630
634
|
|
|
631
|
-
export { Chain$1 as Chain, type
|
|
635
|
+
export { Chain$1 as Chain, type Cursor, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, decodeCursor, encodeCursor, poll, validateCursor, wait };
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _morpho_dev_mempool from '@morpho-dev/mempool';
|
|
2
|
+
import { Compute, Offer, Errors, Format } from '@morpho-dev/mempool';
|
|
2
3
|
export * from '@morpho-dev/mempool';
|
|
3
4
|
import * as viem from 'viem';
|
|
4
5
|
import { Address, PublicClient } from 'viem';
|
|
@@ -7,10 +8,6 @@ import * as zod_v4_core from 'zod/v4/core';
|
|
|
7
8
|
import * as zod_v4 from 'zod/v4';
|
|
8
9
|
import { z, ZodError } from 'zod/v4';
|
|
9
10
|
|
|
10
|
-
type Compute<type> = {
|
|
11
|
-
[key in keyof type]: type[key];
|
|
12
|
-
} & unknown;
|
|
13
|
-
|
|
14
11
|
declare const chainNames: readonly ["ethereum", "base"];
|
|
15
12
|
type ChainName = (typeof chainNames)[number];
|
|
16
13
|
declare const ChainId: {
|
|
@@ -55,7 +52,7 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
55
52
|
offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
|
|
56
53
|
assets: zod_v4.ZodBigInt;
|
|
57
54
|
rate: zod_v4.ZodBigInt;
|
|
58
|
-
maturity: zod_v4.ZodNumber
|
|
55
|
+
maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
|
|
59
56
|
expiry: zod_v4.ZodNumber;
|
|
60
57
|
start: zod_v4.ZodNumber;
|
|
61
58
|
nonce: zod_v4.ZodBigInt;
|
|
@@ -132,6 +129,13 @@ declare namespace RouterOffer$1 {
|
|
|
132
129
|
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_from as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
133
130
|
}
|
|
134
131
|
|
|
132
|
+
type OfferResponse = {
|
|
133
|
+
offer: Offer.Offer;
|
|
134
|
+
consumed: bigint;
|
|
135
|
+
status: OfferStatus;
|
|
136
|
+
metadata?: OfferMetadata;
|
|
137
|
+
};
|
|
138
|
+
|
|
135
139
|
type GetParameters = {
|
|
136
140
|
/** Filter by multiple creator addresses (comma-separated) */
|
|
137
141
|
creators?: string[];
|
|
@@ -221,11 +225,11 @@ type RouterClientConfig = {
|
|
|
221
225
|
type Client = Compute<RouterClientConfig & {
|
|
222
226
|
get: (parameters: GetParameters) => Promise<{
|
|
223
227
|
cursor: string | null;
|
|
224
|
-
offers:
|
|
228
|
+
offers: OfferResponse[];
|
|
225
229
|
}>;
|
|
226
230
|
match: (parameters: MatchParameters) => Promise<{
|
|
227
231
|
cursor: string | null;
|
|
228
|
-
offers:
|
|
232
|
+
offers: OfferResponse[];
|
|
229
233
|
}>;
|
|
230
234
|
}>;
|
|
231
235
|
declare function connect(opts?: {
|
|
@@ -241,7 +245,7 @@ declare namespace connect {
|
|
|
241
245
|
*/
|
|
242
246
|
declare function get(config: RouterClientConfig, parameters: GetParameters): Promise<{
|
|
243
247
|
cursor: string | null;
|
|
244
|
-
offers:
|
|
248
|
+
offers: OfferResponse[];
|
|
245
249
|
}>;
|
|
246
250
|
declare namespace get {
|
|
247
251
|
type ErrorType = GetApiErrorType;
|
|
@@ -252,7 +256,7 @@ declare namespace get {
|
|
|
252
256
|
*/
|
|
253
257
|
declare function match(config: RouterClientConfig, parameters: MatchParameters): Promise<{
|
|
254
258
|
cursor: string | null;
|
|
255
|
-
offers:
|
|
259
|
+
offers: OfferResponse[];
|
|
256
260
|
}>;
|
|
257
261
|
declare namespace match {
|
|
258
262
|
type ErrorType = GetApiErrorType;
|
|
@@ -433,7 +437,7 @@ declare function morpho(parameters: {
|
|
|
433
437
|
readonly offering: Address;
|
|
434
438
|
readonly assets: bigint;
|
|
435
439
|
readonly rate: bigint;
|
|
436
|
-
readonly maturity: number
|
|
440
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
437
441
|
readonly expiry: number;
|
|
438
442
|
readonly nonce: bigint;
|
|
439
443
|
readonly buy: boolean;
|
|
@@ -457,7 +461,7 @@ declare function morpho(parameters: {
|
|
|
457
461
|
readonly offering: Address;
|
|
458
462
|
readonly assets: bigint;
|
|
459
463
|
readonly rate: bigint;
|
|
460
|
-
readonly maturity: number
|
|
464
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
461
465
|
readonly expiry: number;
|
|
462
466
|
readonly nonce: bigint;
|
|
463
467
|
readonly buy: boolean;
|
|
@@ -481,7 +485,7 @@ declare function morpho(parameters: {
|
|
|
481
485
|
readonly offering: Address;
|
|
482
486
|
readonly assets: bigint;
|
|
483
487
|
readonly rate: bigint;
|
|
484
|
-
readonly maturity: number
|
|
488
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
485
489
|
readonly expiry: number;
|
|
486
490
|
readonly nonce: bigint;
|
|
487
491
|
readonly buy: boolean;
|
|
@@ -505,7 +509,7 @@ declare function morpho(parameters: {
|
|
|
505
509
|
readonly offering: Address;
|
|
506
510
|
readonly assets: bigint;
|
|
507
511
|
readonly rate: bigint;
|
|
508
|
-
readonly maturity: number
|
|
512
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
509
513
|
readonly expiry: number;
|
|
510
514
|
readonly nonce: bigint;
|
|
511
515
|
readonly buy: boolean;
|
|
@@ -529,7 +533,7 @@ declare function morpho(parameters: {
|
|
|
529
533
|
readonly offering: Address;
|
|
530
534
|
readonly assets: bigint;
|
|
531
535
|
readonly rate: bigint;
|
|
532
|
-
readonly maturity: number
|
|
536
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
533
537
|
readonly expiry: number;
|
|
534
538
|
readonly nonce: bigint;
|
|
535
539
|
readonly buy: boolean;
|
|
@@ -553,7 +557,7 @@ declare function morpho(parameters: {
|
|
|
553
557
|
readonly offering: Address;
|
|
554
558
|
readonly assets: bigint;
|
|
555
559
|
readonly rate: bigint;
|
|
556
|
-
readonly maturity: number
|
|
560
|
+
readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
|
|
557
561
|
readonly expiry: number;
|
|
558
562
|
readonly nonce: bigint;
|
|
559
563
|
readonly buy: boolean;
|
|
@@ -628,4 +632,4 @@ declare namespace Validation {
|
|
|
628
632
|
export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
|
|
629
633
|
}
|
|
630
634
|
|
|
631
|
-
export { Chain$1 as Chain, type
|
|
635
|
+
export { Chain$1 as Chain, type Cursor, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, decodeCursor, encodeCursor, poll, validateCursor, wait };
|
package/dist/index.browser.js
CHANGED
|
@@ -720,6 +720,26 @@ zodOpenapi.createDocument({
|
|
|
720
720
|
paths
|
|
721
721
|
});
|
|
722
722
|
|
|
723
|
+
// src/core/apiSchema/utils.ts
|
|
724
|
+
function toResponse(routerOffer) {
|
|
725
|
+
const { consumed, status, metadata, ...offer } = routerOffer;
|
|
726
|
+
return {
|
|
727
|
+
offer,
|
|
728
|
+
consumed,
|
|
729
|
+
status,
|
|
730
|
+
metadata
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
function fromResponse(offerResponse) {
|
|
734
|
+
const { offer, consumed, status, metadata } = offerResponse;
|
|
735
|
+
return {
|
|
736
|
+
...offer,
|
|
737
|
+
consumed,
|
|
738
|
+
status,
|
|
739
|
+
metadata
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
|
|
723
743
|
// src/core/Client.ts
|
|
724
744
|
function connect(opts) {
|
|
725
745
|
const u = new URL(opts?.url || "https://router.morpho.dev");
|
|
@@ -821,9 +841,10 @@ async function get(config, parameters) {
|
|
|
821
841
|
url.searchParams.set("limit", parameters.limit.toString());
|
|
822
842
|
}
|
|
823
843
|
const { cursor: returnedCursor, data: offers } = await getApi(config, url);
|
|
844
|
+
const routerOffers = offers.map(mempool.Format.fromSnakeCase).map(fromResponse);
|
|
824
845
|
return {
|
|
825
846
|
cursor: returnedCursor,
|
|
826
|
-
offers:
|
|
847
|
+
offers: routerOffers.map(from).map(toResponse)
|
|
827
848
|
};
|
|
828
849
|
}
|
|
829
850
|
async function match(config, parameters) {
|
|
@@ -862,9 +883,10 @@ async function match(config, parameters) {
|
|
|
862
883
|
url.searchParams.set("limit", parameters.limit.toString());
|
|
863
884
|
}
|
|
864
885
|
const { cursor: returnedCursor, data: offers } = await getApi(config, url);
|
|
886
|
+
const routerOffers = offers.map(mempool.Format.fromSnakeCase).map(fromResponse);
|
|
865
887
|
return {
|
|
866
888
|
cursor: returnedCursor,
|
|
867
|
-
offers:
|
|
889
|
+
offers: routerOffers.map(from).map(toResponse)
|
|
868
890
|
};
|
|
869
891
|
}
|
|
870
892
|
async function getApi(config, url) {
|