@morpho-dev/router 0.0.25 → 0.0.27
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 +61 -13
- package/dist/index.browser.d.ts +61 -13
- package/dist/index.browser.js +64 -86
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +65 -87
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +69 -21
- package/dist/index.node.d.ts +69 -21
- package/dist/index.node.js +64 -86
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +65 -87
- package/dist/index.node.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.browser.d.cts
CHANGED
|
@@ -29,6 +29,7 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
|
29
29
|
};
|
|
30
30
|
}>;
|
|
31
31
|
declare function getChain(chainId: ChainId): Chain | undefined;
|
|
32
|
+
declare const getWhitelistedChains: () => Chain[];
|
|
32
33
|
declare const chains: Record<ChainName, Chain>;
|
|
33
34
|
|
|
34
35
|
type Chain$1_Chain = Chain;
|
|
@@ -38,8 +39,9 @@ declare const Chain$1_chainIds: typeof chainIds;
|
|
|
38
39
|
declare const Chain$1_chainNames: typeof chainNames;
|
|
39
40
|
declare const Chain$1_chains: typeof chains;
|
|
40
41
|
declare const Chain$1_getChain: typeof getChain;
|
|
42
|
+
declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
|
|
41
43
|
declare namespace Chain$1 {
|
|
42
|
-
export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain };
|
|
44
|
+
export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain, Chain$1_getWhitelistedChains as getWhitelistedChains };
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
|
|
@@ -52,6 +54,13 @@ type RouterOffer = Offer.Offer & {
|
|
|
52
54
|
status: OfferStatus;
|
|
53
55
|
metadata?: OfferMetadata;
|
|
54
56
|
};
|
|
57
|
+
type OfferConsumed = {
|
|
58
|
+
id: string;
|
|
59
|
+
chainId: bigint;
|
|
60
|
+
offering: Address;
|
|
61
|
+
nonce: bigint;
|
|
62
|
+
amount: bigint;
|
|
63
|
+
};
|
|
55
64
|
declare const RouterOfferSchema: (parameters?: {
|
|
56
65
|
omitHash?: boolean;
|
|
57
66
|
}) => zod_v4.ZodObject<{
|
|
@@ -88,6 +97,30 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
88
97
|
issue: z.ZodString;
|
|
89
98
|
}, z.core.$strip>>;
|
|
90
99
|
}, zod_v4_core.$strip>;
|
|
100
|
+
/**
|
|
101
|
+
* ABI for the Consumed event emitted by the terms contract.
|
|
102
|
+
*/
|
|
103
|
+
declare const consumedEvent: {
|
|
104
|
+
readonly type: "event";
|
|
105
|
+
readonly name: "Consumed";
|
|
106
|
+
readonly inputs: readonly [{
|
|
107
|
+
readonly name: "user";
|
|
108
|
+
readonly type: "address";
|
|
109
|
+
readonly indexed: true;
|
|
110
|
+
readonly internalType: "address";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "nonce";
|
|
113
|
+
readonly type: "uint256";
|
|
114
|
+
readonly indexed: true;
|
|
115
|
+
readonly internalType: "uint256";
|
|
116
|
+
}, {
|
|
117
|
+
readonly name: "amount";
|
|
118
|
+
readonly type: "uint256";
|
|
119
|
+
readonly indexed: false;
|
|
120
|
+
readonly internalType: "uint256";
|
|
121
|
+
}];
|
|
122
|
+
readonly anonymous: false;
|
|
123
|
+
};
|
|
91
124
|
/**
|
|
92
125
|
* Creates a router offer from a plain object.
|
|
93
126
|
* @throws {InvalidRouterOfferError} If the router offer is invalid.
|
|
@@ -115,6 +148,15 @@ declare namespace fromSnakeCase {
|
|
|
115
148
|
*/
|
|
116
149
|
declare function toSnakeCase(offer: RouterOffer): Format.Snake<RouterOffer>;
|
|
117
150
|
declare function random(): RouterOffer;
|
|
151
|
+
declare function fromConsumedLog(parameters: {
|
|
152
|
+
blockNumber: bigint;
|
|
153
|
+
logIndex: number;
|
|
154
|
+
chainId: number;
|
|
155
|
+
transactionHash: Hex;
|
|
156
|
+
user: Address;
|
|
157
|
+
nonce: bigint;
|
|
158
|
+
amount: bigint;
|
|
159
|
+
}): OfferConsumed;
|
|
118
160
|
declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error> {
|
|
119
161
|
readonly name = "RouterOffer.InvalidRouterOfferError";
|
|
120
162
|
constructor(error: ZodError | Error);
|
|
@@ -122,16 +164,19 @@ declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error>
|
|
|
122
164
|
|
|
123
165
|
type RouterOffer$1_InvalidRouterOfferError = InvalidRouterOfferError;
|
|
124
166
|
declare const RouterOffer$1_InvalidRouterOfferError: typeof InvalidRouterOfferError;
|
|
167
|
+
type RouterOffer$1_OfferConsumed = OfferConsumed;
|
|
125
168
|
type RouterOffer$1_OfferMetadata = OfferMetadata;
|
|
126
169
|
type RouterOffer$1_OfferStatus = OfferStatus;
|
|
127
170
|
declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
|
|
128
171
|
type RouterOffer$1_RouterOffer = RouterOffer;
|
|
129
172
|
declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
|
|
173
|
+
declare const RouterOffer$1_consumedEvent: typeof consumedEvent;
|
|
174
|
+
declare const RouterOffer$1_fromConsumedLog: typeof fromConsumedLog;
|
|
130
175
|
declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
|
|
131
176
|
declare const RouterOffer$1_random: typeof random;
|
|
132
177
|
declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
|
|
133
178
|
declare namespace RouterOffer$1 {
|
|
134
|
-
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, from$1 as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
179
|
+
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferConsumed as OfferConsumed, 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_consumedEvent as consumedEvent, from$1 as from, RouterOffer$1_fromConsumedLog as fromConsumedLog, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
135
180
|
}
|
|
136
181
|
|
|
137
182
|
type OfferResponse = {
|
|
@@ -348,6 +393,7 @@ type OfferStore = {
|
|
|
348
393
|
metadata?: OfferMetadata;
|
|
349
394
|
}) => Promise<void>;
|
|
350
395
|
updateConsumedAmount: (parameters: {
|
|
396
|
+
id: string;
|
|
351
397
|
chainId: Offer.Offer["chainId"];
|
|
352
398
|
offering: Offer.Offer["offering"];
|
|
353
399
|
nonce: Offer.Offer["nonce"];
|
|
@@ -356,13 +402,13 @@ type OfferStore = {
|
|
|
356
402
|
/** Persist latest indexing progress for a chain and event type. */
|
|
357
403
|
saveLatestBlockNumberProcessed: (parameters: {
|
|
358
404
|
chainId: Offer.Offer["chainId"];
|
|
359
|
-
eventType: "offer_created" | "
|
|
405
|
+
eventType: "offer_created" | "offer_consumed";
|
|
360
406
|
latestBlockNumber: number;
|
|
361
407
|
}) => Promise<void>;
|
|
362
408
|
/** Retrieve latest indexing progress for a chain and event type. */
|
|
363
409
|
getLatestBlockNumberProcessed: (parameters: {
|
|
364
410
|
chainId: Offer.Offer["chainId"];
|
|
365
|
-
eventType: "offer_created" | "
|
|
411
|
+
eventType: "offer_created" | "offer_consumed";
|
|
366
412
|
}) => Promise<{
|
|
367
413
|
latestBlockNumber: number;
|
|
368
414
|
} | null>;
|
|
@@ -378,8 +424,8 @@ type GetOffersFilters = {
|
|
|
378
424
|
maxAmount?: bigint;
|
|
379
425
|
minRate?: bigint;
|
|
380
426
|
maxRate?: bigint;
|
|
381
|
-
minMaturity?:
|
|
382
|
-
maxMaturity?:
|
|
427
|
+
minMaturity?: number;
|
|
428
|
+
maxMaturity?: number;
|
|
383
429
|
minExpiry?: number;
|
|
384
430
|
maxExpiry?: number;
|
|
385
431
|
collateralAssets?: string[];
|
|
@@ -389,8 +435,8 @@ type GetOffersFilters = {
|
|
|
389
435
|
oracle?: string;
|
|
390
436
|
lltv?: LLTV.LLTV;
|
|
391
437
|
}>;
|
|
392
|
-
minLltv?:
|
|
393
|
-
maxLltv?:
|
|
438
|
+
minLltv?: number;
|
|
439
|
+
maxLltv?: number;
|
|
394
440
|
sortBy?: "rate" | "maturity" | "expiry" | "amount";
|
|
395
441
|
sortOrder?: "asc" | "desc";
|
|
396
442
|
cursor?: string;
|
|
@@ -405,9 +451,9 @@ type FindMatchingOffersParams = {
|
|
|
405
451
|
oracle: string;
|
|
406
452
|
lltv: LLTV.LLTV;
|
|
407
453
|
}>;
|
|
408
|
-
maturity?:
|
|
409
|
-
minMaturity?:
|
|
410
|
-
maxMaturity?:
|
|
454
|
+
maturity?: number;
|
|
455
|
+
minMaturity?: number;
|
|
456
|
+
maxMaturity?: number;
|
|
411
457
|
loanToken?: string;
|
|
412
458
|
creator?: string;
|
|
413
459
|
/** Filter by offer status; if omitted defaults to ["valid"] */
|
|
@@ -438,13 +484,15 @@ declare namespace index$1 {
|
|
|
438
484
|
export { type index$1_FindMatchingOffersParams as FindMatchingOffersParams, type index$1_GetAllParams as GetAllParams, type index$1_GetOffersFilters as GetOffersFilters, type index$1_OfferStore as OfferStore, index$1_memory as memory };
|
|
439
485
|
}
|
|
440
486
|
|
|
441
|
-
declare const types: readonly ["offer_created", "
|
|
487
|
+
declare const types: readonly ["offer_created", "offer_consumed", "offer_validation"];
|
|
442
488
|
type Type = (typeof types)[number];
|
|
443
489
|
type BaseEvent<type extends Type = Type> = {
|
|
444
490
|
readonly id: string;
|
|
445
491
|
readonly type: type;
|
|
446
492
|
};
|
|
447
|
-
type RouterEvent<type extends Type = Type> = type extends "
|
|
493
|
+
type RouterEvent<type extends Type = Type> = type extends "offer_consumed" ? Compute<BaseEvent<type> & {
|
|
494
|
+
readonly offerConsumed: OfferConsumed;
|
|
495
|
+
}> : type extends "offer_created" | "offer_validation" ? Compute<BaseEvent<type> & {
|
|
448
496
|
readonly offer: Offer.Offer;
|
|
449
497
|
}> : never;
|
|
450
498
|
/**
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
|
29
29
|
};
|
|
30
30
|
}>;
|
|
31
31
|
declare function getChain(chainId: ChainId): Chain | undefined;
|
|
32
|
+
declare const getWhitelistedChains: () => Chain[];
|
|
32
33
|
declare const chains: Record<ChainName, Chain>;
|
|
33
34
|
|
|
34
35
|
type Chain$1_Chain = Chain;
|
|
@@ -38,8 +39,9 @@ declare const Chain$1_chainIds: typeof chainIds;
|
|
|
38
39
|
declare const Chain$1_chainNames: typeof chainNames;
|
|
39
40
|
declare const Chain$1_chains: typeof chains;
|
|
40
41
|
declare const Chain$1_getChain: typeof getChain;
|
|
42
|
+
declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
|
|
41
43
|
declare namespace Chain$1 {
|
|
42
|
-
export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain };
|
|
44
|
+
export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain, Chain$1_getWhitelistedChains as getWhitelistedChains };
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
|
|
@@ -52,6 +54,13 @@ type RouterOffer = Offer.Offer & {
|
|
|
52
54
|
status: OfferStatus;
|
|
53
55
|
metadata?: OfferMetadata;
|
|
54
56
|
};
|
|
57
|
+
type OfferConsumed = {
|
|
58
|
+
id: string;
|
|
59
|
+
chainId: bigint;
|
|
60
|
+
offering: Address;
|
|
61
|
+
nonce: bigint;
|
|
62
|
+
amount: bigint;
|
|
63
|
+
};
|
|
55
64
|
declare const RouterOfferSchema: (parameters?: {
|
|
56
65
|
omitHash?: boolean;
|
|
57
66
|
}) => zod_v4.ZodObject<{
|
|
@@ -88,6 +97,30 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
88
97
|
issue: z.ZodString;
|
|
89
98
|
}, z.core.$strip>>;
|
|
90
99
|
}, zod_v4_core.$strip>;
|
|
100
|
+
/**
|
|
101
|
+
* ABI for the Consumed event emitted by the terms contract.
|
|
102
|
+
*/
|
|
103
|
+
declare const consumedEvent: {
|
|
104
|
+
readonly type: "event";
|
|
105
|
+
readonly name: "Consumed";
|
|
106
|
+
readonly inputs: readonly [{
|
|
107
|
+
readonly name: "user";
|
|
108
|
+
readonly type: "address";
|
|
109
|
+
readonly indexed: true;
|
|
110
|
+
readonly internalType: "address";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "nonce";
|
|
113
|
+
readonly type: "uint256";
|
|
114
|
+
readonly indexed: true;
|
|
115
|
+
readonly internalType: "uint256";
|
|
116
|
+
}, {
|
|
117
|
+
readonly name: "amount";
|
|
118
|
+
readonly type: "uint256";
|
|
119
|
+
readonly indexed: false;
|
|
120
|
+
readonly internalType: "uint256";
|
|
121
|
+
}];
|
|
122
|
+
readonly anonymous: false;
|
|
123
|
+
};
|
|
91
124
|
/**
|
|
92
125
|
* Creates a router offer from a plain object.
|
|
93
126
|
* @throws {InvalidRouterOfferError} If the router offer is invalid.
|
|
@@ -115,6 +148,15 @@ declare namespace fromSnakeCase {
|
|
|
115
148
|
*/
|
|
116
149
|
declare function toSnakeCase(offer: RouterOffer): Format.Snake<RouterOffer>;
|
|
117
150
|
declare function random(): RouterOffer;
|
|
151
|
+
declare function fromConsumedLog(parameters: {
|
|
152
|
+
blockNumber: bigint;
|
|
153
|
+
logIndex: number;
|
|
154
|
+
chainId: number;
|
|
155
|
+
transactionHash: Hex;
|
|
156
|
+
user: Address;
|
|
157
|
+
nonce: bigint;
|
|
158
|
+
amount: bigint;
|
|
159
|
+
}): OfferConsumed;
|
|
118
160
|
declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error> {
|
|
119
161
|
readonly name = "RouterOffer.InvalidRouterOfferError";
|
|
120
162
|
constructor(error: ZodError | Error);
|
|
@@ -122,16 +164,19 @@ declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error>
|
|
|
122
164
|
|
|
123
165
|
type RouterOffer$1_InvalidRouterOfferError = InvalidRouterOfferError;
|
|
124
166
|
declare const RouterOffer$1_InvalidRouterOfferError: typeof InvalidRouterOfferError;
|
|
167
|
+
type RouterOffer$1_OfferConsumed = OfferConsumed;
|
|
125
168
|
type RouterOffer$1_OfferMetadata = OfferMetadata;
|
|
126
169
|
type RouterOffer$1_OfferStatus = OfferStatus;
|
|
127
170
|
declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
|
|
128
171
|
type RouterOffer$1_RouterOffer = RouterOffer;
|
|
129
172
|
declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
|
|
173
|
+
declare const RouterOffer$1_consumedEvent: typeof consumedEvent;
|
|
174
|
+
declare const RouterOffer$1_fromConsumedLog: typeof fromConsumedLog;
|
|
130
175
|
declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
|
|
131
176
|
declare const RouterOffer$1_random: typeof random;
|
|
132
177
|
declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
|
|
133
178
|
declare namespace RouterOffer$1 {
|
|
134
|
-
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, from$1 as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
179
|
+
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferConsumed as OfferConsumed, 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_consumedEvent as consumedEvent, from$1 as from, RouterOffer$1_fromConsumedLog as fromConsumedLog, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
135
180
|
}
|
|
136
181
|
|
|
137
182
|
type OfferResponse = {
|
|
@@ -348,6 +393,7 @@ type OfferStore = {
|
|
|
348
393
|
metadata?: OfferMetadata;
|
|
349
394
|
}) => Promise<void>;
|
|
350
395
|
updateConsumedAmount: (parameters: {
|
|
396
|
+
id: string;
|
|
351
397
|
chainId: Offer.Offer["chainId"];
|
|
352
398
|
offering: Offer.Offer["offering"];
|
|
353
399
|
nonce: Offer.Offer["nonce"];
|
|
@@ -356,13 +402,13 @@ type OfferStore = {
|
|
|
356
402
|
/** Persist latest indexing progress for a chain and event type. */
|
|
357
403
|
saveLatestBlockNumberProcessed: (parameters: {
|
|
358
404
|
chainId: Offer.Offer["chainId"];
|
|
359
|
-
eventType: "offer_created" | "
|
|
405
|
+
eventType: "offer_created" | "offer_consumed";
|
|
360
406
|
latestBlockNumber: number;
|
|
361
407
|
}) => Promise<void>;
|
|
362
408
|
/** Retrieve latest indexing progress for a chain and event type. */
|
|
363
409
|
getLatestBlockNumberProcessed: (parameters: {
|
|
364
410
|
chainId: Offer.Offer["chainId"];
|
|
365
|
-
eventType: "offer_created" | "
|
|
411
|
+
eventType: "offer_created" | "offer_consumed";
|
|
366
412
|
}) => Promise<{
|
|
367
413
|
latestBlockNumber: number;
|
|
368
414
|
} | null>;
|
|
@@ -378,8 +424,8 @@ type GetOffersFilters = {
|
|
|
378
424
|
maxAmount?: bigint;
|
|
379
425
|
minRate?: bigint;
|
|
380
426
|
maxRate?: bigint;
|
|
381
|
-
minMaturity?:
|
|
382
|
-
maxMaturity?:
|
|
427
|
+
minMaturity?: number;
|
|
428
|
+
maxMaturity?: number;
|
|
383
429
|
minExpiry?: number;
|
|
384
430
|
maxExpiry?: number;
|
|
385
431
|
collateralAssets?: string[];
|
|
@@ -389,8 +435,8 @@ type GetOffersFilters = {
|
|
|
389
435
|
oracle?: string;
|
|
390
436
|
lltv?: LLTV.LLTV;
|
|
391
437
|
}>;
|
|
392
|
-
minLltv?:
|
|
393
|
-
maxLltv?:
|
|
438
|
+
minLltv?: number;
|
|
439
|
+
maxLltv?: number;
|
|
394
440
|
sortBy?: "rate" | "maturity" | "expiry" | "amount";
|
|
395
441
|
sortOrder?: "asc" | "desc";
|
|
396
442
|
cursor?: string;
|
|
@@ -405,9 +451,9 @@ type FindMatchingOffersParams = {
|
|
|
405
451
|
oracle: string;
|
|
406
452
|
lltv: LLTV.LLTV;
|
|
407
453
|
}>;
|
|
408
|
-
maturity?:
|
|
409
|
-
minMaturity?:
|
|
410
|
-
maxMaturity?:
|
|
454
|
+
maturity?: number;
|
|
455
|
+
minMaturity?: number;
|
|
456
|
+
maxMaturity?: number;
|
|
411
457
|
loanToken?: string;
|
|
412
458
|
creator?: string;
|
|
413
459
|
/** Filter by offer status; if omitted defaults to ["valid"] */
|
|
@@ -438,13 +484,15 @@ declare namespace index$1 {
|
|
|
438
484
|
export { type index$1_FindMatchingOffersParams as FindMatchingOffersParams, type index$1_GetAllParams as GetAllParams, type index$1_GetOffersFilters as GetOffersFilters, type index$1_OfferStore as OfferStore, index$1_memory as memory };
|
|
439
485
|
}
|
|
440
486
|
|
|
441
|
-
declare const types: readonly ["offer_created", "
|
|
487
|
+
declare const types: readonly ["offer_created", "offer_consumed", "offer_validation"];
|
|
442
488
|
type Type = (typeof types)[number];
|
|
443
489
|
type BaseEvent<type extends Type = Type> = {
|
|
444
490
|
readonly id: string;
|
|
445
491
|
readonly type: type;
|
|
446
492
|
};
|
|
447
|
-
type RouterEvent<type extends Type = Type> = type extends "
|
|
493
|
+
type RouterEvent<type extends Type = Type> = type extends "offer_consumed" ? Compute<BaseEvent<type> & {
|
|
494
|
+
readonly offerConsumed: OfferConsumed;
|
|
495
|
+
}> : type extends "offer_created" | "offer_validation" ? Compute<BaseEvent<type> & {
|
|
448
496
|
readonly offer: Offer.Offer;
|
|
449
497
|
}> : never;
|
|
450
498
|
/**
|
package/dist/index.browser.js
CHANGED
|
@@ -22,7 +22,8 @@ __export(Chain_exports, {
|
|
|
22
22
|
chainIds: () => chainIds,
|
|
23
23
|
chainNames: () => chainNames,
|
|
24
24
|
chains: () => chains,
|
|
25
|
-
getChain: () => getChain
|
|
25
|
+
getChain: () => getChain,
|
|
26
|
+
getWhitelistedChains: () => getWhitelistedChains
|
|
26
27
|
});
|
|
27
28
|
var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
28
29
|
var ChainId = {
|
|
@@ -39,6 +40,9 @@ function getChain(chainId) {
|
|
|
39
40
|
}
|
|
40
41
|
return chains[chainName];
|
|
41
42
|
}
|
|
43
|
+
var getWhitelistedChains = () => {
|
|
44
|
+
return [chains.ethereum, chains["ethereum-virtual-testnet"]];
|
|
45
|
+
};
|
|
42
46
|
var chains = {
|
|
43
47
|
ethereum: {
|
|
44
48
|
...chains$1.mainnet,
|
|
@@ -80,7 +84,8 @@ var chains = {
|
|
|
80
84
|
// DAI
|
|
81
85
|
].map((address) => address.toLowerCase())
|
|
82
86
|
),
|
|
83
|
-
morpho: "
|
|
87
|
+
morpho: "0x11a002d45db720ed47a80d2f3489cba5b833eaf5",
|
|
88
|
+
// @TODO: This is mock Consumed contract, update with Terms once stable
|
|
84
89
|
mempool: {
|
|
85
90
|
address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
|
|
86
91
|
deploymentBlock: 23223727,
|
|
@@ -108,7 +113,9 @@ __export(RouterOffer_exports, {
|
|
|
108
113
|
InvalidRouterOfferError: () => InvalidRouterOfferError,
|
|
109
114
|
OfferStatusValues: () => OfferStatusValues,
|
|
110
115
|
RouterOfferSchema: () => RouterOfferSchema,
|
|
116
|
+
consumedEvent: () => consumedEvent,
|
|
111
117
|
from: () => from,
|
|
118
|
+
fromConsumedLog: () => fromConsumedLog,
|
|
112
119
|
fromSnakeCase: () => fromSnakeCase,
|
|
113
120
|
random: () => random,
|
|
114
121
|
toSnakeCase: () => toSnakeCase
|
|
@@ -126,6 +133,16 @@ var RouterOfferSchema = (parameters) => mempool.Offer.OfferSchema(parameters).ex
|
|
|
126
133
|
issue: v4.z.string()
|
|
127
134
|
}).optional()
|
|
128
135
|
});
|
|
136
|
+
var consumedEvent = {
|
|
137
|
+
type: "event",
|
|
138
|
+
name: "Consumed",
|
|
139
|
+
inputs: [
|
|
140
|
+
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
141
|
+
{ name: "nonce", type: "uint256", indexed: true, internalType: "uint256" },
|
|
142
|
+
{ name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
|
|
143
|
+
],
|
|
144
|
+
anonymous: false
|
|
145
|
+
};
|
|
129
146
|
function from(input) {
|
|
130
147
|
try {
|
|
131
148
|
const parsedOffer = RouterOfferSchema({ omitHash: true }).parse(input);
|
|
@@ -153,6 +170,16 @@ function random() {
|
|
|
153
170
|
consumed: 0n
|
|
154
171
|
});
|
|
155
172
|
}
|
|
173
|
+
function fromConsumedLog(parameters) {
|
|
174
|
+
const { blockNumber, logIndex, chainId, transactionHash, user, nonce, amount } = parameters;
|
|
175
|
+
return {
|
|
176
|
+
id: `${blockNumber.toString()}-${logIndex.toString()}-${chainId}-${transactionHash}`,
|
|
177
|
+
chainId: BigInt(chainId),
|
|
178
|
+
offering: user,
|
|
179
|
+
nonce,
|
|
180
|
+
amount
|
|
181
|
+
};
|
|
182
|
+
}
|
|
156
183
|
var InvalidRouterOfferError = class extends mempool.Errors.BaseError {
|
|
157
184
|
constructor(error) {
|
|
158
185
|
super("Invalid router offer.", { cause: error });
|
|
@@ -364,28 +391,14 @@ var GetOffersQueryParams = v4.z.object({
|
|
|
364
391
|
example: "1500000000000000000"
|
|
365
392
|
}),
|
|
366
393
|
// Time range
|
|
367
|
-
min_maturity: v4.z.coerce.number().int().
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return v4.z.NEVER;
|
|
376
|
-
}
|
|
377
|
-
}).optional(),
|
|
378
|
-
max_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
|
|
379
|
-
try {
|
|
380
|
-
return mempool.Maturity.from(maturity);
|
|
381
|
-
} catch (e) {
|
|
382
|
-
ctx.addIssue({
|
|
383
|
-
code: "custom",
|
|
384
|
-
message: e.message
|
|
385
|
-
});
|
|
386
|
-
return v4.z.NEVER;
|
|
387
|
-
}
|
|
388
|
-
}).optional(),
|
|
394
|
+
min_maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
395
|
+
description: "Minimum maturity timestamp (Unix timestamp in seconds)",
|
|
396
|
+
example: "1700000000"
|
|
397
|
+
}),
|
|
398
|
+
max_maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
399
|
+
description: "Maximum maturity timestamp (Unix timestamp in seconds)",
|
|
400
|
+
example: "1800000000"
|
|
401
|
+
}),
|
|
389
402
|
min_expiry: v4.z.coerce.number().int().optional().meta({
|
|
390
403
|
description: "Minimum expiry timestamp (Unix timestamp in seconds)",
|
|
391
404
|
example: "1700000000"
|
|
@@ -460,33 +473,11 @@ var GetOffersQueryParams = v4.z.object({
|
|
|
460
473
|
description: "Filter by collateral combinations in format: asset:oracle:lltv#asset2:oracle2:lltv2. Oracle and lltv are optional. Use # to separate multiple combinations.",
|
|
461
474
|
example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:86#0x9876543210987654321098765432109876543210:94.5"
|
|
462
475
|
}),
|
|
463
|
-
min_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).
|
|
464
|
-
try {
|
|
465
|
-
return mempool.LLTV.from(viem.parseUnits(lltv.toString(), 16));
|
|
466
|
-
} catch (e) {
|
|
467
|
-
ctx.addIssue({
|
|
468
|
-
code: "custom",
|
|
469
|
-
message: e.message,
|
|
470
|
-
input: lltv
|
|
471
|
-
});
|
|
472
|
-
return v4.z.NEVER;
|
|
473
|
-
}
|
|
474
|
-
}).optional().meta({
|
|
476
|
+
min_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).optional().meta({
|
|
475
477
|
description: "Minimum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal, e.g., 80.5 = 80.5%)",
|
|
476
478
|
example: "80.5"
|
|
477
479
|
}),
|
|
478
|
-
max_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).
|
|
479
|
-
try {
|
|
480
|
-
return mempool.LLTV.from(viem.parseUnits(lltv.toString(), 16));
|
|
481
|
-
} catch (e) {
|
|
482
|
-
ctx.addIssue({
|
|
483
|
-
code: "custom",
|
|
484
|
-
message: e.message,
|
|
485
|
-
input: lltv
|
|
486
|
-
});
|
|
487
|
-
return v4.z.NEVER;
|
|
488
|
-
}
|
|
489
|
-
}).optional().meta({
|
|
480
|
+
max_lltv: v4.z.coerce.number().min(0, { message: "LLTV must be above 0" }).max(100, { message: "LLTV must be below 100" }).optional().meta({
|
|
490
481
|
description: "Maximum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal, e.g., 95.5 = 95.5%)",
|
|
491
482
|
example: "95.5"
|
|
492
483
|
}),
|
|
@@ -629,39 +620,18 @@ var MatchOffersQueryParams = v4.z.object({
|
|
|
629
620
|
example: "0x1234567890123456789012345678901234567890:0xabcdefabcdefabcdefabcdefabcdefabcdefabcd:86#0x9876543210987654321098765432109876543210:0xfedcbafedcbafedcbafedcbafedcbafedcbafedc:94.5"
|
|
630
621
|
}),
|
|
631
622
|
// Maturity filtering
|
|
632
|
-
maturity: v4.z.coerce.number().int().
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
try {
|
|
645
|
-
return mempool.Maturity.from(maturity);
|
|
646
|
-
} catch (e) {
|
|
647
|
-
ctx.addIssue({
|
|
648
|
-
code: "custom",
|
|
649
|
-
message: e.message
|
|
650
|
-
});
|
|
651
|
-
return v4.z.NEVER;
|
|
652
|
-
}
|
|
653
|
-
}).optional(),
|
|
654
|
-
max_maturity: v4.z.coerce.number().int().positive().transform((maturity, ctx) => {
|
|
655
|
-
try {
|
|
656
|
-
return mempool.Maturity.from(maturity);
|
|
657
|
-
} catch (e) {
|
|
658
|
-
ctx.addIssue({
|
|
659
|
-
code: "custom",
|
|
660
|
-
message: e.message
|
|
661
|
-
});
|
|
662
|
-
return v4.z.NEVER;
|
|
663
|
-
}
|
|
664
|
-
}).optional(),
|
|
623
|
+
maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
624
|
+
description: "Maturity timestamp (Unix timestamp in seconds)",
|
|
625
|
+
example: "1700000000"
|
|
626
|
+
}),
|
|
627
|
+
min_maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
628
|
+
description: "Minimum maturity timestamp (Unix timestamp in seconds)",
|
|
629
|
+
example: "1700000000"
|
|
630
|
+
}),
|
|
631
|
+
max_maturity: v4.z.coerce.number().int().min(0).optional().meta({
|
|
632
|
+
description: "Maximum maturity timestamp (Unix timestamp in seconds)",
|
|
633
|
+
example: "1800000000"
|
|
634
|
+
}),
|
|
665
635
|
// Asset and creator filtering
|
|
666
636
|
loan_token: v4.z.string().regex(/^0x[a-fA-F0-9]{40}$/, {
|
|
667
637
|
message: "Loan asset must be a valid Ethereum address"
|
|
@@ -1090,6 +1060,7 @@ __export(OfferStore_exports, {
|
|
|
1090
1060
|
function memory(parameters) {
|
|
1091
1061
|
const map = parameters.offers;
|
|
1092
1062
|
const filled = parameters.filled;
|
|
1063
|
+
const consumedIds = /* @__PURE__ */ new Set();
|
|
1093
1064
|
const indexingProgress = /* @__PURE__ */ new Map();
|
|
1094
1065
|
const create = async (parameters2) => {
|
|
1095
1066
|
if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
|
|
@@ -1259,8 +1230,12 @@ function memory(parameters) {
|
|
|
1259
1230
|
)
|
|
1260
1231
|
)
|
|
1261
1232
|
));
|
|
1262
|
-
minLltv && (offers = offers.filter(
|
|
1263
|
-
|
|
1233
|
+
minLltv && (offers = offers.filter(
|
|
1234
|
+
(o) => o.collaterals.every((c) => c.lltv >= viem.parseUnits(minLltv.toString(), 16))
|
|
1235
|
+
));
|
|
1236
|
+
maxLltv && (offers = offers.filter(
|
|
1237
|
+
(o) => o.collaterals.every((c) => c.lltv <= viem.parseUnits(maxLltv.toString(), 16))
|
|
1238
|
+
));
|
|
1264
1239
|
offers = offers.sort((a, b) => sort(sortBy, sortOrder, a, b));
|
|
1265
1240
|
let nextCursor = null;
|
|
1266
1241
|
if (offers.length > limit) {
|
|
@@ -1423,12 +1398,15 @@ function memory(parameters) {
|
|
|
1423
1398
|
});
|
|
1424
1399
|
},
|
|
1425
1400
|
updateConsumedAmount: async (parameters2) => {
|
|
1401
|
+
if (consumedIds.has(parameters2.id)) return;
|
|
1402
|
+
consumedIds.add(parameters2.id);
|
|
1426
1403
|
const chainId = parameters2.chainId;
|
|
1427
1404
|
const address = parameters2.offering.toLowerCase();
|
|
1428
1405
|
const nonce = parameters2.nonce;
|
|
1429
1406
|
const filledForChain = filled.get(chainId) || /* @__PURE__ */ new Map();
|
|
1430
1407
|
const filledForOffering = filledForChain.get(address) || /* @__PURE__ */ new Map();
|
|
1431
|
-
filledForOffering.
|
|
1408
|
+
const current = filledForOffering.get(nonce) || 0n;
|
|
1409
|
+
filledForOffering.set(nonce, current + parameters2.consumed);
|
|
1432
1410
|
filledForChain.set(address, filledForOffering);
|
|
1433
1411
|
filled.set(chainId, filledForChain);
|
|
1434
1412
|
},
|
|
@@ -1450,9 +1428,9 @@ __export(RouterEvent_exports, {
|
|
|
1450
1428
|
from: () => from2,
|
|
1451
1429
|
types: () => types
|
|
1452
1430
|
});
|
|
1453
|
-
var types = ["offer_created", "
|
|
1431
|
+
var types = ["offer_created", "offer_consumed", "offer_validation"];
|
|
1454
1432
|
function from2(base) {
|
|
1455
|
-
const id = `${base.type}:${base.offer.hash.toLowerCase()}`;
|
|
1433
|
+
const id = base.type === "offer_consumed" ? `${base.type}:${base.offerConsumed.id}` : `${base.type}:${base.offer.hash.toLowerCase()}`;
|
|
1456
1434
|
return { id, ...base };
|
|
1457
1435
|
}
|
|
1458
1436
|
|