Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: merge staging #327

Merged
merged 46 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
45317be
wip
calmdentist Oct 30, 2024
a0f7595
wip: stream signatures, consolidate v3+v4 txns
calmdentist Oct 30, 2024
dbd018c
v4 logsSubscribe
calmdentist Oct 30, 2024
b0f4678
organizing v3 stuff...
calmdentist Oct 30, 2024
5d425e3
clean up
calmdentist Oct 30, 2024
581c4fa
wip: v3 updates
calmdentist Oct 31, 2024
4b39a51
feat: updates drizzle orm and kit
R-K-H Nov 4, 2024
d0f1712
feat: v4 indexer logic complete
calmdentist Nov 5, 2024
f82af2a
feat: updates for new native queries
R-K-H Nov 5, 2024
f65da23
fix: pnpm
R-K-H Nov 5, 2024
07bb7de
feat: v3 subscribe logic in progress
calmdentist Nov 5, 2024
b1fe7f0
Merge branch 'optimized_indexer' of https://github.com/metaDAOproject…
calmdentist Nov 5, 2024
05fda0e
feat: added indexing directly from logs for v3 autocrat
calmdentist Nov 5, 2024
f051c90
feat: fixed crash on staging
calmdentist Nov 6, 2024
1339869
feat: v4 forward/backward filling
calmdentist Nov 6, 2024
e9d09bd
feat: v4 forward/backward filling
calmdentist Nov 6, 2024
55f7d19
feat: v4 + v3 AMM logsSubscribe indexing + fixes
calmdentist Nov 7, 2024
fa34876
feat: adds more native queries and optimization
R-K-H Nov 8, 2024
375416d
feat: unified schema, v4 working perfecto, v3 cleanup in progress
calmdentist Nov 11, 2024
f6d6d4f
feat: filler should never have gaps/lapses
calmdentist Nov 12, 2024
aad9845
feat: db migration wip
calmdentist Nov 12, 2024
8ba6488
feat: db migration done (i think)
calmdentist Nov 12, 2024
d6dfc0c
feat: index price/twap from logs, minor improvements/fixes
calmdentist Nov 13, 2024
215b622
feat: extends queries and API
R-K-H Nov 14, 2024
71b7287
feat: error handling + reduce latency on v4
calmdentist Nov 18, 2024
d16c0c7
feat: prepend env in error logging
calmdentist Nov 18, 2024
60bf81c
feat: creating PR, exported hasura metadata
calmdentist Nov 18, 2024
8136649
Merge branch 'staging' into optimized_indexer
calmdentist Nov 18, 2024
38d3e0d
fix: sync metadata
R-K-H Nov 18, 2024
6a0565b
fix: downgrading futarchy version
calmdentist Nov 18, 2024
00462fd
fix: pnpm version
calmdentist Nov 18, 2024
569114e
Merge pull request #314 from metaDAOproject/optimized_indexer
R-K-H Nov 18, 2024
9f6f833
feat: enrich token from db not rpc
calmdentist Nov 19, 2024
9df1048
feat: one listener for amms/prices/twaps/orders
calmdentist Nov 19, 2024
02273f7
Merge pull request #319 from metaDAOproject/feat/performance
R-K-H Nov 19, 2024
96cd68b
feat: adds extention for orgs vs daos, colors
R-K-H Nov 19, 2024
4071c35
feat: insert sig before processing events v4
calmdentist Nov 19, 2024
f250cb1
Merge branch 'staging' into feat/performance
calmdentist Nov 19, 2024
ed312b5
Merge pull request #321 from metaDAOproject/feat/performance
R-K-H Nov 19, 2024
2aefdfc
feat: clean up comments/console.logs
calmdentist Nov 19, 2024
691d6b7
Merge branch 'staging' into feat/performance
calmdentist Nov 19, 2024
34b195a
feat: index autocrat daos/proposals from logsSubscribe
calmdentist Nov 20, 2024
67cd47f
Merge pull request #320 from metaDAOproject/feat/multi-dao-orgs
R-K-H Nov 20, 2024
2d0be15
Merge pull request #323 from metaDAOproject/feat/performance
R-K-H Nov 20, 2024
a1fd971
fix: ordering of tokens from db bug
calmdentist Nov 20, 2024
06e7801
Merge pull request #326 from metaDAOproject/feat/performance
R-K-H Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
},
"devDependencies": {
"bun": "1.0.26"
}
},
"packageManager": "[email protected]+sha512.4abf725084d7bcbafbd728bfc7bee61f2f791f977fd87542b3579dcb23504d170d46337945e4c66485cd12d588a0c0e570ed9c477e7ccdd8507cf05f3f92eaca"
}
Binary file added packages/database/bun.lockb
Binary file not shown.
6 changes: 6 additions & 0 deletions packages/database/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from "drizzle-kit";
export default defineConfig({
dialect: "postgresql", // "mysql" | "sqlite" | "postgresql"
schema: "./lib/schema.ts",
out: "./drizzle",
});
59 changes: 59 additions & 0 deletions packages/database/drizzle/0009_brainy_karma.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ALTER TABLE "indexers" ADD COLUMN "latest_tx_sig_processed" varchar(88);--> statement-breakpoint
ALTER TABLE "v0_4_merges" DROP COLUMN IF EXISTS "id";--> statement-breakpoint
ALTER TABLE "v0_4_splits" DROP COLUMN IF EXISTS "id";--> statement-breakpoint
-- CREATE VIEW "public"."prices_chart_data" AS (
-- SELECT
-- TIME_BUCKET('30 SECONDS'::INTERVAL, prices.created_at) AS interv,
-- last(price, prices.created_at) FILTER(WHERE prices.created_at IS NOT NULL AND CASE WHEN prices_type = 'spot' THEN TRUE ELSE prices.created_at <= markets.created_at + '5 DAYS'::INTERVAL END) AS price,
-- last(base_amount, prices.created_at) FILTER(WHERE prices.created_at IS NOT NULL AND CASE WHEN prices_type = 'spot' THEN TRUE ELSE prices.created_at <= markets.created_at + '5 DAYS'::INTERVAL END) AS base_amount,
-- last(quote_amount, prices.created_at) FILTER(WHERE prices.created_at IS NOT NULL AND CASE WHEN prices_type = 'spot' THEN TRUE ELSE prices.created_at <= markets.created_at + '5 DAYS'::INTERVAL END) AS quote_amount,
-- prices_type,
-- prices.market_acct AS market_acct
-- FROM prices
-- JOIN markets ON markets.market_acct = prices.market_acct
-- WHERE CASE WHEN prices_type = 'spot' THEN TRUE ELSE prices.created_at <= markets.created_at + '5 DAYS'::INTERVAL END
-- GROUP BY interv, prices.market_acct, prices_type
-- );--> statement-breakpoint
-- CREATE VIEW "public"."proposal_total_trade_volume" AS (
-- WITH pass_market AS (
-- SELECT
-- proposal_acct,
-- orders.market_acct AS pass_market_acct,
-- TIME_BUCKET('1 DAYS'::INTERVAL, orders.order_time) AS interv,
-- SUM(filled_base_amount * quote_price) FILTER(WHERE orders.order_time IS NOT NULL) AS pass_volume
-- FROM proposals
-- JOIN orders
-- ON proposals.pass_market_acct = orders.market_acct
-- GROUP BY proposal_acct, interv, orders.market_acct
-- ),
-- fail_market AS (
-- SELECT
-- proposal_acct,
-- orders.market_acct AS fail_market_acct,
-- TIME_BUCKET('1 DAYS'::INTERVAL, orders.order_time) AS interv,
-- SUM(filled_base_amount * quote_price) FILTER(WHERE orders.order_time IS NOT NULL) AS fail_volume
-- FROM proposals
-- JOIN orders
-- ON proposals.fail_market_acct = orders.market_acct
-- GROUP BY proposal_acct, interv, orders.market_acct
-- )
-- SELECT
-- pass_market.proposal_acct AS proposal_acct,
-- pass_market_acct,
-- fail_market_acct,
-- SUM(pass_volume) AS pass_volume,
-- SUM(fail_volume) AS fail_volume
-- FROM pass_market
-- JOIN fail_market ON fail_market.proposal_acct = pass_market.proposal_acct
-- GROUP BY pass_market.proposal_acct, pass_market_acct, fail_market_acct
-- );--> statement-breakpoint
-- CREATE VIEW "public"."twap_chart_data" AS (
-- SELECT
-- TIME_BUCKET('30 SECONDS'::INTERVAL, "twaps"."created_at") AS interv,
-- last(token_amount, "twaps"."created_at") FILTER(WHERE "twaps"."created_at" IS NOT NULL AND "twaps"."created_at" <= "markets"."created_at" + '5 DAYS'::INTERVAL) AS token_amount,
-- "twaps"."market_acct" AS market_acct
-- FROM "twaps"
-- JOIN "markets" ON "markets"."market_acct" = "twaps"."market_acct"
-- WHERE "twaps"."created_at" <= "markets"."created_at" + '5 DAYS'::INTERVAL
-- GROUP BY interv, "twaps"."market_acct"
-- );
34 changes: 34 additions & 0 deletions packages/database/drizzle/0010_crazy_sentinels.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CREATE TABLE IF NOT EXISTS "organizations" (
"organization_id" bigserial PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"slug" varchar,
"url" varchar,
"description" text,
"image_url" varchar,
"creator_acct" varchar(44),
"admin_accts" jsonb,
"is_hide" boolean,
"socials" jsonb,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "organizations_name_unique" UNIQUE("name"),
CONSTRAINT "organizations_slug_unique" UNIQUE("slug"),
CONSTRAINT "organizations_url_unique" UNIQUE("url")
-- CONSTRAINT "id_name_url" UNIQUE("organization_id","url","name")
);
--> statement-breakpoint
ALTER TABLE "dao_details" ADD COLUMN "organization_id" bigint;--> statement-breakpoint
ALTER TABLE "daos" ADD COLUMN "is_active" boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE "daos" ADD COLUMN "is_primary" boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE "daos" ADD COLUMN "organization_id" bigint;--> statement-breakpoint
ALTER TABLE "daos" ADD COLUMN "colors" jsonb;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "dao_details" ADD CONSTRAINT "dao_details_organization_id_organizations_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("organization_id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "daos" ADD CONSTRAINT "daos_organization_id_organizations_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("organization_id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
Loading
Loading