@morpho-dev/router 0.0.12 → 0.0.13

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
@@ -10,6 +10,16 @@ pnpm add @morpho-dev/router
10
10
 
11
11
  ## Usage
12
12
 
13
+ ### Running the Local Server
14
+
15
+ ```typescript
16
+ import { Router } from "@morpho-dev/router";
17
+
18
+ // Start a local router server on port 8081
19
+ await Router.serve({ port: 8081 });
20
+ // Server will be available at http://localhost:8081
21
+ ```
22
+
13
23
  ### Basic Setup
14
24
 
15
25
  ```typescript
@@ -22,6 +32,11 @@ const router = Router.connect();
22
32
  const router = Router.connect({
23
33
  url: "https://router.morpho.dev"
24
34
  });
35
+
36
+ // Connect to local server
37
+ const router = Router.connect({
38
+ url: "http://localhost:8081"
39
+ });
25
40
  ```
26
41
 
27
42
  ### Get Offers
@@ -0,0 +1,37 @@
1
+ CREATE TABLE "offer_collaterals" (
2
+ "id" serial PRIMARY KEY NOT NULL,
3
+ "offer_hash" varchar(66) NOT NULL,
4
+ "asset" varchar(42) NOT NULL,
5
+ "oracle" varchar(42) NOT NULL,
6
+ "lltv" bigint NOT NULL
7
+ );
8
+ --> statement-breakpoint
9
+ CREATE TABLE "offers" (
10
+ "hash" varchar(66) PRIMARY KEY NOT NULL,
11
+ "address" varchar(42) NOT NULL,
12
+ "assets" bigint NOT NULL,
13
+ "price" bigint NOT NULL,
14
+ "maturity" integer NOT NULL,
15
+ "expiry" integer NOT NULL,
16
+ "nonce" bigint NOT NULL,
17
+ "is_buy" boolean NOT NULL,
18
+ "chain_id" bigint NOT NULL,
19
+ "loan_asset" varchar(42) NOT NULL,
20
+ "callback_address" varchar(42) NOT NULL,
21
+ "callback_data" text NOT NULL,
22
+ "callback_gas_limit" bigint NOT NULL,
23
+ "signature" varchar(132),
24
+ "created_at" timestamp DEFAULT now() NOT NULL
25
+ );
26
+ --> statement-breakpoint
27
+ ALTER TABLE "offer_collaterals" ADD CONSTRAINT "offer_collaterals_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "public"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
28
+ CREATE INDEX "offer_collaterals_offer_hash_idx" ON "offer_collaterals" USING btree ("offer_hash");--> statement-breakpoint
29
+ CREATE INDEX "offer_collaterals_asset_idx" ON "offer_collaterals" USING btree ("asset");--> statement-breakpoint
30
+ CREATE INDEX "offer_collaterals_oracle_idx" ON "offer_collaterals" USING btree ("oracle");--> statement-breakpoint
31
+ CREATE INDEX "offer_collaterals_tuple_idx" ON "offer_collaterals" USING btree ("asset","oracle","lltv");--> statement-breakpoint
32
+ CREATE INDEX "offers_address_idx" ON "offers" USING btree ("address");--> statement-breakpoint
33
+ CREATE INDEX "offers_is_buy_idx" ON "offers" USING btree ("is_buy");--> statement-breakpoint
34
+ CREATE INDEX "offers_chain_id_idx" ON "offers" USING btree ("chain_id");--> statement-breakpoint
35
+ CREATE INDEX "offers_loan_asset_idx" ON "offers" USING btree ("loan_asset");--> statement-breakpoint
36
+ CREATE INDEX "offers_maturity_idx" ON "offers" USING btree ("maturity");--> statement-breakpoint
37
+ CREATE INDEX "offers_expiry_idx" ON "offers" USING btree ("expiry");
@@ -0,0 +1,10 @@
1
+ CREATE TABLE "offer_status" (
2
+ "id" serial PRIMARY KEY NOT NULL,
3
+ "offer_hash" varchar(66) NOT NULL,
4
+ "status" text NOT NULL,
5
+ "metadata" jsonb
6
+ );
7
+ --> statement-breakpoint
8
+ ALTER TABLE "offer_status" ADD CONSTRAINT "offer_status_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "public"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
9
+ CREATE INDEX "offer_status_offer_hash_idx" ON "offer_status" USING btree ("offer_hash");--> statement-breakpoint
10
+ CREATE INDEX "offer_status_status_idx" ON "offer_status" USING btree ("status");
@@ -0,0 +1,3 @@
1
+ DROP INDEX "offer_status_offer_hash_idx";--> statement-breakpoint
2
+ ALTER TABLE "offer_status" ADD COLUMN "created_at" timestamp DEFAULT now() NOT NULL;--> statement-breakpoint
3
+ CREATE INDEX "offer_status_offer_hash_created_at_idx" ON "offer_status" USING btree ("offer_hash","created_at" desc);
@@ -0,0 +1,6 @@
1
+ CREATE INDEX "offers_price_idx" ON "offers" USING btree ("price");--> statement-breakpoint
2
+ CREATE INDEX "offers_assets_idx" ON "offers" USING btree ("assets");--> statement-breakpoint
3
+ CREATE INDEX "offers_price_hash_idx" ON "offers" USING btree ("price","hash");--> statement-breakpoint
4
+ CREATE INDEX "offers_maturity_hash_idx" ON "offers" USING btree ("maturity","hash");--> statement-breakpoint
5
+ CREATE INDEX "offers_expiry_hash_idx" ON "offers" USING btree ("expiry","hash");--> statement-breakpoint
6
+ CREATE INDEX "offers_assets_hash_idx" ON "offers" USING btree ("assets","hash");
@@ -0,0 +1 @@
1
+ ALTER TABLE "offers" ADD COLUMN "start" integer NOT NULL;
@@ -0,0 +1,8 @@
1
+ ALTER TABLE "offers" RENAME COLUMN "price" TO "rate";--> statement-breakpoint
2
+ ALTER TABLE "offers" RENAME COLUMN "loan_asset" TO "loan_token";--> statement-breakpoint
3
+ DROP INDEX "offers_loan_asset_idx";--> statement-breakpoint
4
+ DROP INDEX "offers_price_idx";--> statement-breakpoint
5
+ DROP INDEX "offers_price_hash_idx";--> statement-breakpoint
6
+ CREATE INDEX "offers_loan_token_idx" ON "offers" USING btree ("loan_token");--> statement-breakpoint
7
+ CREATE INDEX "offers_rate_idx" ON "offers" USING btree ("rate");--> statement-breakpoint
8
+ CREATE INDEX "offers_rate_hash_idx" ON "offers" USING btree ("rate","hash");
@@ -0,0 +1,3 @@
1
+ ALTER TABLE "offers" RENAME COLUMN "is_buy" TO "buy";--> statement-breakpoint
2
+ DROP INDEX "offers_is_buy_idx";--> statement-breakpoint
3
+ CREATE INDEX "offers_buy_idx" ON "offers" USING btree ("buy");
@@ -0,0 +1,3 @@
1
+ ALTER TABLE "offers" RENAME COLUMN "address" TO "offering";--> statement-breakpoint
2
+ DROP INDEX "offers_address_idx";--> statement-breakpoint
3
+ CREATE INDEX "offers_offering_idx" ON "offers" USING btree ("offering");
@@ -0,0 +1,344 @@
1
+ {
2
+ "id": "5633b428-6ca8-4994-95c9-4f8f6f320d95",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.offer_collaterals": {
8
+ "name": "offer_collaterals",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "serial",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "offer_hash": {
18
+ "name": "offer_hash",
19
+ "type": "varchar(66)",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "asset": {
24
+ "name": "asset",
25
+ "type": "varchar(42)",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "oracle": {
30
+ "name": "oracle",
31
+ "type": "varchar(42)",
32
+ "primaryKey": false,
33
+ "notNull": true
34
+ },
35
+ "lltv": {
36
+ "name": "lltv",
37
+ "type": "bigint",
38
+ "primaryKey": false,
39
+ "notNull": true
40
+ }
41
+ },
42
+ "indexes": {
43
+ "offer_collaterals_offer_hash_idx": {
44
+ "name": "offer_collaterals_offer_hash_idx",
45
+ "columns": [
46
+ {
47
+ "expression": "offer_hash",
48
+ "isExpression": false,
49
+ "asc": true,
50
+ "nulls": "last"
51
+ }
52
+ ],
53
+ "isUnique": false,
54
+ "concurrently": false,
55
+ "method": "btree",
56
+ "with": {}
57
+ },
58
+ "offer_collaterals_asset_idx": {
59
+ "name": "offer_collaterals_asset_idx",
60
+ "columns": [
61
+ {
62
+ "expression": "asset",
63
+ "isExpression": false,
64
+ "asc": true,
65
+ "nulls": "last"
66
+ }
67
+ ],
68
+ "isUnique": false,
69
+ "concurrently": false,
70
+ "method": "btree",
71
+ "with": {}
72
+ },
73
+ "offer_collaterals_oracle_idx": {
74
+ "name": "offer_collaterals_oracle_idx",
75
+ "columns": [
76
+ {
77
+ "expression": "oracle",
78
+ "isExpression": false,
79
+ "asc": true,
80
+ "nulls": "last"
81
+ }
82
+ ],
83
+ "isUnique": false,
84
+ "concurrently": false,
85
+ "method": "btree",
86
+ "with": {}
87
+ },
88
+ "offer_collaterals_tuple_idx": {
89
+ "name": "offer_collaterals_tuple_idx",
90
+ "columns": [
91
+ {
92
+ "expression": "asset",
93
+ "isExpression": false,
94
+ "asc": true,
95
+ "nulls": "last"
96
+ },
97
+ {
98
+ "expression": "oracle",
99
+ "isExpression": false,
100
+ "asc": true,
101
+ "nulls": "last"
102
+ },
103
+ {
104
+ "expression": "lltv",
105
+ "isExpression": false,
106
+ "asc": true,
107
+ "nulls": "last"
108
+ }
109
+ ],
110
+ "isUnique": false,
111
+ "concurrently": false,
112
+ "method": "btree",
113
+ "with": {}
114
+ }
115
+ },
116
+ "foreignKeys": {
117
+ "offer_collaterals_offer_hash_offers_hash_fk": {
118
+ "name": "offer_collaterals_offer_hash_offers_hash_fk",
119
+ "tableFrom": "offer_collaterals",
120
+ "tableTo": "offers",
121
+ "columnsFrom": [
122
+ "offer_hash"
123
+ ],
124
+ "columnsTo": [
125
+ "hash"
126
+ ],
127
+ "onDelete": "cascade",
128
+ "onUpdate": "no action"
129
+ }
130
+ },
131
+ "compositePrimaryKeys": {},
132
+ "uniqueConstraints": {},
133
+ "policies": {},
134
+ "checkConstraints": {},
135
+ "isRLSEnabled": false
136
+ },
137
+ "public.offers": {
138
+ "name": "offers",
139
+ "schema": "",
140
+ "columns": {
141
+ "hash": {
142
+ "name": "hash",
143
+ "type": "varchar(66)",
144
+ "primaryKey": true,
145
+ "notNull": true
146
+ },
147
+ "address": {
148
+ "name": "address",
149
+ "type": "varchar(42)",
150
+ "primaryKey": false,
151
+ "notNull": true
152
+ },
153
+ "assets": {
154
+ "name": "assets",
155
+ "type": "bigint",
156
+ "primaryKey": false,
157
+ "notNull": true
158
+ },
159
+ "price": {
160
+ "name": "price",
161
+ "type": "bigint",
162
+ "primaryKey": false,
163
+ "notNull": true
164
+ },
165
+ "maturity": {
166
+ "name": "maturity",
167
+ "type": "integer",
168
+ "primaryKey": false,
169
+ "notNull": true
170
+ },
171
+ "expiry": {
172
+ "name": "expiry",
173
+ "type": "integer",
174
+ "primaryKey": false,
175
+ "notNull": true
176
+ },
177
+ "nonce": {
178
+ "name": "nonce",
179
+ "type": "bigint",
180
+ "primaryKey": false,
181
+ "notNull": true
182
+ },
183
+ "is_buy": {
184
+ "name": "is_buy",
185
+ "type": "boolean",
186
+ "primaryKey": false,
187
+ "notNull": true
188
+ },
189
+ "chain_id": {
190
+ "name": "chain_id",
191
+ "type": "bigint",
192
+ "primaryKey": false,
193
+ "notNull": true
194
+ },
195
+ "loan_asset": {
196
+ "name": "loan_asset",
197
+ "type": "varchar(42)",
198
+ "primaryKey": false,
199
+ "notNull": true
200
+ },
201
+ "callback_address": {
202
+ "name": "callback_address",
203
+ "type": "varchar(42)",
204
+ "primaryKey": false,
205
+ "notNull": true
206
+ },
207
+ "callback_data": {
208
+ "name": "callback_data",
209
+ "type": "text",
210
+ "primaryKey": false,
211
+ "notNull": true
212
+ },
213
+ "callback_gas_limit": {
214
+ "name": "callback_gas_limit",
215
+ "type": "bigint",
216
+ "primaryKey": false,
217
+ "notNull": true
218
+ },
219
+ "signature": {
220
+ "name": "signature",
221
+ "type": "varchar(132)",
222
+ "primaryKey": false,
223
+ "notNull": false
224
+ },
225
+ "created_at": {
226
+ "name": "created_at",
227
+ "type": "timestamp",
228
+ "primaryKey": false,
229
+ "notNull": true,
230
+ "default": "now()"
231
+ }
232
+ },
233
+ "indexes": {
234
+ "offers_address_idx": {
235
+ "name": "offers_address_idx",
236
+ "columns": [
237
+ {
238
+ "expression": "address",
239
+ "isExpression": false,
240
+ "asc": true,
241
+ "nulls": "last"
242
+ }
243
+ ],
244
+ "isUnique": false,
245
+ "concurrently": false,
246
+ "method": "btree",
247
+ "with": {}
248
+ },
249
+ "offers_is_buy_idx": {
250
+ "name": "offers_is_buy_idx",
251
+ "columns": [
252
+ {
253
+ "expression": "is_buy",
254
+ "isExpression": false,
255
+ "asc": true,
256
+ "nulls": "last"
257
+ }
258
+ ],
259
+ "isUnique": false,
260
+ "concurrently": false,
261
+ "method": "btree",
262
+ "with": {}
263
+ },
264
+ "offers_chain_id_idx": {
265
+ "name": "offers_chain_id_idx",
266
+ "columns": [
267
+ {
268
+ "expression": "chain_id",
269
+ "isExpression": false,
270
+ "asc": true,
271
+ "nulls": "last"
272
+ }
273
+ ],
274
+ "isUnique": false,
275
+ "concurrently": false,
276
+ "method": "btree",
277
+ "with": {}
278
+ },
279
+ "offers_loan_asset_idx": {
280
+ "name": "offers_loan_asset_idx",
281
+ "columns": [
282
+ {
283
+ "expression": "loan_asset",
284
+ "isExpression": false,
285
+ "asc": true,
286
+ "nulls": "last"
287
+ }
288
+ ],
289
+ "isUnique": false,
290
+ "concurrently": false,
291
+ "method": "btree",
292
+ "with": {}
293
+ },
294
+ "offers_maturity_idx": {
295
+ "name": "offers_maturity_idx",
296
+ "columns": [
297
+ {
298
+ "expression": "maturity",
299
+ "isExpression": false,
300
+ "asc": true,
301
+ "nulls": "last"
302
+ }
303
+ ],
304
+ "isUnique": false,
305
+ "concurrently": false,
306
+ "method": "btree",
307
+ "with": {}
308
+ },
309
+ "offers_expiry_idx": {
310
+ "name": "offers_expiry_idx",
311
+ "columns": [
312
+ {
313
+ "expression": "expiry",
314
+ "isExpression": false,
315
+ "asc": true,
316
+ "nulls": "last"
317
+ }
318
+ ],
319
+ "isUnique": false,
320
+ "concurrently": false,
321
+ "method": "btree",
322
+ "with": {}
323
+ }
324
+ },
325
+ "foreignKeys": {},
326
+ "compositePrimaryKeys": {},
327
+ "uniqueConstraints": {},
328
+ "policies": {},
329
+ "checkConstraints": {},
330
+ "isRLSEnabled": false
331
+ }
332
+ },
333
+ "enums": {},
334
+ "schemas": {},
335
+ "sequences": {},
336
+ "roles": {},
337
+ "policies": {},
338
+ "views": {},
339
+ "_meta": {
340
+ "columns": {},
341
+ "schemas": {},
342
+ "tables": {}
343
+ }
344
+ }