@morpho-dev/router 0.10.0 → 0.12.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.
- package/README.md +20 -5
- package/dist/cli.js +14944 -8994
- package/dist/drizzle/migrations/0031_sell-takeable-reindex.sql +254 -0
- package/dist/drizzle/migrations/0032_callback-type.sql +3 -0
- package/dist/drizzle/migrations/0033_obligation-id-bytes20.sql +255 -0
- package/dist/drizzle/migrations/0034_chain-checkpoints.sql +1 -0
- package/dist/drizzle/migrations/0035_chain-tip-hash-cas.sql +1 -0
- package/dist/drizzle/migrations/0036_pending-links.sql +22 -0
- package/dist/drizzle/migrations/0037_chain-finalized-anchor.sql +2 -0
- package/dist/drizzle/migrations/0038_add-obligation-rcf-threshold.sql +2 -0
- package/dist/drizzle/migrations/0039_add-offers-composite-indexes.sql +2 -0
- package/dist/drizzle/migrations/0040_drop-redundant-offers-indexes.sql +2 -0
- package/dist/drizzle/migrations/0041_add-group-winner-expression-index.sql +10 -0
- package/dist/drizzle/migrations/0042_contract-sync-v1.14.sql +284 -0
- package/dist/drizzle/migrations/0043_add-obligation-side-tick-index.sql +1 -0
- package/dist/drizzle/migrations/0044_index-audit-cleanup.sql +27 -0
- package/dist/drizzle/migrations/0045_add-lots-offsets-availability-indexes.sql +5 -0
- package/dist/drizzle/migrations/0046_add-offers-active-tick-index.sql +1 -0
- package/dist/drizzle/migrations/0047_add-offers-book-winners-index.sql +1 -0
- package/dist/drizzle/migrations/0048_covering-indexes-for-winners-queries.sql +34 -0
- package/dist/drizzle/migrations/0049_contract-sync-v1.15.sql +305 -0
- package/dist/drizzle/migrations/meta/0031_snapshot.json +1652 -0
- package/dist/drizzle/migrations/meta/0033_snapshot.json +1658 -0
- package/dist/drizzle/migrations/meta/0036_snapshot.json +1864 -0
- package/dist/drizzle/migrations/meta/0037_snapshot.json +1876 -0
- package/dist/drizzle/migrations/meta/0038_snapshot.json +1882 -0
- package/dist/drizzle/migrations/meta/0039_snapshot.json +1960 -0
- package/dist/drizzle/migrations/meta/0040_snapshot.json +1912 -0
- package/dist/drizzle/migrations/meta/0041_snapshot.json +1912 -0
- package/dist/drizzle/migrations/meta/0042_snapshot.json +1882 -0
- package/dist/drizzle/migrations/meta/0043_snapshot.json +1909 -0
- package/dist/drizzle/migrations/meta/0044_snapshot.json +1853 -0
- package/dist/drizzle/migrations/meta/0045_snapshot.json +1921 -0
- package/dist/drizzle/migrations/meta/0046_snapshot.json +1966 -0
- package/dist/drizzle/migrations/meta/0047_snapshot.json +2005 -0
- package/dist/drizzle/migrations/meta/0048_snapshot.json +2035 -0
- package/dist/drizzle/migrations/meta/0049_snapshot.json +2035 -0
- package/dist/drizzle/migrations/meta/_journal.json +133 -0
- package/dist/evm/bytecode/morpho.txt +1 -1
- package/dist/index.browser.d.mts +784 -282
- package/dist/index.browser.d.mts.map +1 -1
- package/dist/index.browser.mjs +1516 -675
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.mts +1676 -602
- package/dist/index.node.d.mts.map +1 -1
- package/dist/index.node.mjs +10121 -5251
- package/dist/index.node.mjs.map +1 -1
- package/dist/register-otel-hook.js +7 -0
- package/dist/server-D4xxddev.js +9573 -0
- package/dist/server.js +9617 -0
- package/docs/integrator.md +14 -24
- package/package.json +36 -29
- package/dist/index.browser.d.ts +0 -5007
- package/dist/index.browser.d.ts.map +0 -1
- package/dist/index.browser.js +0 -5825
- package/dist/index.browser.js.map +0 -1
- package/dist/index.node.d.ts +0 -8263
- package/dist/index.node.d.ts.map +0 -1
- package/dist/index.node.js +0 -12566
- package/dist/index.node.js.map +0 -1
package/docs/integrator.md
CHANGED
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Router
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The router improves the discoverability of offers made by **makers** for **takers**. Because offers are published to a **public**, **uncensored mempool**, the router ensures malicious or invalid offers are filtered out before they reach takers, acting as an opinionated infrastructure that lets applications be built without needing custom offer validation or anti-spam logic.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
It follows a set of rules managed by an external service, the **gatekeeper**, exposed at **`GET /v1/config/rules`**. Those rules determine which offers are fully excluded, based on criteria such as offer format, tokens, maturity, callback, and more. Any maker that wants to comply with these rules can call **`POST /v1/validate`** to confirm that their offers are supported by the router.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### The mempool
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Although the mempool is unrestricted, the router supports only a specific offer format. The best way for a maker to stay router-compatible is to call **`POST /v1/validate`** to get the **encoded offer payload**, sign the returned **root**, and publish the payload with the **signature appended** (`data = payload + signature`).
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
To run these checks and validate your offers, call **`POST /v1/validate`**. If validation fails, the response includes `data.issues` describing what needs to be fixed.
|
|
14
|
-
|
|
15
|
-
## Discover supported rules
|
|
16
|
-
|
|
17
|
-
The router publishes configured rules (maturities, loan tokens, and oracles) by chain. These rules are enforced by the gatekeeper when validating offers.
|
|
18
|
-
|
|
19
|
-
Call **`GET /v1/config/rules`** to retrieve the current rules (with pagination). Use the `types` and `chains` query params to filter which rules are returned. The response includes `meta.checksum` so integrators can detect updates.
|
|
20
|
-
|
|
21
|
-
## Push offers to the mempool
|
|
22
|
-
|
|
23
|
-
Once your offer is valid, you must **publish it on-chain** to make it available to all mempool consumers. The router is one consumer of the mempool, but anyone can publish to it or listen to it.
|
|
11
|
+
The maker can then be confident their offers will be indexed correctly when queried.
|
|
24
12
|
|
|
13
|
+
```text
|
|
14
|
+
POST /v1/validate --data "{ chainId, offers: [...] }"
|
|
15
|
+
→ { payload, root }
|
|
16
|
+
→ sign(root)
|
|
17
|
+
→ publish(payload + signature)
|
|
25
18
|
```
|
|
26
|
-
POST /v1/validate → { payload, root } → sign(root) → publish(payload + sig)
|
|
27
|
-
{ offers: [...] }
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Offers are published as a *batch* using a Merkle tree so that a single signature can cover a whole group of offers. The Merkle **root** is a compact commitment to the full set: changing any offer changes the root, which makes the signature invalid. To keep calldata (and therefore gas costs) low, the offer set is embedded in the `payload` as a **gzipped** representation rather than being sent as plain JSON.
|
|
31
19
|
|
|
32
|
-
|
|
20
|
+
Offers are submitted as a batch using a Merkle tree, so one signature can cover multiple offers. The Merkle root is a compact
|
|
21
|
+
commitment to the whole set: any change to any offer changes the root, invalidating the signature. To reduce calldata (and gas)
|
|
22
|
+
usage, the full offer set is embedded in the payload as gzipped data instead of plain JSON.
|
|
33
23
|
|
|
34
24
|
## Router takeable computation
|
|
35
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-dev/router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Router package for Morpho protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,23 +16,23 @@
|
|
|
16
16
|
"dist/*",
|
|
17
17
|
"docs/*"
|
|
18
18
|
],
|
|
19
|
-
"main": "./dist/index.node.
|
|
19
|
+
"main": "./dist/index.node.mjs",
|
|
20
20
|
"module": "./dist/index.node.mjs",
|
|
21
|
-
"types": "./dist/index.node.d.
|
|
21
|
+
"types": "./dist/index.node.d.mts",
|
|
22
22
|
"bin": {
|
|
23
23
|
"router": "./dist/cli.js"
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
27
|
"node": {
|
|
28
|
-
"types": "./dist/index.node.d.
|
|
28
|
+
"types": "./dist/index.node.d.mts",
|
|
29
29
|
"import": "./dist/index.node.mjs",
|
|
30
|
-
"require": "./dist/index.node.
|
|
30
|
+
"require": "./dist/index.node.mjs"
|
|
31
31
|
},
|
|
32
32
|
"default": {
|
|
33
|
-
"types": "./dist/index.browser.d.
|
|
33
|
+
"types": "./dist/index.browser.d.mts",
|
|
34
34
|
"import": "./dist/index.browser.mjs",
|
|
35
|
-
"require": "./dist/index.browser.
|
|
35
|
+
"require": "./dist/index.browser.mjs"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
},
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
"#core": "./src/core/index.ts",
|
|
41
41
|
"#*": "./src/*"
|
|
42
42
|
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=22.22.0",
|
|
45
|
+
"pnpm": ">=10.30.1 <11"
|
|
46
|
+
},
|
|
43
47
|
"devDependencies": {
|
|
44
48
|
"@types/pako": "^2.0.4",
|
|
45
49
|
"@types/pg": "^8.15.5",
|
|
@@ -50,55 +54,58 @@
|
|
|
50
54
|
},
|
|
51
55
|
"dependencies": {
|
|
52
56
|
"@electric-sql/pglite": "^0.3.1",
|
|
53
|
-
"@hono/node-server": "^1.19.
|
|
57
|
+
"@hono/node-server": "^1.19.10",
|
|
54
58
|
"@opentelemetry/api": "^1.9.0",
|
|
55
|
-
"@opentelemetry/exporter-trace-otlp-proto": "^0.
|
|
56
|
-
"@opentelemetry/
|
|
57
|
-
"@opentelemetry/instrumentation": "^0.
|
|
58
|
-
"@opentelemetry/instrumentation-
|
|
59
|
-
"@opentelemetry/
|
|
60
|
-
"@opentelemetry/
|
|
61
|
-
"@opentelemetry/
|
|
62
|
-
"@opentelemetry/sdk-trace-node": "^2.2.0",
|
|
63
|
-
"@opentelemetry/semantic-conventions": "^1.38.0",
|
|
59
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.212.0",
|
|
60
|
+
"@opentelemetry/instrumentation": "^0.212.0",
|
|
61
|
+
"@opentelemetry/instrumentation-http": "^0.212.0",
|
|
62
|
+
"@opentelemetry/instrumentation-pg": "^0.64.0",
|
|
63
|
+
"@opentelemetry/resources": "^2.5.1",
|
|
64
|
+
"@opentelemetry/sdk-trace-node": "^2.5.1",
|
|
65
|
+
"@opentelemetry/semantic-conventions": "^1.39.0",
|
|
64
66
|
"@openzeppelin/merkle-tree": "^1.0.8",
|
|
65
67
|
"commander": "^13.1.0",
|
|
66
68
|
"dotenv": "^17.2.1",
|
|
67
69
|
"drizzle-orm": "^0.43.1",
|
|
68
|
-
"hono": "^4.
|
|
69
|
-
"js-base64": "^3.7.8",
|
|
70
|
+
"hono": "^4.12.7",
|
|
70
71
|
"marked": "^17.0.1",
|
|
71
72
|
"openapi-fetch": "^0.15.0",
|
|
72
73
|
"openapi-metadata": "^0.2.2",
|
|
73
74
|
"pako": "^2.1.0",
|
|
75
|
+
"prom-client": "^15.1.3",
|
|
74
76
|
"pg": "^8.16.0",
|
|
75
77
|
"reflect-metadata": "^0.2.2",
|
|
76
78
|
"smol-toml": "^1.6.0",
|
|
77
79
|
"viem": "^2.37.13",
|
|
78
|
-
"zod": "^4.1.12"
|
|
79
|
-
"zod-openapi": "^5.4.3"
|
|
80
|
+
"zod": "^4.1.12"
|
|
80
81
|
},
|
|
81
82
|
"scripts": {
|
|
82
83
|
"bench": "vitest bench",
|
|
83
84
|
"build": "pnpm openapi:generate && tsdown --config tsdown.config.ts",
|
|
84
|
-
"container:build": "docker build -f Dockerfile -t morpho-router ../../",
|
|
85
|
+
"container:build": "docker buildx build -f Dockerfile -t morpho-router --load ../../",
|
|
85
86
|
"container:run": "docker run -p 7891:7891 -e OTEL_EXPORTER_OTLP_ENDPOINT=http://host.docker.internal:4318/v1/traces --rm -it morpho-router",
|
|
86
|
-
"cli": "pnpm build && node --
|
|
87
|
+
"cli": "pnpm build && node --import ./dist/register-otel-hook.js ./dist/cli.js",
|
|
87
88
|
"dev": "tsdown --config tsdown.config.ts --watch --onSuccess 'echo \"Router package rebuilt\"'",
|
|
88
89
|
"docs:cli": "node ./scripts/generate-readme.mjs",
|
|
89
|
-
"format": "
|
|
90
|
+
"format": "oxfmt src/",
|
|
90
91
|
"lint": "bash ./scripts/lint.sh",
|
|
91
|
-
"lint:
|
|
92
|
+
"lint:fix": "oxlint --fix src/",
|
|
93
|
+
"lint:ci": "bash ./scripts/lint.sh",
|
|
92
94
|
"migrations:create": "drizzle-kit generate --config src/database/drizzle/drizzle.config.ts --name",
|
|
95
|
+
"migrations:verify": "node ./scripts/verify-migration-artifacts.mjs",
|
|
93
96
|
"migrations:run": "drizzle-kit migrate --config src/database/drizzle/drizzle.config.ts",
|
|
94
|
-
"openapi:generate": "node --import tsx src/cli/dump-swagger.ts && pnpm openapi-typescript src/api/Schema/generated/swagger.json -o src/api/Schema/generated/swagger.d.ts &&
|
|
95
|
-
"test": "vitest run",
|
|
97
|
+
"openapi:generate": "node --import tsx src/cli/dump-swagger.ts && pnpm openapi-typescript src/api/Schema/generated/swagger.json -o src/api/Schema/generated/swagger.d.ts && oxfmt src/api/Schema/generated",
|
|
98
|
+
"test": "vitest --config vitest.config.ts run",
|
|
99
|
+
"test:guard:classification": "node --import tsx ./scripts/verify-test-classification.ts",
|
|
100
|
+
"test:integration": "vitest --config vitest.integration.config.ts run",
|
|
101
|
+
"test:unit": "pnpm test:guard:classification && vitest --config vitest.config.ts run",
|
|
96
102
|
"test:e2e": "./scripts/e2e-run.sh",
|
|
97
103
|
"test:tenderly": "vitest --config vitest.e2e.config.ts run",
|
|
98
|
-
"test:ui": "vitest --ui",
|
|
99
|
-
"test:watch": "vitest watch",
|
|
104
|
+
"test:ui": "vitest --config vitest.config.ts --ui",
|
|
105
|
+
"test:watch": "vitest --config vitest.config.ts watch",
|
|
100
106
|
"e2e:setup": "./scripts/e2e-setup.sh",
|
|
101
107
|
"e2e:teardown": "./scripts/e2e-teardown.sh",
|
|
108
|
+
"load:test": "node --import tsx scripts/load-test.ts",
|
|
102
109
|
"typecheck": "pnpm openapi:generate && tsc --project tsconfig.json --noEmit --incremental"
|
|
103
110
|
}
|
|
104
111
|
}
|