From 536cc94a625fd5f9c5b3abec56305ad187638f96 Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Tue, 24 Oct 2023 20:31:58 +0530 Subject: [PATCH 1/4] Checkpoint --- db/migrations/1698085120905-Data.js | 271 ---- db/migrations/1698156475207-Data.js | 77 + schema-ogv.graphql | 105 +- schema.graphql | 105 +- src/abi/governance.abi.ts | 1356 +++++++++++++++++ src/abi/governance.ts | 308 ++++ src/abi/veogv.abi.ts | 945 ++++++++++++ src/abi/veogv.ts | 242 +++ src/main.ts | 12 +- src/model/generated/_ogvLockupEventType.ts | 5 + src/model/generated/_ogvProposalEvent.ts | 7 + src/model/generated/_ogvProposalState.ts | 10 + src/model/generated/_ogvVoteType.ts | 5 + src/model/generated/index.ts | 12 +- src/model/generated/ogv.model.ts | 3 + ...stakedOgv.model.ts => ogvAddress.model.ts} | 26 +- src/model/generated/ogvGovernance.model.ts | 28 - src/model/generated/ogvLockup.model.ts | 37 + src/model/generated/ogvLockupTxLog.model.ts | 26 + src/model/generated/ogvProposal.model.ts | 40 + src/model/generated/ogvProposalTxLog.model.ts | 26 + src/model/generated/ogvProposalVote.model.ts | 35 + src/processors/ogv/governance.ts | 248 +++ src/processors/ogv/ogv-supply.ts | 41 + src/processors/ogv/ogv.ts | 283 ++++ src/utils/addresses.ts | 12 +- 26 files changed, 3907 insertions(+), 358 deletions(-) delete mode 100644 db/migrations/1698085120905-Data.js create mode 100644 db/migrations/1698156475207-Data.js create mode 100644 src/abi/governance.abi.ts create mode 100644 src/abi/governance.ts create mode 100644 src/abi/veogv.abi.ts create mode 100644 src/abi/veogv.ts create mode 100644 src/model/generated/_ogvLockupEventType.ts create mode 100644 src/model/generated/_ogvProposalEvent.ts create mode 100644 src/model/generated/_ogvProposalState.ts create mode 100644 src/model/generated/_ogvVoteType.ts rename src/model/generated/{stakedOgv.model.ts => ogvAddress.model.ts} (50%) delete mode 100644 src/model/generated/ogvGovernance.model.ts create mode 100644 src/model/generated/ogvLockup.model.ts create mode 100644 src/model/generated/ogvLockupTxLog.model.ts create mode 100644 src/model/generated/ogvProposal.model.ts create mode 100644 src/model/generated/ogvProposalTxLog.model.ts create mode 100644 src/model/generated/ogvProposalVote.model.ts create mode 100644 src/processors/ogv/governance.ts create mode 100644 src/processors/ogv/ogv-supply.ts create mode 100644 src/processors/ogv/ogv.ts diff --git a/db/migrations/1698085120905-Data.js b/db/migrations/1698085120905-Data.js deleted file mode 100644 index d366e328..00000000 --- a/db/migrations/1698085120905-Data.js +++ /dev/null @@ -1,271 +0,0 @@ -module.exports = class Data1698085120905 { - name = 'Data1698085120905' - - async up(db) { - await db.query(`CREATE TABLE "exchange_rate" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "pair" text NOT NULL, "base" text NOT NULL, "quote" text NOT NULL, "rate" numeric NOT NULL, CONSTRAINT "PK_5c5d27d2b900ef6cdeef0398472" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_9e23a3f1bf3634820c873a0fe8" ON "exchange_rate" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_c61a93768eed9e58ce399bbe01" ON "exchange_rate" ("block_number") `) - await db.query(`CREATE TABLE "balance" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "token" text NOT NULL, "address" text NOT NULL, "balance" numeric NOT NULL, CONSTRAINT "PK_079dddd31a81672e8143a649ca0" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_a956b410c329b8eca7898c3c51" ON "balance" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_6b451b59c9f6a6fdd685f530b2" ON "balance" ("block_number") `) - await db.query(`CREATE TABLE "strategy_balance" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "strategy" text NOT NULL, "asset" text NOT NULL, "balance" numeric NOT NULL, CONSTRAINT "PK_ca6f93229d1392e9546d01dae4f" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_0113bf0b63183bea0d22cd0d08" ON "strategy_balance" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_a88065dcd92011698bbe7df7b1" ON "strategy_balance" ("block_number") `) - await db.query(`CREATE TABLE "curve_pool_balance" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "address" text NOT NULL, "balance0" numeric NOT NULL, "balance1" numeric NOT NULL, "balance2" numeric NOT NULL, CONSTRAINT "PK_40412750bb910ca560aa084dd88" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_ffb0d0f86f03faacef7cb3e092" ON "curve_pool_balance" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_db5522c865eb8ed76fa7aeb4a8" ON "curve_pool_balance" ("block_number") `) - await db.query(`CREATE TABLE "oeth" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, CONSTRAINT "PK_de1d885501070dbd1ab6f8577ba" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_5b81a67229bac2d68e0dc92cc4" ON "oeth" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_408e5f79f83093aa5cf2b0ea32" ON "oeth" ("block_number") `) - await db.query(`CREATE TABLE "oeth_history" ("id" character varying NOT NULL, "value" numeric NOT NULL, "balance" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "type" character varying(8) NOT NULL, "address_id" character varying, CONSTRAINT "PK_2c7e7571cd9ea02b07a27a303f3" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_94e47c4c49128c78f60b185b46" ON "oeth_history" ("address_id") `) - await db.query(`CREATE INDEX "IDX_96956b1c8d29eb7066a97d5ea7" ON "oeth_history" ("block_number") `) - await db.query(`CREATE INDEX "IDX_b14170bdb7fbc0775bf55df15d" ON "oeth_history" ("tx_hash") `) - await db.query(`CREATE TABLE "oeth_address" ("id" character varying NOT NULL, "is_contract" boolean NOT NULL, "rebasing_option" character varying(6) NOT NULL, "balance" numeric NOT NULL, "earned" numeric NOT NULL, "credits" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, CONSTRAINT "PK_92a966afe47d584af73ce77a1cd" PRIMARY KEY ("id"))`) - await db.query(`CREATE TABLE "oethapy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, CONSTRAINT "PK_8dbb4d04591848361200f18f62a" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_b1a448045d1ed9d655b679a371" ON "oethapy" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_6b8a7a706a0701e659a7d81508" ON "oethapy" ("block_number") `) - await db.query(`CREATE INDEX "IDX_c0c03168bb0139e3cffda4f00e" ON "oethapy" ("tx_hash") `) - await db.query(`CREATE TABLE "oeth_rebase" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "total_supply" numeric NOT NULL, "rebasing_credits" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, "fee" numeric NOT NULL, "yield" numeric NOT NULL, "apy_id" character varying, CONSTRAINT "PK_5f8f4dd071caf685b4ac2d54de3" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_fbb7b3f2fff9896eb683b86de7" ON "oeth_rebase" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_d3255d02d9407bba89380d01fa" ON "oeth_rebase" ("block_number") `) - await db.query(`CREATE INDEX "IDX_8b6bb0243472af88612fe6a01f" ON "oeth_rebase" ("tx_hash") `) - await db.query(`CREATE INDEX "IDX_3331819842173de7c27c046547" ON "oeth_rebase" ("apy_id") `) - await db.query(`CREATE TABLE "oeth_rebase_option" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "status" character varying(6) NOT NULL, "address_id" character varying, CONSTRAINT "PK_32971725d5523200b4b3b7c07e5" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_1fc6bbd88037bfbf4361776909" ON "oeth_rebase_option" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_cbb7ceb49ef7c45432d0171296" ON "oeth_rebase_option" ("block_number") `) - await db.query(`CREATE INDEX "IDX_355826dadaacc5ae2d63c82f28" ON "oeth_rebase_option" ("tx_hash") `) - await db.query(`CREATE INDEX "IDX_034428879698039839b4ba6ffe" ON "oeth_rebase_option" ("address_id") `) - await db.query(`CREATE TABLE "oeth_vault" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, "st_eth" numeric NOT NULL, "r_eth" numeric NOT NULL, "frx_eth" numeric NOT NULL, CONSTRAINT "PK_9debaa84944fe2be9dc4219ba8f" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_d6298a294864b4eaf793cf35a4" ON "oeth_vault" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_e20cb507a673817b2c68720415" ON "oeth_vault" ("block_number") `) - await db.query(`CREATE TABLE "oeth_curve_lp" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "eth" numeric NOT NULL, "oeth" numeric NOT NULL, "total_supply_owned" numeric NOT NULL, "eth_owned" numeric NOT NULL, "oeth_owned" numeric NOT NULL, CONSTRAINT "PK_2b055044664e80f44d6172fdf54" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_d9bbd20e888fa1b4b2c5d2f039" ON "oeth_curve_lp" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_7617d593c36dce1b1565a8d74a" ON "oeth_curve_lp" ("block_number") `) - await db.query(`CREATE TABLE "oeth_frax_staking" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "sfrx_eth" numeric NOT NULL, CONSTRAINT "PK_694f53c8600ae88c7bdcf7305dd" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_ce6c2c65e90967dfeaac97025b" ON "oeth_frax_staking" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_1a7f7d650390e2f9c212651e05" ON "oeth_frax_staking" ("block_number") `) - await db.query(`CREATE TABLE "oeth_morpho_aave" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_86de8f846e9335c92b8ad7df3a1" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_25e239b985844f1d33fac79981" ON "oeth_morpho_aave" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_a6662224e95eb6921bb14cb5f9" ON "oeth_morpho_aave" ("block_number") `) - await db.query(`CREATE TABLE "dripper" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_74fd102c8d1c60f4b1650a61ffc" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_88c58f8948c3294c2a9e2791dc" ON "dripper" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_06822c0a260797711acc9023d5" ON "dripper" ("block_number") `) - await db.query(`CREATE TABLE "oeth_balancer_meta_pool_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "r_eth" numeric NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_6ddf5b8ba878e6d706e59bd6de0" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_5e7ef383756fa18cb602f50089" ON "oeth_balancer_meta_pool_strategy" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_11d344b3e0e03cdb6697dd61f7" ON "oeth_balancer_meta_pool_strategy" ("block_number") `) - await db.query(`CREATE TABLE "oeth_strategy_holding_daily_stat" ("id" character varying NOT NULL, "symbol" text NOT NULL, "amount" numeric NOT NULL, "value" numeric NOT NULL, "strategy_daily_stat_id_id" character varying, CONSTRAINT "PK_7f1a62da5e53cf264c2f39b4acf" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_4e867f220975e615e6077d860c" ON "oeth_strategy_holding_daily_stat" ("strategy_daily_stat_id_id") `) - await db.query(`CREATE TABLE "oeth_strategy_daily_stat" ("id" character varying NOT NULL, "total" numeric NOT NULL, "tvl" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_8af1a0c60e67b05baf928787a8e" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_6c7096c96a000d8471256ca8fc" ON "oeth_strategy_daily_stat" ("daily_stat_id_id") `) - await db.query(`CREATE TABLE "oeth_collateral_daily_stat" ("id" character varying NOT NULL, "symbol" text NOT NULL, "amount" numeric NOT NULL, "price" numeric NOT NULL, "value" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_5fb23d7bae30dffe4543e7aa069" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_a90045de50406be7bd56efd3ea" ON "oeth_collateral_daily_stat" ("daily_stat_id_id") `) - await db.query(`CREATE TABLE "oeth_daily_stat" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "total_supply" numeric NOT NULL, "total_supply_usd" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, "amo_supply" numeric NOT NULL, "yield" numeric NOT NULL, "fees" numeric NOT NULL, "revenue" numeric NOT NULL, "revenue7_day_avg" numeric NOT NULL, "revenue7_day_total" numeric NOT NULL, "revenue_all_time" numeric NOT NULL, "peg_price" numeric NOT NULL, CONSTRAINT "PK_9144a02ab13b1baa818a7d5eae5" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_98d9001013aa37425ca47b7126" ON "oeth_daily_stat" ("block_number") `) - await db.query(`CREATE INDEX "IDX_c3e66051c7df4efd6a8fa8f9c1" ON "oeth_daily_stat" ("timestamp") `) - await db.query(`CREATE TABLE "ogv" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "circulating" numeric NOT NULL, "total" numeric NOT NULL, CONSTRAINT "PK_f16038abf451ce82bd03ea54ee7" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_2418a8b8b92b2f5977be761cf9" ON "ogv" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_b8f20bcf48e4aa77e0f48d77db" ON "ogv" ("block_number") `) - await db.query(`CREATE TABLE "staked_ogv" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total" numeric NOT NULL, "apy" numeric NOT NULL, CONSTRAINT "PK_b135611d9aab36c7889982c3be8" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_533195c60cfaef9e118789dee9" ON "staked_ogv" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_d601233411a33212b9d616aab0" ON "staked_ogv" ("block_number") `) - await db.query(`CREATE TABLE "ogv_governance" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "registered_voters" integer NOT NULL, "open_source_contributors" integer NOT NULL, "improvement_proposals" integer NOT NULL, CONSTRAINT "PK_b22758cd4ee8ff92c1b7ee0cf20" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_a0329e7109d5959b9aa3d9d374" ON "ogv_governance" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_63cd1ca46771965c68f6b85898" ON "ogv_governance" ("block_number") `) - await db.query(`CREATE TABLE "ousd" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, CONSTRAINT "PK_acecae4a20bc14b22d9f6738d8d" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_c8d1e285213b445b088805ac7c" ON "ousd" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_806949dd853b7e8acab5d03b81" ON "ousd" ("block_number") `) - await db.query(`CREATE TABLE "ousd_history" ("id" character varying NOT NULL, "value" numeric NOT NULL, "balance" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "type" character varying(8) NOT NULL, "address_id" character varying, CONSTRAINT "PK_dcbe3223b67f92d9ad4cffe8a7c" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_70291ea600c0c4d67d9bfe6a6b" ON "ousd_history" ("address_id") `) - await db.query(`CREATE INDEX "IDX_4d00d283e1ce3209dc43a0313c" ON "ousd_history" ("block_number") `) - await db.query(`CREATE INDEX "IDX_0c25caa59aa053a688a723d160" ON "ousd_history" ("tx_hash") `) - await db.query(`CREATE TABLE "ousd_address" ("id" character varying NOT NULL, "is_contract" boolean NOT NULL, "rebasing_option" character varying(6) NOT NULL, "balance" numeric NOT NULL, "earned" numeric NOT NULL, "credits" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, CONSTRAINT "PK_bb061344757ede566d62854af6a" PRIMARY KEY ("id"))`) - await db.query(`CREATE TABLE "ousdapy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, CONSTRAINT "PK_d9889b7153efc82dbe88f9a7a33" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_c514963f42908ce84d65a84a77" ON "ousdapy" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_4f606414b3b5ce1a366bd0fbf6" ON "ousdapy" ("block_number") `) - await db.query(`CREATE INDEX "IDX_0e84a81a109b66fe6f01f77c74" ON "ousdapy" ("tx_hash") `) - await db.query(`CREATE TABLE "ousd_rebase" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "total_supply" numeric NOT NULL, "rebasing_credits" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, "fee" numeric NOT NULL, "yield" numeric NOT NULL, "apy_id" character varying, CONSTRAINT "PK_04cf0de72399a99798dde61b237" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_f8eb4a16ce58a146b3227ee21a" ON "ousd_rebase" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_3fb03b1a410e64c7367226d0b6" ON "ousd_rebase" ("block_number") `) - await db.query(`CREATE INDEX "IDX_1a76c478199672aaeec340f619" ON "ousd_rebase" ("tx_hash") `) - await db.query(`CREATE INDEX "IDX_427468c97f9838b804efd6c8e5" ON "ousd_rebase" ("apy_id") `) - await db.query(`CREATE TABLE "ousd_rebase_option" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "status" character varying(6) NOT NULL, "address_id" character varying, CONSTRAINT "PK_d684f90866027104f3c929dfe10" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_64bd23947dc4c67e3b6a3f9352" ON "ousd_rebase_option" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_9b774e46b8b1cf7f828133809a" ON "ousd_rebase_option" ("block_number") `) - await db.query(`CREATE INDEX "IDX_4e95bf069de04533d83a9a97fd" ON "ousd_rebase_option" ("tx_hash") `) - await db.query(`CREATE INDEX "IDX_b04173f9349ddd991a3b60e914" ON "ousd_rebase_option" ("address_id") `) - await db.query(`CREATE TABLE "ousd_vault" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_343f5538c71a1cd78f1659ef9d3" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_6860186ea2f56e2c7d54c22107" ON "ousd_vault" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_0d0a7113a505cf7f7adea9ca81" ON "ousd_vault" ("block_number") `) - await db.query(`CREATE TABLE "ousd_morpho_aave" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_60676cde905a822ba73ff3a5c85" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_78e0701c2e9a28242db37bd8f8" ON "ousd_morpho_aave" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_46ccf673b376d654052fbd53e6" ON "ousd_morpho_aave" ("block_number") `) - await db.query(`CREATE TABLE "ousd_morpho_compound" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_5f715d53ef8fc0fad595cacf4fa" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_9e7bd0d8ae23b877d5979ef80c" ON "ousd_morpho_compound" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_0bb3a0ad84071f1d80f6d4e90f" ON "ousd_morpho_compound" ("block_number") `) - await db.query(`CREATE TABLE "maker_dsr_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, CONSTRAINT "PK_196da2d6910009ae04e3542fe22" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_a35308a3c5dbaab2d321eb1525" ON "maker_dsr_strategy" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_844b219d8faf9b1d24ab2dba9a" ON "maker_dsr_strategy" ("block_number") `) - await db.query(`CREATE TABLE "ousd_flux_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_ac977221429e50e4de1ce253a8b" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_5b165b5d30b13e363d33a66e14" ON "ousd_flux_strategy" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_80f3392968fde7b99cccb805ac" ON "ousd_flux_strategy" ("block_number") `) - await db.query(`CREATE TABLE "ousd_compound_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_9030e82bf3479d03c04e0d1919c" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_6920b1db5dc577295ac4d1379d" ON "ousd_compound_strategy" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_89c6d7d3104bd36dc88a37add4" ON "ousd_compound_strategy" ("block_number") `) - await db.query(`CREATE TABLE "ousd_convex_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_2b8f6e749e15e49d8816f1ac949" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_2deac473cd0b2dd7082e7da148" ON "ousd_convex_strategy" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_157bf74171817dc5c60ee37036" ON "ousd_convex_strategy" ("block_number") `) - await db.query(`CREATE TABLE "ousd_aave_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_b4b7ac6e395aa722df500f93623" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_ca34b5a0a33bc9abdd8213c2fa" ON "ousd_aave_strategy" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_dacd7c98223d7bc8be074d71e4" ON "ousd_aave_strategy" ("block_number") `) - await db.query(`CREATE TABLE "ousd_meta_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_d99170af73d86fe74460bbfacc4" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_7e998dcf775263bc5df76ef987" ON "ousd_meta_strategy" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_55ce185680512d6a5b9fb0af89" ON "ousd_meta_strategy" ("block_number") `) - await db.query(`CREATE TABLE "ousd_convex_lusd_plus3_crv" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_47290aa5dfa3cc5595f468e2f39" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_0783af95efb35fb3f13cde1656" ON "ousd_convex_lusd_plus3_crv" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_74ae01fb596a4f2733087ba454" ON "ousd_convex_lusd_plus3_crv" ("block_number") `) - await db.query(`ALTER TABLE "oeth_history" ADD CONSTRAINT "FK_94e47c4c49128c78f60b185b46b" FOREIGN KEY ("address_id") REFERENCES "oeth_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "oeth_rebase" ADD CONSTRAINT "FK_3331819842173de7c27c046547a" FOREIGN KEY ("apy_id") REFERENCES "oethapy"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "oeth_rebase_option" ADD CONSTRAINT "FK_034428879698039839b4ba6ffe8" FOREIGN KEY ("address_id") REFERENCES "oeth_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" ADD CONSTRAINT "FK_4e867f220975e615e6077d860c1" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "oeth_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "oeth_strategy_daily_stat" ADD CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "oeth_collateral_daily_stat" ADD CONSTRAINT "FK_a90045de50406be7bd56efd3ea4" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ousd_history" ADD CONSTRAINT "FK_70291ea600c0c4d67d9bfe6a6bf" FOREIGN KEY ("address_id") REFERENCES "ousd_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ousd_rebase" ADD CONSTRAINT "FK_427468c97f9838b804efd6c8e55" FOREIGN KEY ("apy_id") REFERENCES "ousdapy"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ousd_rebase_option" ADD CONSTRAINT "FK_b04173f9349ddd991a3b60e914a" FOREIGN KEY ("address_id") REFERENCES "ousd_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - } - - async down(db) { - await db.query(`DROP TABLE "exchange_rate"`) - await db.query(`DROP INDEX "public"."IDX_9e23a3f1bf3634820c873a0fe8"`) - await db.query(`DROP INDEX "public"."IDX_c61a93768eed9e58ce399bbe01"`) - await db.query(`DROP TABLE "balance"`) - await db.query(`DROP INDEX "public"."IDX_a956b410c329b8eca7898c3c51"`) - await db.query(`DROP INDEX "public"."IDX_6b451b59c9f6a6fdd685f530b2"`) - await db.query(`DROP TABLE "strategy_balance"`) - await db.query(`DROP INDEX "public"."IDX_0113bf0b63183bea0d22cd0d08"`) - await db.query(`DROP INDEX "public"."IDX_a88065dcd92011698bbe7df7b1"`) - await db.query(`DROP TABLE "curve_pool_balance"`) - await db.query(`DROP INDEX "public"."IDX_ffb0d0f86f03faacef7cb3e092"`) - await db.query(`DROP INDEX "public"."IDX_db5522c865eb8ed76fa7aeb4a8"`) - await db.query(`DROP TABLE "oeth"`) - await db.query(`DROP INDEX "public"."IDX_5b81a67229bac2d68e0dc92cc4"`) - await db.query(`DROP INDEX "public"."IDX_408e5f79f83093aa5cf2b0ea32"`) - await db.query(`DROP TABLE "oeth_history"`) - await db.query(`DROP INDEX "public"."IDX_94e47c4c49128c78f60b185b46"`) - await db.query(`DROP INDEX "public"."IDX_96956b1c8d29eb7066a97d5ea7"`) - await db.query(`DROP INDEX "public"."IDX_b14170bdb7fbc0775bf55df15d"`) - await db.query(`DROP TABLE "oeth_address"`) - await db.query(`DROP TABLE "oethapy"`) - await db.query(`DROP INDEX "public"."IDX_b1a448045d1ed9d655b679a371"`) - await db.query(`DROP INDEX "public"."IDX_6b8a7a706a0701e659a7d81508"`) - await db.query(`DROP INDEX "public"."IDX_c0c03168bb0139e3cffda4f00e"`) - await db.query(`DROP TABLE "oeth_rebase"`) - await db.query(`DROP INDEX "public"."IDX_fbb7b3f2fff9896eb683b86de7"`) - await db.query(`DROP INDEX "public"."IDX_d3255d02d9407bba89380d01fa"`) - await db.query(`DROP INDEX "public"."IDX_8b6bb0243472af88612fe6a01f"`) - await db.query(`DROP INDEX "public"."IDX_3331819842173de7c27c046547"`) - await db.query(`DROP TABLE "oeth_rebase_option"`) - await db.query(`DROP INDEX "public"."IDX_1fc6bbd88037bfbf4361776909"`) - await db.query(`DROP INDEX "public"."IDX_cbb7ceb49ef7c45432d0171296"`) - await db.query(`DROP INDEX "public"."IDX_355826dadaacc5ae2d63c82f28"`) - await db.query(`DROP INDEX "public"."IDX_034428879698039839b4ba6ffe"`) - await db.query(`DROP TABLE "oeth_vault"`) - await db.query(`DROP INDEX "public"."IDX_d6298a294864b4eaf793cf35a4"`) - await db.query(`DROP INDEX "public"."IDX_e20cb507a673817b2c68720415"`) - await db.query(`DROP TABLE "oeth_curve_lp"`) - await db.query(`DROP INDEX "public"."IDX_d9bbd20e888fa1b4b2c5d2f039"`) - await db.query(`DROP INDEX "public"."IDX_7617d593c36dce1b1565a8d74a"`) - await db.query(`DROP TABLE "oeth_frax_staking"`) - await db.query(`DROP INDEX "public"."IDX_ce6c2c65e90967dfeaac97025b"`) - await db.query(`DROP INDEX "public"."IDX_1a7f7d650390e2f9c212651e05"`) - await db.query(`DROP TABLE "oeth_morpho_aave"`) - await db.query(`DROP INDEX "public"."IDX_25e239b985844f1d33fac79981"`) - await db.query(`DROP INDEX "public"."IDX_a6662224e95eb6921bb14cb5f9"`) - await db.query(`DROP TABLE "dripper"`) - await db.query(`DROP INDEX "public"."IDX_88c58f8948c3294c2a9e2791dc"`) - await db.query(`DROP INDEX "public"."IDX_06822c0a260797711acc9023d5"`) - await db.query(`DROP TABLE "oeth_balancer_meta_pool_strategy"`) - await db.query(`DROP INDEX "public"."IDX_5e7ef383756fa18cb602f50089"`) - await db.query(`DROP INDEX "public"."IDX_11d344b3e0e03cdb6697dd61f7"`) - await db.query(`DROP TABLE "oeth_strategy_holding_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_4e867f220975e615e6077d860c"`) - await db.query(`DROP TABLE "oeth_strategy_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_6c7096c96a000d8471256ca8fc"`) - await db.query(`DROP TABLE "oeth_collateral_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_a90045de50406be7bd56efd3ea"`) - await db.query(`DROP TABLE "oeth_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_98d9001013aa37425ca47b7126"`) - await db.query(`DROP INDEX "public"."IDX_c3e66051c7df4efd6a8fa8f9c1"`) - await db.query(`DROP TABLE "ogv"`) - await db.query(`DROP INDEX "public"."IDX_2418a8b8b92b2f5977be761cf9"`) - await db.query(`DROP INDEX "public"."IDX_b8f20bcf48e4aa77e0f48d77db"`) - await db.query(`DROP TABLE "staked_ogv"`) - await db.query(`DROP INDEX "public"."IDX_533195c60cfaef9e118789dee9"`) - await db.query(`DROP INDEX "public"."IDX_d601233411a33212b9d616aab0"`) - await db.query(`DROP TABLE "ogv_governance"`) - await db.query(`DROP INDEX "public"."IDX_a0329e7109d5959b9aa3d9d374"`) - await db.query(`DROP INDEX "public"."IDX_63cd1ca46771965c68f6b85898"`) - await db.query(`DROP TABLE "ousd"`) - await db.query(`DROP INDEX "public"."IDX_c8d1e285213b445b088805ac7c"`) - await db.query(`DROP INDEX "public"."IDX_806949dd853b7e8acab5d03b81"`) - await db.query(`DROP TABLE "ousd_history"`) - await db.query(`DROP INDEX "public"."IDX_70291ea600c0c4d67d9bfe6a6b"`) - await db.query(`DROP INDEX "public"."IDX_4d00d283e1ce3209dc43a0313c"`) - await db.query(`DROP INDEX "public"."IDX_0c25caa59aa053a688a723d160"`) - await db.query(`DROP TABLE "ousd_address"`) - await db.query(`DROP TABLE "ousdapy"`) - await db.query(`DROP INDEX "public"."IDX_c514963f42908ce84d65a84a77"`) - await db.query(`DROP INDEX "public"."IDX_4f606414b3b5ce1a366bd0fbf6"`) - await db.query(`DROP INDEX "public"."IDX_0e84a81a109b66fe6f01f77c74"`) - await db.query(`DROP TABLE "ousd_rebase"`) - await db.query(`DROP INDEX "public"."IDX_f8eb4a16ce58a146b3227ee21a"`) - await db.query(`DROP INDEX "public"."IDX_3fb03b1a410e64c7367226d0b6"`) - await db.query(`DROP INDEX "public"."IDX_1a76c478199672aaeec340f619"`) - await db.query(`DROP INDEX "public"."IDX_427468c97f9838b804efd6c8e5"`) - await db.query(`DROP TABLE "ousd_rebase_option"`) - await db.query(`DROP INDEX "public"."IDX_64bd23947dc4c67e3b6a3f9352"`) - await db.query(`DROP INDEX "public"."IDX_9b774e46b8b1cf7f828133809a"`) - await db.query(`DROP INDEX "public"."IDX_4e95bf069de04533d83a9a97fd"`) - await db.query(`DROP INDEX "public"."IDX_b04173f9349ddd991a3b60e914"`) - await db.query(`DROP TABLE "ousd_vault"`) - await db.query(`DROP INDEX "public"."IDX_6860186ea2f56e2c7d54c22107"`) - await db.query(`DROP INDEX "public"."IDX_0d0a7113a505cf7f7adea9ca81"`) - await db.query(`DROP TABLE "ousd_morpho_aave"`) - await db.query(`DROP INDEX "public"."IDX_78e0701c2e9a28242db37bd8f8"`) - await db.query(`DROP INDEX "public"."IDX_46ccf673b376d654052fbd53e6"`) - await db.query(`DROP TABLE "ousd_morpho_compound"`) - await db.query(`DROP INDEX "public"."IDX_9e7bd0d8ae23b877d5979ef80c"`) - await db.query(`DROP INDEX "public"."IDX_0bb3a0ad84071f1d80f6d4e90f"`) - await db.query(`DROP TABLE "maker_dsr_strategy"`) - await db.query(`DROP INDEX "public"."IDX_a35308a3c5dbaab2d321eb1525"`) - await db.query(`DROP INDEX "public"."IDX_844b219d8faf9b1d24ab2dba9a"`) - await db.query(`DROP TABLE "ousd_flux_strategy"`) - await db.query(`DROP INDEX "public"."IDX_5b165b5d30b13e363d33a66e14"`) - await db.query(`DROP INDEX "public"."IDX_80f3392968fde7b99cccb805ac"`) - await db.query(`DROP TABLE "ousd_compound_strategy"`) - await db.query(`DROP INDEX "public"."IDX_6920b1db5dc577295ac4d1379d"`) - await db.query(`DROP INDEX "public"."IDX_89c6d7d3104bd36dc88a37add4"`) - await db.query(`DROP TABLE "ousd_convex_strategy"`) - await db.query(`DROP INDEX "public"."IDX_2deac473cd0b2dd7082e7da148"`) - await db.query(`DROP INDEX "public"."IDX_157bf74171817dc5c60ee37036"`) - await db.query(`DROP TABLE "ousd_aave_strategy"`) - await db.query(`DROP INDEX "public"."IDX_ca34b5a0a33bc9abdd8213c2fa"`) - await db.query(`DROP INDEX "public"."IDX_dacd7c98223d7bc8be074d71e4"`) - await db.query(`DROP TABLE "ousd_meta_strategy"`) - await db.query(`DROP INDEX "public"."IDX_7e998dcf775263bc5df76ef987"`) - await db.query(`DROP INDEX "public"."IDX_55ce185680512d6a5b9fb0af89"`) - await db.query(`DROP TABLE "ousd_convex_lusd_plus3_crv"`) - await db.query(`DROP INDEX "public"."IDX_0783af95efb35fb3f13cde1656"`) - await db.query(`DROP INDEX "public"."IDX_74ae01fb596a4f2733087ba454"`) - await db.query(`ALTER TABLE "oeth_history" DROP CONSTRAINT "FK_94e47c4c49128c78f60b185b46b"`) - await db.query(`ALTER TABLE "oeth_rebase" DROP CONSTRAINT "FK_3331819842173de7c27c046547a"`) - await db.query(`ALTER TABLE "oeth_rebase_option" DROP CONSTRAINT "FK_034428879698039839b4ba6ffe8"`) - await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" DROP CONSTRAINT "FK_4e867f220975e615e6077d860c1"`) - await db.query(`ALTER TABLE "oeth_strategy_daily_stat" DROP CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3"`) - await db.query(`ALTER TABLE "oeth_collateral_daily_stat" DROP CONSTRAINT "FK_a90045de50406be7bd56efd3ea4"`) - await db.query(`ALTER TABLE "ousd_history" DROP CONSTRAINT "FK_70291ea600c0c4d67d9bfe6a6bf"`) - await db.query(`ALTER TABLE "ousd_rebase" DROP CONSTRAINT "FK_427468c97f9838b804efd6c8e55"`) - await db.query(`ALTER TABLE "ousd_rebase_option" DROP CONSTRAINT "FK_b04173f9349ddd991a3b60e914a"`) - } -} diff --git a/db/migrations/1698156475207-Data.js b/db/migrations/1698156475207-Data.js new file mode 100644 index 00000000..5403f5e4 --- /dev/null +++ b/db/migrations/1698156475207-Data.js @@ -0,0 +1,77 @@ +module.exports = class Data1698156475207 { + name = 'Data1698156475207' + + async up(db) { + await db.query(`CREATE TABLE "oeth_strategy_holding_daily_stat" ("id" character varying NOT NULL, "symbol" text NOT NULL, "amount" numeric NOT NULL, "value" numeric NOT NULL, "strategy_daily_stat_id_id" character varying, CONSTRAINT "PK_7f1a62da5e53cf264c2f39b4acf" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_4e867f220975e615e6077d860c" ON "oeth_strategy_holding_daily_stat" ("strategy_daily_stat_id_id") `) + await db.query(`CREATE TABLE "oeth_strategy_daily_stat" ("id" character varying NOT NULL, "total" numeric NOT NULL, "tvl" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_8af1a0c60e67b05baf928787a8e" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_6c7096c96a000d8471256ca8fc" ON "oeth_strategy_daily_stat" ("daily_stat_id_id") `) + await db.query(`CREATE TABLE "oeth_collateral_daily_stat" ("id" character varying NOT NULL, "symbol" text NOT NULL, "amount" numeric NOT NULL, "price" numeric NOT NULL, "value" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_5fb23d7bae30dffe4543e7aa069" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_a90045de50406be7bd56efd3ea" ON "oeth_collateral_daily_stat" ("daily_stat_id_id") `) + await db.query(`CREATE TABLE "oeth_daily_stat" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "total_supply" numeric NOT NULL, "total_supply_usd" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, "amo_supply" numeric NOT NULL, "yield" numeric NOT NULL, "fees" numeric NOT NULL, "revenue" numeric NOT NULL, "revenue7_day_avg" numeric NOT NULL, "revenue7_day_total" numeric NOT NULL, "revenue_all_time" numeric NOT NULL, "peg_price" numeric NOT NULL, CONSTRAINT "PK_9144a02ab13b1baa818a7d5eae5" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_98d9001013aa37425ca47b7126" ON "oeth_daily_stat" ("block_number") `) + await db.query(`CREATE INDEX "IDX_c3e66051c7df4efd6a8fa8f9c1" ON "oeth_daily_stat" ("timestamp") `) + await db.query(`CREATE TABLE "ogv_address" ("id" character varying NOT NULL, "balance" numeric NOT NULL, "veogv_balance" numeric NOT NULL, "voting_power" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "delegatee_id" character varying, CONSTRAINT "PK_f13c77575687ef480ca0b7de5d8" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_49d26f287904b8b1aef6e9ac2b" ON "ogv_address" ("delegatee_id") `) + await db.query(`CREATE TABLE "ogv_lockup" ("id" character varying NOT NULL, "lockup_id" integer NOT NULL, "amount" numeric NOT NULL, "end" TIMESTAMP WITH TIME ZONE NOT NULL, "veogv" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "address_id" character varying, CONSTRAINT "PK_6b6d5ed3a004dd3f546c1b11fa4" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_8114101b53d9d6bc26fe80838a" ON "ogv_lockup" ("lockup_id") `) + await db.query(`CREATE INDEX "IDX_8be94cd63e35b91adf1301a156" ON "ogv_lockup" ("address_id") `) + await db.query(`CREATE TABLE "ogv_lockup_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "ogv_lockup_id" character varying, CONSTRAINT "PK_1c4a8425ce42f0c9da10056adee" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_b49fca291c97d9b55cd91f935f" ON "ogv_lockup_tx_log" ("ogv_lockup_id") `) + await db.query(`CREATE TABLE "ogv_proposal" ("id" character varying NOT NULL, "description" text, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "start_block" numeric NOT NULL, "end_block" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "status" character varying(9) NOT NULL, "proposer_id" character varying, CONSTRAINT "PK_b06db02b26fa37882e013579407" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_c62be3f16dfb3e4a09525c85af" ON "ogv_proposal" ("proposer_id") `) + await db.query(`CREATE TABLE "ogv_proposal_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, CONSTRAINT "PK_da43c287069bba678ca5c60b1ad" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_5d5f5e10892290ee366d26de7d" ON "ogv_proposal_tx_log" ("proposal_id") `) + await db.query(`CREATE TABLE "ogv_proposal_voter" ("id" character varying NOT NULL, "votes" numeric NOT NULL, "type" character varying(7) NOT NULL, "tx_hash" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, "voter_id" character varying, CONSTRAINT "PK_5a296bd7a618b75b5da0527f761" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_7b3e7fcd2895ba1d6803e42454" ON "ogv_proposal_voter" ("proposal_id") `) + await db.query(`CREATE INDEX "IDX_39efda99c037122170e2fed29b" ON "ogv_proposal_voter" ("voter_id") `) + await db.query(`ALTER TABLE "ogv" ADD "staked" numeric NOT NULL`) + await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" ADD CONSTRAINT "FK_4e867f220975e615e6077d860c1" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "oeth_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "oeth_strategy_daily_stat" ADD CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "oeth_collateral_daily_stat" ADD CONSTRAINT "FK_a90045de50406be7bd56efd3ea4" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_address" ADD CONSTRAINT "FK_49d26f287904b8b1aef6e9ac2b3" FOREIGN KEY ("delegatee_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_lockup" ADD CONSTRAINT "FK_8be94cd63e35b91adf1301a156c" FOREIGN KEY ("address_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_lockup_tx_log" ADD CONSTRAINT "FK_b49fca291c97d9b55cd91f935f3" FOREIGN KEY ("ogv_lockup_id") REFERENCES "ogv_lockup"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_proposal" ADD CONSTRAINT "FK_c62be3f16dfb3e4a09525c85af8" FOREIGN KEY ("proposer_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_proposal_tx_log" ADD CONSTRAINT "FK_5d5f5e10892290ee366d26de7dc" FOREIGN KEY ("proposal_id") REFERENCES "ogv_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_proposal_voter" ADD CONSTRAINT "FK_7b3e7fcd2895ba1d6803e42454b" FOREIGN KEY ("proposal_id") REFERENCES "ogv_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_proposal_voter" ADD CONSTRAINT "FK_39efda99c037122170e2fed29b1" FOREIGN KEY ("voter_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + } + + async down(db) { + await db.query(`DROP TABLE "oeth_strategy_holding_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_4e867f220975e615e6077d860c"`) + await db.query(`DROP TABLE "oeth_strategy_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_6c7096c96a000d8471256ca8fc"`) + await db.query(`DROP TABLE "oeth_collateral_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_a90045de50406be7bd56efd3ea"`) + await db.query(`DROP TABLE "oeth_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_98d9001013aa37425ca47b7126"`) + await db.query(`DROP INDEX "public"."IDX_c3e66051c7df4efd6a8fa8f9c1"`) + await db.query(`DROP TABLE "ogv_address"`) + await db.query(`DROP INDEX "public"."IDX_49d26f287904b8b1aef6e9ac2b"`) + await db.query(`DROP TABLE "ogv_lockup"`) + await db.query(`DROP INDEX "public"."IDX_8114101b53d9d6bc26fe80838a"`) + await db.query(`DROP INDEX "public"."IDX_8be94cd63e35b91adf1301a156"`) + await db.query(`DROP TABLE "ogv_lockup_tx_log"`) + await db.query(`DROP INDEX "public"."IDX_b49fca291c97d9b55cd91f935f"`) + await db.query(`DROP TABLE "ogv_proposal"`) + await db.query(`DROP INDEX "public"."IDX_c62be3f16dfb3e4a09525c85af"`) + await db.query(`DROP TABLE "ogv_proposal_tx_log"`) + await db.query(`DROP INDEX "public"."IDX_5d5f5e10892290ee366d26de7d"`) + await db.query(`DROP TABLE "ogv_proposal_voter"`) + await db.query(`DROP INDEX "public"."IDX_7b3e7fcd2895ba1d6803e42454"`) + await db.query(`DROP INDEX "public"."IDX_39efda99c037122170e2fed29b"`) + await db.query(`ALTER TABLE "ogv" DROP COLUMN "staked"`) + await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" DROP CONSTRAINT "FK_4e867f220975e615e6077d860c1"`) + await db.query(`ALTER TABLE "oeth_strategy_daily_stat" DROP CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3"`) + await db.query(`ALTER TABLE "oeth_collateral_daily_stat" DROP CONSTRAINT "FK_a90045de50406be7bd56efd3ea4"`) + await db.query(`ALTER TABLE "ogv_address" DROP CONSTRAINT "FK_49d26f287904b8b1aef6e9ac2b3"`) + await db.query(`ALTER TABLE "ogv_lockup" DROP CONSTRAINT "FK_8be94cd63e35b91adf1301a156c"`) + await db.query(`ALTER TABLE "ogv_lockup_tx_log" DROP CONSTRAINT "FK_b49fca291c97d9b55cd91f935f3"`) + await db.query(`ALTER TABLE "ogv_proposal" DROP CONSTRAINT "FK_c62be3f16dfb3e4a09525c85af8"`) + await db.query(`ALTER TABLE "ogv_proposal_tx_log" DROP CONSTRAINT "FK_5d5f5e10892290ee366d26de7dc"`) + await db.query(`ALTER TABLE "ogv_proposal_voter" DROP CONSTRAINT "FK_7b3e7fcd2895ba1d6803e42454b"`) + await db.query(`ALTER TABLE "ogv_proposal_voter" DROP CONSTRAINT "FK_39efda99c037122170e2fed29b1"`) + } +} diff --git a/schema-ogv.graphql b/schema-ogv.graphql index 14ab77b5..0ba5b952 100644 --- a/schema-ogv.graphql +++ b/schema-ogv.graphql @@ -1,35 +1,98 @@ -# OGV Price (5m?) -# OGV Market Cap (5m?) -# OGV Circulating Supply -# OGV Total Supply type OGV @entity { id: ID! timestamp: DateTime! @index blockNumber: Int! @index circulating: BigInt! + staked: BigInt! total: BigInt! } -# OGV Amount Staked & Percentage -# OGV Staking APY -type StakedOGV @entity { # Representing `veOGV` +type OGVAddress @entity { + id: ID! @index + balance: BigInt! + veogvBalance: BigInt! + votingPower: BigInt! + delegatee: OGVAddress + lastUpdated: DateTime! +} + +enum OGVLockupEventType { + Staked + Unstaked + Extended +} + +type OGVLockupTxLog @entity { id: ID! - timestamp: DateTime! @index - blockNumber: Int! @index - total: BigInt! - apy: BigInt! + hash: String! + event: OGVLockupEventType! + timestamp: DateTime! + ogvLockup: OGVLockup! } -# OGV Registered Voters -# OGV Open-source contributors -# OGV Improvement proposals -type OGVGovernance @entity { +type OGVLockup @entity { id: ID! - timestamp: DateTime! @index - blockNumber: Int! @index - registeredVoters: Int! - openSourceContributors: Int! - improvementProposals: Int! + lockupId: Int! @index + address: OGVAddress! @index + logs: [OGVLockupTxLog]! @derivedFrom(field: "ogvLockup") + amount: BigInt! + end: DateTime! + veogv: BigInt! # Amount of veOGV received + timestamp: DateTime! + # active: Boolean +} + +enum OGVProposalState { + Pending + Active + Canceled + Defeated + Succeeded + Queued + Expired + Executed } -# TODO: More +enum OGVProposalEvent { + Created + Queued + Canceled + Extended + Executed +} + +enum OGVVoteType { + Against + For + Abstain +} + +type OGVProposalTxLog @entity { + id: ID! + hash: String! + event: OGVProposalEvent! + timestamp: DateTime! + proposal: OGVProposal! @index +} + +type OGVProposal @entity { + id: ID! @index + description: String + proposer: OGVAddress! + timestamp: DateTime! + startBlock: BigInt! + endBlock: BigInt! + lastUpdated: DateTime! + status: OGVProposalState! + logs: [OGVProposalTxLog]! @derivedFrom(field: "proposal") +} + +type OGVProposalVote @entity { + id: ID! + proposal: OGVProposal! @index + voter: OGVAddress! @index + weight: BigInt! + type: OGVVoteType! + txHash: String! + timestamp: DateTime! +} diff --git a/schema.graphql b/schema.graphql index a66887e1..c045b55f 100644 --- a/schema.graphql +++ b/schema.graphql @@ -308,41 +308,104 @@ type OETHCollateralDailyStat @entity { """ value: BigInt! } -# OGV Price (5m?) -# OGV Market Cap (5m?) -# OGV Circulating Supply -# OGV Total Supply type OGV @entity { id: ID! timestamp: DateTime! @index blockNumber: Int! @index circulating: BigInt! + staked: BigInt! total: BigInt! } -# OGV Amount Staked & Percentage -# OGV Staking APY -type StakedOGV @entity { # Representing `veOGV` +type OGVAddress @entity { + id: ID! @index + balance: BigInt! + veogvBalance: BigInt! + votingPower: BigInt! + delegatee: OGVAddress + lastUpdated: DateTime! +} + +enum OGVLockupEventType { + Staked + Unstaked + Extended +} + +type OGVLockupTxLog @entity { id: ID! - timestamp: DateTime! @index - blockNumber: Int! @index - total: BigInt! - apy: BigInt! + hash: String! + event: OGVLockupEventType! + timestamp: DateTime! + ogvLockup: OGVLockup! } -# OGV Registered Voters -# OGV Open-source contributors -# OGV Improvement proposals -type OGVGovernance @entity { +type OGVLockup @entity { id: ID! - timestamp: DateTime! @index - blockNumber: Int! @index - registeredVoters: Int! - openSourceContributors: Int! - improvementProposals: Int! + lockupId: Int! @index + address: OGVAddress! @index + logs: [OGVLockupTxLog]! @derivedFrom(field: "ogvLockup") + amount: BigInt! + end: DateTime! + veogv: BigInt! # Amount of veOGV received + timestamp: DateTime! + # active: Boolean +} + +enum OGVProposalState { + Pending + Active + Canceled + Defeated + Succeeded + Queued + Expired + Executed } -# TODO: More +enum OGVProposalEvent { + Created + Queued + Canceled + Extended + Executed +} + +enum OGVVoteType { + Against + For + Abstain +} + +type OGVProposalTxLog @entity { + id: ID! + hash: String! + event: OGVProposalEvent! + timestamp: DateTime! + proposal: OGVProposal! @index +} + +type OGVProposal @entity { + id: ID! @index + description: String + proposer: OGVAddress! + timestamp: DateTime! + startBlock: BigInt! + endBlock: BigInt! + lastUpdated: DateTime! + status: OGVProposalState! + logs: [OGVProposalTxLog]! @derivedFrom(field: "proposal") +} + +type OGVProposalVote @entity { + id: ID! + proposal: OGVProposal! @index + voter: OGVAddress! @index + weight: BigInt! + type: OGVVoteType! + txHash: String! + timestamp: DateTime! +} """ The OUSD entity tracks the change in total supply of OUSD over time. """ diff --git a/src/abi/governance.abi.ts b/src/abi/governance.abi.ts new file mode 100644 index 00000000..fbe9ddbf --- /dev/null +++ b/src/abi/governance.abi.ts @@ -0,0 +1,1356 @@ +export const ABI_JSON = [ + { + "type": "constructor", + "stateMutability": "undefined", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_token" + }, + { + "type": "address", + "name": "_timelock" + } + ] + }, + { + "type": "error", + "name": "Empty", + "inputs": [] + }, + { + "type": "event", + "anonymous": false, + "name": "LateQuorumVoteExtensionSet", + "inputs": [ + { + "type": "uint64", + "name": "oldVoteExtension", + "indexed": false + }, + { + "type": "uint64", + "name": "newVoteExtension", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "ProposalCanceled", + "inputs": [ + { + "type": "uint256", + "name": "proposalId", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "ProposalCreated", + "inputs": [ + { + "type": "uint256", + "name": "proposalId", + "indexed": false + }, + { + "type": "address", + "name": "proposer", + "indexed": false + }, + { + "type": "address[]", + "name": "targets" + }, + { + "type": "uint256[]", + "name": "values" + }, + { + "type": "string[]", + "name": "signatures" + }, + { + "type": "bytes[]", + "name": "calldatas" + }, + { + "type": "uint256", + "name": "startBlock", + "indexed": false + }, + { + "type": "uint256", + "name": "endBlock", + "indexed": false + }, + { + "type": "string", + "name": "description", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "ProposalExecuted", + "inputs": [ + { + "type": "uint256", + "name": "proposalId", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "ProposalExtended", + "inputs": [ + { + "type": "uint256", + "name": "proposalId", + "indexed": true + }, + { + "type": "uint64", + "name": "extendedDeadline", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "ProposalQueued", + "inputs": [ + { + "type": "uint256", + "name": "proposalId", + "indexed": false + }, + { + "type": "uint256", + "name": "eta", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "ProposalThresholdSet", + "inputs": [ + { + "type": "uint256", + "name": "oldProposalThreshold", + "indexed": false + }, + { + "type": "uint256", + "name": "newProposalThreshold", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "QuorumNumeratorUpdated", + "inputs": [ + { + "type": "uint256", + "name": "oldQuorumNumerator", + "indexed": false + }, + { + "type": "uint256", + "name": "newQuorumNumerator", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "TimelockChange", + "inputs": [ + { + "type": "address", + "name": "oldTimelock", + "indexed": false + }, + { + "type": "address", + "name": "newTimelock", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "VoteCast", + "inputs": [ + { + "type": "address", + "name": "voter", + "indexed": true + }, + { + "type": "uint256", + "name": "proposalId", + "indexed": false + }, + { + "type": "uint8", + "name": "support", + "indexed": false + }, + { + "type": "uint256", + "name": "weight", + "indexed": false + }, + { + "type": "string", + "name": "reason", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "VoteCastWithParams", + "inputs": [ + { + "type": "address", + "name": "voter", + "indexed": true + }, + { + "type": "uint256", + "name": "proposalId", + "indexed": false + }, + { + "type": "uint8", + "name": "support", + "indexed": false + }, + { + "type": "uint256", + "name": "weight", + "indexed": false + }, + { + "type": "string", + "name": "reason", + "indexed": false + }, + { + "type": "bytes", + "name": "params", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "VotingDelaySet", + "inputs": [ + { + "type": "uint256", + "name": "oldVotingDelay", + "indexed": false + }, + { + "type": "uint256", + "name": "newVotingDelay", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "VotingPeriodSet", + "inputs": [ + { + "type": "uint256", + "name": "oldVotingPeriod", + "indexed": false + }, + { + "type": "uint256", + "name": "newVotingPeriod", + "indexed": false + } + ] + }, + { + "type": "function", + "name": "BALLOT_TYPEHASH", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "COUNTING_MODE", + "constant": true, + "stateMutability": "pure", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "" + } + ] + }, + { + "type": "function", + "name": "EXTENDED_BALLOT_TYPEHASH", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "cancel", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "castVote", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + }, + { + "type": "uint8", + "name": "support" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "castVoteBySig", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + }, + { + "type": "uint8", + "name": "support" + }, + { + "type": "uint8", + "name": "v" + }, + { + "type": "bytes32", + "name": "r" + }, + { + "type": "bytes32", + "name": "s" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "castVoteWithReason", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + }, + { + "type": "uint8", + "name": "support" + }, + { + "type": "string", + "name": "reason" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "castVoteWithReasonAndParams", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + }, + { + "type": "uint8", + "name": "support" + }, + { + "type": "string", + "name": "reason" + }, + { + "type": "bytes", + "name": "params" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "castVoteWithReasonAndParamsBySig", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + }, + { + "type": "uint8", + "name": "support" + }, + { + "type": "string", + "name": "reason" + }, + { + "type": "bytes", + "name": "params" + }, + { + "type": "uint8", + "name": "v" + }, + { + "type": "bytes32", + "name": "r" + }, + { + "type": "bytes32", + "name": "s" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "execute", + "constant": false, + "stateMutability": "payable", + "payable": true, + "inputs": [ + { + "type": "address[]", + "name": "targets" + }, + { + "type": "uint256[]", + "name": "values" + }, + { + "type": "bytes[]", + "name": "calldatas" + }, + { + "type": "bytes32", + "name": "descriptionHash" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "execute", + "constant": false, + "stateMutability": "payable", + "payable": true, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "getActions", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + } + ], + "outputs": [ + { + "type": "address[]", + "name": "targets" + }, + { + "type": "uint256[]", + "name": "values" + }, + { + "type": "string[]", + "name": "signatures" + }, + { + "type": "bytes[]", + "name": "calldatas" + } + ] + }, + { + "type": "function", + "name": "getReceipt", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + }, + { + "type": "address", + "name": "voter" + } + ], + "outputs": [ + { + "type": "tuple", + "name": "", + "components": [ + { + "type": "bool", + "name": "hasVoted" + }, + { + "type": "uint8", + "name": "support" + }, + { + "type": "uint256", + "name": "votes" + } + ] + } + ] + }, + { + "type": "function", + "name": "getVotes", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + }, + { + "type": "uint256", + "name": "blockNumber" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getVotesWithParams", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + }, + { + "type": "uint256", + "name": "blockNumber" + }, + { + "type": "bytes", + "name": "params" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "hasVoted", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + }, + { + "type": "address", + "name": "account" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "hashProposal", + "constant": true, + "stateMutability": "pure", + "payable": false, + "inputs": [ + { + "type": "address[]", + "name": "targets" + }, + { + "type": "uint256[]", + "name": "values" + }, + { + "type": "bytes[]", + "name": "calldatas" + }, + { + "type": "bytes32", + "name": "descriptionHash" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "lateQuorumVoteExtension", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint64", + "name": "" + } + ] + }, + { + "type": "function", + "name": "name", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "" + } + ] + }, + { + "type": "function", + "name": "onERC1155BatchReceived", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "address", + "name": "" + }, + { + "type": "uint256[]", + "name": "" + }, + { + "type": "uint256[]", + "name": "" + }, + { + "type": "bytes", + "name": "" + } + ], + "outputs": [ + { + "type": "bytes4", + "name": "" + } + ] + }, + { + "type": "function", + "name": "onERC1155Received", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "address", + "name": "" + }, + { + "type": "uint256", + "name": "" + }, + { + "type": "uint256", + "name": "" + }, + { + "type": "bytes", + "name": "" + } + ], + "outputs": [ + { + "type": "bytes4", + "name": "" + } + ] + }, + { + "type": "function", + "name": "onERC721Received", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "address", + "name": "" + }, + { + "type": "uint256", + "name": "" + }, + { + "type": "bytes", + "name": "" + } + ], + "outputs": [ + { + "type": "bytes4", + "name": "" + } + ] + }, + { + "type": "function", + "name": "proposalDeadline", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "proposalEta", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "proposalSnapshot", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "proposalThreshold", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "proposals", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "id" + }, + { + "type": "address", + "name": "proposer" + }, + { + "type": "uint256", + "name": "eta" + }, + { + "type": "uint256", + "name": "startBlock" + }, + { + "type": "uint256", + "name": "endBlock" + }, + { + "type": "uint256", + "name": "forVotes" + }, + { + "type": "uint256", + "name": "againstVotes" + }, + { + "type": "uint256", + "name": "abstainVotes" + }, + { + "type": "bool", + "name": "canceled" + }, + { + "type": "bool", + "name": "executed" + } + ] + }, + { + "type": "function", + "name": "propose", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address[]", + "name": "targets" + }, + { + "type": "uint256[]", + "name": "values" + }, + { + "type": "bytes[]", + "name": "calldatas" + }, + { + "type": "string", + "name": "description" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "propose", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address[]", + "name": "targets" + }, + { + "type": "uint256[]", + "name": "values" + }, + { + "type": "string[]", + "name": "signatures" + }, + { + "type": "bytes[]", + "name": "calldatas" + }, + { + "type": "string", + "name": "description" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "queue", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address[]", + "name": "targets" + }, + { + "type": "uint256[]", + "name": "values" + }, + { + "type": "bytes[]", + "name": "calldatas" + }, + { + "type": "bytes32", + "name": "descriptionHash" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "queue", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "quorum", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "blockNumber" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "quorumDenominator", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "quorumNumerator", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "quorumVotes", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "relay", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "target" + }, + { + "type": "uint256", + "name": "value" + }, + { + "type": "bytes", + "name": "data" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setLateQuorumVoteExtension", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint64", + "name": "newVoteExtension" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setProposalThreshold", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "newProposalThreshold" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setVotingDelay", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "newVotingDelay" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "setVotingPeriod", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "newVotingPeriod" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "state", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "proposalId" + } + ], + "outputs": [ + { + "type": "uint8", + "name": "" + } + ] + }, + { + "type": "function", + "name": "supportsInterface", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "bytes4", + "name": "interfaceId" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "timelock", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "token", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "updateQuorumNumerator", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "newQuorumNumerator" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "updateTimelock", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "newTimelock" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "version", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "" + } + ] + }, + { + "type": "function", + "name": "votingDelay", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "votingPeriod", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "receive", + "stateMutability": "payable" + } +] diff --git a/src/abi/governance.ts b/src/abi/governance.ts new file mode 100644 index 00000000..16ee2e26 --- /dev/null +++ b/src/abi/governance.ts @@ -0,0 +1,308 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './governance.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + LateQuorumVoteExtensionSet: new LogEvent<([oldVoteExtension: bigint, newVoteExtension: bigint] & {oldVoteExtension: bigint, newVoteExtension: bigint})>( + abi, '0x7ca4ac117ed3cdce75c1161d8207c440389b1a15d69d096831664657c07dafc2' + ), + ProposalCanceled: new LogEvent<([proposalId: bigint] & {proposalId: bigint})>( + abi, '0x789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c' + ), + ProposalCreated: new LogEvent<([proposalId: bigint, proposer: string, targets: Array, values: Array, signatures: Array, calldatas: Array, startBlock: bigint, endBlock: bigint, description: string] & {proposalId: bigint, proposer: string, targets: Array, signatures: Array, calldatas: Array, startBlock: bigint, endBlock: bigint, description: string})>( + abi, '0x7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e0' + ), + ProposalExecuted: new LogEvent<([proposalId: bigint] & {proposalId: bigint})>( + abi, '0x712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f' + ), + ProposalExtended: new LogEvent<([proposalId: bigint, extendedDeadline: bigint] & {proposalId: bigint, extendedDeadline: bigint})>( + abi, '0x541f725fb9f7c98a30cc9c0ff32fbb14358cd7159c847a3aa20a2bdc442ba511' + ), + ProposalQueued: new LogEvent<([proposalId: bigint, eta: bigint] & {proposalId: bigint, eta: bigint})>( + abi, '0x9a2e42fd6722813d69113e7d0079d3d940171428df7373df9c7f7617cfda2892' + ), + ProposalThresholdSet: new LogEvent<([oldProposalThreshold: bigint, newProposalThreshold: bigint] & {oldProposalThreshold: bigint, newProposalThreshold: bigint})>( + abi, '0xccb45da8d5717e6c4544694297c4ba5cf151d455c9bb0ed4fc7a38411bc05461' + ), + QuorumNumeratorUpdated: new LogEvent<([oldQuorumNumerator: bigint, newQuorumNumerator: bigint] & {oldQuorumNumerator: bigint, newQuorumNumerator: bigint})>( + abi, '0x0553476bf02ef2726e8ce5ced78d63e26e602e4a2257b1f559418e24b4633997' + ), + TimelockChange: new LogEvent<([oldTimelock: string, newTimelock: string] & {oldTimelock: string, newTimelock: string})>( + abi, '0x08f74ea46ef7894f65eabfb5e6e695de773a000b47c529ab559178069b226401' + ), + VoteCast: new LogEvent<([voter: string, proposalId: bigint, support: number, weight: bigint, reason: string] & {voter: string, proposalId: bigint, support: number, weight: bigint, reason: string})>( + abi, '0xb8e138887d0aa13bab447e82de9d5c1777041ecd21ca36ba824ff1e6c07ddda4' + ), + VoteCastWithParams: new LogEvent<([voter: string, proposalId: bigint, support: number, weight: bigint, reason: string, params: string] & {voter: string, proposalId: bigint, support: number, weight: bigint, reason: string, params: string})>( + abi, '0xe2babfbac5889a709b63bb7f598b324e08bc5a4fb9ec647fb3cbc9ec07eb8712' + ), + VotingDelaySet: new LogEvent<([oldVotingDelay: bigint, newVotingDelay: bigint] & {oldVotingDelay: bigint, newVotingDelay: bigint})>( + abi, '0xc565b045403dc03c2eea82b81a0465edad9e2e7fc4d97e11421c209da93d7a93' + ), + VotingPeriodSet: new LogEvent<([oldVotingPeriod: bigint, newVotingPeriod: bigint] & {oldVotingPeriod: bigint, newVotingPeriod: bigint})>( + abi, '0x7e3f7f0708a84de9203036abaa450dccc85ad5ff52f78c170f3edb55cf5e8828' + ), +} + +export const functions = { + BALLOT_TYPEHASH: new Func<[], {}, string>( + abi, '0xdeaaa7cc' + ), + COUNTING_MODE: new Func<[], {}, string>( + abi, '0xdd4e2ba5' + ), + EXTENDED_BALLOT_TYPEHASH: new Func<[], {}, string>( + abi, '0x2fe3e261' + ), + cancel: new Func<[proposalId: bigint], {proposalId: bigint}, []>( + abi, '0x40e58ee5' + ), + castVote: new Func<[proposalId: bigint, support: number], {proposalId: bigint, support: number}, bigint>( + abi, '0x56781388' + ), + castVoteBySig: new Func<[proposalId: bigint, support: number, v: number, r: string, s: string], {proposalId: bigint, support: number, v: number, r: string, s: string}, bigint>( + abi, '0x3bccf4fd' + ), + castVoteWithReason: new Func<[proposalId: bigint, support: number, reason: string], {proposalId: bigint, support: number, reason: string}, bigint>( + abi, '0x7b3c71d3' + ), + castVoteWithReasonAndParams: new Func<[proposalId: bigint, support: number, reason: string, params: string], {proposalId: bigint, support: number, reason: string, params: string}, bigint>( + abi, '0x5f398a14' + ), + castVoteWithReasonAndParamsBySig: new Func<[proposalId: bigint, support: number, reason: string, params: string, v: number, r: string, s: string], {proposalId: bigint, support: number, reason: string, params: string, v: number, r: string, s: string}, bigint>( + abi, '0x03420181' + ), + 'execute(address[],uint256[],bytes[],bytes32)': new Func<[targets: Array, values: Array, calldatas: Array, descriptionHash: string], {targets: Array, calldatas: Array, descriptionHash: string}, bigint>( + abi, '0x2656227d' + ), + 'execute(uint256)': new Func<[proposalId: bigint], {proposalId: bigint}, []>( + abi, '0xfe0d94c1' + ), + getActions: new Func<[proposalId: bigint], {proposalId: bigint}, ([targets: Array, values: Array, signatures: Array, calldatas: Array] & {targets: Array, signatures: Array, calldatas: Array})>( + abi, '0x328dd982' + ), + getReceipt: new Func<[proposalId: bigint, voter: string], {proposalId: bigint, voter: string}, ([hasVoted: boolean, support: number, votes: bigint] & {hasVoted: boolean, support: number, votes: bigint})>( + abi, '0xe23a9a52' + ), + getVotes: new Func<[account: string, blockNumber: bigint], {account: string, blockNumber: bigint}, bigint>( + abi, '0xeb9019d4' + ), + getVotesWithParams: new Func<[account: string, blockNumber: bigint, params: string], {account: string, blockNumber: bigint, params: string}, bigint>( + abi, '0x9a802a6d' + ), + hasVoted: new Func<[proposalId: bigint, account: string], {proposalId: bigint, account: string}, boolean>( + abi, '0x43859632' + ), + hashProposal: new Func<[targets: Array, values: Array, calldatas: Array, descriptionHash: string], {targets: Array, calldatas: Array, descriptionHash: string}, bigint>( + abi, '0xc59057e4' + ), + lateQuorumVoteExtension: new Func<[], {}, bigint>( + abi, '0x32b8113e' + ), + name: new Func<[], {}, string>( + abi, '0x06fdde03' + ), + onERC1155BatchReceived: new Func<[_: string, _: string, _: Array, _: Array, _: string], {}, string>( + abi, '0xbc197c81' + ), + onERC1155Received: new Func<[_: string, _: string, _: bigint, _: bigint, _: string], {}, string>( + abi, '0xf23a6e61' + ), + onERC721Received: new Func<[_: string, _: string, _: bigint, _: string], {}, string>( + abi, '0x150b7a02' + ), + proposalDeadline: new Func<[proposalId: bigint], {proposalId: bigint}, bigint>( + abi, '0xc01f9e37' + ), + proposalEta: new Func<[proposalId: bigint], {proposalId: bigint}, bigint>( + abi, '0xab58fb8e' + ), + proposalSnapshot: new Func<[proposalId: bigint], {proposalId: bigint}, bigint>( + abi, '0x2d63f693' + ), + proposalThreshold: new Func<[], {}, bigint>( + abi, '0xb58131b0' + ), + proposals: new Func<[proposalId: bigint], {proposalId: bigint}, ([id: bigint, proposer: string, eta: bigint, startBlock: bigint, endBlock: bigint, forVotes: bigint, againstVotes: bigint, abstainVotes: bigint, canceled: boolean, executed: boolean] & {id: bigint, proposer: string, eta: bigint, startBlock: bigint, endBlock: bigint, forVotes: bigint, againstVotes: bigint, abstainVotes: bigint, canceled: boolean, executed: boolean})>( + abi, '0x013cf08b' + ), + 'propose(address[],uint256[],bytes[],string)': new Func<[targets: Array, values: Array, calldatas: Array, description: string], {targets: Array, calldatas: Array, description: string}, bigint>( + abi, '0x7d5e81e2' + ), + 'propose(address[],uint256[],string[],bytes[],string)': new Func<[targets: Array, values: Array, signatures: Array, calldatas: Array, description: string], {targets: Array, signatures: Array, calldatas: Array, description: string}, bigint>( + abi, '0xda95691a' + ), + 'queue(address[],uint256[],bytes[],bytes32)': new Func<[targets: Array, values: Array, calldatas: Array, descriptionHash: string], {targets: Array, calldatas: Array, descriptionHash: string}, bigint>( + abi, '0x160cbed7' + ), + 'queue(uint256)': new Func<[proposalId: bigint], {proposalId: bigint}, []>( + abi, '0xddf0b009' + ), + quorum: new Func<[blockNumber: bigint], {blockNumber: bigint}, bigint>( + abi, '0xf8ce560a' + ), + quorumDenominator: new Func<[], {}, bigint>( + abi, '0x97c3d334' + ), + quorumNumerator: new Func<[], {}, bigint>( + abi, '0xa7713a70' + ), + quorumVotes: new Func<[], {}, bigint>( + abi, '0x24bc1a64' + ), + relay: new Func<[target: string, value: bigint, data: string], {target: string, value: bigint, data: string}, []>( + abi, '0xc28bc2fa' + ), + setLateQuorumVoteExtension: new Func<[newVoteExtension: bigint], {newVoteExtension: bigint}, []>( + abi, '0xd07f91e9' + ), + setProposalThreshold: new Func<[newProposalThreshold: bigint], {newProposalThreshold: bigint}, []>( + abi, '0xece40cc1' + ), + setVotingDelay: new Func<[newVotingDelay: bigint], {newVotingDelay: bigint}, []>( + abi, '0x70b0f660' + ), + setVotingPeriod: new Func<[newVotingPeriod: bigint], {newVotingPeriod: bigint}, []>( + abi, '0xea0217cf' + ), + state: new Func<[proposalId: bigint], {proposalId: bigint}, number>( + abi, '0x3e4f49e6' + ), + supportsInterface: new Func<[interfaceId: string], {interfaceId: string}, boolean>( + abi, '0x01ffc9a7' + ), + timelock: new Func<[], {}, string>( + abi, '0xd33219b4' + ), + token: new Func<[], {}, string>( + abi, '0xfc0c546a' + ), + updateQuorumNumerator: new Func<[newQuorumNumerator: bigint], {newQuorumNumerator: bigint}, []>( + abi, '0x06f3f9e6' + ), + updateTimelock: new Func<[newTimelock: string], {newTimelock: string}, []>( + abi, '0xa890c910' + ), + version: new Func<[], {}, string>( + abi, '0x54fd4d50' + ), + votingDelay: new Func<[], {}, bigint>( + abi, '0x3932abb1' + ), + votingPeriod: new Func<[], {}, bigint>( + abi, '0x02a251a3' + ), +} + +export class Contract extends ContractBase { + + BALLOT_TYPEHASH(): Promise { + return this.eth_call(functions.BALLOT_TYPEHASH, []) + } + + COUNTING_MODE(): Promise { + return this.eth_call(functions.COUNTING_MODE, []) + } + + EXTENDED_BALLOT_TYPEHASH(): Promise { + return this.eth_call(functions.EXTENDED_BALLOT_TYPEHASH, []) + } + + getActions(proposalId: bigint): Promise<([targets: Array, values: Array, signatures: Array, calldatas: Array] & {targets: Array, signatures: Array, calldatas: Array})> { + return this.eth_call(functions.getActions, [proposalId]) + } + + getReceipt(proposalId: bigint, voter: string): Promise<([hasVoted: boolean, support: number, votes: bigint] & {hasVoted: boolean, support: number, votes: bigint})> { + return this.eth_call(functions.getReceipt, [proposalId, voter]) + } + + getVotes(account: string, blockNumber: bigint): Promise { + return this.eth_call(functions.getVotes, [account, blockNumber]) + } + + getVotesWithParams(account: string, blockNumber: bigint, params: string): Promise { + return this.eth_call(functions.getVotesWithParams, [account, blockNumber, params]) + } + + hasVoted(proposalId: bigint, account: string): Promise { + return this.eth_call(functions.hasVoted, [proposalId, account]) + } + + hashProposal(targets: Array, values: Array, calldatas: Array, descriptionHash: string): Promise { + return this.eth_call(functions.hashProposal, [targets, values, calldatas, descriptionHash]) + } + + lateQuorumVoteExtension(): Promise { + return this.eth_call(functions.lateQuorumVoteExtension, []) + } + + name(): Promise { + return this.eth_call(functions.name, []) + } + + proposalDeadline(proposalId: bigint): Promise { + return this.eth_call(functions.proposalDeadline, [proposalId]) + } + + proposalEta(proposalId: bigint): Promise { + return this.eth_call(functions.proposalEta, [proposalId]) + } + + proposalSnapshot(proposalId: bigint): Promise { + return this.eth_call(functions.proposalSnapshot, [proposalId]) + } + + proposalThreshold(): Promise { + return this.eth_call(functions.proposalThreshold, []) + } + + proposals(proposalId: bigint): Promise<([id: bigint, proposer: string, eta: bigint, startBlock: bigint, endBlock: bigint, forVotes: bigint, againstVotes: bigint, abstainVotes: bigint, canceled: boolean, executed: boolean] & {id: bigint, proposer: string, eta: bigint, startBlock: bigint, endBlock: bigint, forVotes: bigint, againstVotes: bigint, abstainVotes: bigint, canceled: boolean, executed: boolean})> { + return this.eth_call(functions.proposals, [proposalId]) + } + + quorum(blockNumber: bigint): Promise { + return this.eth_call(functions.quorum, [blockNumber]) + } + + quorumDenominator(): Promise { + return this.eth_call(functions.quorumDenominator, []) + } + + quorumNumerator(): Promise { + return this.eth_call(functions.quorumNumerator, []) + } + + quorumVotes(): Promise { + return this.eth_call(functions.quorumVotes, []) + } + + state(proposalId: bigint): Promise { + return this.eth_call(functions.state, [proposalId]) + } + + supportsInterface(interfaceId: string): Promise { + return this.eth_call(functions.supportsInterface, [interfaceId]) + } + + timelock(): Promise { + return this.eth_call(functions.timelock, []) + } + + token(): Promise { + return this.eth_call(functions.token, []) + } + + version(): Promise { + return this.eth_call(functions.version, []) + } + + votingDelay(): Promise { + return this.eth_call(functions.votingDelay, []) + } + + votingPeriod(): Promise { + return this.eth_call(functions.votingPeriod, []) + } +} diff --git a/src/abi/veogv.abi.ts b/src/abi/veogv.abi.ts new file mode 100644 index 00000000..e1120fd9 --- /dev/null +++ b/src/abi/veogv.abi.ts @@ -0,0 +1,945 @@ +export const ABI_JSON = [ + { + "type": "constructor", + "stateMutability": "undefined", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "ogv_" + }, + { + "type": "uint256", + "name": "epoch_" + }, + { + "type": "uint256", + "name": "minStakeDuration_" + }, + { + "type": "address", + "name": "rewardsSource_" + } + ] + }, + { + "type": "error", + "name": "PRBMathUD60x18__Exp2InputTooBig", + "inputs": [ + { + "type": "uint256", + "name": "x" + } + ] + }, + { + "type": "error", + "name": "PRBMathUD60x18__LogInputTooSmall", + "inputs": [ + { + "type": "uint256", + "name": "x" + } + ] + }, + { + "type": "error", + "name": "PRBMath__MulDivFixedPointOverflow", + "inputs": [ + { + "type": "uint256", + "name": "prod1" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Approval", + "inputs": [ + { + "type": "address", + "name": "owner", + "indexed": true + }, + { + "type": "address", + "name": "spender", + "indexed": true + }, + { + "type": "uint256", + "name": "value", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "DelegateChanged", + "inputs": [ + { + "type": "address", + "name": "delegator", + "indexed": true + }, + { + "type": "address", + "name": "fromDelegate", + "indexed": true + }, + { + "type": "address", + "name": "toDelegate", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "DelegateVotesChanged", + "inputs": [ + { + "type": "address", + "name": "delegate", + "indexed": true + }, + { + "type": "uint256", + "name": "previousBalance", + "indexed": false + }, + { + "type": "uint256", + "name": "newBalance", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Reward", + "inputs": [ + { + "type": "address", + "name": "user", + "indexed": true + }, + { + "type": "uint256", + "name": "amount", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Stake", + "inputs": [ + { + "type": "address", + "name": "user", + "indexed": true + }, + { + "type": "uint256", + "name": "lockupId", + "indexed": false + }, + { + "type": "uint256", + "name": "amount", + "indexed": false + }, + { + "type": "uint256", + "name": "end", + "indexed": false + }, + { + "type": "uint256", + "name": "points", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Transfer", + "inputs": [ + { + "type": "address", + "name": "from", + "indexed": true + }, + { + "type": "address", + "name": "to", + "indexed": true + }, + { + "type": "uint256", + "name": "value", + "indexed": false + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "Unstake", + "inputs": [ + { + "type": "address", + "name": "user", + "indexed": true + }, + { + "type": "uint256", + "name": "lockupId", + "indexed": false + }, + { + "type": "uint256", + "name": "amount", + "indexed": false + }, + { + "type": "uint256", + "name": "end", + "indexed": false + }, + { + "type": "uint256", + "name": "points", + "indexed": false + } + ] + }, + { + "type": "function", + "name": "DOMAIN_SEPARATOR", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bytes32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "accRewardPerShare", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "allowance", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + }, + { + "type": "address", + "name": "spender" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "approve", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "spender" + }, + { + "type": "uint256", + "name": "amount" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "balanceOf", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "checkpoints", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + }, + { + "type": "uint32", + "name": "pos" + } + ], + "outputs": [ + { + "type": "tuple", + "name": "", + "components": [ + { + "type": "uint32", + "name": "fromBlock" + }, + { + "type": "uint224", + "name": "votes" + } + ] + } + ] + }, + { + "type": "function", + "name": "collectRewards", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "decimals", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint8", + "name": "" + } + ] + }, + { + "type": "function", + "name": "decreaseAllowance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "spender" + }, + { + "type": "uint256", + "name": "subtractedValue" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "delegate", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "delegatee" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "delegateBySig", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "delegatee" + }, + { + "type": "uint256", + "name": "nonce" + }, + { + "type": "uint256", + "name": "expiry" + }, + { + "type": "uint8", + "name": "v" + }, + { + "type": "bytes32", + "name": "r" + }, + { + "type": "bytes32", + "name": "s" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "delegates", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + } + ], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "epoch", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "extend", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "lockupId" + }, + { + "type": "uint256", + "name": "duration" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "getPastTotalSupply", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "blockNumber" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getPastVotes", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + }, + { + "type": "uint256", + "name": "blockNumber" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "getVotes", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "hasDelegationSet", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "increaseAllowance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "spender" + }, + { + "type": "uint256", + "name": "addedValue" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "lockups", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "uint128", + "name": "amount" + }, + { + "type": "uint128", + "name": "end" + }, + { + "type": "uint256", + "name": "points" + } + ] + }, + { + "type": "function", + "name": "minStakeDuration", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "name", + "constant": true, + "stateMutability": "pure", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "" + } + ] + }, + { + "type": "function", + "name": "nonces", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "numCheckpoints", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "account" + } + ], + "outputs": [ + { + "type": "uint32", + "name": "" + } + ] + }, + { + "type": "function", + "name": "ogv", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "permit", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "owner" + }, + { + "type": "address", + "name": "spender" + }, + { + "type": "uint256", + "name": "value" + }, + { + "type": "uint256", + "name": "deadline" + }, + { + "type": "uint8", + "name": "v" + }, + { + "type": "bytes32", + "name": "r" + }, + { + "type": "bytes32", + "name": "s" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "previewPoints", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "amount" + }, + { + "type": "uint256", + "name": "duration" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + }, + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "previewRewards", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "user" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rewardDebtPerShare", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "rewardsSource", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "stake", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "amount" + }, + { + "type": "uint256", + "name": "duration" + }, + { + "type": "address", + "name": "to" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "stake", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "amount" + }, + { + "type": "uint256", + "name": "duration" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "symbol", + "constant": true, + "stateMutability": "pure", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "" + } + ] + }, + { + "type": "function", + "name": "totalSupply", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "transfer", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "transferFrom", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "" + }, + { + "type": "address", + "name": "" + }, + { + "type": "uint256", + "name": "" + } + ], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "unstake", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "lockupId" + } + ], + "outputs": [] + } +] diff --git a/src/abi/veogv.ts b/src/abi/veogv.ts new file mode 100644 index 00000000..3a885fa0 --- /dev/null +++ b/src/abi/veogv.ts @@ -0,0 +1,242 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './veogv.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( + abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' + ), + DelegateChanged: new LogEvent<([delegator: string, fromDelegate: string, toDelegate: string] & {delegator: string, fromDelegate: string, toDelegate: string})>( + abi, '0x3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f' + ), + DelegateVotesChanged: new LogEvent<([delegate: string, previousBalance: bigint, newBalance: bigint] & {delegate: string, previousBalance: bigint, newBalance: bigint})>( + abi, '0xdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724' + ), + Reward: new LogEvent<([user: string, amount: bigint] & {user: string, amount: bigint})>( + abi, '0x619caafabdd75649b302ba8419e48cccf64f37f1983ac4727cfb38b57703ffc9' + ), + Stake: new LogEvent<([user: string, lockupId: bigint, amount: bigint, end: bigint, points: bigint] & {user: string, lockupId: bigint, amount: bigint, end: bigint, points: bigint})>( + abi, '0x2720efa4b2dd4f3f8a347da3cbd290a522e9432da9072c5b8e6300496fdde282' + ), + Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( + abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' + ), + Unstake: new LogEvent<([user: string, lockupId: bigint, amount: bigint, end: bigint, points: bigint] & {user: string, lockupId: bigint, amount: bigint, end: bigint, points: bigint})>( + abi, '0x05b744e3e9358bc00ba3cc0c6606a4d6536134dba00b2d2ee4b5de169acd6427' + ), +} + +export const functions = { + DOMAIN_SEPARATOR: new Func<[], {}, string>( + abi, '0x3644e515' + ), + accRewardPerShare: new Func<[], {}, bigint>( + abi, '0x939d6237' + ), + allowance: new Func<[owner: string, spender: string], {owner: string, spender: string}, bigint>( + abi, '0xdd62ed3e' + ), + approve: new Func<[spender: string, amount: bigint], {spender: string, amount: bigint}, boolean>( + abi, '0x095ea7b3' + ), + balanceOf: new Func<[account: string], {account: string}, bigint>( + abi, '0x70a08231' + ), + checkpoints: new Func<[account: string, pos: number], {account: string, pos: number}, ([fromBlock: number, votes: bigint] & {fromBlock: number, votes: bigint})>( + abi, '0xf1127ed8' + ), + collectRewards: new Func<[], {}, []>( + abi, '0x70bb45b3' + ), + decimals: new Func<[], {}, number>( + abi, '0x313ce567' + ), + decreaseAllowance: new Func<[spender: string, subtractedValue: bigint], {spender: string, subtractedValue: bigint}, boolean>( + abi, '0xa457c2d7' + ), + delegate: new Func<[delegatee: string], {delegatee: string}, []>( + abi, '0x5c19a95c' + ), + delegateBySig: new Func<[delegatee: string, nonce: bigint, expiry: bigint, v: number, r: string, s: string], {delegatee: string, nonce: bigint, expiry: bigint, v: number, r: string, s: string}, []>( + abi, '0xc3cda520' + ), + delegates: new Func<[account: string], {account: string}, string>( + abi, '0x587cde1e' + ), + epoch: new Func<[], {}, bigint>( + abi, '0x900cf0cf' + ), + extend: new Func<[lockupId: bigint, duration: bigint], {lockupId: bigint, duration: bigint}, []>( + abi, '0xc89258db' + ), + getPastTotalSupply: new Func<[blockNumber: bigint], {blockNumber: bigint}, bigint>( + abi, '0x8e539e8c' + ), + getPastVotes: new Func<[account: string, blockNumber: bigint], {account: string, blockNumber: bigint}, bigint>( + abi, '0x3a46b1a8' + ), + getVotes: new Func<[account: string], {account: string}, bigint>( + abi, '0x9ab24eb0' + ), + hasDelegationSet: new Func<[_: string], {}, boolean>( + abi, '0x0348dbf1' + ), + increaseAllowance: new Func<[spender: string, addedValue: bigint], {spender: string, addedValue: bigint}, boolean>( + abi, '0x39509351' + ), + lockups: new Func<[_: string, _: bigint], {}, ([amount: bigint, end: bigint, points: bigint] & {amount: bigint, end: bigint, points: bigint})>( + abi, '0xc93d0b1e' + ), + minStakeDuration: new Func<[], {}, bigint>( + abi, '0x5fec5c64' + ), + name: new Func<[], {}, string>( + abi, '0x06fdde03' + ), + nonces: new Func<[owner: string], {owner: string}, bigint>( + abi, '0x7ecebe00' + ), + numCheckpoints: new Func<[account: string], {account: string}, number>( + abi, '0x6fcfff45' + ), + ogv: new Func<[], {}, string>( + abi, '0x142561cf' + ), + permit: new Func<[owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string], {owner: string, spender: string, value: bigint, deadline: bigint, v: number, r: string, s: string}, []>( + abi, '0xd505accf' + ), + previewPoints: new Func<[amount: bigint, duration: bigint], {amount: bigint, duration: bigint}, [_: bigint, _: bigint]>( + abi, '0x4fd0e648' + ), + previewRewards: new Func<[user: string], {user: string}, bigint>( + abi, '0xf166e920' + ), + rewardDebtPerShare: new Func<[_: string], {}, bigint>( + abi, '0x4423bf57' + ), + rewardsSource: new Func<[], {}, string>( + abi, '0xf7240d2f' + ), + 'stake(uint256,uint256,address)': new Func<[amount: bigint, duration: bigint, to: string], {amount: bigint, duration: bigint, to: string}, []>( + abi, '0x7628a37d' + ), + 'stake(uint256,uint256)': new Func<[amount: bigint, duration: bigint], {amount: bigint, duration: bigint}, []>( + abi, '0x7b0472f0' + ), + symbol: new Func<[], {}, string>( + abi, '0x95d89b41' + ), + totalSupply: new Func<[], {}, bigint>( + abi, '0x18160ddd' + ), + transfer: new Func<[_: string, _: bigint], {}, boolean>( + abi, '0xa9059cbb' + ), + transferFrom: new Func<[_: string, _: string, _: bigint], {}, boolean>( + abi, '0x23b872dd' + ), + unstake: new Func<[lockupId: bigint], {lockupId: bigint}, []>( + abi, '0x2e17de78' + ), +} + +export class Contract extends ContractBase { + + DOMAIN_SEPARATOR(): Promise { + return this.eth_call(functions.DOMAIN_SEPARATOR, []) + } + + accRewardPerShare(): Promise { + return this.eth_call(functions.accRewardPerShare, []) + } + + allowance(owner: string, spender: string): Promise { + return this.eth_call(functions.allowance, [owner, spender]) + } + + balanceOf(account: string): Promise { + return this.eth_call(functions.balanceOf, [account]) + } + + checkpoints(account: string, pos: number): Promise<([fromBlock: number, votes: bigint] & {fromBlock: number, votes: bigint})> { + return this.eth_call(functions.checkpoints, [account, pos]) + } + + decimals(): Promise { + return this.eth_call(functions.decimals, []) + } + + delegates(account: string): Promise { + return this.eth_call(functions.delegates, [account]) + } + + epoch(): Promise { + return this.eth_call(functions.epoch, []) + } + + getPastTotalSupply(blockNumber: bigint): Promise { + return this.eth_call(functions.getPastTotalSupply, [blockNumber]) + } + + getPastVotes(account: string, blockNumber: bigint): Promise { + return this.eth_call(functions.getPastVotes, [account, blockNumber]) + } + + getVotes(account: string): Promise { + return this.eth_call(functions.getVotes, [account]) + } + + hasDelegationSet(arg0: string): Promise { + return this.eth_call(functions.hasDelegationSet, [arg0]) + } + + lockups(arg0: string, arg1: bigint): Promise<([amount: bigint, end: bigint, points: bigint] & {amount: bigint, end: bigint, points: bigint})> { + return this.eth_call(functions.lockups, [arg0, arg1]) + } + + minStakeDuration(): Promise { + return this.eth_call(functions.minStakeDuration, []) + } + + name(): Promise { + return this.eth_call(functions.name, []) + } + + nonces(owner: string): Promise { + return this.eth_call(functions.nonces, [owner]) + } + + numCheckpoints(account: string): Promise { + return this.eth_call(functions.numCheckpoints, [account]) + } + + ogv(): Promise { + return this.eth_call(functions.ogv, []) + } + + previewPoints(amount: bigint, duration: bigint): Promise<[_: bigint, _: bigint]> { + return this.eth_call(functions.previewPoints, [amount, duration]) + } + + previewRewards(user: string): Promise { + return this.eth_call(functions.previewRewards, [user]) + } + + rewardDebtPerShare(arg0: string): Promise { + return this.eth_call(functions.rewardDebtPerShare, [arg0]) + } + + rewardsSource(): Promise { + return this.eth_call(functions.rewardsSource, []) + } + + symbol(): Promise { + return this.eth_call(functions.symbol, []) + } + + totalSupply(): Promise { + return this.eth_call(functions.totalSupply, []) + } +} diff --git a/src/main.ts b/src/main.ts index e29c5521..96f6504a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,7 +11,10 @@ import * as dripper from './processors/oeth/dripper' import * as fraxStaking from './processors/oeth/frax-staking' import * as morphoAave from './processors/oeth/morpho-aave' import * as vault from './processors/oeth/vault' -import * as ousd from './processors/ousd' +import * as governance from './processors/ogv/governance' +import * as ogv from './processors/ogv/ogv' +import * as ogvSupply from './processors/ogv/ogv-supply' +// import * as ousd from './processors/ousd' import * as strategies from './processors/strategies' run({ @@ -20,6 +23,8 @@ run({ aaveCompound, curve, strategies, + ogvSupply, + // OETH Related oeth, vault, @@ -30,7 +35,10 @@ run({ balancerMetaPoolStrategy, // OUSD Related // ousd, + + // OGV + ogv, ], - postProcessors: [exchangeRates, dailyStats], + postProcessors: [exchangeRates, dailyStats, governance], validators: [validateOeth], }) diff --git a/src/model/generated/_ogvLockupEventType.ts b/src/model/generated/_ogvLockupEventType.ts new file mode 100644 index 00000000..478da945 --- /dev/null +++ b/src/model/generated/_ogvLockupEventType.ts @@ -0,0 +1,5 @@ +export enum OGVLockupEventType { + Staked = "Staked", + Unstaked = "Unstaked", + Extended = "Extended", +} diff --git a/src/model/generated/_ogvProposalEvent.ts b/src/model/generated/_ogvProposalEvent.ts new file mode 100644 index 00000000..e74114e9 --- /dev/null +++ b/src/model/generated/_ogvProposalEvent.ts @@ -0,0 +1,7 @@ +export enum OGVProposalEvent { + Created = "Created", + Queued = "Queued", + Canceled = "Canceled", + Extended = "Extended", + Executed = "Executed", +} diff --git a/src/model/generated/_ogvProposalState.ts b/src/model/generated/_ogvProposalState.ts new file mode 100644 index 00000000..8460802b --- /dev/null +++ b/src/model/generated/_ogvProposalState.ts @@ -0,0 +1,10 @@ +export enum OGVProposalState { + Pending = "Pending", + Active = "Active", + Canceled = "Canceled", + Defeated = "Defeated", + Succeeded = "Succeeded", + Queued = "Queued", + Expired = "Expired", + Executed = "Executed", +} diff --git a/src/model/generated/_ogvVoteType.ts b/src/model/generated/_ogvVoteType.ts new file mode 100644 index 00000000..4960ff53 --- /dev/null +++ b/src/model/generated/_ogvVoteType.ts @@ -0,0 +1,5 @@ +export enum OGVVoteType { + Against = "Against", + For = "For", + Abstain = "Abstain", +} diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index d6c96de3..e9841832 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -21,8 +21,16 @@ export * from "./oethStrategyDailyStat.model" export * from "./oethStrategyHoldingDailyStat.model" export * from "./oethCollateralDailyStat.model" export * from "./ogv.model" -export * from "./stakedOgv.model" -export * from "./ogvGovernance.model" +export * from "./ogvAddress.model" +export * from "./ogvLockupTxLog.model" +export * from "./_ogvLockupEventType" +export * from "./ogvLockup.model" +export * from "./ogvProposalTxLog.model" +export * from "./_ogvProposalEvent" +export * from "./ogvProposal.model" +export * from "./_ogvProposalState" +export * from "./ogvProposalVote.model" +export * from "./_ogvVoteType" export * from "./ousd.model" export * from "./ousdAddress.model" export * from "./ousdHistory.model" diff --git a/src/model/generated/ogv.model.ts b/src/model/generated/ogv.model.ts index 719425ee..1e1b3fd6 100644 --- a/src/model/generated/ogv.model.ts +++ b/src/model/generated/ogv.model.ts @@ -21,6 +21,9 @@ export class OGV { @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) circulating!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + staked!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) total!: bigint } diff --git a/src/model/generated/stakedOgv.model.ts b/src/model/generated/ogvAddress.model.ts similarity index 50% rename from src/model/generated/stakedOgv.model.ts rename to src/model/generated/ogvAddress.model.ts index 91f16a3f..50b1de1d 100644 --- a/src/model/generated/stakedOgv.model.ts +++ b/src/model/generated/ogvAddress.model.ts @@ -1,26 +1,28 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" import * as marshal from "./marshal" @Entity_() -export class StakedOGV { - constructor(props?: Partial) { +export class OGVAddress { + constructor(props?: Partial) { Object.assign(this, props) } @PrimaryColumn_() id!: string - @Index_() - @Column_("timestamp with time zone", {nullable: false}) - timestamp!: Date - - @Index_() - @Column_("int4", {nullable: false}) - blockNumber!: number + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + balance!: bigint @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) - total!: bigint + veogvBalance!: bigint @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) - apy!: bigint + votingPower!: bigint + + @Index_() + @ManyToOne_(() => OGVAddress, {nullable: true}) + delegatee!: OGVAddress | undefined | null + + @Column_("timestamp with time zone", {nullable: false}) + lastUpdated!: Date } diff --git a/src/model/generated/ogvGovernance.model.ts b/src/model/generated/ogvGovernance.model.ts deleted file mode 100644 index e3e14b3d..00000000 --- a/src/model/generated/ogvGovernance.model.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_} from "typeorm" - -@Entity_() -export class OGVGovernance { - constructor(props?: Partial) { - Object.assign(this, props) - } - - @PrimaryColumn_() - id!: string - - @Index_() - @Column_("timestamp with time zone", {nullable: false}) - timestamp!: Date - - @Index_() - @Column_("int4", {nullable: false}) - blockNumber!: number - - @Column_("int4", {nullable: false}) - registeredVoters!: number - - @Column_("int4", {nullable: false}) - openSourceContributors!: number - - @Column_("int4", {nullable: false}) - improvementProposals!: number -} diff --git a/src/model/generated/ogvLockup.model.ts b/src/model/generated/ogvLockup.model.ts new file mode 100644 index 00000000..531ff292 --- /dev/null +++ b/src/model/generated/ogvLockup.model.ts @@ -0,0 +1,37 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, ManyToOne as ManyToOne_, OneToMany as OneToMany_} from "typeorm" +import * as marshal from "./marshal" +import {OGVAddress} from "./ogvAddress.model" +import {OGVLockupTxLog} from "./ogvLockupTxLog.model" + +@Entity_() +export class OGVLockup { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @Column_("int4", {nullable: false}) + lockupId!: number + + @Index_() + @ManyToOne_(() => OGVAddress, {nullable: true}) + address!: OGVAddress + + @OneToMany_(() => OGVLockupTxLog, e => e.ogvLockup) + logs!: OGVLockupTxLog[] + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + amount!: bigint + + @Column_("timestamp with time zone", {nullable: false}) + end!: Date + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + veogv!: bigint + + @Column_("timestamp with time zone", {nullable: false}) + timestamp!: Date +} diff --git a/src/model/generated/ogvLockupTxLog.model.ts b/src/model/generated/ogvLockupTxLog.model.ts new file mode 100644 index 00000000..893a2938 --- /dev/null +++ b/src/model/generated/ogvLockupTxLog.model.ts @@ -0,0 +1,26 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" +import {OGVLockupEventType} from "./_ogvLockupEventType" +import {OGVLockup} from "./ogvLockup.model" + +@Entity_() +export class OGVLockupTxLog { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Column_("text", {nullable: false}) + hash!: string + + @Column_("varchar", {length: 8, nullable: false}) + event!: OGVLockupEventType + + @Column_("timestamp with time zone", {nullable: false}) + timestamp!: Date + + @Index_() + @ManyToOne_(() => OGVLockup, {nullable: true}) + ogvLockup!: OGVLockup +} diff --git a/src/model/generated/ogvProposal.model.ts b/src/model/generated/ogvProposal.model.ts new file mode 100644 index 00000000..d00d7f25 --- /dev/null +++ b/src/model/generated/ogvProposal.model.ts @@ -0,0 +1,40 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, OneToMany as OneToMany_} from "typeorm" +import * as marshal from "./marshal" +import {OGVAddress} from "./ogvAddress.model" +import {OGVProposalState} from "./_ogvProposalState" +import {OGVProposalTxLog} from "./ogvProposalTxLog.model" + +@Entity_() +export class OGVProposal { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Column_("text", {nullable: true}) + description!: string | undefined | null + + @Index_() + @ManyToOne_(() => OGVAddress, {nullable: true}) + proposer!: OGVAddress + + @Column_("timestamp with time zone", {nullable: false}) + timestamp!: Date + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + startBlock!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + endBlock!: bigint + + @Column_("timestamp with time zone", {nullable: false}) + lastUpdated!: Date + + @Column_("varchar", {length: 9, nullable: false}) + status!: OGVProposalState + + @OneToMany_(() => OGVProposalTxLog, e => e.proposal) + logs!: OGVProposalTxLog[] +} diff --git a/src/model/generated/ogvProposalTxLog.model.ts b/src/model/generated/ogvProposalTxLog.model.ts new file mode 100644 index 00000000..c3e851bb --- /dev/null +++ b/src/model/generated/ogvProposalTxLog.model.ts @@ -0,0 +1,26 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" +import {OGVProposalEvent} from "./_ogvProposalEvent" +import {OGVProposal} from "./ogvProposal.model" + +@Entity_() +export class OGVProposalTxLog { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Column_("text", {nullable: false}) + hash!: string + + @Column_("varchar", {length: 8, nullable: false}) + event!: OGVProposalEvent + + @Column_("timestamp with time zone", {nullable: false}) + timestamp!: Date + + @Index_() + @ManyToOne_(() => OGVProposal, {nullable: true}) + proposal!: OGVProposal +} diff --git a/src/model/generated/ogvProposalVote.model.ts b/src/model/generated/ogvProposalVote.model.ts new file mode 100644 index 00000000..8e41581e --- /dev/null +++ b/src/model/generated/ogvProposalVote.model.ts @@ -0,0 +1,35 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" +import * as marshal from "./marshal" +import {OGVProposal} from "./ogvProposal.model" +import {OGVAddress} from "./ogvAddress.model" +import {OGVVoteType} from "./_ogvVoteType" + +@Entity_() +export class OGVProposalVote { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @ManyToOne_(() => OGVProposal, {nullable: true}) + proposal!: OGVProposal + + @Index_() + @ManyToOne_(() => OGVAddress, {nullable: true}) + voter!: OGVAddress + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + weight!: bigint + + @Column_("varchar", {length: 7, nullable: false}) + type!: OGVVoteType + + @Column_("text", {nullable: false}) + txHash!: string + + @Column_("timestamp with time zone", {nullable: false}) + timestamp!: Date +} diff --git a/src/processors/ogv/governance.ts b/src/processors/ogv/governance.ts new file mode 100644 index 00000000..7f75cb8e --- /dev/null +++ b/src/processors/ogv/governance.ts @@ -0,0 +1,248 @@ +import { EvmBatchProcessor } from '@subsquid/evm-processor' + +import * as erc20Abi from '../../abi/erc20' +import * as governanceAbi from '../../abi/governance' +import { OGVAddress, OGVProposal, OGVProposalEvent, OGVProposalState, OGVProposalTxLog, OGVProposalVote, OGVVoteType } from '../../model' +import { Block, Context, Log } from '../../processor' +import { + GOVERNANCE_ADDRESS, + OGV_ADDRESS, + VEOGV_ADDRESS, +} from '../../utils/addresses' + +export const from = 14439231 // https://etherscan.io/tx/0x9295cac246169f06a3d4ec33fdbd87fced7a9e19ea61177cae75034e45ae66f4 +export const veogvFrom = 15089597 // https://etherscan.io/tx/0x70c582e56ea1c49b7e9df70a0b40ddbfac9362b8b172cb527c329c2302d7d48a + +interface IProcessResult { + addresses: Map, + proposals: Map, + proposalLogs: OGVProposalTxLog[], + votes: OGVProposalVote[], +} + +export const setup = (processor: EvmBatchProcessor) => { + processor.addLog({ + address: [OGV_ADDRESS], + topic0: [erc20Abi.events.Transfer.topic], + range: { from }, + }) + processor.addLog({ + address: [VEOGV_ADDRESS], + topic0: [ + governanceAbi.events.ProposalCreated, + governanceAbi.events.ProposalExecuted, + governanceAbi.events.ProposalExtended, + governanceAbi.events.ProposalQueued, + governanceAbi.events.ProposalCanceled, + governanceAbi.events.VoteCast, + governanceAbi.events.VoteCastWithParams, + ].map(ev => ev.topic), + range: { from: veogvFrom }, + }) +} + +export const process = async (ctx: Context) => { + const result: IProcessResult = { + addresses: new Map(), + proposals: new Map(), + proposalLogs: [], + votes: [] + } + const addresses = new Map(); + + for (const block of ctx.blocks) { + for (const log of block.logs) { + const firstTopic = log.topics[0] + + if (firstTopic == governanceAbi.events.ProposalCreated.topic) { + await _processProposalCreated(ctx, result, block, log); + } else if (firstTopic == governanceAbi.events.ProposalExtended.topic) { + await _processProposalExtended(ctx, result, block, log); + } else if ([governanceAbi.events.ProposalQueued.topic, governanceAbi.events.ProposalCanceled.topic, governanceAbi.events.ProposalExecuted.topic].includes(firstTopic)) { + await _processProposalEvents(ctx, result, block, log); + } else if ([governanceAbi.events.VoteCast.topic, governanceAbi.events.VoteCastWithParams.topic].includes(firstTopic)) { + await _processVoteCast(ctx, result, block, log) + } + } + } + + await ctx.store.upsert(Array.from(addresses.values())) +} + +const _processProposalCreated = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log +) => { + const { proposalId, proposer: proposerAddr, description, startBlock, endBlock } = governanceAbi.events.ProposalCreated.decode(log) + const proposer = await _getAddress(ctx, proposerAddr, result) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = new OGVProposal({ + id: proposalId.toString(), + description, + proposer, + timestamp: blockTimestamp, + startBlock, + endBlock, + lastUpdated: new Date(), + status: OGVProposalState.Pending + }) + + const proposalTxLog = new OGVProposalTxLog({ + id: `${proposalId}:${log.transactionHash}:${log.logIndex}`, + proposal, + event: OGVProposalEvent.Created, + hash: log.transactionHash, + timestamp: blockTimestamp, + }) + + result.proposals.set(proposalId.toString(), proposal) + result.proposalLogs.push(proposalTxLog) +} + +const proposalStateMap = [ + OGVProposalState.Pending, + OGVProposalState.Active, + OGVProposalState.Canceled, + OGVProposalState.Defeated, + OGVProposalState.Succeeded, + OGVProposalState.Queued, + OGVProposalState.Expired, + OGVProposalState.Executed, +] + +const eventMapper = { + [governanceAbi.events.ProposalQueued.topic]: { + decode: governanceAbi.events.ProposalQueued.decode, + status: OGVProposalState.Queued, + event: OGVProposalEvent.Queued + }, + [governanceAbi.events.ProposalCanceled.topic]: { + decode: governanceAbi.events.ProposalCanceled.decode, + status: OGVProposalState.Canceled, + event: OGVProposalEvent.Canceled + }, + [governanceAbi.events.ProposalExecuted.topic]: { + decode: governanceAbi.events.ProposalExecuted.decode, + status: OGVProposalState.Executed, + event: OGVProposalEvent.Executed + }, +} + +const _processProposalEvents = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log +) => { + const { decode, status, event } = eventMapper[log.topics[0]]! + + const { proposalId } = decode(log) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = await _getProposal(ctx, proposalId.toString(), result) + proposal.status = status; + + + const proposalTxLog = new OGVProposalTxLog({ + id: `${proposalId}:${log.transactionHash}:${log.logIndex}`, + proposal, + event, + hash: log.transactionHash, + timestamp: blockTimestamp, + }) + + result.proposalLogs.push(proposalTxLog) +} + +const _processProposalExtended = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log +) => { + const { proposalId, extendedDeadline } = governanceAbi.events.ProposalExtended.decode(log) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = await _getProposal(ctx, proposalId.toString(), result) + proposal.endBlock = extendedDeadline + proposal.status = await _getProposalState(ctx, block, proposalId) + + const proposalTxLog = new OGVProposalTxLog({ + id: `${proposalId}:${log.transactionHash}:${log.logIndex}`, + proposal, + event: OGVProposalEvent.Extended, + hash: log.transactionHash, + timestamp: blockTimestamp, + }) + + result.proposalLogs.push(proposalTxLog) +} + +const _processVoteCast = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log +) => { + const decode = (log.topics[0] == governanceAbi.events.VoteCast.topic) ? governanceAbi.events.VoteCast.decode : governanceAbi.events.VoteCastWithParams.decode + const { proposalId, voter: voterAddr, weight, support } = decode(log) + const blockTimestamp = new Date(block.header.timestamp) + + const proposal = await _getProposal(ctx, proposalId.toString(), result) + const voter = await _getAddress(ctx, voterAddr, result) + + const proposalVote = new OGVProposalVote({ + id: `${proposalId.toString()}:${log.transactionHash}:${voter.id}`, + proposal, + voter, + txHash: log.transactionHash, + timestamp: blockTimestamp, + weight, + type: [OGVVoteType.Against, OGVVoteType.For, OGVVoteType.Abstain][parseInt(support.toString())] + }) + + result.votes.push(proposalVote) +} + +const _getProposalState = async (ctx: Context, block: Block, proposalId: bigint): Promise => { + const governance = new governanceAbi.Contract(ctx, block.header, GOVERNANCE_ADDRESS) + return proposalStateMap[ + parseInt((await governance.state(proposalId)).toString()) + ] || OGVProposalState.Pending; +} + +const _getAddress = async (ctx: Context, id: string, result: IProcessResult): Promise => { + id = id.toLowerCase() + const { addresses } = result + + if (addresses.has(id)) { + return addresses.get(id)! + } + + const address = await ctx.store.findOneByOrFail(OGVAddress, { + id + }) + + addresses.set(id, address) + + return address +} + +const _getProposal = async (ctx: Context, id: string, result: IProcessResult): Promise => { + const { proposals } = result + + if (proposals.has(id)) { + return proposals.get(id)! + } + + const proposal = await ctx.store.findOneByOrFail(OGVProposal, { + id + }) + + proposals.set(id, proposal) + + return proposal +} diff --git a/src/processors/ogv/ogv-supply.ts b/src/processors/ogv/ogv-supply.ts new file mode 100644 index 00000000..eb082e77 --- /dev/null +++ b/src/processors/ogv/ogv-supply.ts @@ -0,0 +1,41 @@ +import { EvmBatchProcessor } from '@subsquid/evm-processor'; +import { Context } from '../../processor'; +import { blockFrequencyUpdater } from '../../utils/blockFrequencyUpdater'; +import { OGV } from '../../model'; + +import * as erc20Abi from '../../abi/erc20' +import { OGV_ADDRESS, VEOGV_ADDRESS } from '../../utils/addresses'; + +export const from = 14439231 // https://etherscan.io/tx/0x9295cac246169f06a3d4ec33fdbd87fced7a9e19ea61177cae75034e45ae66f4 + +export const setup = (processor: EvmBatchProcessor) => { + processor.includeAllBlocks({ + from + }) +} +const update = blockFrequencyUpdater({ from }) + +export const process = async (ctx: Context) => { + const supplyData: OGV[] = [] + + await update(ctx, async (ctx, block) => { + const ogvToken = new erc20Abi.Contract(ctx, block.header, OGV_ADDRESS) + + const staked = await ogvToken.balanceOf(VEOGV_ADDRESS) + const total = await ogvToken.totalSupply() + const circulating = total - staked + + const supplyAtBlock = new OGV({ + id: `${block.header.height}`, + timestamp: new Date(block.header.timestamp), + blockNumber: block.header.height, + circulating, + staked, + total, + }) + + supplyData.push(supplyAtBlock) + }) + + await ctx.store.insert(supplyData) +} diff --git a/src/processors/ogv/ogv.ts b/src/processors/ogv/ogv.ts new file mode 100644 index 00000000..953a4f49 --- /dev/null +++ b/src/processors/ogv/ogv.ts @@ -0,0 +1,283 @@ +import { EvmBatchProcessor } from '@subsquid/evm-processor' + +import * as erc20Abi from '../../abi/erc20' +import * as veogvAbi from '../../abi/veogv' +import { OGVAddress, OGVLockup, OGVLockupEventType, OGVLockupTxLog } from '../../model' +import { Block, Context, Log } from '../../processor' +import { + ADDRESS_ZERO, + OGV_ADDRESS, + VEOGV_ADDRESS, +} from '../../utils/addresses' + +export const from = 14439231 // https://etherscan.io/tx/0x9295cac246169f06a3d4ec33fdbd87fced7a9e19ea61177cae75034e45ae66f4 +export const veogvFrom = 15089597 // https://etherscan.io/tx/0x70c582e56ea1c49b7e9df70a0b40ddbfac9362b8b172cb527c329c2302d7d48a + +interface IProcessResult { + addresses: Map, + lockups: Map, + lockupEvents: OGVLockupTxLog[], +} + +export const setup = (processor: EvmBatchProcessor) => { + processor.addLog({ + address: [OGV_ADDRESS], + topic0: [erc20Abi.events.Transfer.topic], + range: { from }, + }) + processor.addLog({ + address: [VEOGV_ADDRESS], + topic0: [ + veogvAbi.events.Transfer, + veogvAbi.events.Stake, + veogvAbi.events.Unstake, + veogvAbi.events.DelegateChanged, + veogvAbi.events.DelegateVotesChanged + ].map(ev => ev.topic), + range: { from: veogvFrom }, + }) +} + +export const process = async (ctx: Context) => { + const result: IProcessResult = { + addresses: new Map(), + lockups: new Map(), + lockupEvents: [] + } + const addresses = new Map(); + + for (const block of ctx.blocks) { + for (const log of block.logs) { + const firstTopic = log.topics[0] + + if (firstTopic == veogvAbi.events.Transfer.topic) { + await _processTransfer(ctx, result, block, log) + } else if (firstTopic == veogvAbi.events.DelegateChanged.topic) { + await _processDelegateChanged(ctx, result, block, log) + } else if (firstTopic == veogvAbi.events.DelegateVotesChanged.topic) { + await _processDelegateVotesChanged(ctx, result, block, log) + } else if (firstTopic == veogvAbi.events.Stake.topic) { + await _processStake(ctx, result, block, log) + } else if (firstTopic == veogvAbi.events.Unstake.topic) { + await _processUnstake(ctx, result, block, log) + } + } + } + + await ctx.store.upsert(Array.from(addresses.values())) +} + +const _processTransfer = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log +) => { + const { addresses } = result + let { from, to, value } = erc20Abi.events.Transfer.decode(log) + + from = from.toLowerCase() + to = to.toLowerCase() + + // const isStakingEvent = [from, to].includes(VEOGV_ADDRESS.toLowerCase()) + const isVeOGV = log.address.toLowerCase() == VEOGV_ADDRESS.toLowerCase() + + const blockTimestamp = new Date(block.header.timestamp) + + if (from != ADDRESS_ZERO) { + const sender = await _getAddress(ctx, from, result) + // TODO: Check sender.balance >= value + if (isVeOGV) { + sender.veogvBalance -= value; + } else { + sender.balance -= value; + } + sender.lastUpdated = blockTimestamp + // addresses.set(from, sender) + } + + if (to != ADDRESS_ZERO) { + const receiver = await _getAddress(ctx, from, result) + if (isVeOGV) { + receiver.veogvBalance += value; + } else { + receiver.balance += value; + } + receiver.lastUpdated = blockTimestamp + // addresses.set(to, receiver) + } +} + +const _processDelegateChanged = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log +) => { + + const { addresses } = result + let { delegator, toDelegate } = veogvAbi.events.DelegateChanged.decode(log) + delegator = delegator.toLowerCase() + toDelegate = toDelegate.toLowerCase() + + const address = await _getAddress(ctx, delegator, result) + + address.delegatee = await _getAddress(ctx, toDelegate, result) + address.lastUpdated = new Date(block.header.timestamp) + + // addresses.set(delegator, address); +} + +const _processDelegateVotesChanged = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log +) => { + const { addresses } = result + let { delegate, newBalance } = veogvAbi.events.DelegateVotesChanged.decode(log) + delegate = delegate.toLowerCase() + + const address = await _getAddress(ctx, delegate, result) + + address.votingPower = newBalance + address.lastUpdated = new Date(block.header.timestamp) + + // addresses.set(delegate, address); +} + +const _processStake = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log +) => { + const { lockups } = result + + const { lockupId, amount, user, points, end } = veogvAbi.events.Stake.decode(log) + const address = await _getAddress(ctx, user, result) + const lockup = await _getLockup(ctx, lockupId.toString(), address, result) + + const isExtend = !!lockup.timestamp + + lockup.amount = amount + lockup.veogv = points + lockup.end = new Date(Number(end.toString())) + lockup.timestamp = new Date(block.header.timestamp) + // lockups.set(lockup.id, lockup) + + if (isExtend) { + // Find last Unstake txLog and replace it + const unstakeIndex = result.lockupEvents.findIndex(x => + x.event == OGVLockupEventType.Unstaked + // Unstake is emitted just before Stake for Extend + && x.id == `${log.transactionHash}:${log.logIndex - 1}` + ) + + result.lockupEvents[unstakeIndex].event = OGVLockupEventType.Extended + } else { + result.lockupEvents.push(new OGVLockupTxLog({ + id: `${log.transactionHash}:${log.logIndex}`, + hash: log.transactionHash, + event: OGVLockupEventType.Staked, + timestamp: new Date(block.header.timestamp), + ogvLockup: lockup, + })) + } + + await _updateVotingPowers(ctx, result, block, address) +} + +const _processUnstake = async ( + ctx: Context, + result: IProcessResult, + block: Block, + log: Log +) => { + const { lockupId, user } = veogvAbi.events.Unstake.decode(log) + const address = await _getAddress(ctx, user, result) + const lockup = await _getLockup(ctx, lockupId.toString(), address, result) + + result.lockupEvents.push(new OGVLockupTxLog({ + id: `${log.transactionHash}:${log.logIndex}`, + hash: log.transactionHash, + event: OGVLockupEventType.Unstaked, + timestamp: new Date(block.header.timestamp), + ogvLockup: lockup, + })) + + await _updateVotingPowers(ctx, result, block, address) +} + +const _updateVotingPowers = async( + ctx: Context, + result: IProcessResult, + block: Block, + address: OGVAddress +) => { + const { addresses } = result + const veogv = new veogvAbi.Contract(ctx, block.header, VEOGV_ADDRESS) + + address.votingPower = await veogv.getVotes(address.id) + address.lastUpdated = new Date(block.header.timestamp) + // addresses.set(address.id, address) + + const delegateeId = address.delegatee?.id + if (delegateeId && delegateeId !== address.id) { + const delegatee = await _getAddress(ctx, address.delegatee?.id!, result) + delegatee.votingPower = await veogv.getVotes(delegateeId) + delegatee.lastUpdated = new Date(block.header.timestamp) + // addresses.set(delegateeId, delegatee) + } +} + +const _getAddress = async (ctx: Context, id: string, result: IProcessResult): Promise => { + id = id.toLowerCase() + const { addresses } = result + + if (addresses.has(id)) { + return addresses.get(id)! + } + + let address = await ctx.store.findOneBy(OGVAddress, { + id + }) + + if (!address) { + address = new OGVAddress({ + id: id.toLowerCase(), + balance: 0n, + veogvBalance: 0n, + votingPower: 0n, + lastUpdated: new Date(), + }) + } + + addresses.set(id, address) + + return address +} + +const _getLockup = async (ctx: Context, lockupId: string, address: OGVAddress, result: IProcessResult): Promise => { + const id = `${address.id}:${lockupId}`.toLowerCase() + const { lockups } = result + + if (lockups.has(id)) { + return lockups.get(id)! + } + + let lockup = await ctx.store.findOneBy(OGVLockup, { + id + }) + + if (!lockup) { + lockup = new OGVLockup({ + id, + address, + }) + } + + lockups.set(id, lockup) + + return lockup +} diff --git a/src/utils/addresses.ts b/src/utils/addresses.ts index bd1ecebd..845369a1 100644 --- a/src/utils/addresses.ts +++ b/src/utils/addresses.ts @@ -44,4 +44,14 @@ export const OETH_STRATEGY_BALANCER_ADDRESS = '0x49109629ac1deb03f2e9b2fe2ac4a623e0e7dfdc' -export const BALANCER_VAULT = '0xba12222222228d8ba445958a75a0704d566bf2c8' \ No newline at end of file +export const BALANCER_VAULT = '0xba12222222228d8ba445958a75a0704d566bf2c8' + + +export const GOVERNANCE_ADDRESS = + '0x3cdd07c16614059e66344a7b579dab4f9516c0b6' + +export const OGV_ADDRESS = + '0x9c354503c38481a7a7a51629142963f98ecc12d0' + +export const VEOGV_ADDRESS = + '0x0c4576ca1c365868e162554af8e385dc3e7c66d9' From 330e0de95ba19f4136011a666efac1241dae3a87 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Tue, 24 Oct 2023 15:12:41 -0700 Subject: [PATCH 2/4] regenerate codegen and db migration --- db/migrations/1698156475207-Data.js | 77 ------- db/migrations/1698185492705-Data.js | 301 ++++++++++++++++++++++++++++ 2 files changed, 301 insertions(+), 77 deletions(-) delete mode 100644 db/migrations/1698156475207-Data.js create mode 100644 db/migrations/1698185492705-Data.js diff --git a/db/migrations/1698156475207-Data.js b/db/migrations/1698156475207-Data.js deleted file mode 100644 index 5403f5e4..00000000 --- a/db/migrations/1698156475207-Data.js +++ /dev/null @@ -1,77 +0,0 @@ -module.exports = class Data1698156475207 { - name = 'Data1698156475207' - - async up(db) { - await db.query(`CREATE TABLE "oeth_strategy_holding_daily_stat" ("id" character varying NOT NULL, "symbol" text NOT NULL, "amount" numeric NOT NULL, "value" numeric NOT NULL, "strategy_daily_stat_id_id" character varying, CONSTRAINT "PK_7f1a62da5e53cf264c2f39b4acf" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_4e867f220975e615e6077d860c" ON "oeth_strategy_holding_daily_stat" ("strategy_daily_stat_id_id") `) - await db.query(`CREATE TABLE "oeth_strategy_daily_stat" ("id" character varying NOT NULL, "total" numeric NOT NULL, "tvl" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_8af1a0c60e67b05baf928787a8e" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_6c7096c96a000d8471256ca8fc" ON "oeth_strategy_daily_stat" ("daily_stat_id_id") `) - await db.query(`CREATE TABLE "oeth_collateral_daily_stat" ("id" character varying NOT NULL, "symbol" text NOT NULL, "amount" numeric NOT NULL, "price" numeric NOT NULL, "value" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_5fb23d7bae30dffe4543e7aa069" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_a90045de50406be7bd56efd3ea" ON "oeth_collateral_daily_stat" ("daily_stat_id_id") `) - await db.query(`CREATE TABLE "oeth_daily_stat" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "total_supply" numeric NOT NULL, "total_supply_usd" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, "amo_supply" numeric NOT NULL, "yield" numeric NOT NULL, "fees" numeric NOT NULL, "revenue" numeric NOT NULL, "revenue7_day_avg" numeric NOT NULL, "revenue7_day_total" numeric NOT NULL, "revenue_all_time" numeric NOT NULL, "peg_price" numeric NOT NULL, CONSTRAINT "PK_9144a02ab13b1baa818a7d5eae5" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_98d9001013aa37425ca47b7126" ON "oeth_daily_stat" ("block_number") `) - await db.query(`CREATE INDEX "IDX_c3e66051c7df4efd6a8fa8f9c1" ON "oeth_daily_stat" ("timestamp") `) - await db.query(`CREATE TABLE "ogv_address" ("id" character varying NOT NULL, "balance" numeric NOT NULL, "veogv_balance" numeric NOT NULL, "voting_power" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "delegatee_id" character varying, CONSTRAINT "PK_f13c77575687ef480ca0b7de5d8" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_49d26f287904b8b1aef6e9ac2b" ON "ogv_address" ("delegatee_id") `) - await db.query(`CREATE TABLE "ogv_lockup" ("id" character varying NOT NULL, "lockup_id" integer NOT NULL, "amount" numeric NOT NULL, "end" TIMESTAMP WITH TIME ZONE NOT NULL, "veogv" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "address_id" character varying, CONSTRAINT "PK_6b6d5ed3a004dd3f546c1b11fa4" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_8114101b53d9d6bc26fe80838a" ON "ogv_lockup" ("lockup_id") `) - await db.query(`CREATE INDEX "IDX_8be94cd63e35b91adf1301a156" ON "ogv_lockup" ("address_id") `) - await db.query(`CREATE TABLE "ogv_lockup_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "ogv_lockup_id" character varying, CONSTRAINT "PK_1c4a8425ce42f0c9da10056adee" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_b49fca291c97d9b55cd91f935f" ON "ogv_lockup_tx_log" ("ogv_lockup_id") `) - await db.query(`CREATE TABLE "ogv_proposal" ("id" character varying NOT NULL, "description" text, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "start_block" numeric NOT NULL, "end_block" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "status" character varying(9) NOT NULL, "proposer_id" character varying, CONSTRAINT "PK_b06db02b26fa37882e013579407" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_c62be3f16dfb3e4a09525c85af" ON "ogv_proposal" ("proposer_id") `) - await db.query(`CREATE TABLE "ogv_proposal_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, CONSTRAINT "PK_da43c287069bba678ca5c60b1ad" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_5d5f5e10892290ee366d26de7d" ON "ogv_proposal_tx_log" ("proposal_id") `) - await db.query(`CREATE TABLE "ogv_proposal_voter" ("id" character varying NOT NULL, "votes" numeric NOT NULL, "type" character varying(7) NOT NULL, "tx_hash" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, "voter_id" character varying, CONSTRAINT "PK_5a296bd7a618b75b5da0527f761" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_7b3e7fcd2895ba1d6803e42454" ON "ogv_proposal_voter" ("proposal_id") `) - await db.query(`CREATE INDEX "IDX_39efda99c037122170e2fed29b" ON "ogv_proposal_voter" ("voter_id") `) - await db.query(`ALTER TABLE "ogv" ADD "staked" numeric NOT NULL`) - await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" ADD CONSTRAINT "FK_4e867f220975e615e6077d860c1" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "oeth_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "oeth_strategy_daily_stat" ADD CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "oeth_collateral_daily_stat" ADD CONSTRAINT "FK_a90045de50406be7bd56efd3ea4" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ogv_address" ADD CONSTRAINT "FK_49d26f287904b8b1aef6e9ac2b3" FOREIGN KEY ("delegatee_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ogv_lockup" ADD CONSTRAINT "FK_8be94cd63e35b91adf1301a156c" FOREIGN KEY ("address_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ogv_lockup_tx_log" ADD CONSTRAINT "FK_b49fca291c97d9b55cd91f935f3" FOREIGN KEY ("ogv_lockup_id") REFERENCES "ogv_lockup"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ogv_proposal" ADD CONSTRAINT "FK_c62be3f16dfb3e4a09525c85af8" FOREIGN KEY ("proposer_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ogv_proposal_tx_log" ADD CONSTRAINT "FK_5d5f5e10892290ee366d26de7dc" FOREIGN KEY ("proposal_id") REFERENCES "ogv_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ogv_proposal_voter" ADD CONSTRAINT "FK_7b3e7fcd2895ba1d6803e42454b" FOREIGN KEY ("proposal_id") REFERENCES "ogv_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ogv_proposal_voter" ADD CONSTRAINT "FK_39efda99c037122170e2fed29b1" FOREIGN KEY ("voter_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - } - - async down(db) { - await db.query(`DROP TABLE "oeth_strategy_holding_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_4e867f220975e615e6077d860c"`) - await db.query(`DROP TABLE "oeth_strategy_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_6c7096c96a000d8471256ca8fc"`) - await db.query(`DROP TABLE "oeth_collateral_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_a90045de50406be7bd56efd3ea"`) - await db.query(`DROP TABLE "oeth_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_98d9001013aa37425ca47b7126"`) - await db.query(`DROP INDEX "public"."IDX_c3e66051c7df4efd6a8fa8f9c1"`) - await db.query(`DROP TABLE "ogv_address"`) - await db.query(`DROP INDEX "public"."IDX_49d26f287904b8b1aef6e9ac2b"`) - await db.query(`DROP TABLE "ogv_lockup"`) - await db.query(`DROP INDEX "public"."IDX_8114101b53d9d6bc26fe80838a"`) - await db.query(`DROP INDEX "public"."IDX_8be94cd63e35b91adf1301a156"`) - await db.query(`DROP TABLE "ogv_lockup_tx_log"`) - await db.query(`DROP INDEX "public"."IDX_b49fca291c97d9b55cd91f935f"`) - await db.query(`DROP TABLE "ogv_proposal"`) - await db.query(`DROP INDEX "public"."IDX_c62be3f16dfb3e4a09525c85af"`) - await db.query(`DROP TABLE "ogv_proposal_tx_log"`) - await db.query(`DROP INDEX "public"."IDX_5d5f5e10892290ee366d26de7d"`) - await db.query(`DROP TABLE "ogv_proposal_voter"`) - await db.query(`DROP INDEX "public"."IDX_7b3e7fcd2895ba1d6803e42454"`) - await db.query(`DROP INDEX "public"."IDX_39efda99c037122170e2fed29b"`) - await db.query(`ALTER TABLE "ogv" DROP COLUMN "staked"`) - await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" DROP CONSTRAINT "FK_4e867f220975e615e6077d860c1"`) - await db.query(`ALTER TABLE "oeth_strategy_daily_stat" DROP CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3"`) - await db.query(`ALTER TABLE "oeth_collateral_daily_stat" DROP CONSTRAINT "FK_a90045de50406be7bd56efd3ea4"`) - await db.query(`ALTER TABLE "ogv_address" DROP CONSTRAINT "FK_49d26f287904b8b1aef6e9ac2b3"`) - await db.query(`ALTER TABLE "ogv_lockup" DROP CONSTRAINT "FK_8be94cd63e35b91adf1301a156c"`) - await db.query(`ALTER TABLE "ogv_lockup_tx_log" DROP CONSTRAINT "FK_b49fca291c97d9b55cd91f935f3"`) - await db.query(`ALTER TABLE "ogv_proposal" DROP CONSTRAINT "FK_c62be3f16dfb3e4a09525c85af8"`) - await db.query(`ALTER TABLE "ogv_proposal_tx_log" DROP CONSTRAINT "FK_5d5f5e10892290ee366d26de7dc"`) - await db.query(`ALTER TABLE "ogv_proposal_voter" DROP CONSTRAINT "FK_7b3e7fcd2895ba1d6803e42454b"`) - await db.query(`ALTER TABLE "ogv_proposal_voter" DROP CONSTRAINT "FK_39efda99c037122170e2fed29b1"`) - } -} diff --git a/db/migrations/1698185492705-Data.js b/db/migrations/1698185492705-Data.js new file mode 100644 index 00000000..6609b968 --- /dev/null +++ b/db/migrations/1698185492705-Data.js @@ -0,0 +1,301 @@ +module.exports = class Data1698185492705 { + name = 'Data1698185492705' + + async up(db) { + await db.query(`CREATE TABLE "exchange_rate" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "pair" text NOT NULL, "base" text NOT NULL, "quote" text NOT NULL, "rate" numeric NOT NULL, CONSTRAINT "PK_5c5d27d2b900ef6cdeef0398472" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_9e23a3f1bf3634820c873a0fe8" ON "exchange_rate" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_c61a93768eed9e58ce399bbe01" ON "exchange_rate" ("block_number") `) + await db.query(`CREATE TABLE "balance" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "token" text NOT NULL, "address" text NOT NULL, "balance" numeric NOT NULL, CONSTRAINT "PK_079dddd31a81672e8143a649ca0" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_a956b410c329b8eca7898c3c51" ON "balance" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_6b451b59c9f6a6fdd685f530b2" ON "balance" ("block_number") `) + await db.query(`CREATE TABLE "strategy_balance" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "strategy" text NOT NULL, "asset" text NOT NULL, "balance" numeric NOT NULL, CONSTRAINT "PK_ca6f93229d1392e9546d01dae4f" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_0113bf0b63183bea0d22cd0d08" ON "strategy_balance" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_a88065dcd92011698bbe7df7b1" ON "strategy_balance" ("block_number") `) + await db.query(`CREATE TABLE "curve_pool_balance" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "address" text NOT NULL, "balance0" numeric NOT NULL, "balance1" numeric NOT NULL, "balance2" numeric NOT NULL, CONSTRAINT "PK_40412750bb910ca560aa084dd88" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_ffb0d0f86f03faacef7cb3e092" ON "curve_pool_balance" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_db5522c865eb8ed76fa7aeb4a8" ON "curve_pool_balance" ("block_number") `) + await db.query(`CREATE TABLE "oeth" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, CONSTRAINT "PK_de1d885501070dbd1ab6f8577ba" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_5b81a67229bac2d68e0dc92cc4" ON "oeth" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_408e5f79f83093aa5cf2b0ea32" ON "oeth" ("block_number") `) + await db.query(`CREATE TABLE "oeth_history" ("id" character varying NOT NULL, "value" numeric NOT NULL, "balance" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "type" character varying(8) NOT NULL, "address_id" character varying, CONSTRAINT "PK_2c7e7571cd9ea02b07a27a303f3" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_94e47c4c49128c78f60b185b46" ON "oeth_history" ("address_id") `) + await db.query(`CREATE INDEX "IDX_96956b1c8d29eb7066a97d5ea7" ON "oeth_history" ("block_number") `) + await db.query(`CREATE INDEX "IDX_b14170bdb7fbc0775bf55df15d" ON "oeth_history" ("tx_hash") `) + await db.query(`CREATE TABLE "oeth_address" ("id" character varying NOT NULL, "is_contract" boolean NOT NULL, "rebasing_option" character varying(6) NOT NULL, "balance" numeric NOT NULL, "earned" numeric NOT NULL, "credits" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, CONSTRAINT "PK_92a966afe47d584af73ce77a1cd" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "oethapy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, CONSTRAINT "PK_8dbb4d04591848361200f18f62a" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_b1a448045d1ed9d655b679a371" ON "oethapy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_6b8a7a706a0701e659a7d81508" ON "oethapy" ("block_number") `) + await db.query(`CREATE INDEX "IDX_c0c03168bb0139e3cffda4f00e" ON "oethapy" ("tx_hash") `) + await db.query(`CREATE TABLE "oeth_rebase" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "total_supply" numeric NOT NULL, "rebasing_credits" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, "fee" numeric NOT NULL, "yield" numeric NOT NULL, "apy_id" character varying, CONSTRAINT "PK_5f8f4dd071caf685b4ac2d54de3" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_fbb7b3f2fff9896eb683b86de7" ON "oeth_rebase" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_d3255d02d9407bba89380d01fa" ON "oeth_rebase" ("block_number") `) + await db.query(`CREATE INDEX "IDX_8b6bb0243472af88612fe6a01f" ON "oeth_rebase" ("tx_hash") `) + await db.query(`CREATE INDEX "IDX_3331819842173de7c27c046547" ON "oeth_rebase" ("apy_id") `) + await db.query(`CREATE TABLE "oeth_rebase_option" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "status" character varying(6) NOT NULL, "address_id" character varying, CONSTRAINT "PK_32971725d5523200b4b3b7c07e5" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_1fc6bbd88037bfbf4361776909" ON "oeth_rebase_option" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_cbb7ceb49ef7c45432d0171296" ON "oeth_rebase_option" ("block_number") `) + await db.query(`CREATE INDEX "IDX_355826dadaacc5ae2d63c82f28" ON "oeth_rebase_option" ("tx_hash") `) + await db.query(`CREATE INDEX "IDX_034428879698039839b4ba6ffe" ON "oeth_rebase_option" ("address_id") `) + await db.query(`CREATE TABLE "oeth_vault" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, "st_eth" numeric NOT NULL, "r_eth" numeric NOT NULL, "frx_eth" numeric NOT NULL, CONSTRAINT "PK_9debaa84944fe2be9dc4219ba8f" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_d6298a294864b4eaf793cf35a4" ON "oeth_vault" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_e20cb507a673817b2c68720415" ON "oeth_vault" ("block_number") `) + await db.query(`CREATE TABLE "oeth_curve_lp" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "eth" numeric NOT NULL, "oeth" numeric NOT NULL, "total_supply_owned" numeric NOT NULL, "eth_owned" numeric NOT NULL, "oeth_owned" numeric NOT NULL, CONSTRAINT "PK_2b055044664e80f44d6172fdf54" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_d9bbd20e888fa1b4b2c5d2f039" ON "oeth_curve_lp" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_7617d593c36dce1b1565a8d74a" ON "oeth_curve_lp" ("block_number") `) + await db.query(`CREATE TABLE "oeth_frax_staking" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "sfrx_eth" numeric NOT NULL, CONSTRAINT "PK_694f53c8600ae88c7bdcf7305dd" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_ce6c2c65e90967dfeaac97025b" ON "oeth_frax_staking" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_1a7f7d650390e2f9c212651e05" ON "oeth_frax_staking" ("block_number") `) + await db.query(`CREATE TABLE "oeth_morpho_aave" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_86de8f846e9335c92b8ad7df3a1" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_25e239b985844f1d33fac79981" ON "oeth_morpho_aave" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_a6662224e95eb6921bb14cb5f9" ON "oeth_morpho_aave" ("block_number") `) + await db.query(`CREATE TABLE "dripper" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_74fd102c8d1c60f4b1650a61ffc" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_88c58f8948c3294c2a9e2791dc" ON "dripper" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_06822c0a260797711acc9023d5" ON "dripper" ("block_number") `) + await db.query(`CREATE TABLE "oeth_balancer_meta_pool_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "r_eth" numeric NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_6ddf5b8ba878e6d706e59bd6de0" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_5e7ef383756fa18cb602f50089" ON "oeth_balancer_meta_pool_strategy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_11d344b3e0e03cdb6697dd61f7" ON "oeth_balancer_meta_pool_strategy" ("block_number") `) + await db.query(`CREATE TABLE "oeth_strategy_holding_daily_stat" ("id" character varying NOT NULL, "symbol" text NOT NULL, "amount" numeric NOT NULL, "value" numeric NOT NULL, "strategy_daily_stat_id_id" character varying, CONSTRAINT "PK_7f1a62da5e53cf264c2f39b4acf" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_4e867f220975e615e6077d860c" ON "oeth_strategy_holding_daily_stat" ("strategy_daily_stat_id_id") `) + await db.query(`CREATE TABLE "oeth_strategy_daily_stat" ("id" character varying NOT NULL, "total" numeric NOT NULL, "tvl" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_8af1a0c60e67b05baf928787a8e" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_6c7096c96a000d8471256ca8fc" ON "oeth_strategy_daily_stat" ("daily_stat_id_id") `) + await db.query(`CREATE TABLE "oeth_collateral_daily_stat" ("id" character varying NOT NULL, "symbol" text NOT NULL, "amount" numeric NOT NULL, "price" numeric NOT NULL, "value" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_5fb23d7bae30dffe4543e7aa069" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_a90045de50406be7bd56efd3ea" ON "oeth_collateral_daily_stat" ("daily_stat_id_id") `) + await db.query(`CREATE TABLE "oeth_daily_stat" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "total_supply" numeric NOT NULL, "total_supply_usd" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, "amo_supply" numeric NOT NULL, "yield" numeric NOT NULL, "fees" numeric NOT NULL, "revenue" numeric NOT NULL, "revenue7_day_avg" numeric NOT NULL, "revenue7_day_total" numeric NOT NULL, "revenue_all_time" numeric NOT NULL, "peg_price" numeric NOT NULL, CONSTRAINT "PK_9144a02ab13b1baa818a7d5eae5" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_98d9001013aa37425ca47b7126" ON "oeth_daily_stat" ("block_number") `) + await db.query(`CREATE INDEX "IDX_c3e66051c7df4efd6a8fa8f9c1" ON "oeth_daily_stat" ("timestamp") `) + await db.query(`CREATE TABLE "ogv" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "circulating" numeric NOT NULL, "staked" numeric NOT NULL, "total" numeric NOT NULL, CONSTRAINT "PK_f16038abf451ce82bd03ea54ee7" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_2418a8b8b92b2f5977be761cf9" ON "ogv" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_b8f20bcf48e4aa77e0f48d77db" ON "ogv" ("block_number") `) + await db.query(`CREATE TABLE "ogv_address" ("id" character varying NOT NULL, "balance" numeric NOT NULL, "veogv_balance" numeric NOT NULL, "voting_power" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "delegatee_id" character varying, CONSTRAINT "PK_f13c77575687ef480ca0b7de5d8" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_49d26f287904b8b1aef6e9ac2b" ON "ogv_address" ("delegatee_id") `) + await db.query(`CREATE TABLE "ogv_lockup" ("id" character varying NOT NULL, "lockup_id" integer NOT NULL, "amount" numeric NOT NULL, "end" TIMESTAMP WITH TIME ZONE NOT NULL, "veogv" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "address_id" character varying, CONSTRAINT "PK_6b6d5ed3a004dd3f546c1b11fa4" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_8114101b53d9d6bc26fe80838a" ON "ogv_lockup" ("lockup_id") `) + await db.query(`CREATE INDEX "IDX_8be94cd63e35b91adf1301a156" ON "ogv_lockup" ("address_id") `) + await db.query(`CREATE TABLE "ogv_lockup_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "ogv_lockup_id" character varying, CONSTRAINT "PK_1c4a8425ce42f0c9da10056adee" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_b49fca291c97d9b55cd91f935f" ON "ogv_lockup_tx_log" ("ogv_lockup_id") `) + await db.query(`CREATE TABLE "ogv_proposal" ("id" character varying NOT NULL, "description" text, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "start_block" numeric NOT NULL, "end_block" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "status" character varying(9) NOT NULL, "proposer_id" character varying, CONSTRAINT "PK_b06db02b26fa37882e013579407" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_c62be3f16dfb3e4a09525c85af" ON "ogv_proposal" ("proposer_id") `) + await db.query(`CREATE TABLE "ogv_proposal_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, CONSTRAINT "PK_da43c287069bba678ca5c60b1ad" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_5d5f5e10892290ee366d26de7d" ON "ogv_proposal_tx_log" ("proposal_id") `) + await db.query(`CREATE TABLE "ogv_proposal_vote" ("id" character varying NOT NULL, "weight" numeric NOT NULL, "type" character varying(7) NOT NULL, "tx_hash" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "proposal_id" character varying, "voter_id" character varying, CONSTRAINT "PK_93c03f35b95221586cb8b83f523" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_58d732bc6523c2609d2725cc0a" ON "ogv_proposal_vote" ("proposal_id") `) + await db.query(`CREATE INDEX "IDX_2fd621aea353448fb3f17721bc" ON "ogv_proposal_vote" ("voter_id") `) + await db.query(`CREATE TABLE "ousd" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "total_supply" numeric NOT NULL, "rebasing_supply" numeric NOT NULL, "non_rebasing_supply" numeric NOT NULL, CONSTRAINT "PK_acecae4a20bc14b22d9f6738d8d" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_c8d1e285213b445b088805ac7c" ON "ousd" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_806949dd853b7e8acab5d03b81" ON "ousd" ("block_number") `) + await db.query(`CREATE TABLE "ousd_history" ("id" character varying NOT NULL, "value" numeric NOT NULL, "balance" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "type" character varying(8) NOT NULL, "address_id" character varying, CONSTRAINT "PK_dcbe3223b67f92d9ad4cffe8a7c" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_70291ea600c0c4d67d9bfe6a6b" ON "ousd_history" ("address_id") `) + await db.query(`CREATE INDEX "IDX_4d00d283e1ce3209dc43a0313c" ON "ousd_history" ("block_number") `) + await db.query(`CREATE INDEX "IDX_0c25caa59aa053a688a723d160" ON "ousd_history" ("tx_hash") `) + await db.query(`CREATE TABLE "ousd_address" ("id" character varying NOT NULL, "is_contract" boolean NOT NULL, "rebasing_option" character varying(6) NOT NULL, "balance" numeric NOT NULL, "earned" numeric NOT NULL, "credits" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, CONSTRAINT "PK_bb061344757ede566d62854af6a" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "ousdapy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, "apy7_day_avg" numeric NOT NULL, "apy14_day_avg" numeric NOT NULL, "apy30_day_avg" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, CONSTRAINT "PK_d9889b7153efc82dbe88f9a7a33" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_c514963f42908ce84d65a84a77" ON "ousdapy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_4f606414b3b5ce1a366bd0fbf6" ON "ousdapy" ("block_number") `) + await db.query(`CREATE INDEX "IDX_0e84a81a109b66fe6f01f77c74" ON "ousdapy" ("tx_hash") `) + await db.query(`CREATE TABLE "ousd_rebase" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "total_supply" numeric NOT NULL, "rebasing_credits" numeric NOT NULL, "rebasing_credits_per_token" numeric NOT NULL, "fee" numeric NOT NULL, "yield" numeric NOT NULL, "apy_id" character varying, CONSTRAINT "PK_04cf0de72399a99798dde61b237" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_f8eb4a16ce58a146b3227ee21a" ON "ousd_rebase" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_3fb03b1a410e64c7367226d0b6" ON "ousd_rebase" ("block_number") `) + await db.query(`CREATE INDEX "IDX_1a76c478199672aaeec340f619" ON "ousd_rebase" ("tx_hash") `) + await db.query(`CREATE INDEX "IDX_427468c97f9838b804efd6c8e5" ON "ousd_rebase" ("apy_id") `) + await db.query(`CREATE TABLE "ousd_rebase_option" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "status" character varying(6) NOT NULL, "address_id" character varying, CONSTRAINT "PK_d684f90866027104f3c929dfe10" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_64bd23947dc4c67e3b6a3f9352" ON "ousd_rebase_option" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_9b774e46b8b1cf7f828133809a" ON "ousd_rebase_option" ("block_number") `) + await db.query(`CREATE INDEX "IDX_4e95bf069de04533d83a9a97fd" ON "ousd_rebase_option" ("tx_hash") `) + await db.query(`CREATE INDEX "IDX_b04173f9349ddd991a3b60e914" ON "ousd_rebase_option" ("address_id") `) + await db.query(`CREATE TABLE "ousd_vault" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_343f5538c71a1cd78f1659ef9d3" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_6860186ea2f56e2c7d54c22107" ON "ousd_vault" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_0d0a7113a505cf7f7adea9ca81" ON "ousd_vault" ("block_number") `) + await db.query(`CREATE TABLE "ousd_morpho_aave" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_60676cde905a822ba73ff3a5c85" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_78e0701c2e9a28242db37bd8f8" ON "ousd_morpho_aave" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_46ccf673b376d654052fbd53e6" ON "ousd_morpho_aave" ("block_number") `) + await db.query(`CREATE TABLE "ousd_morpho_compound" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_5f715d53ef8fc0fad595cacf4fa" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_9e7bd0d8ae23b877d5979ef80c" ON "ousd_morpho_compound" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_0bb3a0ad84071f1d80f6d4e90f" ON "ousd_morpho_compound" ("block_number") `) + await db.query(`CREATE TABLE "maker_dsr_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, CONSTRAINT "PK_196da2d6910009ae04e3542fe22" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_a35308a3c5dbaab2d321eb1525" ON "maker_dsr_strategy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_844b219d8faf9b1d24ab2dba9a" ON "maker_dsr_strategy" ("block_number") `) + await db.query(`CREATE TABLE "ousd_flux_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_ac977221429e50e4de1ce253a8b" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_5b165b5d30b13e363d33a66e14" ON "ousd_flux_strategy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_80f3392968fde7b99cccb805ac" ON "ousd_flux_strategy" ("block_number") `) + await db.query(`CREATE TABLE "ousd_compound_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_9030e82bf3479d03c04e0d1919c" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_6920b1db5dc577295ac4d1379d" ON "ousd_compound_strategy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_89c6d7d3104bd36dc88a37add4" ON "ousd_compound_strategy" ("block_number") `) + await db.query(`CREATE TABLE "ousd_convex_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_2b8f6e749e15e49d8816f1ac949" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_2deac473cd0b2dd7082e7da148" ON "ousd_convex_strategy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_157bf74171817dc5c60ee37036" ON "ousd_convex_strategy" ("block_number") `) + await db.query(`CREATE TABLE "ousd_aave_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_b4b7ac6e395aa722df500f93623" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_ca34b5a0a33bc9abdd8213c2fa" ON "ousd_aave_strategy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_dacd7c98223d7bc8be074d71e4" ON "ousd_aave_strategy" ("block_number") `) + await db.query(`CREATE TABLE "ousd_meta_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_d99170af73d86fe74460bbfacc4" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_7e998dcf775263bc5df76ef987" ON "ousd_meta_strategy" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_55ce185680512d6a5b9fb0af89" ON "ousd_meta_strategy" ("block_number") `) + await db.query(`CREATE TABLE "ousd_convex_lusd_plus3_crv" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "dai" numeric NOT NULL, "usdt" numeric NOT NULL, "usdc" numeric NOT NULL, CONSTRAINT "PK_47290aa5dfa3cc5595f468e2f39" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_0783af95efb35fb3f13cde1656" ON "ousd_convex_lusd_plus3_crv" ("timestamp") `) + await db.query(`CREATE INDEX "IDX_74ae01fb596a4f2733087ba454" ON "ousd_convex_lusd_plus3_crv" ("block_number") `) + await db.query(`ALTER TABLE "oeth_history" ADD CONSTRAINT "FK_94e47c4c49128c78f60b185b46b" FOREIGN KEY ("address_id") REFERENCES "oeth_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "oeth_rebase" ADD CONSTRAINT "FK_3331819842173de7c27c046547a" FOREIGN KEY ("apy_id") REFERENCES "oethapy"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "oeth_rebase_option" ADD CONSTRAINT "FK_034428879698039839b4ba6ffe8" FOREIGN KEY ("address_id") REFERENCES "oeth_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" ADD CONSTRAINT "FK_4e867f220975e615e6077d860c1" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "oeth_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "oeth_strategy_daily_stat" ADD CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "oeth_collateral_daily_stat" ADD CONSTRAINT "FK_a90045de50406be7bd56efd3ea4" FOREIGN KEY ("daily_stat_id_id") REFERENCES "oeth_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_address" ADD CONSTRAINT "FK_49d26f287904b8b1aef6e9ac2b3" FOREIGN KEY ("delegatee_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_lockup" ADD CONSTRAINT "FK_8be94cd63e35b91adf1301a156c" FOREIGN KEY ("address_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_lockup_tx_log" ADD CONSTRAINT "FK_b49fca291c97d9b55cd91f935f3" FOREIGN KEY ("ogv_lockup_id") REFERENCES "ogv_lockup"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_proposal" ADD CONSTRAINT "FK_c62be3f16dfb3e4a09525c85af8" FOREIGN KEY ("proposer_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_proposal_tx_log" ADD CONSTRAINT "FK_5d5f5e10892290ee366d26de7dc" FOREIGN KEY ("proposal_id") REFERENCES "ogv_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_proposal_vote" ADD CONSTRAINT "FK_58d732bc6523c2609d2725cc0ac" FOREIGN KEY ("proposal_id") REFERENCES "ogv_proposal"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ogv_proposal_vote" ADD CONSTRAINT "FK_2fd621aea353448fb3f17721bc8" FOREIGN KEY ("voter_id") REFERENCES "ogv_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ousd_history" ADD CONSTRAINT "FK_70291ea600c0c4d67d9bfe6a6bf" FOREIGN KEY ("address_id") REFERENCES "ousd_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ousd_rebase" ADD CONSTRAINT "FK_427468c97f9838b804efd6c8e55" FOREIGN KEY ("apy_id") REFERENCES "ousdapy"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ousd_rebase_option" ADD CONSTRAINT "FK_b04173f9349ddd991a3b60e914a" FOREIGN KEY ("address_id") REFERENCES "ousd_address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + } + + async down(db) { + await db.query(`DROP TABLE "exchange_rate"`) + await db.query(`DROP INDEX "public"."IDX_9e23a3f1bf3634820c873a0fe8"`) + await db.query(`DROP INDEX "public"."IDX_c61a93768eed9e58ce399bbe01"`) + await db.query(`DROP TABLE "balance"`) + await db.query(`DROP INDEX "public"."IDX_a956b410c329b8eca7898c3c51"`) + await db.query(`DROP INDEX "public"."IDX_6b451b59c9f6a6fdd685f530b2"`) + await db.query(`DROP TABLE "strategy_balance"`) + await db.query(`DROP INDEX "public"."IDX_0113bf0b63183bea0d22cd0d08"`) + await db.query(`DROP INDEX "public"."IDX_a88065dcd92011698bbe7df7b1"`) + await db.query(`DROP TABLE "curve_pool_balance"`) + await db.query(`DROP INDEX "public"."IDX_ffb0d0f86f03faacef7cb3e092"`) + await db.query(`DROP INDEX "public"."IDX_db5522c865eb8ed76fa7aeb4a8"`) + await db.query(`DROP TABLE "oeth"`) + await db.query(`DROP INDEX "public"."IDX_5b81a67229bac2d68e0dc92cc4"`) + await db.query(`DROP INDEX "public"."IDX_408e5f79f83093aa5cf2b0ea32"`) + await db.query(`DROP TABLE "oeth_history"`) + await db.query(`DROP INDEX "public"."IDX_94e47c4c49128c78f60b185b46"`) + await db.query(`DROP INDEX "public"."IDX_96956b1c8d29eb7066a97d5ea7"`) + await db.query(`DROP INDEX "public"."IDX_b14170bdb7fbc0775bf55df15d"`) + await db.query(`DROP TABLE "oeth_address"`) + await db.query(`DROP TABLE "oethapy"`) + await db.query(`DROP INDEX "public"."IDX_b1a448045d1ed9d655b679a371"`) + await db.query(`DROP INDEX "public"."IDX_6b8a7a706a0701e659a7d81508"`) + await db.query(`DROP INDEX "public"."IDX_c0c03168bb0139e3cffda4f00e"`) + await db.query(`DROP TABLE "oeth_rebase"`) + await db.query(`DROP INDEX "public"."IDX_fbb7b3f2fff9896eb683b86de7"`) + await db.query(`DROP INDEX "public"."IDX_d3255d02d9407bba89380d01fa"`) + await db.query(`DROP INDEX "public"."IDX_8b6bb0243472af88612fe6a01f"`) + await db.query(`DROP INDEX "public"."IDX_3331819842173de7c27c046547"`) + await db.query(`DROP TABLE "oeth_rebase_option"`) + await db.query(`DROP INDEX "public"."IDX_1fc6bbd88037bfbf4361776909"`) + await db.query(`DROP INDEX "public"."IDX_cbb7ceb49ef7c45432d0171296"`) + await db.query(`DROP INDEX "public"."IDX_355826dadaacc5ae2d63c82f28"`) + await db.query(`DROP INDEX "public"."IDX_034428879698039839b4ba6ffe"`) + await db.query(`DROP TABLE "oeth_vault"`) + await db.query(`DROP INDEX "public"."IDX_d6298a294864b4eaf793cf35a4"`) + await db.query(`DROP INDEX "public"."IDX_e20cb507a673817b2c68720415"`) + await db.query(`DROP TABLE "oeth_curve_lp"`) + await db.query(`DROP INDEX "public"."IDX_d9bbd20e888fa1b4b2c5d2f039"`) + await db.query(`DROP INDEX "public"."IDX_7617d593c36dce1b1565a8d74a"`) + await db.query(`DROP TABLE "oeth_frax_staking"`) + await db.query(`DROP INDEX "public"."IDX_ce6c2c65e90967dfeaac97025b"`) + await db.query(`DROP INDEX "public"."IDX_1a7f7d650390e2f9c212651e05"`) + await db.query(`DROP TABLE "oeth_morpho_aave"`) + await db.query(`DROP INDEX "public"."IDX_25e239b985844f1d33fac79981"`) + await db.query(`DROP INDEX "public"."IDX_a6662224e95eb6921bb14cb5f9"`) + await db.query(`DROP TABLE "dripper"`) + await db.query(`DROP INDEX "public"."IDX_88c58f8948c3294c2a9e2791dc"`) + await db.query(`DROP INDEX "public"."IDX_06822c0a260797711acc9023d5"`) + await db.query(`DROP TABLE "oeth_balancer_meta_pool_strategy"`) + await db.query(`DROP INDEX "public"."IDX_5e7ef383756fa18cb602f50089"`) + await db.query(`DROP INDEX "public"."IDX_11d344b3e0e03cdb6697dd61f7"`) + await db.query(`DROP TABLE "oeth_strategy_holding_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_4e867f220975e615e6077d860c"`) + await db.query(`DROP TABLE "oeth_strategy_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_6c7096c96a000d8471256ca8fc"`) + await db.query(`DROP TABLE "oeth_collateral_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_a90045de50406be7bd56efd3ea"`) + await db.query(`DROP TABLE "oeth_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_98d9001013aa37425ca47b7126"`) + await db.query(`DROP INDEX "public"."IDX_c3e66051c7df4efd6a8fa8f9c1"`) + await db.query(`DROP TABLE "ogv"`) + await db.query(`DROP INDEX "public"."IDX_2418a8b8b92b2f5977be761cf9"`) + await db.query(`DROP INDEX "public"."IDX_b8f20bcf48e4aa77e0f48d77db"`) + await db.query(`DROP TABLE "ogv_address"`) + await db.query(`DROP INDEX "public"."IDX_49d26f287904b8b1aef6e9ac2b"`) + await db.query(`DROP TABLE "ogv_lockup"`) + await db.query(`DROP INDEX "public"."IDX_8114101b53d9d6bc26fe80838a"`) + await db.query(`DROP INDEX "public"."IDX_8be94cd63e35b91adf1301a156"`) + await db.query(`DROP TABLE "ogv_lockup_tx_log"`) + await db.query(`DROP INDEX "public"."IDX_b49fca291c97d9b55cd91f935f"`) + await db.query(`DROP TABLE "ogv_proposal"`) + await db.query(`DROP INDEX "public"."IDX_c62be3f16dfb3e4a09525c85af"`) + await db.query(`DROP TABLE "ogv_proposal_tx_log"`) + await db.query(`DROP INDEX "public"."IDX_5d5f5e10892290ee366d26de7d"`) + await db.query(`DROP TABLE "ogv_proposal_vote"`) + await db.query(`DROP INDEX "public"."IDX_58d732bc6523c2609d2725cc0a"`) + await db.query(`DROP INDEX "public"."IDX_2fd621aea353448fb3f17721bc"`) + await db.query(`DROP TABLE "ousd"`) + await db.query(`DROP INDEX "public"."IDX_c8d1e285213b445b088805ac7c"`) + await db.query(`DROP INDEX "public"."IDX_806949dd853b7e8acab5d03b81"`) + await db.query(`DROP TABLE "ousd_history"`) + await db.query(`DROP INDEX "public"."IDX_70291ea600c0c4d67d9bfe6a6b"`) + await db.query(`DROP INDEX "public"."IDX_4d00d283e1ce3209dc43a0313c"`) + await db.query(`DROP INDEX "public"."IDX_0c25caa59aa053a688a723d160"`) + await db.query(`DROP TABLE "ousd_address"`) + await db.query(`DROP TABLE "ousdapy"`) + await db.query(`DROP INDEX "public"."IDX_c514963f42908ce84d65a84a77"`) + await db.query(`DROP INDEX "public"."IDX_4f606414b3b5ce1a366bd0fbf6"`) + await db.query(`DROP INDEX "public"."IDX_0e84a81a109b66fe6f01f77c74"`) + await db.query(`DROP TABLE "ousd_rebase"`) + await db.query(`DROP INDEX "public"."IDX_f8eb4a16ce58a146b3227ee21a"`) + await db.query(`DROP INDEX "public"."IDX_3fb03b1a410e64c7367226d0b6"`) + await db.query(`DROP INDEX "public"."IDX_1a76c478199672aaeec340f619"`) + await db.query(`DROP INDEX "public"."IDX_427468c97f9838b804efd6c8e5"`) + await db.query(`DROP TABLE "ousd_rebase_option"`) + await db.query(`DROP INDEX "public"."IDX_64bd23947dc4c67e3b6a3f9352"`) + await db.query(`DROP INDEX "public"."IDX_9b774e46b8b1cf7f828133809a"`) + await db.query(`DROP INDEX "public"."IDX_4e95bf069de04533d83a9a97fd"`) + await db.query(`DROP INDEX "public"."IDX_b04173f9349ddd991a3b60e914"`) + await db.query(`DROP TABLE "ousd_vault"`) + await db.query(`DROP INDEX "public"."IDX_6860186ea2f56e2c7d54c22107"`) + await db.query(`DROP INDEX "public"."IDX_0d0a7113a505cf7f7adea9ca81"`) + await db.query(`DROP TABLE "ousd_morpho_aave"`) + await db.query(`DROP INDEX "public"."IDX_78e0701c2e9a28242db37bd8f8"`) + await db.query(`DROP INDEX "public"."IDX_46ccf673b376d654052fbd53e6"`) + await db.query(`DROP TABLE "ousd_morpho_compound"`) + await db.query(`DROP INDEX "public"."IDX_9e7bd0d8ae23b877d5979ef80c"`) + await db.query(`DROP INDEX "public"."IDX_0bb3a0ad84071f1d80f6d4e90f"`) + await db.query(`DROP TABLE "maker_dsr_strategy"`) + await db.query(`DROP INDEX "public"."IDX_a35308a3c5dbaab2d321eb1525"`) + await db.query(`DROP INDEX "public"."IDX_844b219d8faf9b1d24ab2dba9a"`) + await db.query(`DROP TABLE "ousd_flux_strategy"`) + await db.query(`DROP INDEX "public"."IDX_5b165b5d30b13e363d33a66e14"`) + await db.query(`DROP INDEX "public"."IDX_80f3392968fde7b99cccb805ac"`) + await db.query(`DROP TABLE "ousd_compound_strategy"`) + await db.query(`DROP INDEX "public"."IDX_6920b1db5dc577295ac4d1379d"`) + await db.query(`DROP INDEX "public"."IDX_89c6d7d3104bd36dc88a37add4"`) + await db.query(`DROP TABLE "ousd_convex_strategy"`) + await db.query(`DROP INDEX "public"."IDX_2deac473cd0b2dd7082e7da148"`) + await db.query(`DROP INDEX "public"."IDX_157bf74171817dc5c60ee37036"`) + await db.query(`DROP TABLE "ousd_aave_strategy"`) + await db.query(`DROP INDEX "public"."IDX_ca34b5a0a33bc9abdd8213c2fa"`) + await db.query(`DROP INDEX "public"."IDX_dacd7c98223d7bc8be074d71e4"`) + await db.query(`DROP TABLE "ousd_meta_strategy"`) + await db.query(`DROP INDEX "public"."IDX_7e998dcf775263bc5df76ef987"`) + await db.query(`DROP INDEX "public"."IDX_55ce185680512d6a5b9fb0af89"`) + await db.query(`DROP TABLE "ousd_convex_lusd_plus3_crv"`) + await db.query(`DROP INDEX "public"."IDX_0783af95efb35fb3f13cde1656"`) + await db.query(`DROP INDEX "public"."IDX_74ae01fb596a4f2733087ba454"`) + await db.query(`ALTER TABLE "oeth_history" DROP CONSTRAINT "FK_94e47c4c49128c78f60b185b46b"`) + await db.query(`ALTER TABLE "oeth_rebase" DROP CONSTRAINT "FK_3331819842173de7c27c046547a"`) + await db.query(`ALTER TABLE "oeth_rebase_option" DROP CONSTRAINT "FK_034428879698039839b4ba6ffe8"`) + await db.query(`ALTER TABLE "oeth_strategy_holding_daily_stat" DROP CONSTRAINT "FK_4e867f220975e615e6077d860c1"`) + await db.query(`ALTER TABLE "oeth_strategy_daily_stat" DROP CONSTRAINT "FK_6c7096c96a000d8471256ca8fc3"`) + await db.query(`ALTER TABLE "oeth_collateral_daily_stat" DROP CONSTRAINT "FK_a90045de50406be7bd56efd3ea4"`) + await db.query(`ALTER TABLE "ogv_address" DROP CONSTRAINT "FK_49d26f287904b8b1aef6e9ac2b3"`) + await db.query(`ALTER TABLE "ogv_lockup" DROP CONSTRAINT "FK_8be94cd63e35b91adf1301a156c"`) + await db.query(`ALTER TABLE "ogv_lockup_tx_log" DROP CONSTRAINT "FK_b49fca291c97d9b55cd91f935f3"`) + await db.query(`ALTER TABLE "ogv_proposal" DROP CONSTRAINT "FK_c62be3f16dfb3e4a09525c85af8"`) + await db.query(`ALTER TABLE "ogv_proposal_tx_log" DROP CONSTRAINT "FK_5d5f5e10892290ee366d26de7dc"`) + await db.query(`ALTER TABLE "ogv_proposal_vote" DROP CONSTRAINT "FK_58d732bc6523c2609d2725cc0ac"`) + await db.query(`ALTER TABLE "ogv_proposal_vote" DROP CONSTRAINT "FK_2fd621aea353448fb3f17721bc8"`) + await db.query(`ALTER TABLE "ousd_history" DROP CONSTRAINT "FK_70291ea600c0c4d67d9bfe6a6bf"`) + await db.query(`ALTER TABLE "ousd_rebase" DROP CONSTRAINT "FK_427468c97f9838b804efd6c8e55"`) + await db.query(`ALTER TABLE "ousd_rebase_option" DROP CONSTRAINT "FK_b04173f9349ddd991a3b60e914a"`) + } +} From aae16683d939a12b69d1c0a446e4948f6aa487b7 Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Sun, 29 Oct 2023 08:33:05 +0530 Subject: [PATCH 3/4] Fixes --- ...44256133-Data.js => 1698545669111-Data.js} | 8 +-- schema-ogv.graphql | 3 +- schema.graphql | 3 +- src/main-ogv.ts | 10 +-- src/model/generated/ogvAddress.model.ts | 3 + src/model/generated/ogvLockup.model.ts | 4 +- .../ogv => ogv/post-processors}/governance.ts | 10 ++- .../ogv => ogv/processors}/ogv-supply.ts | 0 src/{processors/ogv => ogv/processors}/ogv.ts | 64 +++++++++++-------- 9 files changed, 65 insertions(+), 40 deletions(-) rename db/migrations/{1698344256133-Data.js => 1698545669111-Data.js} (98%) rename src/{processors/ogv => ogv/post-processors}/governance.ts (96%) rename src/{processors/ogv => ogv/processors}/ogv-supply.ts (100%) rename src/{processors/ogv => ogv/processors}/ogv.ts (84%) diff --git a/db/migrations/1698344256133-Data.js b/db/migrations/1698545669111-Data.js similarity index 98% rename from db/migrations/1698344256133-Data.js rename to db/migrations/1698545669111-Data.js index 0ca4c7d0..5f4ca472 100644 --- a/db/migrations/1698344256133-Data.js +++ b/db/migrations/1698545669111-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1698344256133 { - name = 'Data1698344256133' +module.exports = class Data1698545669111 { + name = 'Data1698545669111' async up(db) { await db.query(`CREATE TABLE "exchange_rate" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "pair" text NOT NULL, "base" text NOT NULL, "quote" text NOT NULL, "rate" numeric NOT NULL, CONSTRAINT "PK_5c5d27d2b900ef6cdeef0398472" PRIMARY KEY ("id"))`) @@ -69,9 +69,9 @@ module.exports = class Data1698344256133 { await db.query(`CREATE TABLE "ogv" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "circulating" numeric NOT NULL, "staked" numeric NOT NULL, "total" numeric NOT NULL, CONSTRAINT "PK_f16038abf451ce82bd03ea54ee7" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_2418a8b8b92b2f5977be761cf9" ON "ogv" ("timestamp") `) await db.query(`CREATE INDEX "IDX_b8f20bcf48e4aa77e0f48d77db" ON "ogv" ("block_number") `) - await db.query(`CREATE TABLE "ogv_address" ("id" character varying NOT NULL, "balance" numeric NOT NULL, "veogv_balance" numeric NOT NULL, "voting_power" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "delegatee_id" character varying, CONSTRAINT "PK_f13c77575687ef480ca0b7de5d8" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "ogv_address" ("id" character varying NOT NULL, "balance" numeric NOT NULL, "staked" numeric NOT NULL, "veogv_balance" numeric NOT NULL, "voting_power" numeric NOT NULL, "last_updated" TIMESTAMP WITH TIME ZONE NOT NULL, "delegatee_id" character varying, CONSTRAINT "PK_f13c77575687ef480ca0b7de5d8" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_49d26f287904b8b1aef6e9ac2b" ON "ogv_address" ("delegatee_id") `) - await db.query(`CREATE TABLE "ogv_lockup" ("id" character varying NOT NULL, "lockup_id" integer NOT NULL, "amount" numeric NOT NULL, "end" TIMESTAMP WITH TIME ZONE NOT NULL, "veogv" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "address_id" character varying, CONSTRAINT "PK_6b6d5ed3a004dd3f546c1b11fa4" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "ogv_lockup" ("id" character varying NOT NULL, "lockup_id" text NOT NULL, "amount" numeric NOT NULL, "end" TIMESTAMP WITH TIME ZONE NOT NULL, "veogv" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "address_id" character varying, CONSTRAINT "PK_6b6d5ed3a004dd3f546c1b11fa4" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_8114101b53d9d6bc26fe80838a" ON "ogv_lockup" ("lockup_id") `) await db.query(`CREATE INDEX "IDX_8be94cd63e35b91adf1301a156" ON "ogv_lockup" ("address_id") `) await db.query(`CREATE TABLE "ogv_lockup_tx_log" ("id" character varying NOT NULL, "hash" text NOT NULL, "event" character varying(8) NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "ogv_lockup_id" character varying, CONSTRAINT "PK_1c4a8425ce42f0c9da10056adee" PRIMARY KEY ("id"))`) diff --git a/schema-ogv.graphql b/schema-ogv.graphql index 0ba5b952..1d6c95e4 100644 --- a/schema-ogv.graphql +++ b/schema-ogv.graphql @@ -10,6 +10,7 @@ type OGV @entity { type OGVAddress @entity { id: ID! @index balance: BigInt! + staked: BigInt! veogvBalance: BigInt! votingPower: BigInt! delegatee: OGVAddress @@ -32,7 +33,7 @@ type OGVLockupTxLog @entity { type OGVLockup @entity { id: ID! - lockupId: Int! @index + lockupId: String! @index address: OGVAddress! @index logs: [OGVLockupTxLog]! @derivedFrom(field: "ogvLockup") amount: BigInt! diff --git a/schema.graphql b/schema.graphql index 24216583..50f7b7ac 100644 --- a/schema.graphql +++ b/schema.graphql @@ -330,6 +330,7 @@ type OETHRewardTokenCollected @entity { type OGVAddress @entity { id: ID! @index balance: BigInt! + staked: BigInt! veogvBalance: BigInt! votingPower: BigInt! delegatee: OGVAddress @@ -352,7 +353,7 @@ type OGVLockupTxLog @entity { type OGVLockup @entity { id: ID! - lockupId: Int! @index + lockupId: String! @index address: OGVAddress! @index logs: [OGVLockupTxLog]! @derivedFrom(field: "ogvLockup") amount: BigInt! diff --git a/src/main-ogv.ts b/src/main-ogv.ts index f4a3aa73..30589c20 100644 --- a/src/main-ogv.ts +++ b/src/main-ogv.ts @@ -1,11 +1,11 @@ -import * as ousd from './ousd/processors/ousd' import { run } from './processor' -import * as ogv from './processors/ogv/ogv' -import * as exchangeRates from './shared/post-processors/exchange-rates' +import * as ogv from './ogv/processors/ogv' +import * as ogvSupply from './ogv/processors/ogv-supply' +import * as governance from './ogv/post-processors/governance' run({ stateSchema: 'ogv-processor', - processors: [ogv], - postProcessors: [], + processors: [ogvSupply, ogv], + postProcessors: [governance], validators: [], }) diff --git a/src/model/generated/ogvAddress.model.ts b/src/model/generated/ogvAddress.model.ts index 50b1de1d..6d8f018e 100644 --- a/src/model/generated/ogvAddress.model.ts +++ b/src/model/generated/ogvAddress.model.ts @@ -13,6 +13,9 @@ export class OGVAddress { @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) balance!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + staked!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) veogvBalance!: bigint diff --git a/src/model/generated/ogvLockup.model.ts b/src/model/generated/ogvLockup.model.ts index 531ff292..1c7616db 100644 --- a/src/model/generated/ogvLockup.model.ts +++ b/src/model/generated/ogvLockup.model.ts @@ -13,8 +13,8 @@ export class OGVLockup { id!: string @Index_() - @Column_("int4", {nullable: false}) - lockupId!: number + @Column_("text", {nullable: false}) + lockupId!: string @Index_() @ManyToOne_(() => OGVAddress, {nullable: true}) diff --git a/src/processors/ogv/governance.ts b/src/ogv/post-processors/governance.ts similarity index 96% rename from src/processors/ogv/governance.ts rename to src/ogv/post-processors/governance.ts index 7f75cb8e..93d53372 100644 --- a/src/processors/ogv/governance.ts +++ b/src/ogv/post-processors/governance.ts @@ -48,12 +48,15 @@ export const process = async (ctx: Context) => { proposalLogs: [], votes: [] } - const addresses = new Map(); for (const block of ctx.blocks) { for (const log of block.logs) { const firstTopic = log.topics[0] + if (![VEOGV_ADDRESS, OGV_ADDRESS].includes(log.address)) { + return + } + if (firstTopic == governanceAbi.events.ProposalCreated.topic) { await _processProposalCreated(ctx, result, block, log); } else if (firstTopic == governanceAbi.events.ProposalExtended.topic) { @@ -66,7 +69,10 @@ export const process = async (ctx: Context) => { } } - await ctx.store.upsert(Array.from(addresses.values())) + await ctx.store.upsert(Array.from(result.addresses.values())) + await ctx.store.upsert(Array.from(result.proposals.values())) + await ctx.store.upsert(result.proposalLogs) + await ctx.store.upsert(result.votes) } const _processProposalCreated = async ( diff --git a/src/processors/ogv/ogv-supply.ts b/src/ogv/processors/ogv-supply.ts similarity index 100% rename from src/processors/ogv/ogv-supply.ts rename to src/ogv/processors/ogv-supply.ts diff --git a/src/processors/ogv/ogv.ts b/src/ogv/processors/ogv.ts similarity index 84% rename from src/processors/ogv/ogv.ts rename to src/ogv/processors/ogv.ts index 953a4f49..65e528c3 100644 --- a/src/processors/ogv/ogv.ts +++ b/src/ogv/processors/ogv.ts @@ -44,12 +44,15 @@ export const process = async (ctx: Context) => { lockups: new Map(), lockupEvents: [] } - const addresses = new Map(); for (const block of ctx.blocks) { for (const log of block.logs) { const firstTopic = log.topics[0] + if (![VEOGV_ADDRESS, OGV_ADDRESS].includes(log.address.toLowerCase())) { + return + } + if (firstTopic == veogvAbi.events.Transfer.topic) { await _processTransfer(ctx, result, block, log) } else if (firstTopic == veogvAbi.events.DelegateChanged.topic) { @@ -63,8 +66,13 @@ export const process = async (ctx: Context) => { } } } - - await ctx.store.upsert(Array.from(addresses.values())) + + await ctx.store.upsert( + Array.from(result.addresses.values()) + .sort((a, b) => a.delegatee?.id ? 1 : -1) + ) + await ctx.store.upsert(Array.from(result.lockups.values())) + await ctx.store.upsert(result.lockupEvents) } const _processTransfer = async ( @@ -79,7 +87,6 @@ const _processTransfer = async ( from = from.toLowerCase() to = to.toLowerCase() - // const isStakingEvent = [from, to].includes(VEOGV_ADDRESS.toLowerCase()) const isVeOGV = log.address.toLowerCase() == VEOGV_ADDRESS.toLowerCase() const blockTimestamp = new Date(block.header.timestamp) @@ -93,18 +100,18 @@ const _processTransfer = async ( sender.balance -= value; } sender.lastUpdated = blockTimestamp - // addresses.set(from, sender) + addresses.set(from, sender) } if (to != ADDRESS_ZERO) { - const receiver = await _getAddress(ctx, from, result) + const receiver = await _getAddress(ctx, to, result) if (isVeOGV) { receiver.veogvBalance += value; } else { receiver.balance += value; } receiver.lastUpdated = blockTimestamp - // addresses.set(to, receiver) + addresses.set(to, receiver) } } @@ -125,7 +132,8 @@ const _processDelegateChanged = async ( address.delegatee = await _getAddress(ctx, toDelegate, result) address.lastUpdated = new Date(block.header.timestamp) - // addresses.set(delegator, address); + addresses.set(toDelegate, address.delegatee); + addresses.set(delegator, address); } const _processDelegateVotesChanged = async ( @@ -143,7 +151,7 @@ const _processDelegateVotesChanged = async ( address.votingPower = newBalance address.lastUpdated = new Date(block.header.timestamp) - // addresses.set(delegate, address); + addresses.set(delegate, address); } const _processStake = async ( @@ -158,24 +166,24 @@ const _processStake = async ( const address = await _getAddress(ctx, user, result) const lockup = await _getLockup(ctx, lockupId.toString(), address, result) - const isExtend = !!lockup.timestamp - lockup.amount = amount lockup.veogv = points - lockup.end = new Date(Number(end.toString())) + lockup.end = new Date(Number(end) * 1000) lockup.timestamp = new Date(block.header.timestamp) - // lockups.set(lockup.id, lockup) - - if (isExtend) { - // Find last Unstake txLog and replace it - const unstakeIndex = result.lockupEvents.findIndex(x => - x.event == OGVLockupEventType.Unstaked - // Unstake is emitted just before Stake for Extend - && x.id == `${log.transactionHash}:${log.logIndex - 1}` - ) - + lockups.set(lockup.id, lockup) + + // Find last Unstake txLog + const unstakeIndex = result.lockupEvents.findIndex(x => + x.event == OGVLockupEventType.Unstaked + // Unstake is emitted just before Stake for Extend + && x.id == `${log.transactionHash}:${log.logIndex - 1}` + ) + + if (unstakeIndex >= 0) { + // If it exists, it's an extend result.lockupEvents[unstakeIndex].event = OGVLockupEventType.Extended } else { + // If not, it's just a new stake result.lockupEvents.push(new OGVLockupTxLog({ id: `${log.transactionHash}:${log.logIndex}`, hash: log.transactionHash, @@ -185,6 +193,8 @@ const _processStake = async ( })) } + address.staked += amount; + await _updateVotingPowers(ctx, result, block, address) } @@ -194,7 +204,7 @@ const _processUnstake = async ( block: Block, log: Log ) => { - const { lockupId, user } = veogvAbi.events.Unstake.decode(log) + const { lockupId, user, amount } = veogvAbi.events.Unstake.decode(log) const address = await _getAddress(ctx, user, result) const lockup = await _getLockup(ctx, lockupId.toString(), address, result) @@ -206,6 +216,8 @@ const _processUnstake = async ( ogvLockup: lockup, })) + address.staked -= amount; + await _updateVotingPowers(ctx, result, block, address) } @@ -220,14 +232,14 @@ const _updateVotingPowers = async( address.votingPower = await veogv.getVotes(address.id) address.lastUpdated = new Date(block.header.timestamp) - // addresses.set(address.id, address) + addresses.set(address.id, address) const delegateeId = address.delegatee?.id if (delegateeId && delegateeId !== address.id) { const delegatee = await _getAddress(ctx, address.delegatee?.id!, result) delegatee.votingPower = await veogv.getVotes(delegateeId) delegatee.lastUpdated = new Date(block.header.timestamp) - // addresses.set(delegateeId, delegatee) + addresses.set(delegateeId, delegatee) } } @@ -247,6 +259,7 @@ const _getAddress = async (ctx: Context, id: string, result: IProcessResult): Pr address = new OGVAddress({ id: id.toLowerCase(), balance: 0n, + staked: 0n, veogvBalance: 0n, votingPower: 0n, lastUpdated: new Date(), @@ -274,6 +287,7 @@ const _getLockup = async (ctx: Context, lockupId: string, address: OGVAddress, r lockup = new OGVLockup({ id, address, + lockupId }) } From 18aad4b953ece1bc34a0b69da6abbc75a598d23b Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Thu, 2 Nov 2023 13:22:40 +0530 Subject: [PATCH 4/4] Merge master --- README.md | 9 + abi/dripper.json | 191 +++++++++++++++++ ...45669111-Data.js => 1698911538983-Data.js} | 6 +- schema-oeth.graphql | 3 + schema.graphql | 3 + src/abi/dripper.abi.ts | 192 ++++++++++++++++++ src/abi/dripper.ts | 73 +++++++ src/main-oeth.ts | 6 +- src/model/generated/oethDripper.model.ts | 9 + src/oeth/processors/dripper.ts | 12 ++ src/oeth/processors/exchange-rates.ts | 18 ++ .../processor-templates/otoken/utils.ts | 7 +- 12 files changed, 522 insertions(+), 7 deletions(-) create mode 100644 abi/dripper.json rename db/migrations/{1698545669111-Data.js => 1698911538983-Data.js} (99%) create mode 100644 src/abi/dripper.abi.ts create mode 100644 src/abi/dripper.ts create mode 100644 src/oeth/processors/exchange-rates.ts diff --git a/README.md b/README.md index 73d89a89..4968d48b 100644 --- a/README.md +++ b/README.md @@ -109,3 +109,12 @@ Squid tools assume a certain [project layout](https://docs.subsquid.io/basics/sq - Database schema must be defined in `schema.graphql`. - Database migrations must reside in `db/migrations` and must be plain js files. - `sqd(1)` and `squid-*(1)` executables consult `.env` file for environment variables. + +## Deploy a new version + +- Visit [Squid deploy dashboard](https://app.subsquid.io/squids/deploy) +- Auth with `sqd auth -k sqd_XXX` (key is on squid deploy page) +- Update `squid.yaml` to set the correct version +- Run `sqd deploy .` +- Make branch for new version (eg v9) and push to origin +- Switch back to main branch diff --git a/abi/dripper.json b/abi/dripper.json new file mode 100644 index 00000000..84bc490c --- /dev/null +++ b/abi/dripper.json @@ -0,0 +1,191 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_vault", + "type": "address" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernor", + "type": "address" + } + ], + "name": "GovernorshipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernor", + "type": "address" + } + ], + "name": "PendingGovernorshipTransfer", + "type": "event" + }, + { + "inputs": [], + "name": "availableFunds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claimGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collect", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collectAndRebase", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "drip", + "outputs": [ + { + "internalType": "uint64", + "name": "lastCollect", + "type": "uint64" + }, + { + "internalType": "uint192", + "name": "perBlock", + "type": "uint192" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "dripDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isGovernor", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_durationSeconds", + "type": "uint256" + } + ], + "name": "setDripDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newGovernor", + "type": "address" + } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "transferToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/db/migrations/1698545669111-Data.js b/db/migrations/1698911538983-Data.js similarity index 99% rename from db/migrations/1698545669111-Data.js rename to db/migrations/1698911538983-Data.js index 5f4ca472..e2496737 100644 --- a/db/migrations/1698545669111-Data.js +++ b/db/migrations/1698911538983-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1698545669111 { - name = 'Data1698545669111' +module.exports = class Data1698911538983 { + name = 'Data1698911538983' async up(db) { await db.query(`CREATE TABLE "exchange_rate" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "pair" text NOT NULL, "base" text NOT NULL, "quote" text NOT NULL, "rate" numeric NOT NULL, CONSTRAINT "PK_5c5d27d2b900ef6cdeef0398472" PRIMARY KEY ("id"))`) @@ -48,7 +48,7 @@ module.exports = class Data1698545669111 { await db.query(`CREATE TABLE "oeth_morpho_aave" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_86de8f846e9335c92b8ad7df3a1" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_25e239b985844f1d33fac79981" ON "oeth_morpho_aave" ("timestamp") `) await db.query(`CREATE INDEX "IDX_a6662224e95eb6921bb14cb5f9" ON "oeth_morpho_aave" ("block_number") `) - await db.query(`CREATE TABLE "oeth_dripper" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_77731281c1564c24eff0c265984" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "oeth_dripper" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "weth" numeric NOT NULL, "last_collect_timestamp" integer NOT NULL, "drip_rate_per_block" numeric NOT NULL, "drip_duration" numeric NOT NULL, CONSTRAINT "PK_77731281c1564c24eff0c265984" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_16ac742ceeb05d28e530da9649" ON "oeth_dripper" ("timestamp") `) await db.query(`CREATE INDEX "IDX_d356832c14603916a492608e7b" ON "oeth_dripper" ("block_number") `) await db.query(`CREATE TABLE "oeth_balancer_meta_pool_strategy" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "r_eth" numeric NOT NULL, "weth" numeric NOT NULL, CONSTRAINT "PK_6ddf5b8ba878e6d706e59bd6de0" PRIMARY KEY ("id"))`) diff --git a/schema-oeth.graphql b/schema-oeth.graphql index 78a253df..e1d13066 100644 --- a/schema-oeth.graphql +++ b/schema-oeth.graphql @@ -137,6 +137,9 @@ type OETHDripper @entity { timestamp: DateTime! @index blockNumber: Int! @index weth: BigInt! + lastCollectTimestamp: Int! + dripRatePerBlock: BigInt! + dripDuration: BigInt! } # OETHBalancerMetaPoolStrategy: 0x49109629ac1deb03f2e9b2fe2ac4a623e0e7dfdc diff --git a/schema.graphql b/schema.graphql index 50f7b7ac..32d51423 100644 --- a/schema.graphql +++ b/schema.graphql @@ -200,6 +200,9 @@ type OETHDripper @entity { timestamp: DateTime! @index blockNumber: Int! @index weth: BigInt! + lastCollectTimestamp: Int! + dripRatePerBlock: BigInt! + dripDuration: BigInt! } # OETHBalancerMetaPoolStrategy: 0x49109629ac1deb03f2e9b2fe2ac4a623e0e7dfdc diff --git a/src/abi/dripper.abi.ts b/src/abi/dripper.abi.ts new file mode 100644 index 00000000..978669c4 --- /dev/null +++ b/src/abi/dripper.abi.ts @@ -0,0 +1,192 @@ +export const ABI_JSON = [ + { + "type": "constructor", + "stateMutability": "undefined", + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_vault" + }, + { + "type": "address", + "name": "_token" + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "GovernorshipTransferred", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "event", + "anonymous": false, + "name": "PendingGovernorshipTransfer", + "inputs": [ + { + "type": "address", + "name": "previousGovernor", + "indexed": true + }, + { + "type": "address", + "name": "newGovernor", + "indexed": true + } + ] + }, + { + "type": "function", + "name": "availableFunds", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "claimGovernance", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "collect", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "collectAndRebase", + "constant": false, + "payable": false, + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "drip", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint64", + "name": "lastCollect" + }, + { + "type": "uint192", + "name": "perBlock" + } + ] + }, + { + "type": "function", + "name": "dripDuration", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "" + } + ] + }, + { + "type": "function", + "name": "governor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "" + } + ] + }, + { + "type": "function", + "name": "isGovernor", + "constant": true, + "stateMutability": "view", + "payable": false, + "inputs": [], + "outputs": [ + { + "type": "bool", + "name": "" + } + ] + }, + { + "type": "function", + "name": "setDripDuration", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "uint256", + "name": "_durationSeconds" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "transferGovernance", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_newGovernor" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "transferToken", + "constant": false, + "payable": false, + "inputs": [ + { + "type": "address", + "name": "_asset" + }, + { + "type": "uint256", + "name": "_amount" + } + ], + "outputs": [] + } +] diff --git a/src/abi/dripper.ts b/src/abi/dripper.ts new file mode 100644 index 00000000..0b5b0e88 --- /dev/null +++ b/src/abi/dripper.ts @@ -0,0 +1,73 @@ +import * as ethers from 'ethers' +import {LogEvent, Func, ContractBase} from './abi.support' +import {ABI_JSON} from './dripper.abi' + +export const abi = new ethers.Interface(ABI_JSON); + +export const events = { + GovernorshipTransferred: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a' + ), + PendingGovernorshipTransfer: new LogEvent<([previousGovernor: string, newGovernor: string] & {previousGovernor: string, newGovernor: string})>( + abi, '0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d' + ), +} + +export const functions = { + availableFunds: new Func<[], {}, bigint>( + abi, '0x46fcff4c' + ), + claimGovernance: new Func<[], {}, []>( + abi, '0x5d36b190' + ), + collect: new Func<[], {}, []>( + abi, '0xe5225381' + ), + collectAndRebase: new Func<[], {}, []>( + abi, '0x73796297' + ), + drip: new Func<[], {}, ([lastCollect: bigint, perBlock: bigint] & {lastCollect: bigint, perBlock: bigint})>( + abi, '0x9f678cca' + ), + dripDuration: new Func<[], {}, bigint>( + abi, '0xbb7a632e' + ), + governor: new Func<[], {}, string>( + abi, '0x0c340a24' + ), + isGovernor: new Func<[], {}, boolean>( + abi, '0xc7af3352' + ), + setDripDuration: new Func<[_durationSeconds: bigint], {_durationSeconds: bigint}, []>( + abi, '0x0493a0fa' + ), + transferGovernance: new Func<[_newGovernor: string], {_newGovernor: string}, []>( + abi, '0xd38bfff4' + ), + transferToken: new Func<[_asset: string, _amount: bigint], {_asset: string, _amount: bigint}, []>( + abi, '0x1072cbea' + ), +} + +export class Contract extends ContractBase { + + availableFunds(): Promise { + return this.eth_call(functions.availableFunds, []) + } + + drip(): Promise<([lastCollect: bigint, perBlock: bigint] & {lastCollect: bigint, perBlock: bigint})> { + return this.eth_call(functions.drip, []) + } + + dripDuration(): Promise { + return this.eth_call(functions.dripDuration, []) + } + + governor(): Promise { + return this.eth_call(functions.governor, []) + } + + isGovernor(): Promise { + return this.eth_call(functions.isGovernor, []) + } +} diff --git a/src/main-oeth.ts b/src/main-oeth.ts index 7c6248a5..e456107d 100644 --- a/src/main-oeth.ts +++ b/src/main-oeth.ts @@ -3,13 +3,14 @@ import * as oeth from './oeth/processors' import * as balancerMetaPoolStrategy from './oeth/processors/balancer-meta-pool' import * as curveLp from './oeth/processors/curve-lp' import * as dripper from './oeth/processors/dripper' +import * as exchangeRates from './oeth/processors/exchange-rates' import * as fraxStaking from './oeth/processors/frax-staking' import * as morphoAave from './oeth/processors/morpho-aave' import * as strategies from './oeth/processors/strategies' import * as vault from './oeth/processors/vault' import * as validateOeth from './oeth/validators/validate-oeth' import { run } from './processor' -import * as exchangeRates from './shared/post-processors/exchange-rates' +import * as exchangeRatesPostProcessor from './shared/post-processors/exchange-rates' run({ stateSchema: 'oeth-processor', @@ -22,7 +23,8 @@ run({ curveLp, balancerMetaPoolStrategy, strategies, + exchangeRates, ], - postProcessors: [exchangeRates, dailyStats], + postProcessors: [exchangeRatesPostProcessor, dailyStats], validators: [validateOeth], }) diff --git a/src/model/generated/oethDripper.model.ts b/src/model/generated/oethDripper.model.ts index 229127fa..2de15545 100644 --- a/src/model/generated/oethDripper.model.ts +++ b/src/model/generated/oethDripper.model.ts @@ -20,4 +20,13 @@ export class OETHDripper { @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) weth!: bigint + + @Column_("int4", {nullable: false}) + lastCollectTimestamp!: number + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + dripRatePerBlock!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + dripDuration!: bigint } diff --git a/src/oeth/processors/dripper.ts b/src/oeth/processors/dripper.ts index 97a57740..871cd257 100644 --- a/src/oeth/processors/dripper.ts +++ b/src/oeth/processors/dripper.ts @@ -1,6 +1,7 @@ import { EvmBatchProcessor } from '@subsquid/evm-processor' import { pad } from 'viem' +import * as dripperAbi from '../../abi/dripper' import * as erc20 from '../../abi/erc20' import { OETHDripper } from '../../model' import { Context } from '../../processor' @@ -63,6 +64,12 @@ const processTransfer = async ( timestampId, ) + const dripperContract = new dripperAbi.Contract( + ctx, + block.header, + OETH_DRIPPER_ADDRESS, + ) + let dripper = current if (!dripper) { await ensureExchangeRate(ctx, block, 'ETH', 'WETH') // No async since WETH. @@ -75,7 +82,12 @@ const processTransfer = async ( result.drippers.push(dripper) } + const drip = await dripperContract.drip() + dripper.weth += change + dripper.lastCollectTimestamp = Number(drip.lastCollect) + dripper.dripRatePerBlock = drip.perBlock + dripper.dripDuration = await dripperContract.dripDuration() }, }) } diff --git a/src/oeth/processors/exchange-rates.ts b/src/oeth/processors/exchange-rates.ts new file mode 100644 index 00000000..5c2b22af --- /dev/null +++ b/src/oeth/processors/exchange-rates.ts @@ -0,0 +1,18 @@ +import { EvmBatchProcessor } from '@subsquid/evm-processor' + +import { Context } from '../../processor' +import { ensureExchangeRates } from '../../shared/post-processors/exchange-rates' +import { blockFrequencyUpdater } from '../../utils/blockFrequencyUpdater' + +export const from = 16933090 // OETH Deploy + +export const setup = (processor: EvmBatchProcessor) => { + processor.includeAllBlocks({ from }) +} + +export const process = async (ctx: Context) => { + const blockFrequencyUpdate = blockFrequencyUpdater({ from }) + await blockFrequencyUpdate(ctx, async (ctx, block) => { + await ensureExchangeRates(ctx, block, [['ETH', 'USD']]) + }) +} diff --git a/src/shared/processor-templates/otoken/utils.ts b/src/shared/processor-templates/otoken/utils.ts index d2555c64..2ad49be3 100644 --- a/src/shared/processor-templates/otoken/utils.ts +++ b/src/shared/processor-templates/otoken/utils.ts @@ -159,8 +159,11 @@ export async function createRebaseAPY< await Promise.all( [last7daysDateId, last14daysDateId, last30daysDateId].map(async (i) => { const pastAPYs = await ctx.store - .findBy(OTokenAPY, { - id: MoreThanOrEqual(i.value), + .find(OTokenAPY, { + where: { + id: MoreThanOrEqual(i.value), + }, + order: { id: 'asc' }, }) .then((r) => r.slice(0, i.days - 1)) apy![i.key] =