@morpho-dev/router 0.11.0 → 0.12.1

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.
Files changed (48) hide show
  1. package/README.md +20 -5
  2. package/dist/cli.js +12198 -6809
  3. package/dist/drizzle/migrations/0034_chain-checkpoints.sql +1 -0
  4. package/dist/drizzle/migrations/0035_chain-tip-hash-cas.sql +1 -0
  5. package/dist/drizzle/migrations/0036_pending-links.sql +22 -0
  6. package/dist/drizzle/migrations/0037_chain-finalized-anchor.sql +2 -0
  7. package/dist/drizzle/migrations/0038_add-obligation-rcf-threshold.sql +2 -0
  8. package/dist/drizzle/migrations/0039_add-offers-composite-indexes.sql +2 -0
  9. package/dist/drizzle/migrations/0040_drop-redundant-offers-indexes.sql +2 -0
  10. package/dist/drizzle/migrations/0041_add-group-winner-expression-index.sql +10 -0
  11. package/dist/drizzle/migrations/0042_contract-sync-v1.14.sql +284 -0
  12. package/dist/drizzle/migrations/0043_add-obligation-side-tick-index.sql +1 -0
  13. package/dist/drizzle/migrations/0044_index-audit-cleanup.sql +27 -0
  14. package/dist/drizzle/migrations/0045_add-lots-offsets-availability-indexes.sql +5 -0
  15. package/dist/drizzle/migrations/0046_add-offers-active-tick-index.sql +1 -0
  16. package/dist/drizzle/migrations/0047_add-offers-book-winners-index.sql +1 -0
  17. package/dist/drizzle/migrations/0048_covering-indexes-for-winners-queries.sql +34 -0
  18. package/dist/drizzle/migrations/0049_contract-sync-v1.15.sql +305 -0
  19. package/dist/drizzle/migrations/0050_contract-sync-v1.16.sql +305 -0
  20. package/dist/drizzle/migrations/meta/0036_snapshot.json +1864 -0
  21. package/dist/drizzle/migrations/meta/0037_snapshot.json +1876 -0
  22. package/dist/drizzle/migrations/meta/0038_snapshot.json +1882 -0
  23. package/dist/drizzle/migrations/meta/0039_snapshot.json +1960 -0
  24. package/dist/drizzle/migrations/meta/0040_snapshot.json +1912 -0
  25. package/dist/drizzle/migrations/meta/0041_snapshot.json +1912 -0
  26. package/dist/drizzle/migrations/meta/0042_snapshot.json +1882 -0
  27. package/dist/drizzle/migrations/meta/0043_snapshot.json +1909 -0
  28. package/dist/drizzle/migrations/meta/0044_snapshot.json +1853 -0
  29. package/dist/drizzle/migrations/meta/0045_snapshot.json +1921 -0
  30. package/dist/drizzle/migrations/meta/0046_snapshot.json +1966 -0
  31. package/dist/drizzle/migrations/meta/0047_snapshot.json +2005 -0
  32. package/dist/drizzle/migrations/meta/0048_snapshot.json +2035 -0
  33. package/dist/drizzle/migrations/meta/0049_snapshot.json +2035 -0
  34. package/dist/drizzle/migrations/meta/0050_snapshot.json +2035 -0
  35. package/dist/drizzle/migrations/meta/_journal.json +119 -0
  36. package/dist/evm/bytecode/morpho.txt +1 -1
  37. package/dist/index.browser.d.mts +611 -282
  38. package/dist/index.browser.d.mts.map +1 -1
  39. package/dist/index.browser.mjs +735 -448
  40. package/dist/index.browser.mjs.map +1 -1
  41. package/dist/index.node.d.mts +1525 -614
  42. package/dist/index.node.d.mts.map +1 -1
  43. package/dist/index.node.mjs +9493 -5238
  44. package/dist/index.node.mjs.map +1 -1
  45. package/dist/server-DNFuP89-.js +9573 -0
  46. package/dist/server.js +9617 -0
  47. package/docs/integrator.md +14 -24
  48. package/package.json +7 -4
