@morpho-dev/router 0.9.0 → 0.11.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.
Files changed (34) hide show
  1. package/dist/cli.js +5926 -3770
  2. package/dist/drizzle/migrations/0027_debt-to-transfers.sql +239 -0
  3. package/dist/drizzle/migrations/0028_obligation_id_and_keys.sql +247 -0
  4. package/dist/drizzle/migrations/0029_collateral-positions.sql +248 -0
  5. package/dist/drizzle/migrations/0030_remove_chain_id_from_offer.sql +37 -0
  6. package/dist/drizzle/migrations/0031_sell-takeable-reindex.sql +254 -0
  7. package/dist/drizzle/migrations/0032_callback-type.sql +3 -0
  8. package/dist/drizzle/migrations/0033_obligation-id-bytes20.sql +255 -0
  9. package/dist/drizzle/migrations/meta/0027_snapshot.json +1581 -0
  10. package/dist/drizzle/migrations/meta/0028_snapshot.json +1632 -0
  11. package/dist/drizzle/migrations/meta/0029_snapshot.json +1619 -0
  12. package/dist/drizzle/migrations/meta/0030_snapshot.json +1652 -0
  13. package/dist/drizzle/migrations/meta/0031_snapshot.json +1652 -0
  14. package/dist/drizzle/migrations/meta/0033_snapshot.json +1658 -0
  15. package/dist/drizzle/migrations/meta/_journal.json +49 -0
  16. package/dist/evm/bytecode/morpho.txt +1 -1
  17. package/dist/index.browser.d.mts +820 -449
  18. package/dist/index.browser.d.mts.map +1 -1
  19. package/dist/index.browser.mjs +4913 -4195
  20. package/dist/index.browser.mjs.map +1 -1
  21. package/dist/index.node.d.mts +1248 -534
  22. package/dist/index.node.d.mts.map +1 -1
  23. package/dist/index.node.mjs +3803 -1842
  24. package/dist/index.node.mjs.map +1 -1
  25. package/dist/register-otel-hook.js +7 -0
  26. package/package.json +32 -28
  27. package/dist/index.browser.d.ts +0 -4822
  28. package/dist/index.browser.d.ts.map +0 -1
  29. package/dist/index.browser.js +0 -5705
  30. package/dist/index.browser.js.map +0 -1
  31. package/dist/index.node.d.ts +0 -7752
  32. package/dist/index.node.d.ts.map +0 -1
  33. package/dist/index.node.js +0 -11633
  34. package/dist/index.node.js.map +0 -1
