@morpho-dev/router 0.1.12 → 0.1.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/README.md +97 -64
- package/dist/cli.js +6041 -0
- package/dist/cli.js.map +1 -0
- package/dist/drizzle/router_v1.4/0000_add_obligation_id.sql +112 -0
- package/dist/drizzle/router_v1.4/0001_update-primary-key-on-link.sql +3 -0
- package/dist/drizzle/{router_v1.1 → router_v1.4}/meta/0000_snapshot.json +305 -265
- package/dist/drizzle/router_v1.4/meta/0001_snapshot.json +972 -0
- package/dist/drizzle/router_v1.4/meta/_journal.json +20 -0
- package/dist/index.browser.d.cts +1384 -603
- package/dist/index.browser.d.ts +1384 -603
- package/dist/index.browser.js +2103 -1343
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +2054 -1322
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +2380 -1328
- package/dist/index.node.d.ts +2380 -1328
- package/dist/index.node.js +5744 -3514
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +5703 -3513
- package/dist/index.node.mjs.map +1 -1
- package/package.json +20 -16
- package/dist/drizzle/router_v1.1/0000_init.sql +0 -103
- package/dist/drizzle/router_v1.1/meta/_journal.json +0 -13
package/README.md
CHANGED
|
@@ -1,83 +1,116 @@
|
|
|
1
|
-
# Router
|
|
1
|
+
# Router
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Status: Alpha – this is under active development and interfaces/behavior are subject to change.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## CLI
|
|
6
|
+
|
|
7
|
+
CLI install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
pnpm add @morpho-dev/router
|
|
10
|
+
pnpm add -g @morpho-dev/router
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
- Router starts on http://localhost:7891 by default
|
|
14
|
+
- Seed random offers with --seed <n> for testing
|
|
15
|
+
- Load offers from JSON file with --file <path>
|
|
16
|
+
- Start services using --services indexer,api
|
|
17
|
+
- --db-endpoint plugs the router on top of a postgres instance
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Router with seeded random offers
|
|
23
|
+
router start --seed 100
|
|
12
24
|
|
|
13
|
-
|
|
25
|
+
# Router with postgres database and custom port
|
|
26
|
+
router start --db-endpoint <db url> --port 8080
|
|
14
27
|
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
# Router with offers loaded from file
|
|
29
|
+
router start --file offers.json
|
|
17
30
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// Server will be available at http://localhost:8081
|
|
31
|
+
# Start Router indexer (Default indexer,api)
|
|
32
|
+
router start --services indexer
|
|
21
33
|
```
|
|
22
34
|
|
|
23
|
-
|
|
35
|
+
<!-- AUTO-GENERATED: CLI-HELP START -->
|
|
36
|
+
### CLI reference
|
|
24
37
|
|
|
25
|
-
|
|
26
|
-
import { RouterApi } from "@morpho-dev/router";
|
|
38
|
+
#### Global
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
```text
|
|
41
|
+
Usage: router [options] [command]
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
const router = RouterApi.connect({ url: "https://router.morpho.dev" });
|
|
43
|
+
Router package for Morpho protocol
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
Options:
|
|
46
|
+
-V, --version output the version number
|
|
47
|
+
-h, --help display help for command
|
|
48
|
+
|
|
49
|
+
Commands:
|
|
50
|
+
start [options] Start Router services.
|
|
51
|
+
tunnel [options] Expose the local Router via ngrok
|
|
52
|
+
mempool [options] Start a local chain with the mempool contract
|
|
53
|
+
help [command] display help for command
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### start
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
Usage: router start [options]
|
|
60
|
+
|
|
61
|
+
Start Router services.
|
|
62
|
+
|
|
63
|
+
Options:
|
|
64
|
+
--port <n> (default: 7891, env: ROUTER_PORT)
|
|
65
|
+
--chain <chain> (choices: "ethereum", "base",
|
|
66
|
+
"ethereum-virtual-testnet", "anvil", default:
|
|
67
|
+
"ethereum", env: ROUTER_CHAIN)
|
|
68
|
+
--rpc-url <url> (env: ROUTER_RPC_URL)
|
|
69
|
+
--router-url <url> (default: "https://router.morpho.dev", env:
|
|
70
|
+
ROUTER_REMOTE_URL)
|
|
71
|
+
--store <type> (choices: "pglite", "pg", default: "pglite", env:
|
|
72
|
+
ROUTER_STORE)
|
|
73
|
+
--db-endpoint <url> (env: ROUTER_DB_ENDPOINT)
|
|
74
|
+
--log-level <level> (choices: "trace", "debug", "info", "warn", "error",
|
|
75
|
+
"fatal", "silent", default: "info", env:
|
|
76
|
+
ROUTER_LOG_LEVEL)
|
|
77
|
+
--log-pretty Enable pretty logs (default: true, env:
|
|
78
|
+
ROUTER_LOG_PRETTY)
|
|
79
|
+
--block-window <n> Block window to get logs from (default: 100)
|
|
80
|
+
--seed <n> Seed random offers to router (default: 0)
|
|
81
|
+
--file <path> Seed offers from a JSON file
|
|
82
|
+
--max-block-number <n> Block number at which to stop indexing
|
|
83
|
+
--services <list> Comma-separated services to run. Default: api,indexer
|
|
84
|
+
(default: ["indexer","api"], env: ROUTER_SERVICES)
|
|
85
|
+
-h, --help display help for command
|
|
36
86
|
```
|
|
37
87
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
88
|
+
#### tunnel
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
Usage: router tunnel [options]
|
|
92
|
+
|
|
93
|
+
Expose the local Router via ngrok
|
|
94
|
+
|
|
95
|
+
Options:
|
|
96
|
+
--port <n> (default: 7891, env: ROUTER_PORT)
|
|
97
|
+
--ngrok-authtoken <token> (env: NGROK_AUTHTOKEN)
|
|
98
|
+
-h, --help display help for command
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### mempool
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
Usage: router mempool [options]
|
|
105
|
+
|
|
106
|
+
Start a local chain with the mempool contract
|
|
107
|
+
|
|
108
|
+
Options:
|
|
109
|
+
--port <port> (default: 8545, env: MEMPOOL_PORT)
|
|
110
|
+
--fork-url <url> (default: "https://ethereum-rpc.publicnode.com",
|
|
111
|
+
env: MEMPOOL_FORK_URL)
|
|
112
|
+
--block-number <number> (default: 0)
|
|
113
|
+
-h, --help display help for command
|
|
59
114
|
```
|
|
60
115
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
// Match offers for buy on Ethereum mainnet
|
|
65
|
-
const result = await router.match({ side: "buy", chainId: 1 });
|
|
66
|
-
|
|
67
|
-
// Match with specific requirements
|
|
68
|
-
const result = await router.match({
|
|
69
|
-
side: "sell",
|
|
70
|
-
chainId: 1,
|
|
71
|
-
rate: 1000000000000000000n,
|
|
72
|
-
loanToken: "0x1234567890123456789012345678901234567890",
|
|
73
|
-
collaterals: [
|
|
74
|
-
{
|
|
75
|
-
asset: "0x1234567890123456789012345678901234567890",
|
|
76
|
-
oracle: "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
|
|
77
|
-
lltv: 800000000000000000n
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
minMaturity: 1700000000,
|
|
81
|
-
maxMaturity: 1800000000
|
|
82
|
-
});
|
|
83
|
-
```
|
|
116
|
+
<!-- AUTO-GENERATED: CLI-HELP END -->
|