@@ -0,0 +1,305 @@
1
+ CREATE TYPE "router_v1.15"."callback_type" AS ENUM('empty');--> statement-breakpoint
2
+ CREATE TYPE "router_v1.15"."position_type" AS ENUM('erc20', 'vault_v1', 'debtOf', 'collateralOf');--> statement-breakpoint
3
+ CREATE TYPE "router_v1.15"."status_code" AS ENUM('VALID', 'SIMULATION_ERROR');--> statement-breakpoint
4
+ CREATE TABLE "router_v1.15"."callbacks" (
5
+ "id" varchar(66) PRIMARY KEY NOT NULL,
6
+ "position_chain_id" bigint NOT NULL,
7
+ "position_contract" varchar(66) NOT NULL,
8
+ "position_user" varchar(42) NOT NULL,
9
+ "position_type_id" integer NOT NULL,
10
+ "type" "router_v1.15"."callback_type" NOT NULL
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE TABLE "router_v1.15"."chains" (
14
+ "chain_id" bigint NOT NULL,
15
+ "block_number" bigint NOT NULL,
16
+ "epoch" numeric(78, 0) DEFAULT '0' NOT NULL,
17
+ "checkpoints" text DEFAULT '[]' NOT NULL,
18
+ "tip_hash" text,
19
+ "finalized_block_number" bigint,
20
+ "finalized_block_hash" text,
21
+ "updated_at" timestamp DEFAULT now() NOT NULL
22
+ );
23
+ --> statement-breakpoint
24
+ CREATE TABLE "router_v1.15"."collectors" (
25
+ "chain_id" bigint NOT NULL,
26
+ "name" text NOT NULL,
27
+ "block_number" bigint NOT NULL,
28
+ "epoch" numeric(78, 0) DEFAULT '0' NOT NULL,
29
+ "updated_at" timestamp DEFAULT now() NOT NULL
30
+ );
31
+ --> statement-breakpoint
32
+ CREATE TABLE "router_v1.15"."consumed_events" (
33
+ "event_id" varchar(128) PRIMARY KEY NOT NULL,
34
+ "chain_id" bigint NOT NULL,
35
+ "maker" varchar(42) NOT NULL,
36
+ "group" varchar(66) NOT NULL,
37
+ "amount" numeric(78, 0) NOT NULL,
38
+ "block_number" bigint NOT NULL,
39
+ "created_at" timestamp DEFAULT now() NOT NULL
40
+ );
41
+ --> statement-breakpoint
42
+ CREATE TABLE "router_v1.15"."groups" (
43
+ "chain_id" bigint NOT NULL,
44
+ "maker" varchar(42) NOT NULL,
45
+ "group" varchar(66) NOT NULL,
46
+ "consumed" numeric(78, 0) NOT NULL,
47
+ "block_number" bigint NOT NULL,
48
+ "updated_at" timestamp DEFAULT now() NOT NULL,
49
+ CONSTRAINT "groups_pk" PRIMARY KEY("chain_id","maker","group")
50
+ );
51
+ --> statement-breakpoint
52
+ CREATE TABLE "router_v1.15"."lots" (
53
+ "chain_id" bigint NOT NULL,
54
+ "user" varchar(42) NOT NULL,
55
+ "contract" varchar(66) NOT NULL,
56
+ "group" varchar(66) NOT NULL,
57
+ "obligation_id" varchar(66) NOT NULL,
58
+ "lower" numeric(78, 0) NOT NULL,
59
+ "upper" numeric(78, 0) NOT NULL,
60
+ CONSTRAINT "lots_pk" PRIMARY KEY("chain_id","user","contract","group","obligation_id")
61
+ );
62
+ --> statement-breakpoint
63
+ CREATE TABLE "router_v1.15"."lots_positions" (
64
+ "chain_id" bigint NOT NULL,
65
+ "contract" varchar(66) NOT NULL,
66
+ "user" varchar(42) NOT NULL,
67
+ "position_type_id" integer NOT NULL,
68
+ CONSTRAINT "lots_positions_pk" PRIMARY KEY("chain_id","contract","user")
69
+ );
70
+ --> statement-breakpoint
71
+ CREATE TABLE "router_v1.15"."merkle_paths" (
72
+ "offer_hash" varchar(66) NOT NULL,
73
+ "obligation_id" varchar(66) NOT NULL,
74
+ "tree_root" varchar(66) NOT NULL,
75
+ "proof_nodes" text NOT NULL,
76
+ "created_at" timestamp DEFAULT now() NOT NULL,
77
+ CONSTRAINT "merkle_paths_pk" PRIMARY KEY("offer_hash","obligation_id")
78
+ );
79
+ --> statement-breakpoint
80
+ CREATE TABLE "router_v1.15"."obligation_collaterals_v2" (
81
+ "obligation_key" varchar(66) NOT NULL,
82
+ "asset" varchar(42) NOT NULL,
83
+ "oracle_address" varchar(42) NOT NULL,
84
+ "lltv" bigint NOT NULL,
85
+ "max_lif" bigint NOT NULL,
86
+ "collateral_index" integer NOT NULL,
87
+ "updated_at" timestamp DEFAULT now() NOT NULL,
88
+ CONSTRAINT "obligation_collaterals_v2_pk" PRIMARY KEY("obligation_key","asset")
89
+ );
90
+ --> statement-breakpoint
91
+ CREATE TABLE "router_v1.15"."obligation_id_keys" (
92
+ "obligation_id" varchar(66) PRIMARY KEY NOT NULL,
93
+ "obligation_key" varchar(66) NOT NULL,
94
+ "chain_id" bigint NOT NULL,
95
+ "morpho_v2" varchar(42) NOT NULL
96
+ );
97
+ --> statement-breakpoint
98
+ CREATE TABLE "router_v1.15"."obligations" (
99
+ "obligation_key" varchar(66) PRIMARY KEY NOT NULL,
100
+ "loan_token" varchar(42) NOT NULL,
101
+ "maturity" integer NOT NULL,
102
+ "rcf_threshold" numeric(78, 0) NOT NULL
103
+ );
104
+ --> statement-breakpoint
105
+ CREATE TABLE "router_v1.15"."offers" (
106
+ "hash" varchar(66) NOT NULL,
107
+ "obligation_id" varchar(66) NOT NULL,
108
+ "obligation_units" numeric(78, 0) DEFAULT '0' NOT NULL,
109
+ "tick" integer NOT NULL,
110
+ "maturity" integer NOT NULL,
111
+ "expiry" integer NOT NULL,
112
+ "start" integer NOT NULL,
113
+ "group_chain_id" bigint NOT NULL,
114
+ "group_maker" varchar(42) NOT NULL,
115
+ "group_group" varchar(66) NOT NULL,
116
+ "session" varchar(66) NOT NULL,
117
+ "buy" boolean NOT NULL,
118
+ "callback_address" varchar(42) NOT NULL,
119
+ "callback_data" text NOT NULL,
120
+ "receiver_if_maker_is_seller" varchar(42),
121
+ "exit_only" boolean DEFAULT false NOT NULL,
122
+ "block_number" bigint NOT NULL,
123
+ "updated_at" timestamp DEFAULT now() NOT NULL,
124
+ CONSTRAINT "offers_pk" PRIMARY KEY("hash","obligation_id")
125
+ );
126
+ --> statement-breakpoint
127
+ CREATE TABLE "router_v1.15"."offers_callbacks" (
128
+ "offer_hash" varchar(66) NOT NULL,
129
+ "obligation_id" varchar(66) NOT NULL,
130
+ "callback_id" varchar(66),
131
+ CONSTRAINT "offers_callbacks_pk" PRIMARY KEY("offer_hash","obligation_id","callback_id")
132
+ );
133
+ --> statement-breakpoint
134
+ CREATE TABLE "router_v1.15"."offsets" (
135
+ "chain_id" bigint NOT NULL,
136
+ "user" varchar(42) NOT NULL,
137
+ "contract" varchar(66) NOT NULL,
138
+ "group" varchar(66) NOT NULL,
139
+ "obligation_id" varchar(66) NOT NULL,
140
+ "value" numeric(78, 0) NOT NULL,
141
+ CONSTRAINT "offsets_pk" PRIMARY KEY("chain_id","user","contract","group","obligation_id")
142
+ );
143
+ --> statement-breakpoint
144
+ CREATE TABLE "router_v1.15"."oracles" (
145
+ "chain_id" bigint NOT NULL,
146
+ "address" varchar(42) NOT NULL,
147
+ "price" numeric(78, 0),
148
+ "block_number" bigint NOT NULL,
149
+ "updated_at" timestamp DEFAULT now() NOT NULL,
150
+ CONSTRAINT "oracles_pk" PRIMARY KEY("chain_id","address")
151
+ );
152
+ --> statement-breakpoint
153
+ CREATE TABLE "router_v1.15"."pending_links" (
154
+ "key" varchar(191) PRIMARY KEY NOT NULL,
155
+ "type" text NOT NULL,
156
+ "status" text NOT NULL,
157
+ "chain_id" bigint NOT NULL,
158
+ "event_id" varchar(128) NOT NULL,
159
+ "obligation_id" varchar(66) NOT NULL,
160
+ "collateral_index" integer NOT NULL,
161
+ "user" varchar(42) NOT NULL,
162
+ "amount" numeric(78, 0) NOT NULL,
163
+ "block_number" bigint NOT NULL,
164
+ "first_seen_block" bigint NOT NULL,
165
+ "last_tried_block" bigint,
166
+ "attempts" integer DEFAULT 0 NOT NULL,
167
+ "ignored_reason" text,
168
+ "resolved_at" timestamp,
169
+ "updated_at" timestamp DEFAULT now() NOT NULL
170
+ );
171
+ --> statement-breakpoint
172
+ CREATE TABLE "router_v1.15"."position_types" (
173
+ "id" serial PRIMARY KEY NOT NULL,
174
+ "type" "router_v1.15"."position_type" NOT NULL
175
+ );
176
+ --> statement-breakpoint
177
+ CREATE TABLE "router_v1.15"."positions" (
178
+ "chain_id" bigint NOT NULL,
179
+ "contract" varchar(66) NOT NULL,
180
+ "user" varchar(42) NOT NULL,
181
+ "position_type_id" integer NOT NULL,
182
+ "balance" numeric(78, 0),
183
+ "asset" varchar(42) NOT NULL,
184
+ "block_number" bigint NOT NULL,
185
+ "updated_at" timestamp DEFAULT now() NOT NULL,
186
+ CONSTRAINT "positions_pk" PRIMARY KEY("chain_id","contract","user","position_type_id","asset")
187
+ );
188
+ --> statement-breakpoint
189
+ CREATE TABLE "router_v1.15"."status" (
190
+ "id" serial PRIMARY KEY NOT NULL,
191
+ "code" "router_v1.15"."status_code",
192
+ CONSTRAINT "status_code_unique" UNIQUE("code")
193
+ );
194
+ --> statement-breakpoint
195
+ CREATE TABLE "router_v1.15"."transfers" (
196
+ "event_id" varchar(128) PRIMARY KEY NOT NULL,
197
+ "chain_id" bigint NOT NULL,
198
+ "contract" varchar(66) NOT NULL,
199
+ "from" varchar(42) NOT NULL,
200
+ "to" varchar(42) NOT NULL,
201
+ "value" numeric(78, 0) NOT NULL,
202
+ "position_type_id" integer NOT NULL,
203
+ "asset" varchar(42) NOT NULL,
204
+ "block_number" bigint NOT NULL,
205
+ "created_at" timestamp DEFAULT now() NOT NULL
206
+ );
207
+ --> statement-breakpoint
208
+ CREATE TABLE "router_v1.15"."trees" (
209
+ "root" varchar(66) PRIMARY KEY NOT NULL,
210
+ "root_signature" varchar(132) NOT NULL,
211
+ "created_at" timestamp DEFAULT now() NOT NULL
212
+ );
213
+ --> statement-breakpoint
214
+ CREATE TABLE "router_v1.15"."validations" (
215
+ "offer_hash" varchar(66) NOT NULL,
216
+ "obligation_id" varchar(66) NOT NULL,
217
+ "status_id" integer NOT NULL,
218
+ "updated_at" timestamp DEFAULT now() NOT NULL,
219
+ CONSTRAINT "validations_pk" PRIMARY KEY("offer_hash","obligation_id")
220
+ );
221
+ --> statement-breakpoint
222
+ CREATE UNIQUE INDEX "chains_chain_id_idx" ON "router_v1.15"."chains" USING btree ("chain_id");--> statement-breakpoint
223
+ CREATE UNIQUE INDEX "collectors_chain_name_idx" ON "router_v1.15"."collectors" USING btree ("chain_id","name");--> statement-breakpoint
224
+ DROP TABLE "router_v1.14"."callbacks" CASCADE;--> statement-breakpoint
225
+ DROP TABLE "router_v1.14"."chains" CASCADE;--> statement-breakpoint
226
+ DROP TABLE "router_v1.14"."collectors" CASCADE;--> statement-breakpoint
227
+ DROP TABLE "router_v1.14"."consumed_events" CASCADE;--> statement-breakpoint
228
+ DROP TABLE "router_v1.14"."groups" CASCADE;--> statement-breakpoint
229
+ DROP TABLE "router_v1.14"."lots" CASCADE;--> statement-breakpoint
230
+ DROP TABLE "router_v1.14"."lots_positions" CASCADE;--> statement-breakpoint
231
+ DROP TABLE "router_v1.14"."merkle_paths" CASCADE;--> statement-breakpoint
232
+ DROP TABLE "router_v1.14"."obligation_collaterals_v2" CASCADE;--> statement-breakpoint
233
+ DROP TABLE "router_v1.14"."obligation_id_keys" CASCADE;--> statement-breakpoint
234
+ DROP TABLE "router_v1.14"."obligations" CASCADE;--> statement-breakpoint
235
+ DROP TABLE "router_v1.14"."offers" CASCADE;--> statement-breakpoint
236
+ DROP TABLE "router_v1.14"."offers_callbacks" CASCADE;--> statement-breakpoint
237
+ DROP TABLE "router_v1.14"."offsets" CASCADE;--> statement-breakpoint
238
+ DROP TABLE "router_v1.14"."oracles" CASCADE;--> statement-breakpoint
239
+ DROP TABLE "router_v1.14"."pending_links" CASCADE;--> statement-breakpoint
240
+ DROP TABLE "router_v1.14"."position_types" CASCADE;--> statement-breakpoint
241
+ DROP TABLE "router_v1.14"."positions" CASCADE;--> statement-breakpoint
242
+ DROP TABLE "router_v1.14"."status" CASCADE;--> statement-breakpoint
243
+ DROP TABLE "router_v1.14"."transfers" CASCADE;--> statement-breakpoint
244
+ DROP TABLE "router_v1.14"."trees" CASCADE;--> statement-breakpoint
245
+ DROP TABLE "router_v1.14"."validations" CASCADE;--> statement-breakpoint
246
+ ALTER TABLE "router_v1.15"."callbacks" ADD CONSTRAINT "callbacks_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.15"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
247
+ ALTER TABLE "router_v1.15"."collectors" ADD CONSTRAINT "collectors_chain_id_chains_chain_id_fk" FOREIGN KEY ("chain_id") REFERENCES "router_v1.15"."chains"("chain_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
248
+ ALTER TABLE "router_v1.15"."consumed_events" ADD CONSTRAINT "consumed_events_groups_fk" FOREIGN KEY ("chain_id","maker","group") REFERENCES "router_v1.15"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
249
+ ALTER TABLE "router_v1.15"."lots" ADD CONSTRAINT "lots_lots_positions_fk" FOREIGN KEY ("chain_id","contract","user") REFERENCES "router_v1.15"."lots_positions"("chain_id","contract","user") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
250
+ ALTER TABLE "router_v1.15"."lots" ADD CONSTRAINT "lots_groups_fk" FOREIGN KEY ("chain_id","user","group") REFERENCES "router_v1.15"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
251
+ ALTER TABLE "router_v1.15"."lots_positions" ADD CONSTRAINT "lots_positions_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.15"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
252
+ ALTER TABLE "router_v1.15"."merkle_paths" ADD CONSTRAINT "merkle_paths_tree_root_trees_root_fk" FOREIGN KEY ("tree_root") REFERENCES "router_v1.15"."trees"("root") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
253
+ ALTER TABLE "router_v1.15"."merkle_paths" ADD CONSTRAINT "merkle_paths_offer_fk" FOREIGN KEY ("offer_hash","obligation_id") REFERENCES "router_v1.15"."offers"("hash","obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
254
+ ALTER TABLE "router_v1.15"."obligation_collaterals_v2" ADD CONSTRAINT "obligation_collaterals_v2_obligation_key_obligations_obligation_key_fk" FOREIGN KEY ("obligation_key") REFERENCES "router_v1.15"."obligations"("obligation_key") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
255
+ ALTER TABLE "router_v1.15"."obligation_id_keys" ADD CONSTRAINT "obligation_id_keys_obligation_key_obligations_obligation_key_fk" FOREIGN KEY ("obligation_key") REFERENCES "router_v1.15"."obligations"("obligation_key") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
256
+ ALTER TABLE "router_v1.15"."offers" ADD CONSTRAINT "offers_obligation_id_obligation_id_keys_obligation_id_fk" FOREIGN KEY ("obligation_id") REFERENCES "router_v1.15"."obligation_id_keys"("obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
257
+ ALTER TABLE "router_v1.15"."offers" ADD CONSTRAINT "offers_groups_fk" FOREIGN KEY ("group_chain_id","group_maker","group_group") REFERENCES "router_v1.15"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
258
+ ALTER TABLE "router_v1.15"."offers_callbacks" ADD CONSTRAINT "offers_callbacks_offer_fk" FOREIGN KEY ("offer_hash","obligation_id") REFERENCES "router_v1.15"."offers"("hash","obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
259
+ ALTER TABLE "router_v1.15"."offsets" ADD CONSTRAINT "offsets_lots_positions_fk" FOREIGN KEY ("chain_id","contract","user") REFERENCES "router_v1.15"."lots_positions"("chain_id","contract","user") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
260
+ ALTER TABLE "router_v1.15"."positions" ADD CONSTRAINT "positions_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.15"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
261
+ ALTER TABLE "router_v1.15"."transfers" ADD CONSTRAINT "transfers_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.15"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
262
+ ALTER TABLE "router_v1.15"."transfers" ADD CONSTRAINT "transfers_positions_from_fk" FOREIGN KEY ("chain_id","contract","from","position_type_id","asset") REFERENCES "router_v1.15"."positions"("chain_id","contract","user","position_type_id","asset") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
263
+ ALTER TABLE "router_v1.15"."transfers" ADD CONSTRAINT "transfers_positions_to_fk" FOREIGN KEY ("chain_id","contract","to","position_type_id","asset") REFERENCES "router_v1.15"."positions"("chain_id","contract","user","position_type_id","asset") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
264
+ ALTER TABLE "router_v1.15"."validations" ADD CONSTRAINT "validations_status_id_status_id_fk" FOREIGN KEY ("status_id") REFERENCES "router_v1.15"."status"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
265
+ ALTER TABLE "router_v1.15"."validations" ADD CONSTRAINT "validations_offer_fk" FOREIGN KEY ("offer_hash","obligation_id") REFERENCES "router_v1.15"."offers"("hash","obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
266
+ CREATE INDEX "consumed_events_group_idx" ON "router_v1.15"."consumed_events" USING btree ("chain_id","maker","group");--> statement-breakpoint
267
+ CREATE INDEX "consumed_events_block_number_idx" ON "router_v1.15"."consumed_events" USING btree ("block_number");--> statement-breakpoint
268
+ CREATE INDEX "merkle_paths_tree_root_idx" ON "router_v1.15"."merkle_paths" USING btree ("tree_root");--> statement-breakpoint
269
+ CREATE INDEX "obligation_id_keys_obligation_key_idx" ON "router_v1.15"."obligation_id_keys" USING btree ("obligation_key");--> statement-breakpoint
270
+ CREATE INDEX "obligation_id_keys_chain_id_idx" ON "router_v1.15"."obligation_id_keys" USING btree ("chain_id");--> statement-breakpoint
271
+ CREATE INDEX "offers_group_and_hash_idx" ON "router_v1.15"."offers" USING btree ("group_chain_id","group_maker","group_group","hash");--> statement-breakpoint
272
+ CREATE INDEX "offers_obligation_side_tick_idx" ON "router_v1.15"."offers" USING btree ("obligation_id","buy","tick");--> statement-breakpoint
273
+ CREATE INDEX "offers_obligation_active_tick_idx" ON "router_v1.15"."offers" USING btree ("obligation_id","buy","expiry","maturity","start","tick");--> statement-breakpoint
274
+ CREATE INDEX "offers_group_maker_idx" ON "router_v1.15"."offers" USING btree ("group_maker","hash","obligation_id");--> statement-breakpoint
275
+ CREATE INDEX "offers_group_winner_expr_idx" ON "router_v1.15"."offers" (
276
+ "group_chain_id",
277
+ "group_maker",
278
+ "group_group",
279
+ "obligation_id",
280
+ "buy",
281
+ (CASE WHEN "buy" THEN -"tick" ELSE "tick" END),
282
+ "block_number",
283
+ "obligation_units" DESC,
284
+ "hash"
285
+ );--> statement-breakpoint
286
+ CREATE INDEX "offers_book_winners_covering_idx" ON "router_v1.15"."offers" (
287
+ "obligation_id",
288
+ "buy",
289
+ "group_chain_id",
290
+ "group_maker",
291
+ "group_group",
292
+ (CASE WHEN "buy" THEN -"tick" ELSE "tick" END),
293
+ "block_number",
294
+ "obligation_units" DESC,
295
+ "hash"
296
+ );--> statement-breakpoint
297
+ CREATE INDEX "lots_position_group_obligation_idx" ON "router_v1.15"."lots" USING btree ("chain_id","user","group","obligation_id");--> statement-breakpoint
298
+ CREATE INDEX "offsets_position_obligation_idx" ON "router_v1.15"."offsets" USING btree ("chain_id","contract","user","obligation_id");--> statement-breakpoint
299
+ CREATE INDEX "pending_links_pending_scan_idx" ON "router_v1.15"."pending_links" USING btree ("chain_id","type","status","first_seen_block");--> statement-breakpoint
300
+ CREATE INDEX "pending_links_event_id_idx" ON "router_v1.15"."pending_links" USING btree ("chain_id","event_id");--> statement-breakpoint
301
+ CREATE INDEX "transfers_chain_contract_user_idx" ON "router_v1.15"."transfers" USING btree ("chain_id","contract","from","to","block_number");--> statement-breakpoint
302
+ CREATE INDEX "transfers_chain_type_block_idx" ON "router_v1.15"."transfers" USING btree ("chain_id","position_type_id","block_number");--> statement-breakpoint
303
+ DROP TYPE "router_v1.14"."callback_type";--> statement-breakpoint
304
+ DROP TYPE "router_v1.14"."position_type";--> statement-breakpoint
305
+ DROP TYPE "router_v1.14"."status_code";
@@ -0,0 +1,305 @@
1
+ CREATE TYPE "router_v1.16"."callback_type" AS ENUM('empty');--> statement-breakpoint
2
+ CREATE TYPE "router_v1.16"."position_type" AS ENUM('erc20', 'vault_v1', 'debtOf', 'collateralOf');--> statement-breakpoint
3
+ CREATE TYPE "router_v1.16"."status_code" AS ENUM('VALID', 'SIMULATION_ERROR');--> statement-breakpoint
4
+ CREATE TABLE "router_v1.16"."callbacks" (
5
+ "id" varchar(66) PRIMARY KEY NOT NULL,
6
+ "position_chain_id" bigint NOT NULL,
7
+ "position_contract" varchar(66) NOT NULL,
8
+ "position_user" varchar(42) NOT NULL,
9
+ "position_type_id" integer NOT NULL,
10
+ "type" "router_v1.16"."callback_type" NOT NULL
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE TABLE "router_v1.16"."chains" (
14
+ "chain_id" bigint NOT NULL,
15
+ "block_number" bigint NOT NULL,
16
+ "epoch" numeric(78, 0) DEFAULT '0' NOT NULL,
17
+ "checkpoints" text DEFAULT '[]' NOT NULL,
18
+ "tip_hash" text,
19
+ "finalized_block_number" bigint,
20
+ "finalized_block_hash" text,
21
+ "updated_at" timestamp DEFAULT now() NOT NULL
22
+ );
23
+ --> statement-breakpoint
24
+ CREATE TABLE "router_v1.16"."collectors" (
25
+ "chain_id" bigint NOT NULL,
26
+ "name" text NOT NULL,
27
+ "block_number" bigint NOT NULL,
28
+ "epoch" numeric(78, 0) DEFAULT '0' NOT NULL,
29
+ "updated_at" timestamp DEFAULT now() NOT NULL
30
+ );
31
+ --> statement-breakpoint
32
+ CREATE TABLE "router_v1.16"."consumed_events" (
33
+ "event_id" varchar(128) PRIMARY KEY NOT NULL,
34
+ "chain_id" bigint NOT NULL,
35
+ "maker" varchar(42) NOT NULL,
36
+ "group" varchar(66) NOT NULL,
37
+ "amount" numeric(78, 0) NOT NULL,
38
+ "block_number" bigint NOT NULL,
39
+ "created_at" timestamp DEFAULT now() NOT NULL
40
+ );
41
+ --> statement-breakpoint
42
+ CREATE TABLE "router_v1.16"."groups" (
43
+ "chain_id" bigint NOT NULL,
44
+ "maker" varchar(42) NOT NULL,
45
+ "group" varchar(66) NOT NULL,
46
+ "consumed" numeric(78, 0) NOT NULL,
47
+ "block_number" bigint NOT NULL,
48
+ "updated_at" timestamp DEFAULT now() NOT NULL,
49
+ CONSTRAINT "groups_pk" PRIMARY KEY("chain_id","maker","group")
50
+ );
51
+ --> statement-breakpoint
52
+ CREATE TABLE "router_v1.16"."lots" (
53
+ "chain_id" bigint NOT NULL,
54
+ "user" varchar(42) NOT NULL,
55
+ "contract" varchar(66) NOT NULL,
56
+ "group" varchar(66) NOT NULL,
57
+ "obligation_id" varchar(66) NOT NULL,
58
+ "lower" numeric(78, 0) NOT NULL,
59
+ "upper" numeric(78, 0) NOT NULL,
60
+ CONSTRAINT "lots_pk" PRIMARY KEY("chain_id","user","contract","group","obligation_id")
61
+ );
62
+ --> statement-breakpoint
63
+ CREATE TABLE "router_v1.16"."lots_positions" (
64
+ "chain_id" bigint NOT NULL,
65
+ "contract" varchar(66) NOT NULL,
66
+ "user" varchar(42) NOT NULL,
67
+ "position_type_id" integer NOT NULL,
68
+ CONSTRAINT "lots_positions_pk" PRIMARY KEY("chain_id","contract","user")
69
+ );
70
+ --> statement-breakpoint
71
+ CREATE TABLE "router_v1.16"."merkle_paths" (
72
+ "offer_hash" varchar(66) NOT NULL,
73
+ "obligation_id" varchar(66) NOT NULL,
74
+ "tree_root" varchar(66) NOT NULL,
75
+ "proof_nodes" text NOT NULL,
76
+ "created_at" timestamp DEFAULT now() NOT NULL,
77
+ CONSTRAINT "merkle_paths_pk" PRIMARY KEY("offer_hash","obligation_id")
78
+ );
79
+ --> statement-breakpoint
80
+ CREATE TABLE "router_v1.16"."obligation_collaterals_v2" (
81
+ "obligation_key" varchar(66) NOT NULL,
82
+ "asset" varchar(42) NOT NULL,
83
+ "oracle_address" varchar(42) NOT NULL,
84
+ "lltv" bigint NOT NULL,
85
+ "max_lif" bigint NOT NULL,
86
+ "collateral_index" integer NOT NULL,
87
+ "updated_at" timestamp DEFAULT now() NOT NULL,
88
+ CONSTRAINT "obligation_collaterals_v2_pk" PRIMARY KEY("obligation_key","asset")
89
+ );
90
+ --> statement-breakpoint
91
+ CREATE TABLE "router_v1.16"."obligation_id_keys" (
92
+ "obligation_id" varchar(66) PRIMARY KEY NOT NULL,
93
+ "obligation_key" varchar(66) NOT NULL,
94
+ "chain_id" bigint NOT NULL,
95
+ "morpho_v2" varchar(42) NOT NULL
96
+ );
97
+ --> statement-breakpoint
98
+ CREATE TABLE "router_v1.16"."obligations" (
99
+ "obligation_key" varchar(66) PRIMARY KEY NOT NULL,
100
+ "loan_token" varchar(42) NOT NULL,
101
+ "maturity" integer NOT NULL,
102
+ "rcf_threshold" numeric(78, 0) NOT NULL
103
+ );
104
+ --> statement-breakpoint
105
+ CREATE TABLE "router_v1.16"."offers" (
106
+ "hash" varchar(66) NOT NULL,
107
+ "obligation_id" varchar(66) NOT NULL,
108
+ "max_units" numeric(78, 0) DEFAULT '0' NOT NULL,
109
+ "tick" integer NOT NULL,
110
+ "maturity" integer NOT NULL,
111
+ "expiry" integer NOT NULL,
112
+ "start" integer NOT NULL,
113
+ "group_chain_id" bigint NOT NULL,
114
+ "group_maker" varchar(42) NOT NULL,
115
+ "group_group" varchar(66) NOT NULL,
116
+ "session" varchar(66) NOT NULL,
117
+ "buy" boolean NOT NULL,
118
+ "callback_address" varchar(42) NOT NULL,
119
+ "callback_data" text NOT NULL,
120
+ "receiver_if_maker_is_seller" varchar(42),
121
+ "exit_only" boolean DEFAULT false NOT NULL,
122
+ "block_number" bigint NOT NULL,
123
+ "updated_at" timestamp DEFAULT now() NOT NULL,
124
+ CONSTRAINT "offers_pk" PRIMARY KEY("hash","obligation_id")
125
+ );
126
+ --> statement-breakpoint
127
+ CREATE TABLE "router_v1.16"."offers_callbacks" (
128
+ "offer_hash" varchar(66) NOT NULL,
129
+ "obligation_id" varchar(66) NOT NULL,
130
+ "callback_id" varchar(66),
131
+ CONSTRAINT "offers_callbacks_pk" PRIMARY KEY("offer_hash","obligation_id","callback_id")
132
+ );
133
+ --> statement-breakpoint
134
+ CREATE TABLE "router_v1.16"."offsets" (
135
+ "chain_id" bigint NOT NULL,
136
+ "user" varchar(42) NOT NULL,
137
+ "contract" varchar(66) NOT NULL,
138
+ "group" varchar(66) NOT NULL,
139
+ "obligation_id" varchar(66) NOT NULL,
140
+ "value" numeric(78, 0) NOT NULL,
141
+ CONSTRAINT "offsets_pk" PRIMARY KEY("chain_id","user","contract","group","obligation_id")
142
+ );
143
+ --> statement-breakpoint
144
+ CREATE TABLE "router_v1.16"."oracles" (
145
+ "chain_id" bigint NOT NULL,
146
+ "address" varchar(42) NOT NULL,
147
+ "price" numeric(78, 0),
148
+ "block_number" bigint NOT NULL,
149
+ "updated_at" timestamp DEFAULT now() NOT NULL,
150
+ CONSTRAINT "oracles_pk" PRIMARY KEY("chain_id","address")
151
+ );
152
+ --> statement-breakpoint
153
+ CREATE TABLE "router_v1.16"."pending_links" (
154
+ "key" varchar(191) PRIMARY KEY NOT NULL,
155
+ "type" text NOT NULL,
156
+ "status" text NOT NULL,
157
+ "chain_id" bigint NOT NULL,
158
+ "event_id" varchar(128) NOT NULL,
159
+ "obligation_id" varchar(66) NOT NULL,
160
+ "collateral_index" integer NOT NULL,
161
+ "user" varchar(42) NOT NULL,
162
+ "amount" numeric(78, 0) NOT NULL,
163
+ "block_number" bigint NOT NULL,
164
+ "first_seen_block" bigint NOT NULL,
165
+ "last_tried_block" bigint,
166
+ "attempts" integer DEFAULT 0 NOT NULL,
167
+ "ignored_reason" text,
168
+ "resolved_at" timestamp,
169
+ "updated_at" timestamp DEFAULT now() NOT NULL
170
+ );
171
+ --> statement-breakpoint
172
+ CREATE TABLE "router_v1.16"."position_types" (
173
+ "id" serial PRIMARY KEY NOT NULL,
174
+ "type" "router_v1.16"."position_type" NOT NULL
175
+ );
176
+ --> statement-breakpoint
177
+ CREATE TABLE "router_v1.16"."positions" (
178
+ "chain_id" bigint NOT NULL,
179
+ "contract" varchar(66) NOT NULL,
180
+ "user" varchar(42) NOT NULL,
181
+ "position_type_id" integer NOT NULL,
182
+ "balance" numeric(78, 0),
183
+ "asset" varchar(42) NOT NULL,
184
+ "block_number" bigint NOT NULL,
185
+ "updated_at" timestamp DEFAULT now() NOT NULL,
186
+ CONSTRAINT "positions_pk" PRIMARY KEY("chain_id","contract","user","position_type_id","asset")
187
+ );
188
+ --> statement-breakpoint
189
+ CREATE TABLE "router_v1.16"."status" (
190
+ "id" serial PRIMARY KEY NOT NULL,
191
+ "code" "router_v1.16"."status_code",
192
+ CONSTRAINT "status_code_unique" UNIQUE("code")
193
+ );
194
+ --> statement-breakpoint
195
+ CREATE TABLE "router_v1.16"."transfers" (
196
+ "event_id" varchar(128) PRIMARY KEY NOT NULL,
197
+ "chain_id" bigint NOT NULL,
198
+ "contract" varchar(66) NOT NULL,
199
+ "from" varchar(42) NOT NULL,
200
+ "to" varchar(42) NOT NULL,
201
+ "value" numeric(78, 0) NOT NULL,
202
+ "position_type_id" integer NOT NULL,
203
+ "asset" varchar(42) NOT NULL,
204
+ "block_number" bigint NOT NULL,
205
+ "created_at" timestamp DEFAULT now() NOT NULL
206
+ );
207
+ --> statement-breakpoint
208
+ CREATE TABLE "router_v1.16"."trees" (
209
+ "root" varchar(66) PRIMARY KEY NOT NULL,
210
+ "root_signature" varchar(132) NOT NULL,
211
+ "created_at" timestamp DEFAULT now() NOT NULL
212
+ );
213
+ --> statement-breakpoint
214
+ CREATE TABLE "router_v1.16"."validations" (
215
+ "offer_hash" varchar(66) NOT NULL,
216
+ "obligation_id" varchar(66) NOT NULL,
217
+ "status_id" integer NOT NULL,
218
+ "updated_at" timestamp DEFAULT now() NOT NULL,
219
+ CONSTRAINT "validations_pk" PRIMARY KEY("offer_hash","obligation_id")
220
+ );
221
+ --> statement-breakpoint
222
+ CREATE UNIQUE INDEX "chains_chain_id_idx" ON "router_v1.16"."chains" USING btree ("chain_id");--> statement-breakpoint
223
+ CREATE UNIQUE INDEX "collectors_chain_name_idx" ON "router_v1.16"."collectors" USING btree ("chain_id","name");--> statement-breakpoint
224
+ DROP TABLE "router_v1.15"."callbacks" CASCADE;--> statement-breakpoint
225
+ DROP TABLE "router_v1.15"."chains" CASCADE;--> statement-breakpoint
226
+ DROP TABLE "router_v1.15"."collectors" CASCADE;--> statement-breakpoint
227
+ DROP TABLE "router_v1.15"."consumed_events" CASCADE;--> statement-breakpoint
228
+ DROP TABLE "router_v1.15"."groups" CASCADE;--> statement-breakpoint
229
+ DROP TABLE "router_v1.15"."lots" CASCADE;--> statement-breakpoint
230
+ DROP TABLE "router_v1.15"."lots_positions" CASCADE;--> statement-breakpoint
231
+ DROP TABLE "router_v1.15"."merkle_paths" CASCADE;--> statement-breakpoint
232
+ DROP TABLE "router_v1.15"."obligation_collaterals_v2" CASCADE;--> statement-breakpoint
233
+ DROP TABLE "router_v1.15"."obligation_id_keys" CASCADE;--> statement-breakpoint
234
+ DROP TABLE "router_v1.15"."obligations" CASCADE;--> statement-breakpoint
235
+ DROP TABLE "router_v1.15"."offers" CASCADE;--> statement-breakpoint
236
+ DROP TABLE "router_v1.15"."offers_callbacks" CASCADE;--> statement-breakpoint
237
+ DROP TABLE "router_v1.15"."offsets" CASCADE;--> statement-breakpoint
238
+ DROP TABLE "router_v1.15"."oracles" CASCADE;--> statement-breakpoint
239
+ DROP TABLE "router_v1.15"."pending_links" CASCADE;--> statement-breakpoint
240
+ DROP TABLE "router_v1.15"."position_types" CASCADE;--> statement-breakpoint
241
+ DROP TABLE "router_v1.15"."positions" CASCADE;--> statement-breakpoint
242
+ DROP TABLE "router_v1.15"."status" CASCADE;--> statement-breakpoint
243
+ DROP TABLE "router_v1.15"."transfers" CASCADE;--> statement-breakpoint
244
+ DROP TABLE "router_v1.15"."trees" CASCADE;--> statement-breakpoint
245
+ DROP TABLE "router_v1.15"."validations" CASCADE;--> statement-breakpoint
246
+ ALTER TABLE "router_v1.16"."callbacks" ADD CONSTRAINT "callbacks_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.16"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
247
+ ALTER TABLE "router_v1.16"."collectors" ADD CONSTRAINT "collectors_chain_id_chains_chain_id_fk" FOREIGN KEY ("chain_id") REFERENCES "router_v1.16"."chains"("chain_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
248
+ ALTER TABLE "router_v1.16"."consumed_events" ADD CONSTRAINT "consumed_events_groups_fk" FOREIGN KEY ("chain_id","maker","group") REFERENCES "router_v1.16"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
249
+ ALTER TABLE "router_v1.16"."lots" ADD CONSTRAINT "lots_lots_positions_fk" FOREIGN KEY ("chain_id","contract","user") REFERENCES "router_v1.16"."lots_positions"("chain_id","contract","user") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
250
+ ALTER TABLE "router_v1.16"."lots" ADD CONSTRAINT "lots_groups_fk" FOREIGN KEY ("chain_id","user","group") REFERENCES "router_v1.16"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
251
+ ALTER TABLE "router_v1.16"."lots_positions" ADD CONSTRAINT "lots_positions_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.16"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
252
+ ALTER TABLE "router_v1.16"."merkle_paths" ADD CONSTRAINT "merkle_paths_tree_root_trees_root_fk" FOREIGN KEY ("tree_root") REFERENCES "router_v1.16"."trees"("root") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
253
+ ALTER TABLE "router_v1.16"."merkle_paths" ADD CONSTRAINT "merkle_paths_offer_fk" FOREIGN KEY ("offer_hash","obligation_id") REFERENCES "router_v1.16"."offers"("hash","obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
254
+ ALTER TABLE "router_v1.16"."obligation_collaterals_v2" ADD CONSTRAINT "obligation_collaterals_v2_obligation_key_obligations_obligation_key_fk" FOREIGN KEY ("obligation_key") REFERENCES "router_v1.16"."obligations"("obligation_key") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
255
+ ALTER TABLE "router_v1.16"."obligation_id_keys" ADD CONSTRAINT "obligation_id_keys_obligation_key_obligations_obligation_key_fk" FOREIGN KEY ("obligation_key") REFERENCES "router_v1.16"."obligations"("obligation_key") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
256
+ ALTER TABLE "router_v1.16"."offers" ADD CONSTRAINT "offers_obligation_id_obligation_id_keys_obligation_id_fk" FOREIGN KEY ("obligation_id") REFERENCES "router_v1.16"."obligation_id_keys"("obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
257
+ ALTER TABLE "router_v1.16"."offers" ADD CONSTRAINT "offers_groups_fk" FOREIGN KEY ("group_chain_id","group_maker","group_group") REFERENCES "router_v1.16"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
258
+ ALTER TABLE "router_v1.16"."offers_callbacks" ADD CONSTRAINT "offers_callbacks_offer_fk" FOREIGN KEY ("offer_hash","obligation_id") REFERENCES "router_v1.16"."offers"("hash","obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
259
+ ALTER TABLE "router_v1.16"."offsets" ADD CONSTRAINT "offsets_lots_positions_fk" FOREIGN KEY ("chain_id","contract","user") REFERENCES "router_v1.16"."lots_positions"("chain_id","contract","user") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
260
+ ALTER TABLE "router_v1.16"."positions" ADD CONSTRAINT "positions_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.16"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
261
+ ALTER TABLE "router_v1.16"."transfers" ADD CONSTRAINT "transfers_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.16"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
262
+ ALTER TABLE "router_v1.16"."transfers" ADD CONSTRAINT "transfers_positions_from_fk" FOREIGN KEY ("chain_id","contract","from","position_type_id","asset") REFERENCES "router_v1.16"."positions"("chain_id","contract","user","position_type_id","asset") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
263
+ ALTER TABLE "router_v1.16"."transfers" ADD CONSTRAINT "transfers_positions_to_fk" FOREIGN KEY ("chain_id","contract","to","position_type_id","asset") REFERENCES "router_v1.16"."positions"("chain_id","contract","user","position_type_id","asset") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
264
+ ALTER TABLE "router_v1.16"."validations" ADD CONSTRAINT "validations_status_id_status_id_fk" FOREIGN KEY ("status_id") REFERENCES "router_v1.16"."status"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
265
+ ALTER TABLE "router_v1.16"."validations" ADD CONSTRAINT "validations_offer_fk" FOREIGN KEY ("offer_hash","obligation_id") REFERENCES "router_v1.16"."offers"("hash","obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
266
+ CREATE INDEX "consumed_events_group_idx" ON "router_v1.16"."consumed_events" USING btree ("chain_id","maker","group");--> statement-breakpoint
267
+ CREATE INDEX "consumed_events_block_number_idx" ON "router_v1.16"."consumed_events" USING btree ("block_number");--> statement-breakpoint
268
+ CREATE INDEX "merkle_paths_tree_root_idx" ON "router_v1.16"."merkle_paths" USING btree ("tree_root");--> statement-breakpoint
269
+ CREATE INDEX "obligation_id_keys_obligation_key_idx" ON "router_v1.16"."obligation_id_keys" USING btree ("obligation_key");--> statement-breakpoint
270
+ CREATE INDEX "obligation_id_keys_chain_id_idx" ON "router_v1.16"."obligation_id_keys" USING btree ("chain_id");--> statement-breakpoint
271
+ CREATE INDEX "offers_group_and_hash_idx" ON "router_v1.16"."offers" USING btree ("group_chain_id","group_maker","group_group","hash");--> statement-breakpoint
272
+ CREATE INDEX "offers_obligation_side_tick_idx" ON "router_v1.16"."offers" USING btree ("obligation_id","buy","tick");--> statement-breakpoint
273
+ CREATE INDEX "offers_obligation_active_tick_idx" ON "router_v1.16"."offers" USING btree ("obligation_id","buy","expiry","maturity","start","tick");--> statement-breakpoint
274
+ CREATE INDEX "offers_group_maker_idx" ON "router_v1.16"."offers" USING btree ("group_maker","hash","obligation_id");--> statement-breakpoint
275
+ CREATE INDEX "offers_group_winner_expr_idx" ON "router_v1.16"."offers" (
276
+ "group_chain_id",
277
+ "group_maker",
278
+ "group_group",
279
+ "obligation_id",
280
+ "buy",
281
+ (CASE WHEN "buy" THEN -"tick" ELSE "tick" END),
282
+ "block_number",
283
+ "max_units" DESC,
284
+ "hash"
285
+ );--> statement-breakpoint
286
+ CREATE INDEX "offers_book_winners_covering_idx" ON "router_v1.16"."offers" (
287
+ "obligation_id",
288
+ "buy",
289
+ "group_chain_id",
290
+ "group_maker",
291
+ "group_group",
292
+ (CASE WHEN "buy" THEN -"tick" ELSE "tick" END),
293
+ "block_number",
294
+ "max_units" DESC,
295
+ "hash"
296
+ );--> statement-breakpoint
297
+ CREATE INDEX "lots_position_group_obligation_idx" ON "router_v1.16"."lots" USING btree ("chain_id","user","group","obligation_id");--> statement-breakpoint
298
+ CREATE INDEX "offsets_position_obligation_idx" ON "router_v1.16"."offsets" USING btree ("chain_id","contract","user","obligation_id");--> statement-breakpoint
299
+ CREATE INDEX "pending_links_pending_scan_idx" ON "router_v1.16"."pending_links" USING btree ("chain_id","type","status","first_seen_block");--> statement-breakpoint
300
+ CREATE INDEX "pending_links_event_id_idx" ON "router_v1.16"."pending_links" USING btree ("chain_id","event_id");--> statement-breakpoint
301
+ CREATE INDEX "transfers_chain_contract_user_idx" ON "router_v1.16"."transfers" USING btree ("chain_id","contract","from","to","block_number");--> statement-breakpoint
302
+ CREATE INDEX "transfers_chain_type_block_idx" ON "router_v1.16"."transfers" USING btree ("chain_id","position_type_id","block_number");--> statement-breakpoint
303
+ DROP TYPE "router_v1.15"."callback_type";--> statement-breakpoint
304
+ DROP TYPE "router_v1.15"."position_type";--> statement-breakpoint
305
+ DROP TYPE "router_v1.15"."status_code";