@@ -0,0 +1,239 @@
1
+ CREATE TYPE "router_v1.9"."position_type" AS ENUM('erc20', 'vault_v1', 'debtOf');--> statement-breakpoint
2
+ CREATE TYPE "router_v1.9"."status_code" AS ENUM('VALID', 'SIMULATION_ERROR');--> statement-breakpoint
3
+ CREATE TABLE "router_v1.9"."callbacks" (
4
+ "id" varchar(66) PRIMARY KEY NOT NULL,
5
+ "position_chain_id" bigint NOT NULL,
6
+ "position_contract" varchar(42) NOT NULL,
7
+ "position_user" varchar(42) NOT NULL,
8
+ "position_type_id" integer NOT NULL,
9
+ "amount" numeric(78, 0)
10
+ );
11
+ --> statement-breakpoint
12
+ CREATE TABLE "router_v1.9"."chains" (
13
+ "chain_id" bigint NOT NULL,
14
+ "block_number" bigint NOT NULL,
15
+ "epoch" numeric(78, 0) DEFAULT '0' NOT NULL,
16
+ "updated_at" timestamp DEFAULT now() NOT NULL
17
+ );
18
+ --> statement-breakpoint
19
+ CREATE TABLE "router_v1.9"."collectors" (
20
+ "chain_id" bigint NOT NULL,
21
+ "name" text NOT NULL,
22
+ "block_number" bigint NOT NULL,
23
+ "epoch" numeric(78, 0) DEFAULT '0' NOT NULL,
24
+ "updated_at" timestamp DEFAULT now() NOT NULL
25
+ );
26
+ --> statement-breakpoint
27
+ CREATE TABLE "router_v1.9"."consumed_events" (
28
+ "event_id" varchar(128) PRIMARY KEY NOT NULL,
29
+ "chain_id" bigint NOT NULL,
30
+ "maker" varchar(42) NOT NULL,
31
+ "group" varchar(66) NOT NULL,
32
+ "amount" numeric(78, 0) NOT NULL,
33
+ "block_number" bigint NOT NULL,
34
+ "created_at" timestamp DEFAULT now() NOT NULL
35
+ );
36
+ --> statement-breakpoint
37
+ CREATE TABLE "router_v1.9"."groups" (
38
+ "chain_id" bigint NOT NULL,
39
+ "maker" varchar(42) NOT NULL,
40
+ "group" varchar(66) NOT NULL,
41
+ "consumed" numeric(78, 0) NOT NULL,
42
+ "block_number" bigint NOT NULL,
43
+ "updated_at" timestamp DEFAULT now() NOT NULL,
44
+ CONSTRAINT "groups_pk" PRIMARY KEY("chain_id","maker","group")
45
+ );
46
+ --> statement-breakpoint
47
+ CREATE TABLE "router_v1.9"."lots" (
48
+ "chain_id" bigint NOT NULL,
49
+ "user" varchar(42) NOT NULL,
50
+ "contract" varchar(42) NOT NULL,
51
+ "group" varchar(66) NOT NULL,
52
+ "obligation_id" varchar(66) NOT NULL,
53
+ "lower" numeric(78, 0) NOT NULL,
54
+ "upper" numeric(78, 0) NOT NULL,
55
+ CONSTRAINT "lots_pk" PRIMARY KEY("chain_id","user","contract","group","obligation_id")
56
+ );
57
+ --> statement-breakpoint
58
+ CREATE TABLE "router_v1.9"."lots_positions" (
59
+ "chain_id" bigint NOT NULL,
60
+ "contract" varchar(42) NOT NULL,
61
+ "user" varchar(42) NOT NULL,
62
+ "position_type_id" integer NOT NULL,
63
+ CONSTRAINT "lots_positions_pk" PRIMARY KEY("chain_id","contract","user")
64
+ );
65
+ --> statement-breakpoint
66
+ CREATE TABLE "router_v1.9"."merkle_paths" (
67
+ "offer_hash" varchar(66) PRIMARY KEY NOT NULL,
68
+ "tree_root" varchar(66) NOT NULL,
69
+ "proof_nodes" text NOT NULL,
70
+ "created_at" timestamp DEFAULT now() NOT NULL
71
+ );
72
+ --> statement-breakpoint
73
+ CREATE TABLE "router_v1.9"."obligation_collaterals_v2" (
74
+ "obligation_id" varchar(66) NOT NULL,
75
+ "asset" varchar(42) NOT NULL,
76
+ "oracle_chain_id" bigint NOT NULL,
77
+ "oracle_address" varchar(42) NOT NULL,
78
+ "lltv" bigint NOT NULL,
79
+ "updated_at" timestamp DEFAULT now() NOT NULL,
80
+ CONSTRAINT "obligation_collaterals_v2_pk" PRIMARY KEY("obligation_id","asset")
81
+ );
82
+ --> statement-breakpoint
83
+ CREATE TABLE "router_v1.9"."obligations" (
84
+ "obligation_id" varchar(66) PRIMARY KEY NOT NULL,
85
+ "chain_id" bigint NOT NULL,
86
+ "loan_token" varchar(42) NOT NULL,
87
+ "maturity" integer NOT NULL
88
+ );
89
+ --> statement-breakpoint
90
+ CREATE TABLE "router_v1.9"."offers" (
91
+ "hash" varchar(66) PRIMARY KEY NOT NULL,
92
+ "obligation_id" varchar(66) NOT NULL,
93
+ "assets" numeric(78, 0) NOT NULL,
94
+ "obligation_units" numeric(78, 0) DEFAULT '0' NOT NULL,
95
+ "obligation_shares" numeric(78, 0) DEFAULT '0' NOT NULL,
96
+ "tick" integer NOT NULL,
97
+ "maturity" integer NOT NULL,
98
+ "expiry" integer NOT NULL,
99
+ "start" integer NOT NULL,
100
+ "group_chain_id" bigint NOT NULL,
101
+ "group_maker" varchar(42) NOT NULL,
102
+ "group_group" varchar(66) NOT NULL,
103
+ "session" varchar(66) NOT NULL,
104
+ "buy" boolean NOT NULL,
105
+ "callback_address" varchar(42) NOT NULL,
106
+ "callback_data" text NOT NULL,
107
+ "receiver_if_maker_is_seller" varchar(42),
108
+ "block_number" bigint NOT NULL,
109
+ "updated_at" timestamp DEFAULT now() NOT NULL
110
+ );
111
+ --> statement-breakpoint
112
+ CREATE TABLE "router_v1.9"."offers_callbacks" (
113
+ "offer_hash" varchar(66) NOT NULL,
114
+ "callback_id" varchar(66),
115
+ CONSTRAINT "offers_callbacks_pk" PRIMARY KEY("offer_hash","callback_id")
116
+ );
117
+ --> statement-breakpoint
118
+ CREATE TABLE "router_v1.9"."offsets" (
119
+ "chain_id" bigint NOT NULL,
120
+ "user" varchar(42) NOT NULL,
121
+ "contract" varchar(42) NOT NULL,
122
+ "group" varchar(66) NOT NULL,
123
+ "obligation_id" varchar(66) NOT NULL,
124
+ "value" numeric(78, 0) NOT NULL,
125
+ CONSTRAINT "offsets_pk" PRIMARY KEY("chain_id","user","contract","group","obligation_id")
126
+ );
127
+ --> statement-breakpoint
128
+ CREATE TABLE "router_v1.9"."oracles" (
129
+ "chain_id" bigint NOT NULL,
130
+ "address" varchar(42) NOT NULL,
131
+ "price" numeric(78, 0),
132
+ "block_number" bigint NOT NULL,
133
+ "updated_at" timestamp DEFAULT now() NOT NULL,
134
+ CONSTRAINT "oracles_pk" PRIMARY KEY("chain_id","address")
135
+ );
136
+ --> statement-breakpoint
137
+ CREATE TABLE "router_v1.9"."position_types" (
138
+ "id" serial PRIMARY KEY NOT NULL,
139
+ "type" "router_v1.9"."position_type" NOT NULL
140
+ );
141
+ --> statement-breakpoint
142
+ CREATE TABLE "router_v1.9"."positions" (
143
+ "chain_id" bigint NOT NULL,
144
+ "contract" varchar(66) NOT NULL,
145
+ "user" varchar(42) NOT NULL,
146
+ "position_type_id" integer NOT NULL,
147
+ "balance" numeric(78, 0),
148
+ "asset" varchar(42),
149
+ "block_number" bigint NOT NULL,
150
+ "updated_at" timestamp DEFAULT now() NOT NULL,
151
+ CONSTRAINT "positions_pk" PRIMARY KEY("chain_id","contract","user","position_type_id")
152
+ );
153
+ --> statement-breakpoint
154
+ CREATE TABLE "router_v1.9"."status" (
155
+ "id" serial PRIMARY KEY NOT NULL,
156
+ "code" "router_v1.9"."status_code",
157
+ CONSTRAINT "status_code_unique" UNIQUE("code")
158
+ );
159
+ --> statement-breakpoint
160
+ CREATE TABLE "router_v1.9"."transfers" (
161
+ "event_id" varchar(128) PRIMARY KEY NOT NULL,
162
+ "chain_id" bigint NOT NULL,
163
+ "contract" varchar(66) NOT NULL,
164
+ "from" varchar(42) NOT NULL,
165
+ "to" varchar(42) NOT NULL,
166
+ "value" numeric(78, 0) NOT NULL,
167
+ "position_type_id" integer NOT NULL,
168
+ "block_number" bigint NOT NULL,
169
+ "created_at" timestamp DEFAULT now() NOT NULL
170
+ );
171
+ --> statement-breakpoint
172
+ CREATE TABLE "router_v1.9"."trees" (
173
+ "root" varchar(66) PRIMARY KEY NOT NULL,
174
+ "root_signature" varchar(132) NOT NULL,
175
+ "created_at" timestamp DEFAULT now() NOT NULL
176
+ );
177
+ --> statement-breakpoint
178
+ CREATE TABLE "router_v1.9"."validations" (
179
+ "offer_hash" varchar(66) PRIMARY KEY NOT NULL,
180
+ "status_id" integer NOT NULL,
181
+ "updated_at" timestamp DEFAULT now() NOT NULL
182
+ );
183
+ --> statement-breakpoint
184
+ DROP TABLE "router_v1.8"."callbacks" CASCADE;--> statement-breakpoint
185
+ DROP TABLE "router_v1.8"."chains" CASCADE;--> statement-breakpoint
186
+ DROP TABLE "router_v1.8"."collectors" CASCADE;--> statement-breakpoint
187
+ DROP TABLE "router_v1.8"."consumed_events" CASCADE;--> statement-breakpoint
188
+ DROP TABLE "router_v1.8"."groups" CASCADE;--> statement-breakpoint
189
+ DROP TABLE "router_v1.8"."lots" CASCADE;--> statement-breakpoint
190
+ DROP TABLE "router_v1.8"."merkle_paths" CASCADE;--> statement-breakpoint
191
+ DROP TABLE "router_v1.8"."obligation_collaterals_v2" CASCADE;--> statement-breakpoint
192
+ DROP TABLE "router_v1.8"."obligations" CASCADE;--> statement-breakpoint
193
+ DROP TABLE "router_v1.8"."offers" CASCADE;--> statement-breakpoint
194
+ DROP TABLE "router_v1.8"."offers_callbacks" CASCADE;--> statement-breakpoint
195
+ DROP TABLE "router_v1.8"."offsets" CASCADE;--> statement-breakpoint
196
+ DROP TABLE "router_v1.8"."oracles" CASCADE;--> statement-breakpoint
197
+ DROP TABLE "router_v1.8"."position_types" CASCADE;--> statement-breakpoint
198
+ DROP TABLE "router_v1.8"."positions" CASCADE;--> statement-breakpoint
199
+ DROP TABLE "router_v1.8"."status" CASCADE;--> statement-breakpoint
200
+ DROP TABLE "router_v1.8"."transfers" CASCADE;--> statement-breakpoint
201
+ DROP TABLE "router_v1.8"."trees" CASCADE;--> statement-breakpoint
202
+ DROP TABLE "router_v1.8"."validations" CASCADE;--> statement-breakpoint
203
+ CREATE UNIQUE INDEX "chains_chain_id_idx" ON "router_v1.9"."chains" USING btree ("chain_id");--> statement-breakpoint
204
+ CREATE UNIQUE INDEX "collectors_chain_name_idx" ON "router_v1.9"."collectors" USING btree ("chain_id","name");--> statement-breakpoint
205
+ ALTER TABLE "router_v1.9"."callbacks" ADD CONSTRAINT "callbacks_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.9"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
206
+ ALTER TABLE "router_v1.9"."callbacks" ADD CONSTRAINT "callbacks_positions_fk" FOREIGN KEY ("position_chain_id","position_contract","position_user","position_type_id") REFERENCES "router_v1.9"."positions"("chain_id","contract","user","position_type_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
207
+ ALTER TABLE "router_v1.9"."collectors" ADD CONSTRAINT "collectors_chain_id_chains_chain_id_fk" FOREIGN KEY ("chain_id") REFERENCES "router_v1.9"."chains"("chain_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
208
+ ALTER TABLE "router_v1.9"."consumed_events" ADD CONSTRAINT "consumed_events_groups_fk" FOREIGN KEY ("chain_id","maker","group") REFERENCES "router_v1.9"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
209
+ ALTER TABLE "router_v1.9"."lots" ADD CONSTRAINT "lots_lots_positions_fk" FOREIGN KEY ("chain_id","contract","user") REFERENCES "router_v1.9"."lots_positions"("chain_id","contract","user") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
210
+ ALTER TABLE "router_v1.9"."lots" ADD CONSTRAINT "lots_groups_fk" FOREIGN KEY ("chain_id","user","group") REFERENCES "router_v1.9"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
211
+ ALTER TABLE "router_v1.9"."lots_positions" ADD CONSTRAINT "lots_positions_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.9"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
212
+ ALTER TABLE "router_v1.9"."lots_positions" ADD CONSTRAINT "lots_positions_positions_fk" FOREIGN KEY ("chain_id","contract","user","position_type_id") REFERENCES "router_v1.9"."positions"("chain_id","contract","user","position_type_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
213
+ ALTER TABLE "router_v1.9"."merkle_paths" ADD CONSTRAINT "merkle_paths_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "router_v1.9"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
214
+ ALTER TABLE "router_v1.9"."merkle_paths" ADD CONSTRAINT "merkle_paths_tree_root_trees_root_fk" FOREIGN KEY ("tree_root") REFERENCES "router_v1.9"."trees"("root") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
215
+ ALTER TABLE "router_v1.9"."obligation_collaterals_v2" ADD CONSTRAINT "obligation_collaterals_v2_obligation_id_obligations_obligation_id_fk" FOREIGN KEY ("obligation_id") REFERENCES "router_v1.9"."obligations"("obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
216
+ ALTER TABLE "router_v1.9"."obligation_collaterals_v2" ADD CONSTRAINT "obligation_collaterals_v2_oracles_fk" FOREIGN KEY ("oracle_chain_id","oracle_address") REFERENCES "router_v1.9"."oracles"("chain_id","address") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
217
+ ALTER TABLE "router_v1.9"."offers" ADD CONSTRAINT "offers_obligation_id_obligations_obligation_id_fk" FOREIGN KEY ("obligation_id") REFERENCES "router_v1.9"."obligations"("obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
218
+ ALTER TABLE "router_v1.9"."offers" ADD CONSTRAINT "offers_groups_fk" FOREIGN KEY ("group_chain_id","group_maker","group_group") REFERENCES "router_v1.9"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
219
+ ALTER TABLE "router_v1.9"."offers_callbacks" ADD CONSTRAINT "offers_callbacks_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "router_v1.9"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
220
+ ALTER TABLE "router_v1.9"."offsets" ADD CONSTRAINT "offsets_lots_positions_fk" FOREIGN KEY ("chain_id","contract","user") REFERENCES "router_v1.9"."lots_positions"("chain_id","contract","user") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
221
+ ALTER TABLE "router_v1.9"."positions" ADD CONSTRAINT "positions_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.9"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
222
+ ALTER TABLE "router_v1.9"."transfers" ADD CONSTRAINT "transfers_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.9"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
223
+ ALTER TABLE "router_v1.9"."transfers" ADD CONSTRAINT "transfers_positions_from_fk" FOREIGN KEY ("chain_id","contract","from","position_type_id") REFERENCES "router_v1.9"."positions"("chain_id","contract","user","position_type_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
224
+ ALTER TABLE "router_v1.9"."transfers" ADD CONSTRAINT "transfers_positions_to_fk" FOREIGN KEY ("chain_id","contract","to","position_type_id") REFERENCES "router_v1.9"."positions"("chain_id","contract","user","position_type_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
225
+ ALTER TABLE "router_v1.9"."validations" ADD CONSTRAINT "validations_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "router_v1.9"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
226
+ ALTER TABLE "router_v1.9"."validations" ADD CONSTRAINT "validations_status_id_status_id_fk" FOREIGN KEY ("status_id") REFERENCES "router_v1.9"."status"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
227
+ CREATE INDEX "consumed_events_group_idx" ON "router_v1.9"."consumed_events" USING btree ("chain_id","maker","group");--> statement-breakpoint
228
+ CREATE INDEX "consumed_events_block_number_idx" ON "router_v1.9"."consumed_events" USING btree ("block_number");--> statement-breakpoint
229
+ CREATE INDEX "groups_chain_id_maker_group_consumed_idx" ON "router_v1.9"."groups" USING btree ("chain_id","maker","group","consumed");--> statement-breakpoint
230
+ CREATE INDEX "merkle_paths_tree_root_idx" ON "router_v1.9"."merkle_paths" USING btree ("tree_root");--> statement-breakpoint
231
+ CREATE INDEX "obligation_collaterals_v2_obligation_id_idx" ON "router_v1.9"."obligation_collaterals_v2" USING btree ("obligation_id");--> statement-breakpoint
232
+ CREATE INDEX "obligation_collaterals_v2_oracle_fk_idx" ON "router_v1.9"."obligation_collaterals_v2" USING btree ("oracle_chain_id","oracle_address");--> statement-breakpoint
233
+ CREATE INDEX "offers_group_fk_idx" ON "router_v1.9"."offers" USING btree ("group_chain_id","group_maker","group_group");--> statement-breakpoint
234
+ CREATE INDEX "offers_group_and_hash_idx" ON "router_v1.9"."offers" USING btree ("group_chain_id","group_maker","group_group","hash");--> statement-breakpoint
235
+ CREATE INDEX "offers_obligation_id_side_idx" ON "router_v1.9"."offers" USING btree ("obligation_id","buy");--> statement-breakpoint
236
+ CREATE INDEX "transfers_chain_contract_user_idx" ON "router_v1.9"."transfers" USING btree ("chain_id","contract","from","to","block_number");--> statement-breakpoint
237
+ CREATE INDEX "transfers_chain_type_block_idx" ON "router_v1.9"."transfers" USING btree ("chain_id","position_type_id","block_number");--> statement-breakpoint
238
+ DROP TYPE "router_v1.8"."position_type";--> statement-breakpoint
239
+ DROP TYPE "router_v1.8"."status_code";
@@ -0,0 +1,247 @@
1
+ CREATE TYPE "router_v1.10"."position_type" AS ENUM('erc20', 'vault_v1', 'debtOf');--> statement-breakpoint
2
+ CREATE TYPE "router_v1.10"."status_code" AS ENUM('VALID', 'SIMULATION_ERROR');--> statement-breakpoint
3
+ CREATE TABLE "router_v1.10"."callbacks" (
4
+ "id" varchar(66) PRIMARY KEY NOT NULL,
5
+ "position_chain_id" bigint NOT NULL,
6
+ "position_contract" varchar(42) NOT NULL,
7
+ "position_user" varchar(42) NOT NULL,
8
+ "position_type_id" integer NOT NULL,
9
+ "amount" numeric(78, 0)
10
+ );
11
+ --> statement-breakpoint
12
+ CREATE TABLE "router_v1.10"."chains" (
13
+ "chain_id" bigint NOT NULL,
14
+ "block_number" bigint NOT NULL,
15
+ "epoch" numeric(78, 0) DEFAULT '0' NOT NULL,
16
+ "updated_at" timestamp DEFAULT now() NOT NULL
17
+ );
18
+ --> statement-breakpoint
19
+ CREATE UNIQUE INDEX "chains_chain_id_idx" ON "router_v1.10"."chains" USING btree ("chain_id");--> statement-breakpoint
20
+ CREATE TABLE "router_v1.10"."collectors" (
21
+ "chain_id" bigint NOT NULL,
22
+ "name" text NOT NULL,
23
+ "block_number" bigint NOT NULL,
24
+ "epoch" numeric(78, 0) DEFAULT '0' NOT NULL,
25
+ "updated_at" timestamp DEFAULT now() NOT NULL
26
+ );
27
+ --> statement-breakpoint
28
+ CREATE TABLE "router_v1.10"."consumed_events" (
29
+ "event_id" varchar(128) PRIMARY KEY NOT NULL,
30
+ "chain_id" bigint NOT NULL,
31
+ "maker" varchar(42) NOT NULL,
32
+ "group" varchar(66) NOT NULL,
33
+ "amount" numeric(78, 0) NOT NULL,
34
+ "block_number" bigint NOT NULL,
35
+ "created_at" timestamp DEFAULT now() NOT NULL
36
+ );
37
+ --> statement-breakpoint
38
+ CREATE TABLE "router_v1.10"."groups" (
39
+ "chain_id" bigint NOT NULL,
40
+ "maker" varchar(42) NOT NULL,
41
+ "group" varchar(66) NOT NULL,
42
+ "consumed" numeric(78, 0) NOT NULL,
43
+ "block_number" bigint NOT NULL,
44
+ "updated_at" timestamp DEFAULT now() NOT NULL,
45
+ CONSTRAINT "groups_pk" PRIMARY KEY("chain_id","maker","group")
46
+ );
47
+ --> statement-breakpoint
48
+ CREATE TABLE "router_v1.10"."lots" (
49
+ "chain_id" bigint NOT NULL,
50
+ "user" varchar(42) NOT NULL,
51
+ "contract" varchar(42) NOT NULL,
52
+ "group" varchar(66) NOT NULL,
53
+ "obligation_id" varchar(66) NOT NULL,
54
+ "lower" numeric(78, 0) NOT NULL,
55
+ "upper" numeric(78, 0) NOT NULL,
56
+ CONSTRAINT "lots_pk" PRIMARY KEY("chain_id","user","contract","group","obligation_id")
57
+ );
58
+ --> statement-breakpoint
59
+ CREATE TABLE "router_v1.10"."lots_positions" (
60
+ "chain_id" bigint NOT NULL,
61
+ "contract" varchar(42) NOT NULL,
62
+ "user" varchar(42) NOT NULL,
63
+ "position_type_id" integer NOT NULL,
64
+ CONSTRAINT "lots_positions_pk" PRIMARY KEY("chain_id","contract","user")
65
+ );
66
+ --> statement-breakpoint
67
+ CREATE TABLE "router_v1.10"."merkle_paths" (
68
+ "offer_hash" varchar(66) PRIMARY KEY NOT NULL,
69
+ "tree_root" varchar(66) NOT NULL,
70
+ "proof_nodes" text NOT NULL,
71
+ "created_at" timestamp DEFAULT now() NOT NULL
72
+ );
73
+ --> statement-breakpoint
74
+ CREATE TABLE "router_v1.10"."obligation_collaterals_v2" (
75
+ "obligation_key" varchar(66) NOT NULL,
76
+ "asset" varchar(42) NOT NULL,
77
+ "oracle_address" varchar(42) NOT NULL,
78
+ "lltv" bigint NOT NULL,
79
+ "updated_at" timestamp DEFAULT now() NOT NULL,
80
+ CONSTRAINT "obligation_collaterals_v2_pk" PRIMARY KEY("obligation_key","asset")
81
+ );
82
+ --> statement-breakpoint
83
+ CREATE TABLE "router_v1.10"."obligation_id_keys" (
84
+ "obligation_id" varchar(66) PRIMARY KEY NOT NULL,
85
+ "obligation_key" varchar(66) NOT NULL,
86
+ "chain_id" bigint NOT NULL,
87
+ "morpho_v2" varchar(42) NOT NULL
88
+ );
89
+ --> statement-breakpoint
90
+ CREATE TABLE "router_v1.10"."obligations" (
91
+ "obligation_key" varchar(66) PRIMARY KEY NOT NULL,
92
+ "loan_token" varchar(42) NOT NULL,
93
+ "maturity" integer NOT NULL
94
+ );
95
+ --> statement-breakpoint
96
+ CREATE TABLE "router_v1.10"."offers" (
97
+ "hash" varchar(66) PRIMARY KEY NOT NULL,
98
+ "obligation_id" varchar(66) NOT NULL,
99
+ "assets" numeric(78, 0) NOT NULL,
100
+ "obligation_units" numeric(78, 0) DEFAULT '0' NOT NULL,
101
+ "obligation_shares" numeric(78, 0) DEFAULT '0' NOT NULL,
102
+ "tick" integer NOT NULL,
103
+ "maturity" integer NOT NULL,
104
+ "expiry" integer NOT NULL,
105
+ "start" integer NOT NULL,
106
+ "group_chain_id" bigint NOT NULL,
107
+ "group_maker" varchar(42) NOT NULL,
108
+ "group_group" varchar(66) NOT NULL,
109
+ "session" varchar(66) NOT NULL,
110
+ "buy" boolean NOT NULL,
111
+ "callback_address" varchar(42) NOT NULL,
112
+ "callback_data" text NOT NULL,
113
+ "receiver_if_maker_is_seller" varchar(42),
114
+ "block_number" bigint NOT NULL,
115
+ "updated_at" timestamp DEFAULT now() NOT NULL
116
+ );
117
+ --> statement-breakpoint
118
+ CREATE TABLE "router_v1.10"."offers_callbacks" (
119
+ "offer_hash" varchar(66) NOT NULL,
120
+ "callback_id" varchar(66),
121
+ CONSTRAINT "offers_callbacks_pk" PRIMARY KEY("offer_hash","callback_id")
122
+ );
123
+ --> statement-breakpoint
124
+ CREATE TABLE "router_v1.10"."offsets" (
125
+ "chain_id" bigint NOT NULL,
126
+ "user" varchar(42) NOT NULL,
127
+ "contract" varchar(42) NOT NULL,
128
+ "group" varchar(66) NOT NULL,
129
+ "obligation_id" varchar(66) NOT NULL,
130
+ "value" numeric(78, 0) NOT NULL,
131
+ CONSTRAINT "offsets_pk" PRIMARY KEY("chain_id","user","contract","group","obligation_id")
132
+ );
133
+ --> statement-breakpoint
134
+ CREATE TABLE "router_v1.10"."oracles" (
135
+ "chain_id" bigint NOT NULL,
136
+ "address" varchar(42) NOT NULL,
137
+ "price" numeric(78, 0),
138
+ "block_number" bigint NOT NULL,
139
+ "updated_at" timestamp DEFAULT now() NOT NULL,
140
+ CONSTRAINT "oracles_pk" PRIMARY KEY("chain_id","address")
141
+ );
142
+ --> statement-breakpoint
143
+ CREATE TABLE "router_v1.10"."position_types" (
144
+ "id" serial PRIMARY KEY NOT NULL,
145
+ "type" "router_v1.10"."position_type" NOT NULL
146
+ );
147
+ --> statement-breakpoint
148
+ CREATE TABLE "router_v1.10"."positions" (
149
+ "chain_id" bigint NOT NULL,
150
+ "contract" varchar(66) NOT NULL,
151
+ "user" varchar(42) NOT NULL,
152
+ "position_type_id" integer NOT NULL,
153
+ "balance" numeric(78, 0),
154
+ "asset" varchar(42),
155
+ "block_number" bigint NOT NULL,
156
+ "updated_at" timestamp DEFAULT now() NOT NULL,
157
+ CONSTRAINT "positions_pk" PRIMARY KEY("chain_id","contract","user","position_type_id")
158
+ );
159
+ --> statement-breakpoint
160
+ CREATE TABLE "router_v1.10"."status" (
161
+ "id" serial PRIMARY KEY NOT NULL,
162
+ "code" "router_v1.10"."status_code",
163
+ CONSTRAINT "status_code_unique" UNIQUE("code")
164
+ );
165
+ --> statement-breakpoint
166
+ CREATE TABLE "router_v1.10"."transfers" (
167
+ "event_id" varchar(128) PRIMARY KEY NOT NULL,
168
+ "chain_id" bigint NOT NULL,
169
+ "contract" varchar(66) NOT NULL,
170
+ "from" varchar(42) NOT NULL,
171
+ "to" varchar(42) NOT NULL,
172
+ "value" numeric(78, 0) NOT NULL,
173
+ "position_type_id" integer NOT NULL,
174
+ "block_number" bigint NOT NULL,
175
+ "created_at" timestamp DEFAULT now() NOT NULL
176
+ );
177
+ --> statement-breakpoint
178
+ CREATE TABLE "router_v1.10"."trees" (
179
+ "root" varchar(66) PRIMARY KEY NOT NULL,
180
+ "root_signature" varchar(132) NOT NULL,
181
+ "created_at" timestamp DEFAULT now() NOT NULL
182
+ );
183
+ --> statement-breakpoint
184
+ CREATE TABLE "router_v1.10"."validations" (
185
+ "offer_hash" varchar(66) PRIMARY KEY NOT NULL,
186
+ "status_id" integer NOT NULL,
187
+ "updated_at" timestamp DEFAULT now() NOT NULL
188
+ );
189
+ --> statement-breakpoint
190
+ DROP TABLE "router_v1.9"."callbacks" CASCADE;--> statement-breakpoint
191
+ DROP TABLE "router_v1.9"."chains" CASCADE;--> statement-breakpoint
192
+ DROP TABLE "router_v1.9"."collectors" CASCADE;--> statement-breakpoint
193
+ DROP TABLE "router_v1.9"."consumed_events" CASCADE;--> statement-breakpoint
194
+ DROP TABLE "router_v1.9"."groups" CASCADE;--> statement-breakpoint
195
+ DROP TABLE "router_v1.9"."lots" CASCADE;--> statement-breakpoint
196
+ DROP TABLE "router_v1.9"."lots_positions" CASCADE;--> statement-breakpoint
197
+ DROP TABLE "router_v1.9"."merkle_paths" CASCADE;--> statement-breakpoint
198
+ DROP TABLE "router_v1.9"."obligation_collaterals_v2" CASCADE;--> statement-breakpoint
199
+ DROP TABLE "router_v1.9"."obligations" CASCADE;--> statement-breakpoint
200
+ DROP TABLE "router_v1.9"."offers" CASCADE;--> statement-breakpoint
201
+ DROP TABLE "router_v1.9"."offers_callbacks" CASCADE;--> statement-breakpoint
202
+ DROP TABLE "router_v1.9"."offsets" CASCADE;--> statement-breakpoint
203
+ DROP TABLE "router_v1.9"."oracles" CASCADE;--> statement-breakpoint
204
+ DROP TABLE "router_v1.9"."position_types" CASCADE;--> statement-breakpoint
205
+ DROP TABLE "router_v1.9"."positions" CASCADE;--> statement-breakpoint
206
+ DROP TABLE "router_v1.9"."status" CASCADE;--> statement-breakpoint
207
+ DROP TABLE "router_v1.9"."transfers" CASCADE;--> statement-breakpoint
208
+ DROP TABLE "router_v1.9"."trees" CASCADE;--> statement-breakpoint
209
+ DROP TABLE "router_v1.9"."validations" CASCADE;--> statement-breakpoint
210
+ ALTER TABLE "router_v1.10"."callbacks" ADD CONSTRAINT "callbacks_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.10"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
211
+ ALTER TABLE "router_v1.10"."callbacks" ADD CONSTRAINT "callbacks_positions_fk" FOREIGN KEY ("position_chain_id","position_contract","position_user","position_type_id") REFERENCES "router_v1.10"."positions"("chain_id","contract","user","position_type_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
212
+ ALTER TABLE "router_v1.10"."collectors" ADD CONSTRAINT "collectors_chain_id_chains_chain_id_fk" FOREIGN KEY ("chain_id") REFERENCES "router_v1.10"."chains"("chain_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
213
+ ALTER TABLE "router_v1.10"."consumed_events" ADD CONSTRAINT "consumed_events_groups_fk" FOREIGN KEY ("chain_id","maker","group") REFERENCES "router_v1.10"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
214
+ ALTER TABLE "router_v1.10"."lots" ADD CONSTRAINT "lots_lots_positions_fk" FOREIGN KEY ("chain_id","contract","user") REFERENCES "router_v1.10"."lots_positions"("chain_id","contract","user") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
215
+ ALTER TABLE "router_v1.10"."lots" ADD CONSTRAINT "lots_groups_fk" FOREIGN KEY ("chain_id","user","group") REFERENCES "router_v1.10"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
216
+ ALTER TABLE "router_v1.10"."lots_positions" ADD CONSTRAINT "lots_positions_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.10"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
217
+ ALTER TABLE "router_v1.10"."lots_positions" ADD CONSTRAINT "lots_positions_positions_fk" FOREIGN KEY ("chain_id","contract","user","position_type_id") REFERENCES "router_v1.10"."positions"("chain_id","contract","user","position_type_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
218
+ ALTER TABLE "router_v1.10"."merkle_paths" ADD CONSTRAINT "merkle_paths_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "router_v1.10"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
219
+ ALTER TABLE "router_v1.10"."merkle_paths" ADD CONSTRAINT "merkle_paths_tree_root_trees_root_fk" FOREIGN KEY ("tree_root") REFERENCES "router_v1.10"."trees"("root") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
220
+ ALTER TABLE "router_v1.10"."obligation_collaterals_v2" ADD CONSTRAINT "obligation_collaterals_v2_obligation_key_obligations_obligation_key_fk" FOREIGN KEY ("obligation_key") REFERENCES "router_v1.10"."obligations"("obligation_key") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
221
+ ALTER TABLE "router_v1.10"."obligation_id_keys" ADD CONSTRAINT "obligation_id_keys_obligation_key_obligations_obligation_key_fk" FOREIGN KEY ("obligation_key") REFERENCES "router_v1.10"."obligations"("obligation_key") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
222
+ ALTER TABLE "router_v1.10"."offers" ADD CONSTRAINT "offers_obligation_id_obligation_id_keys_obligation_id_fk" FOREIGN KEY ("obligation_id") REFERENCES "router_v1.10"."obligation_id_keys"("obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
223
+ ALTER TABLE "router_v1.10"."offers" ADD CONSTRAINT "offers_groups_fk" FOREIGN KEY ("group_chain_id","group_maker","group_group") REFERENCES "router_v1.10"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
224
+ ALTER TABLE "router_v1.10"."offers_callbacks" ADD CONSTRAINT "offers_callbacks_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "router_v1.10"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
225
+ ALTER TABLE "router_v1.10"."offsets" ADD CONSTRAINT "offsets_lots_positions_fk" FOREIGN KEY ("chain_id","contract","user") REFERENCES "router_v1.10"."lots_positions"("chain_id","contract","user") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
226
+ ALTER TABLE "router_v1.10"."positions" ADD CONSTRAINT "positions_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.10"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
227
+ ALTER TABLE "router_v1.10"."transfers" ADD CONSTRAINT "transfers_position_type_id_position_types_id_fk" FOREIGN KEY ("position_type_id") REFERENCES "router_v1.10"."position_types"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
228
+ ALTER TABLE "router_v1.10"."transfers" ADD CONSTRAINT "transfers_positions_from_fk" FOREIGN KEY ("chain_id","contract","from","position_type_id") REFERENCES "router_v1.10"."positions"("chain_id","contract","user","position_type_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
229
+ ALTER TABLE "router_v1.10"."transfers" ADD CONSTRAINT "transfers_positions_to_fk" FOREIGN KEY ("chain_id","contract","to","position_type_id") REFERENCES "router_v1.10"."positions"("chain_id","contract","user","position_type_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
230
+ ALTER TABLE "router_v1.10"."validations" ADD CONSTRAINT "validations_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "router_v1.10"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
231
+ ALTER TABLE "router_v1.10"."validations" ADD CONSTRAINT "validations_status_id_status_id_fk" FOREIGN KEY ("status_id") REFERENCES "router_v1.10"."status"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
232
+ CREATE UNIQUE INDEX "collectors_chain_name_idx" ON "router_v1.10"."collectors" USING btree ("chain_id","name");--> statement-breakpoint
233
+ CREATE INDEX "consumed_events_group_idx" ON "router_v1.10"."consumed_events" USING btree ("chain_id","maker","group");--> statement-breakpoint
234
+ CREATE INDEX "consumed_events_block_number_idx" ON "router_v1.10"."consumed_events" USING btree ("block_number");--> statement-breakpoint
235
+ CREATE INDEX "groups_chain_id_maker_group_consumed_idx" ON "router_v1.10"."groups" USING btree ("chain_id","maker","group","consumed");--> statement-breakpoint
236
+ CREATE INDEX "merkle_paths_tree_root_idx" ON "router_v1.10"."merkle_paths" USING btree ("tree_root");--> statement-breakpoint
237
+ CREATE INDEX "obligation_collaterals_v2_obligation_key_idx" ON "router_v1.10"."obligation_collaterals_v2" USING btree ("obligation_key");--> statement-breakpoint
238
+ CREATE INDEX "obligation_collaterals_v2_oracle_address_idx" ON "router_v1.10"."obligation_collaterals_v2" USING btree ("oracle_address");--> statement-breakpoint
239
+ CREATE INDEX "obligation_id_keys_obligation_key_idx" ON "router_v1.10"."obligation_id_keys" USING btree ("obligation_key");--> statement-breakpoint
240
+ CREATE INDEX "obligation_id_keys_chain_id_idx" ON "router_v1.10"."obligation_id_keys" USING btree ("chain_id");--> statement-breakpoint
241
+ CREATE INDEX "offers_group_fk_idx" ON "router_v1.10"."offers" USING btree ("group_chain_id","group_maker","group_group");--> statement-breakpoint
242
+ CREATE INDEX "offers_group_and_hash_idx" ON "router_v1.10"."offers" USING btree ("group_chain_id","group_maker","group_group","hash");--> statement-breakpoint
243
+ CREATE INDEX "offers_obligation_id_side_idx" ON "router_v1.10"."offers" USING btree ("obligation_id","buy");--> statement-breakpoint
244
+ CREATE INDEX "transfers_chain_contract_user_idx" ON "router_v1.10"."transfers" USING btree ("chain_id","contract","from","to","block_number");--> statement-breakpoint
245
+ CREATE INDEX "transfers_chain_type_block_idx" ON "router_v1.10"."transfers" USING btree ("chain_id","position_type_id","block_number");--> statement-breakpoint
246
+ DROP TYPE "router_v1.9"."position_type";--> statement-breakpoint
247
+ DROP TYPE "router_v1.9"."status_code";