@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 CHANGED
@@ -1,83 +1,116 @@
1
- # Router Client
1
+ # Router
2
2
 
3
- A TypeScript client to interact with the Morpho Router.
3
+ > Status: Alpha this is under active development and interfaces/behavior are subject to change.
4
4
 
5
- ## Installation
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
- ## Usage
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
- ### Running the Local Server
25
+ # Router with postgres database and custom port
26
+ router start --db-endpoint <db url> --port 8080
14
27
 
15
- ```typescript
16
- import { RouterApi } from "@morpho-dev/router";
28
+ # Router with offers loaded from file
29
+ router start --file offers.json
17
30
 
18
- // Start a local router api on port 8081
19
- await RouterApi.serve({ port: 8081 });
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
- ### Basic Setup
35
+ <!-- AUTO-GENERATED: CLI-HELP START -->
36
+ ### CLI reference
24
37
 
25
- ```typescript
26
- import { RouterApi } from "@morpho-dev/router";
38
+ #### Global
27
39
 
28
- // Create a router client
29
- const router = RouterApi.connect();
40
+ ```text
41
+ Usage: router [options] [command]
30
42
 
31
- // With custom URL
32
- const router = RouterApi.connect({ url: "https://router.morpho.dev" });
43
+ Router package for Morpho protocol
33
44
 
34
- // Connect to local server
35
- const router = RouterApi.connect({ url: "http://localhost:8081" });
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
- ### Get Offers
39
-
40
- ```typescript
41
- // Get all offers
42
- const result = await router.get({});
43
-
44
- // Get buy offers on Ethereum mainnet
45
- const result = await router.get({ side: "buy", chains: [1], limit: 10 });
46
-
47
- // Get offers with specific filters
48
- const result = await router.get({
49
- side: "sell",
50
- chains: [1, 137],
51
- loanTokens: ["0x1234567890123456789012345678901234567890"],
52
- minAmount: 1000n,
53
- maxAmount: 10000n,
54
- minRate: 500000000000000000n,
55
- maxRate: 1500000000000000000n,
56
- sortBy: "rate",
57
- sortOrder: "asc"
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
- ### Match Offers
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 -->