@morpho-dev/router 0.1.0 → 0.1.2
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 +29 -81
- package/dist/index.browser.d.ts +29 -81
- package/dist/index.browser.js +37 -108
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +39 -109
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +31 -83
- package/dist/index.node.d.ts +31 -83
- package/dist/index.node.js +37 -108
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +39 -109
- package/dist/index.node.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.browser.d.cts
CHANGED
|
@@ -1,49 +1,10 @@
|
|
|
1
1
|
import * as _morpho_dev_mempool from '@morpho-dev/mempool';
|
|
2
|
-
import {
|
|
2
|
+
import { Offer, Errors, Format, Maturity, LLTV, Compute, Chain } from '@morpho-dev/mempool';
|
|
3
3
|
export * from '@morpho-dev/mempool';
|
|
4
4
|
import * as viem from 'viem';
|
|
5
5
|
import { Address, Hex, PublicClient } from 'viem';
|
|
6
|
-
import { Chain as Chain$2 } from 'viem/chains';
|
|
7
|
-
import * as zod_v4_core from 'zod/v4/core';
|
|
8
|
-
import * as zod_v4 from 'zod/v4';
|
|
9
6
|
import { z, ZodError } from 'zod/v4';
|
|
10
7
|
|
|
11
|
-
declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
12
|
-
type ChainName = (typeof chainNames)[number];
|
|
13
|
-
declare const ChainId: {
|
|
14
|
-
ETHEREUM: bigint;
|
|
15
|
-
BASE: bigint;
|
|
16
|
-
"ETHEREUM-VIRTUAL-TESTNET": bigint;
|
|
17
|
-
};
|
|
18
|
-
type ChainId = (typeof ChainId)[keyof typeof ChainId];
|
|
19
|
-
declare const chainIds: Set<bigint>;
|
|
20
|
-
type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
21
|
-
id: ChainId;
|
|
22
|
-
name: ChainName;
|
|
23
|
-
whitelistedAssets: Set<Address>;
|
|
24
|
-
morpho: Address;
|
|
25
|
-
mempool?: {
|
|
26
|
-
address: Address;
|
|
27
|
-
deploymentBlock: number;
|
|
28
|
-
reindexBuffer: number;
|
|
29
|
-
};
|
|
30
|
-
}>;
|
|
31
|
-
declare function getChain(chainId: ChainId): Chain | undefined;
|
|
32
|
-
declare const getWhitelistedChains: () => Chain[];
|
|
33
|
-
declare const chains: Record<ChainName, Chain>;
|
|
34
|
-
|
|
35
|
-
type Chain$1_Chain = Chain;
|
|
36
|
-
type Chain$1_ChainId = ChainId;
|
|
37
|
-
type Chain$1_ChainName = ChainName;
|
|
38
|
-
declare const Chain$1_chainIds: typeof chainIds;
|
|
39
|
-
declare const Chain$1_chainNames: typeof chainNames;
|
|
40
|
-
declare const Chain$1_chains: typeof chains;
|
|
41
|
-
declare const Chain$1_getChain: typeof getChain;
|
|
42
|
-
declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
|
|
43
|
-
declare namespace Chain$1 {
|
|
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 };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
8
|
declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
|
|
48
9
|
type OfferStatus = (typeof OfferStatusValues)[number];
|
|
49
10
|
type OfferMetadata = {
|
|
@@ -63,29 +24,29 @@ type OfferConsumed = {
|
|
|
63
24
|
};
|
|
64
25
|
declare const RouterOfferSchema: (parameters?: {
|
|
65
26
|
omitHash?: boolean;
|
|
66
|
-
}) =>
|
|
67
|
-
offering:
|
|
68
|
-
assets:
|
|
69
|
-
rate:
|
|
70
|
-
maturity:
|
|
71
|
-
expiry:
|
|
72
|
-
start:
|
|
73
|
-
nonce:
|
|
74
|
-
buy:
|
|
75
|
-
chainId:
|
|
76
|
-
loanToken:
|
|
77
|
-
collaterals:
|
|
78
|
-
asset:
|
|
79
|
-
oracle:
|
|
80
|
-
lltv:
|
|
81
|
-
},
|
|
82
|
-
callback:
|
|
83
|
-
address:
|
|
84
|
-
data:
|
|
85
|
-
gasLimit:
|
|
86
|
-
},
|
|
87
|
-
signature:
|
|
88
|
-
createdAt:
|
|
27
|
+
}) => z.ZodObject<{
|
|
28
|
+
offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
29
|
+
assets: z.ZodBigInt;
|
|
30
|
+
rate: z.ZodBigInt;
|
|
31
|
+
maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
|
|
32
|
+
expiry: z.ZodNumber;
|
|
33
|
+
start: z.ZodNumber;
|
|
34
|
+
nonce: z.ZodBigInt;
|
|
35
|
+
buy: z.ZodBoolean;
|
|
36
|
+
chainId: z.ZodBigInt;
|
|
37
|
+
loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
38
|
+
collaterals: z.ZodArray<z.ZodObject<{
|
|
39
|
+
asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
40
|
+
oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
41
|
+
lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
callback: z.ZodObject<{
|
|
44
|
+
address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
45
|
+
data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
46
|
+
gasLimit: z.ZodBigInt;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
|
|
49
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
89
50
|
consumed: z.ZodBigInt;
|
|
90
51
|
status: z.ZodEnum<{
|
|
91
52
|
valid: "valid";
|
|
@@ -96,7 +57,7 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
96
57
|
metadata: z.ZodOptional<z.ZodObject<{
|
|
97
58
|
issue: z.ZodString;
|
|
98
59
|
}, z.core.$strip>>;
|
|
99
|
-
},
|
|
60
|
+
}, z.core.$strip>;
|
|
100
61
|
/**
|
|
101
62
|
* ABI for the Consumed event emitted by the terms contract.
|
|
102
63
|
*/
|
|
@@ -400,19 +361,6 @@ type OfferStore = {
|
|
|
400
361
|
nonce: Offer.Offer["nonce"];
|
|
401
362
|
consumed: bigint;
|
|
402
363
|
}) => Promise<void>;
|
|
403
|
-
/** Persist latest indexing progress for a chain and event type. */
|
|
404
|
-
saveLatestBlockNumberProcessed: (parameters: {
|
|
405
|
-
chainId: Offer.Offer["chainId"];
|
|
406
|
-
eventType: "offer_created" | "offer_consumed";
|
|
407
|
-
latestBlockNumber: number;
|
|
408
|
-
}) => Promise<void>;
|
|
409
|
-
/** Retrieve latest indexing progress for a chain and event type. */
|
|
410
|
-
getLatestBlockNumberProcessed: (parameters: {
|
|
411
|
-
chainId: Offer.Offer["chainId"];
|
|
412
|
-
eventType: "offer_created" | "offer_consumed";
|
|
413
|
-
}) => Promise<{
|
|
414
|
-
latestBlockNumber: number;
|
|
415
|
-
} | null>;
|
|
416
364
|
};
|
|
417
365
|
type GetOffersFilters = {
|
|
418
366
|
creators?: string[];
|
|
@@ -473,7 +421,7 @@ declare function memory(parameters: {
|
|
|
473
421
|
status: OfferStatus;
|
|
474
422
|
metadata?: OfferMetadata;
|
|
475
423
|
}>;
|
|
476
|
-
filled: Map<
|
|
424
|
+
filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
|
|
477
425
|
}): OfferStore;
|
|
478
426
|
|
|
479
427
|
type index$1_FindMatchingOffersParams = FindMatchingOffersParams;
|
|
@@ -612,10 +560,10 @@ declare function single<Name extends string, T, Ctx = void>(name: Name, run: Sin
|
|
|
612
560
|
*/
|
|
613
561
|
declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
|
|
614
562
|
type MorphoContext = {
|
|
615
|
-
publicClients: Partial<Record<ChainName, PublicClient>>;
|
|
563
|
+
publicClients: Partial<Record<Chain.ChainName, PublicClient>>;
|
|
616
564
|
};
|
|
617
565
|
declare function morpho(parameters: {
|
|
618
|
-
whitelistedChains: Chain[];
|
|
566
|
+
whitelistedChains: Chain.Chain[];
|
|
619
567
|
}): (Rule<{
|
|
620
568
|
readonly offering: Address;
|
|
621
569
|
readonly assets: bigint;
|
|
@@ -815,4 +763,4 @@ declare namespace Validation {
|
|
|
815
763
|
export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
|
|
816
764
|
}
|
|
817
765
|
|
|
818
|
-
export {
|
|
766
|
+
export { index$1 as OfferStore, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,49 +1,10 @@
|
|
|
1
1
|
import * as _morpho_dev_mempool from '@morpho-dev/mempool';
|
|
2
|
-
import {
|
|
2
|
+
import { Offer, Errors, Format, Maturity, LLTV, Compute, Chain } from '@morpho-dev/mempool';
|
|
3
3
|
export * from '@morpho-dev/mempool';
|
|
4
4
|
import * as viem from 'viem';
|
|
5
5
|
import { Address, Hex, PublicClient } from 'viem';
|
|
6
|
-
import { Chain as Chain$2 } from 'viem/chains';
|
|
7
|
-
import * as zod_v4_core from 'zod/v4/core';
|
|
8
|
-
import * as zod_v4 from 'zod/v4';
|
|
9
6
|
import { z, ZodError } from 'zod/v4';
|
|
10
7
|
|
|
11
|
-
declare const chainNames: readonly ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
12
|
-
type ChainName = (typeof chainNames)[number];
|
|
13
|
-
declare const ChainId: {
|
|
14
|
-
ETHEREUM: bigint;
|
|
15
|
-
BASE: bigint;
|
|
16
|
-
"ETHEREUM-VIRTUAL-TESTNET": bigint;
|
|
17
|
-
};
|
|
18
|
-
type ChainId = (typeof ChainId)[keyof typeof ChainId];
|
|
19
|
-
declare const chainIds: Set<bigint>;
|
|
20
|
-
type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
21
|
-
id: ChainId;
|
|
22
|
-
name: ChainName;
|
|
23
|
-
whitelistedAssets: Set<Address>;
|
|
24
|
-
morpho: Address;
|
|
25
|
-
mempool?: {
|
|
26
|
-
address: Address;
|
|
27
|
-
deploymentBlock: number;
|
|
28
|
-
reindexBuffer: number;
|
|
29
|
-
};
|
|
30
|
-
}>;
|
|
31
|
-
declare function getChain(chainId: ChainId): Chain | undefined;
|
|
32
|
-
declare const getWhitelistedChains: () => Chain[];
|
|
33
|
-
declare const chains: Record<ChainName, Chain>;
|
|
34
|
-
|
|
35
|
-
type Chain$1_Chain = Chain;
|
|
36
|
-
type Chain$1_ChainId = ChainId;
|
|
37
|
-
type Chain$1_ChainName = ChainName;
|
|
38
|
-
declare const Chain$1_chainIds: typeof chainIds;
|
|
39
|
-
declare const Chain$1_chainNames: typeof chainNames;
|
|
40
|
-
declare const Chain$1_chains: typeof chains;
|
|
41
|
-
declare const Chain$1_getChain: typeof getChain;
|
|
42
|
-
declare const Chain$1_getWhitelistedChains: typeof getWhitelistedChains;
|
|
43
|
-
declare namespace Chain$1 {
|
|
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 };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
8
|
declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
|
|
48
9
|
type OfferStatus = (typeof OfferStatusValues)[number];
|
|
49
10
|
type OfferMetadata = {
|
|
@@ -63,29 +24,29 @@ type OfferConsumed = {
|
|
|
63
24
|
};
|
|
64
25
|
declare const RouterOfferSchema: (parameters?: {
|
|
65
26
|
omitHash?: boolean;
|
|
66
|
-
}) =>
|
|
67
|
-
offering:
|
|
68
|
-
assets:
|
|
69
|
-
rate:
|
|
70
|
-
maturity:
|
|
71
|
-
expiry:
|
|
72
|
-
start:
|
|
73
|
-
nonce:
|
|
74
|
-
buy:
|
|
75
|
-
chainId:
|
|
76
|
-
loanToken:
|
|
77
|
-
collaterals:
|
|
78
|
-
asset:
|
|
79
|
-
oracle:
|
|
80
|
-
lltv:
|
|
81
|
-
},
|
|
82
|
-
callback:
|
|
83
|
-
address:
|
|
84
|
-
data:
|
|
85
|
-
gasLimit:
|
|
86
|
-
},
|
|
87
|
-
signature:
|
|
88
|
-
createdAt:
|
|
27
|
+
}) => z.ZodObject<{
|
|
28
|
+
offering: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
29
|
+
assets: z.ZodBigInt;
|
|
30
|
+
rate: z.ZodBigInt;
|
|
31
|
+
maturity: z.ZodPipe<z.ZodNumber, z.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
|
|
32
|
+
expiry: z.ZodNumber;
|
|
33
|
+
start: z.ZodNumber;
|
|
34
|
+
nonce: z.ZodBigInt;
|
|
35
|
+
buy: z.ZodBoolean;
|
|
36
|
+
chainId: z.ZodBigInt;
|
|
37
|
+
loanToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
38
|
+
collaterals: z.ZodArray<z.ZodObject<{
|
|
39
|
+
asset: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
40
|
+
oracle: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
41
|
+
lltv: z.ZodPipe<z.ZodBigInt, z.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
callback: z.ZodObject<{
|
|
44
|
+
address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
45
|
+
data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
46
|
+
gasLimit: z.ZodBigInt;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
signature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
|
|
49
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
89
50
|
consumed: z.ZodBigInt;
|
|
90
51
|
status: z.ZodEnum<{
|
|
91
52
|
valid: "valid";
|
|
@@ -96,7 +57,7 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
96
57
|
metadata: z.ZodOptional<z.ZodObject<{
|
|
97
58
|
issue: z.ZodString;
|
|
98
59
|
}, z.core.$strip>>;
|
|
99
|
-
},
|
|
60
|
+
}, z.core.$strip>;
|
|
100
61
|
/**
|
|
101
62
|
* ABI for the Consumed event emitted by the terms contract.
|
|
102
63
|
*/
|
|
@@ -400,19 +361,6 @@ type OfferStore = {
|
|
|
400
361
|
nonce: Offer.Offer["nonce"];
|
|
401
362
|
consumed: bigint;
|
|
402
363
|
}) => Promise<void>;
|
|
403
|
-
/** Persist latest indexing progress for a chain and event type. */
|
|
404
|
-
saveLatestBlockNumberProcessed: (parameters: {
|
|
405
|
-
chainId: Offer.Offer["chainId"];
|
|
406
|
-
eventType: "offer_created" | "offer_consumed";
|
|
407
|
-
latestBlockNumber: number;
|
|
408
|
-
}) => Promise<void>;
|
|
409
|
-
/** Retrieve latest indexing progress for a chain and event type. */
|
|
410
|
-
getLatestBlockNumberProcessed: (parameters: {
|
|
411
|
-
chainId: Offer.Offer["chainId"];
|
|
412
|
-
eventType: "offer_created" | "offer_consumed";
|
|
413
|
-
}) => Promise<{
|
|
414
|
-
latestBlockNumber: number;
|
|
415
|
-
} | null>;
|
|
416
364
|
};
|
|
417
365
|
type GetOffersFilters = {
|
|
418
366
|
creators?: string[];
|
|
@@ -473,7 +421,7 @@ declare function memory(parameters: {
|
|
|
473
421
|
status: OfferStatus;
|
|
474
422
|
metadata?: OfferMetadata;
|
|
475
423
|
}>;
|
|
476
|
-
filled: Map<
|
|
424
|
+
filled: Map<Chain.Id, Map<Address, Map<bigint, bigint>>>;
|
|
477
425
|
}): OfferStore;
|
|
478
426
|
|
|
479
427
|
type index$1_FindMatchingOffersParams = FindMatchingOffersParams;
|
|
@@ -612,10 +560,10 @@ declare function single<Name extends string, T, Ctx = void>(name: Name, run: Sin
|
|
|
612
560
|
*/
|
|
613
561
|
declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
|
|
614
562
|
type MorphoContext = {
|
|
615
|
-
publicClients: Partial<Record<ChainName, PublicClient>>;
|
|
563
|
+
publicClients: Partial<Record<Chain.ChainName, PublicClient>>;
|
|
616
564
|
};
|
|
617
565
|
declare function morpho(parameters: {
|
|
618
|
-
whitelistedChains: Chain[];
|
|
566
|
+
whitelistedChains: Chain.Chain[];
|
|
619
567
|
}): (Rule<{
|
|
620
568
|
readonly offering: Address;
|
|
621
569
|
readonly assets: bigint;
|
|
@@ -815,4 +763,4 @@ declare namespace Validation {
|
|
|
815
763
|
export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
|
|
816
764
|
}
|
|
817
765
|
|
|
818
|
-
export {
|
|
766
|
+
export { index$1 as OfferStore, Client$1 as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, index as Utils, Validation, ValidationRule };
|
package/dist/index.browser.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var mempool = require('@morpho-dev/mempool');
|
|
4
|
-
var chains$1 = require('viem/chains');
|
|
5
4
|
var viem = require('viem');
|
|
6
5
|
var v4 = require('zod/v4');
|
|
7
6
|
var zodOpenapi = require('zod-openapi');
|
|
@@ -15,85 +14,6 @@ var __export = (target, all) => {
|
|
|
15
14
|
};
|
|
16
15
|
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
|
|
17
16
|
|
|
18
|
-
// src/Chain.ts
|
|
19
|
-
var Chain_exports = {};
|
|
20
|
-
__export(Chain_exports, {
|
|
21
|
-
ChainId: () => ChainId,
|
|
22
|
-
chainIds: () => chainIds,
|
|
23
|
-
chainNames: () => chainNames,
|
|
24
|
-
chains: () => chains,
|
|
25
|
-
getChain: () => getChain,
|
|
26
|
-
getWhitelistedChains: () => getWhitelistedChains
|
|
27
|
-
});
|
|
28
|
-
var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
29
|
-
var ChainId = {
|
|
30
|
-
ETHEREUM: BigInt(chains$1.mainnet.id),
|
|
31
|
-
BASE: BigInt(chains$1.base.id),
|
|
32
|
-
"ETHEREUM-VIRTUAL-TESTNET": 109111114n
|
|
33
|
-
};
|
|
34
|
-
var chainIds = new Set(Object.values(ChainId));
|
|
35
|
-
var chainNameLookup = new Map(Object.entries(ChainId).map(([key, value]) => [value, key]));
|
|
36
|
-
function getChain(chainId) {
|
|
37
|
-
const chainName = chainNameLookup.get(chainId)?.toLowerCase();
|
|
38
|
-
if (!chainName) {
|
|
39
|
-
return void 0;
|
|
40
|
-
}
|
|
41
|
-
return chains[chainName];
|
|
42
|
-
}
|
|
43
|
-
var getWhitelistedChains = () => {
|
|
44
|
-
return [chains.ethereum, chains.base, chains["ethereum-virtual-testnet"]];
|
|
45
|
-
};
|
|
46
|
-
var chains = {
|
|
47
|
-
ethereum: {
|
|
48
|
-
...chains$1.mainnet,
|
|
49
|
-
id: ChainId.ETHEREUM,
|
|
50
|
-
name: "ethereum",
|
|
51
|
-
whitelistedAssets: new Set(
|
|
52
|
-
[
|
|
53
|
-
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
54
|
-
// USDC
|
|
55
|
-
"0x6B175474E89094C44Da98b954EedeAC495271d0F"
|
|
56
|
-
// DAI
|
|
57
|
-
].map((address) => address.toLowerCase())
|
|
58
|
-
),
|
|
59
|
-
morpho: "0x0000000000000000000000000000000000000000"
|
|
60
|
-
},
|
|
61
|
-
base: {
|
|
62
|
-
...chains$1.base,
|
|
63
|
-
id: ChainId.BASE,
|
|
64
|
-
name: "base",
|
|
65
|
-
whitelistedAssets: new Set(
|
|
66
|
-
[
|
|
67
|
-
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
68
|
-
// USDC
|
|
69
|
-
"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"
|
|
70
|
-
// DAI
|
|
71
|
-
].map((address) => address.toLowerCase())
|
|
72
|
-
),
|
|
73
|
-
morpho: "0x0000000000000000000000000000000000000000"
|
|
74
|
-
},
|
|
75
|
-
"ethereum-virtual-testnet": {
|
|
76
|
-
...chains$1.mainnet,
|
|
77
|
-
id: 109111114n,
|
|
78
|
-
name: "ethereum-virtual-testnet",
|
|
79
|
-
whitelistedAssets: new Set(
|
|
80
|
-
[
|
|
81
|
-
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
82
|
-
// USDC
|
|
83
|
-
"0x6B175474E89094C44Da98b954EedeAC495271d0F"
|
|
84
|
-
// DAI
|
|
85
|
-
].map((address) => address.toLowerCase())
|
|
86
|
-
),
|
|
87
|
-
morpho: "0x11a002d45db720ed47a80d2f3489cba5b833eaf5",
|
|
88
|
-
// @TODO: This is mock Consumed contract, update with Terms once stable
|
|
89
|
-
mempool: {
|
|
90
|
-
address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
|
|
91
|
-
deploymentBlock: 23223727,
|
|
92
|
-
reindexBuffer: 10
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
17
|
// src/core/router/Client.ts
|
|
98
18
|
var Client_exports = {};
|
|
99
19
|
__export(Client_exports, {
|
|
@@ -420,12 +340,15 @@ var GetOffersQueryParams = v4.z.object({
|
|
|
420
340
|
description: "Filter by multiple rate oracles (comma-separated)",
|
|
421
341
|
example: "0x1234567890123456789012345678901234567890,0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"
|
|
422
342
|
}),
|
|
423
|
-
collateral_tuple: v4.z.string().
|
|
424
|
-
/^(0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)(#0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)
|
|
425
|
-
{
|
|
426
|
-
|
|
343
|
+
collateral_tuple: v4.z.string().transform((val, ctx) => {
|
|
344
|
+
const pattern = /^(0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)(#0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)*$/;
|
|
345
|
+
if (!pattern.test(val)) {
|
|
346
|
+
ctx.addIssue({
|
|
347
|
+
code: "custom",
|
|
348
|
+
message: "collateral_tuple has an invalid format",
|
|
349
|
+
input: val
|
|
350
|
+
});
|
|
427
351
|
}
|
|
428
|
-
).transform((val, ctx) => {
|
|
429
352
|
return val.split("#").map((tuple) => {
|
|
430
353
|
const parts = tuple.split(":");
|
|
431
354
|
if (parts.length === 0 || !parts[0]) {
|
|
@@ -555,9 +478,23 @@ var MatchOffersQueryParams = v4.z.object({
|
|
|
555
478
|
description: "The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell. If your intent is to sell, buy offers will be returned, and vice versa.",
|
|
556
479
|
example: "buy"
|
|
557
480
|
}),
|
|
558
|
-
chain_id: v4.z.string().
|
|
559
|
-
|
|
560
|
-
|
|
481
|
+
chain_id: v4.z.string().transform((val, ctx) => {
|
|
482
|
+
const numericLike = /^-?\d+$/.test(val);
|
|
483
|
+
if (!numericLike) {
|
|
484
|
+
ctx.addIssue({
|
|
485
|
+
code: "custom",
|
|
486
|
+
message: "chain_id has an invalid format",
|
|
487
|
+
input: val
|
|
488
|
+
});
|
|
489
|
+
ctx.addIssue({
|
|
490
|
+
code: "custom",
|
|
491
|
+
message: "Invalid input: expected number, received NaN",
|
|
492
|
+
input: val
|
|
493
|
+
});
|
|
494
|
+
return v4.z.NEVER;
|
|
495
|
+
}
|
|
496
|
+
return Number.parseInt(val, 10);
|
|
497
|
+
}).pipe(v4.z.number().positive()).meta({
|
|
561
498
|
description: "The blockchain network chain ID",
|
|
562
499
|
example: "1"
|
|
563
500
|
}),
|
|
@@ -569,12 +506,15 @@ var MatchOffersQueryParams = v4.z.object({
|
|
|
569
506
|
example: "1000000000000000000"
|
|
570
507
|
}),
|
|
571
508
|
// Collateral filtering
|
|
572
|
-
collaterals: v4.z.string().
|
|
573
|
-
/^(0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)(#0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)
|
|
574
|
-
{
|
|
575
|
-
|
|
509
|
+
collaterals: v4.z.string().transform((val, ctx) => {
|
|
510
|
+
const pattern = /^(0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)(#0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)*$/;
|
|
511
|
+
if (!pattern.test(val)) {
|
|
512
|
+
ctx.addIssue({
|
|
513
|
+
code: "custom",
|
|
514
|
+
message: "Collaterals must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. All fields are required for each collateral.",
|
|
515
|
+
input: val
|
|
516
|
+
});
|
|
576
517
|
}
|
|
577
|
-
).transform((val, ctx) => {
|
|
578
518
|
return val.split("#").map((collateral) => {
|
|
579
519
|
const parts = collateral.split(":");
|
|
580
520
|
if (parts.length !== 3) {
|
|
@@ -1061,7 +1001,6 @@ function memory(parameters) {
|
|
|
1061
1001
|
const map = parameters.offers;
|
|
1062
1002
|
const filled = parameters.filled;
|
|
1063
1003
|
const consumedIds = /* @__PURE__ */ new Set();
|
|
1064
|
-
const indexingProgress = /* @__PURE__ */ new Map();
|
|
1065
1004
|
const create = async (parameters2) => {
|
|
1066
1005
|
if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
|
|
1067
1006
|
map.set(parameters2.offer.hash.toLowerCase(), {
|
|
@@ -1132,7 +1071,7 @@ function memory(parameters) {
|
|
|
1132
1071
|
let {
|
|
1133
1072
|
creators,
|
|
1134
1073
|
side,
|
|
1135
|
-
chains
|
|
1074
|
+
chains,
|
|
1136
1075
|
loanTokens,
|
|
1137
1076
|
status = ["valid"],
|
|
1138
1077
|
callbackAddresses,
|
|
@@ -1203,7 +1142,7 @@ function memory(parameters) {
|
|
|
1203
1142
|
offers = offers.filter((o) => o.expiry >= now);
|
|
1204
1143
|
creators && (offers = offers.filter((o) => creators.includes(o.offering.toLowerCase())));
|
|
1205
1144
|
side && (offers = offers.filter((o) => o.buy === buy));
|
|
1206
|
-
|
|
1145
|
+
chains && (offers = offers.filter((o) => chains.includes(Number(o.chainId))));
|
|
1207
1146
|
loanTokens && (offers = offers.filter((o) => loanTokens.includes(o.loanToken.toLowerCase())));
|
|
1208
1147
|
status && (offers = offers.filter((o) => status.includes(o.status)));
|
|
1209
1148
|
callbackAddresses && (offers = offers.filter(
|
|
@@ -1409,15 +1348,6 @@ function memory(parameters) {
|
|
|
1409
1348
|
filledForOffering.set(nonce, current + parameters2.consumed);
|
|
1410
1349
|
filledForChain.set(address, filledForOffering);
|
|
1411
1350
|
filled.set(chainId, filledForChain);
|
|
1412
|
-
},
|
|
1413
|
-
saveLatestBlockNumberProcessed: async (parameters2) => {
|
|
1414
|
-
const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
|
|
1415
|
-
indexingProgress.set(key, parameters2.latestBlockNumber);
|
|
1416
|
-
},
|
|
1417
|
-
getLatestBlockNumberProcessed: async (parameters2) => {
|
|
1418
|
-
const key = `${parameters2.chainId.toString()}:${parameters2.eventType}`;
|
|
1419
|
-
const value = indexingProgress.get(key);
|
|
1420
|
-
return value === void 0 ? null : { latestBlockNumber: value };
|
|
1421
1351
|
}
|
|
1422
1352
|
};
|
|
1423
1353
|
}
|
|
@@ -1556,7 +1486,7 @@ function morpho(parameters) {
|
|
|
1556
1486
|
);
|
|
1557
1487
|
const buyOffersPerLoanAsset = /* @__PURE__ */ new Map();
|
|
1558
1488
|
for (const offer of buyOffers) {
|
|
1559
|
-
const chainName = getChain(offer.chainId)?.name;
|
|
1489
|
+
const chainName = mempool.Chain.getChain(offer.chainId)?.name;
|
|
1560
1490
|
const loanTokens = buyOffersPerLoanAsset.get(chainName) ?? /* @__PURE__ */ new Map();
|
|
1561
1491
|
const offers2 = loanTokens.get(offer.loanToken.toLowerCase()) ?? [];
|
|
1562
1492
|
offers2.push(offer);
|
|
@@ -1567,7 +1497,7 @@ function morpho(parameters) {
|
|
|
1567
1497
|
Array.from(buyOffersPerLoanAsset.entries()).map(async ([name, loanTokens]) => {
|
|
1568
1498
|
const chainName = name;
|
|
1569
1499
|
const publicClient = publicClients[chainName];
|
|
1570
|
-
const morpho2 = morphoPerChain.get(chains[chainName].id);
|
|
1500
|
+
const morpho2 = morphoPerChain.get(mempool.Chain.chains[chainName].id);
|
|
1571
1501
|
if (!publicClient) {
|
|
1572
1502
|
const offers2 = Array.from(loanTokens.values()).flat();
|
|
1573
1503
|
for (const offer of offers2) {
|
|
@@ -1647,7 +1577,6 @@ function morpho(parameters) {
|
|
|
1647
1577
|
];
|
|
1648
1578
|
}
|
|
1649
1579
|
|
|
1650
|
-
exports.Chain = Chain_exports;
|
|
1651
1580
|
exports.OfferStore = OfferStore_exports;
|
|
1652
1581
|
exports.Router = Client_exports;
|
|
1653
1582
|
exports.RouterEvent = RouterEvent_exports;
|