From 2a68061dd60f551196c3b22b3f083afe16e40f66 Mon Sep 17 00:00:00 2001 From: Nick Poulden Date: Thu, 30 Nov 2023 16:32:00 -0700 Subject: [PATCH 1/6] OUSD daily stats + converted yield stats --- ...76030021-Data.js => 1701383939578-Data.js} | 34 ++- schema-oeth.graphql | 9 + schema-ousd.graphql | 66 +++++ schema.graphql | 75 ++++++ src/main-ousd.ts | 3 +- src/model/generated/index.ts | 4 + src/model/generated/oethDailyStat.model.ts | 18 ++ src/model/generated/oethRebase.model.ts | 6 + .../ousdCollateralDailyStat.model.ts | 29 +++ src/model/generated/ousdDailyStat.model.ts | 103 ++++++++ src/model/generated/ousdRebase.model.ts | 6 + .../generated/ousdStrategyDailyStat.model.ts | 30 +++ .../ousdStrategyHoldingDailyStat.model.ts | 26 ++ .../daily-stats/daily-stats.ts | 42 ++- .../daily-stats/daily-stats.ts | 245 ++++++++++++++++++ src/ousd/post-processors/daily-stats/index.ts | 1 + .../processor-templates/otoken/otoken.ts | 7 + .../processor-templates/otoken/utils.ts | 23 +- 18 files changed, 715 insertions(+), 12 deletions(-) rename db/migrations/{1701276030021-Data.js => 1701383939578-Data.js} (89%) create mode 100644 src/model/generated/ousdCollateralDailyStat.model.ts create mode 100644 src/model/generated/ousdDailyStat.model.ts create mode 100644 src/model/generated/ousdStrategyDailyStat.model.ts create mode 100644 src/model/generated/ousdStrategyHoldingDailyStat.model.ts create mode 100644 src/ousd/post-processors/daily-stats/daily-stats.ts create mode 100644 src/ousd/post-processors/daily-stats/index.ts diff --git a/db/migrations/1701276030021-Data.js b/db/migrations/1701383939578-Data.js similarity index 89% rename from db/migrations/1701276030021-Data.js rename to db/migrations/1701383939578-Data.js index e290900d..3afa712e 100644 --- a/db/migrations/1701276030021-Data.js +++ b/db/migrations/1701383939578-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1701276030021 { - name = 'Data1701276030021' +module.exports = class Data1701383939578 { + name = 'Data1701383939578' 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"))`) @@ -32,7 +32,7 @@ module.exports = class Data1701276030021 { 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 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, "fee_converted" numeric NOT NULL, "yield_converted" 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") `) @@ -66,7 +66,7 @@ module.exports = class Data1701276030021 { 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, "dripper_weth" numeric NOT NULL, "wrapped_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 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, "dripper_weth" numeric NOT NULL, "wrapped_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, "yield_converted" numeric NOT NULL, "fees_converted" numeric NOT NULL, "revenue_converted" numeric NOT NULL, "revenue7_day_avg_converted" numeric NOT NULL, "revenue7_day_total_converted" numeric NOT NULL, "revenue_all_time_converted" 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 "oeth_reward_token_collected" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "strategy" text NOT NULL, "recipient" text NOT NULL, "reward_token" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_47098cc5fbc7cb95c2374fa33cd" PRIMARY KEY ("id"))`) @@ -105,7 +105,7 @@ module.exports = class Data1701276030021 { 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 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, "fee_converted" numeric NOT NULL, "yield_converted" 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") `) @@ -149,6 +149,15 @@ module.exports = class Data1701276030021 { await db.query(`CREATE INDEX "IDX_87dcf07f9e54c132535acf47a4" ON "ousd_activity" ("timestamp") `) await db.query(`CREATE INDEX "IDX_e80a0f99e9f31fe69ac50b5a4c" ON "ousd_activity" ("block_number") `) await db.query(`CREATE INDEX "IDX_2af2ad9975c024d1aa3535928f" ON "ousd_activity" ("tx_hash") `) + await db.query(`CREATE TABLE "ousd_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_ef2f51867e1d465c554262efd1b" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_e1a93bab3d12271dc114234d3a" ON "ousd_strategy_holding_daily_stat" ("strategy_daily_stat_id_id") `) + await db.query(`CREATE TABLE "ousd_strategy_daily_stat" ("id" character varying NOT NULL, "name" text NOT NULL, "total" numeric NOT NULL, "tvl" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_ac65d3f28f290211ddeb950e157" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_3edda581683682257159cb0863" ON "ousd_strategy_daily_stat" ("daily_stat_id_id") `) + await db.query(`CREATE TABLE "ousd_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_85a804677f14a0784914e27b7b9" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_78be9d3f3dc1f31cf17ae810fe" ON "ousd_collateral_daily_stat" ("daily_stat_id_id") `) + await db.query(`CREATE TABLE "ousd_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, "dripper_weth" numeric NOT NULL, "wrapped_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, "yield_converted" numeric NOT NULL, "fees_converted" numeric NOT NULL, "revenue_converted" numeric NOT NULL, "revenue7_day_avg_converted" numeric NOT NULL, "revenue7_day_total_converted" numeric NOT NULL, "revenue_all_time_converted" numeric NOT NULL, "peg_price" numeric NOT NULL, CONSTRAINT "PK_f8adaf321a99f2b4b877c262880" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_f9020d89932aad2d0de8923490" ON "ousd_daily_stat" ("block_number") `) + await db.query(`CREATE INDEX "IDX_0bb5f72bf5fa59ce8c232caa4c" ON "ousd_daily_stat" ("timestamp") `) 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`) @@ -165,6 +174,9 @@ module.exports = class Data1701276030021 { 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`) + await db.query(`ALTER TABLE "ousd_strategy_holding_daily_stat" ADD CONSTRAINT "FK_e1a93bab3d12271dc114234d3ae" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "ousd_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ousd_strategy_daily_stat" ADD CONSTRAINT "FK_3edda581683682257159cb08638" FOREIGN KEY ("daily_stat_id_id") REFERENCES "ousd_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) + await db.query(`ALTER TABLE "ousd_collateral_daily_stat" ADD CONSTRAINT "FK_78be9d3f3dc1f31cf17ae810fee" FOREIGN KEY ("daily_stat_id_id") REFERENCES "ousd_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) } async down(db) { @@ -315,6 +327,15 @@ module.exports = class Data1701276030021 { await db.query(`DROP INDEX "public"."IDX_87dcf07f9e54c132535acf47a4"`) await db.query(`DROP INDEX "public"."IDX_e80a0f99e9f31fe69ac50b5a4c"`) await db.query(`DROP INDEX "public"."IDX_2af2ad9975c024d1aa3535928f"`) + await db.query(`DROP TABLE "ousd_strategy_holding_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_e1a93bab3d12271dc114234d3a"`) + await db.query(`DROP TABLE "ousd_strategy_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_3edda581683682257159cb0863"`) + await db.query(`DROP TABLE "ousd_collateral_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_78be9d3f3dc1f31cf17ae810fe"`) + await db.query(`DROP TABLE "ousd_daily_stat"`) + await db.query(`DROP INDEX "public"."IDX_f9020d89932aad2d0de8923490"`) + await db.query(`DROP INDEX "public"."IDX_0bb5f72bf5fa59ce8c232caa4c"`) 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"`) @@ -331,5 +352,8 @@ module.exports = class Data1701276030021 { 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"`) + await db.query(`ALTER TABLE "ousd_strategy_holding_daily_stat" DROP CONSTRAINT "FK_e1a93bab3d12271dc114234d3ae"`) + await db.query(`ALTER TABLE "ousd_strategy_daily_stat" DROP CONSTRAINT "FK_3edda581683682257159cb08638"`) + await db.query(`ALTER TABLE "ousd_collateral_daily_stat" DROP CONSTRAINT "FK_78be9d3f3dc1f31cf17ae810fee"`) } } diff --git a/schema-oeth.graphql b/schema-oeth.graphql index f413b5c8..886c77b3 100644 --- a/schema-oeth.graphql +++ b/schema-oeth.graphql @@ -52,6 +52,8 @@ type OETHRebase @entity { apy: OETHAPY! fee: BigInt! yield: BigInt! + feeConverted: BigInt! + yieldConverted: BigInt! } """ @@ -185,6 +187,13 @@ type OETHDailyStat @entity { revenue7DayTotal: BigInt! revenueAllTime: BigInt! + yieldConverted: BigInt! + feesConverted: BigInt! + revenueConverted: BigInt! + revenue7DayAvgConverted: BigInt! + revenue7DayTotalConverted: BigInt! + revenueAllTimeConverted: BigInt! + pegPrice: BigInt! """ Price of OETH in ETH diff --git a/schema-ousd.graphql b/schema-ousd.graphql index 768a279f..a00592c4 100644 --- a/schema-ousd.graphql +++ b/schema-ousd.graphql @@ -52,6 +52,8 @@ type OUSDRebase @entity { apy: OUSDAPY! fee: BigInt! yield: BigInt! + feeConverted: BigInt! + yieldConverted: BigInt! } """ @@ -192,3 +194,67 @@ type OUSDActivity @entity { toSymbol: String amount: BigInt } + +type OUSDDailyStat @entity { + id: ID! + blockNumber: Int! @index + timestamp: DateTime! @index + apr: Float! + apy: Float! + apy7DayAvg: Float! + apy14DayAvg: Float! + apy30DayAvg: Float! + + totalSupply: BigInt! + totalSupplyUSD: Float! + rebasingSupply: BigInt! + nonRebasingSupply: BigInt! + amoSupply: BigInt! + dripperWETH: BigInt! + wrappedSupply: BigInt! + + yield: BigInt! + fees: BigInt! + revenue: BigInt! + revenue7DayAvg: BigInt! + revenue7DayTotal: BigInt! + revenueAllTime: BigInt! + + yieldConverted: BigInt! + feesConverted: BigInt! + revenueConverted: BigInt! + revenue7DayAvgConverted: BigInt! + revenue7DayTotalConverted: BigInt! + revenueAllTimeConverted: BigInt! + + pegPrice: BigInt! + strategies: [OUSDStrategyDailyStat] @derivedFrom(field: "dailyStatId") + collateral: [OUSDCollateralDailyStat] @derivedFrom(field: "dailyStatId") +} + +type OUSDStrategyDailyStat @entity { + id: ID! + dailyStatId: OUSDDailyStat! + name: String! + total: BigInt! + tvl: BigInt! + holdings: [OUSDStrategyHoldingDailyStat] + @derivedFrom(field: "strategyDailyStatId") +} + +type OUSDStrategyHoldingDailyStat @entity { + id: ID! + strategyDailyStatId: OUSDStrategyDailyStat! + symbol: String! + amount: BigInt! + value: BigInt! +} + +type OUSDCollateralDailyStat @entity { + id: ID! + dailyStatId: OUSDDailyStat! @index + symbol: String! + amount: BigInt! + price: BigInt! + value: BigInt! +} diff --git a/schema.graphql b/schema.graphql index 38f82b95..87b2fd0d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -147,6 +147,8 @@ type OETHRebase @entity { apy: OETHAPY! fee: BigInt! yield: BigInt! + feeConverted: BigInt! + yieldConverted: BigInt! } """ @@ -280,6 +282,13 @@ type OETHDailyStat @entity { revenue7DayTotal: BigInt! revenueAllTime: BigInt! + yieldConverted: BigInt! + feesConverted: BigInt! + revenueConverted: BigInt! + revenue7DayAvgConverted: BigInt! + revenue7DayTotalConverted: BigInt! + revenueAllTimeConverted: BigInt! + pegPrice: BigInt! """ Price of OETH in ETH @@ -528,6 +537,8 @@ type OUSDRebase @entity { apy: OUSDAPY! fee: BigInt! yield: BigInt! + feeConverted: BigInt! + yieldConverted: BigInt! } """ @@ -668,3 +679,67 @@ type OUSDActivity @entity { toSymbol: String amount: BigInt } + +type OUSDDailyStat @entity { + id: ID! + blockNumber: Int! @index + timestamp: DateTime! @index + apr: Float! + apy: Float! + apy7DayAvg: Float! + apy14DayAvg: Float! + apy30DayAvg: Float! + + totalSupply: BigInt! + totalSupplyUSD: Float! + rebasingSupply: BigInt! + nonRebasingSupply: BigInt! + amoSupply: BigInt! + dripperWETH: BigInt! + wrappedSupply: BigInt! + + yield: BigInt! + fees: BigInt! + revenue: BigInt! + revenue7DayAvg: BigInt! + revenue7DayTotal: BigInt! + revenueAllTime: BigInt! + + yieldConverted: BigInt! + feesConverted: BigInt! + revenueConverted: BigInt! + revenue7DayAvgConverted: BigInt! + revenue7DayTotalConverted: BigInt! + revenueAllTimeConverted: BigInt! + + pegPrice: BigInt! + strategies: [OUSDStrategyDailyStat] @derivedFrom(field: "dailyStatId") + collateral: [OUSDCollateralDailyStat] @derivedFrom(field: "dailyStatId") +} + +type OUSDStrategyDailyStat @entity { + id: ID! + dailyStatId: OUSDDailyStat! + name: String! + total: BigInt! + tvl: BigInt! + holdings: [OUSDStrategyHoldingDailyStat] + @derivedFrom(field: "strategyDailyStatId") +} + +type OUSDStrategyHoldingDailyStat @entity { + id: ID! + strategyDailyStatId: OUSDStrategyDailyStat! + symbol: String! + amount: BigInt! + value: BigInt! +} + +type OUSDCollateralDailyStat @entity { + id: ID! + dailyStatId: OUSDDailyStat! @index + symbol: String! + amount: BigInt! + price: BigInt! + value: BigInt! +} diff --git a/src/main-ousd.ts b/src/main-ousd.ts index b384c389..4f2d4506 100644 --- a/src/main-ousd.ts +++ b/src/main-ousd.ts @@ -1,3 +1,4 @@ +import * as dailyStats from './ousd/post-processors/daily-stats' import * as ousd from './ousd/processors/ousd' import * as strategies from './ousd/processors/strategies/strategies' import * as validateOusd from './ousd/validators/validate-ousd' @@ -7,7 +8,7 @@ import * as exchangeRates from './shared/post-processors/exchange-rates' export const processor = { stateSchema: 'ousd-processor', processors: [ousd, strategies], - postProcessors: [exchangeRates], + postProcessors: [exchangeRates, dailyStats], validators: [validateOusd], } export default processor diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index 53235a21..c4a8d343 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -52,3 +52,7 @@ export * from "./ousdAaveStrategy.model" export * from "./ousdMetaStrategy.model" export * from "./ousdConvexLusdPlus3Crv.model" export * from "./ousdActivity.model" +export * from "./ousdDailyStat.model" +export * from "./ousdStrategyDailyStat.model" +export * from "./ousdStrategyHoldingDailyStat.model" +export * from "./ousdCollateralDailyStat.model" diff --git a/src/model/generated/oethDailyStat.model.ts b/src/model/generated/oethDailyStat.model.ts index 6cf65561..c0de0bd8 100644 --- a/src/model/generated/oethDailyStat.model.ts +++ b/src/model/generated/oethDailyStat.model.ts @@ -83,6 +83,24 @@ export class OETHDailyStat { @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) revenueAllTime!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yieldConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + feesConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenueConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenue7DayAvgConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenue7DayTotalConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenueAllTimeConverted!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) pegPrice!: bigint diff --git a/src/model/generated/oethRebase.model.ts b/src/model/generated/oethRebase.model.ts index 126e8ad5..824c42ea 100644 --- a/src/model/generated/oethRebase.model.ts +++ b/src/model/generated/oethRebase.model.ts @@ -44,4 +44,10 @@ export class OETHRebase { @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) yield!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + feeConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yieldConverted!: bigint } diff --git a/src/model/generated/ousdCollateralDailyStat.model.ts b/src/model/generated/ousdCollateralDailyStat.model.ts new file mode 100644 index 00000000..30b3dc41 --- /dev/null +++ b/src/model/generated/ousdCollateralDailyStat.model.ts @@ -0,0 +1,29 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_} from "typeorm" +import * as marshal from "./marshal" +import {OUSDDailyStat} from "./ousdDailyStat.model" + +@Entity_() +export class OUSDCollateralDailyStat { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @ManyToOne_(() => OUSDDailyStat, {nullable: true}) + dailyStatId!: OUSDDailyStat + + @Column_("text", {nullable: false}) + symbol!: string + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + amount!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + price!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + value!: bigint +} diff --git a/src/model/generated/ousdDailyStat.model.ts b/src/model/generated/ousdDailyStat.model.ts new file mode 100644 index 00000000..f3420d09 --- /dev/null +++ b/src/model/generated/ousdDailyStat.model.ts @@ -0,0 +1,103 @@ +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, OneToMany as OneToMany_} from "typeorm" +import * as marshal from "./marshal" +import {OUSDStrategyDailyStat} from "./ousdStrategyDailyStat.model" +import {OUSDCollateralDailyStat} from "./ousdCollateralDailyStat.model" + +@Entity_() +export class OUSDDailyStat { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @Column_("int4", {nullable: false}) + blockNumber!: number + + @Index_() + @Column_("timestamp with time zone", {nullable: false}) + timestamp!: Date + + @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + apr!: number + + @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + apy!: number + + @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + apy7DayAvg!: number + + @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + apy14DayAvg!: number + + @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + apy30DayAvg!: number + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + totalSupply!: bigint + + @Column_("numeric", {transformer: marshal.floatTransformer, nullable: false}) + totalSupplyUSD!: number + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + rebasingSupply!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + nonRebasingSupply!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + amoSupply!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + dripperWETH!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + wrappedSupply!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yield!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + fees!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenue!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenue7DayAvg!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenue7DayTotal!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenueAllTime!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yieldConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + feesConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenueConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenue7DayAvgConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenue7DayTotalConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + revenueAllTimeConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + pegPrice!: bigint + + @OneToMany_(() => OUSDStrategyDailyStat, e => e.dailyStatId) + strategies!: OUSDStrategyDailyStat[] + + @OneToMany_(() => OUSDCollateralDailyStat, e => e.dailyStatId) + collateral!: OUSDCollateralDailyStat[] +} diff --git a/src/model/generated/ousdRebase.model.ts b/src/model/generated/ousdRebase.model.ts index 524deea1..c5b0981c 100644 --- a/src/model/generated/ousdRebase.model.ts +++ b/src/model/generated/ousdRebase.model.ts @@ -44,4 +44,10 @@ export class OUSDRebase { @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) yield!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + feeConverted!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yieldConverted!: bigint } diff --git a/src/model/generated/ousdStrategyDailyStat.model.ts b/src/model/generated/ousdStrategyDailyStat.model.ts new file mode 100644 index 00000000..03fbb355 --- /dev/null +++ b/src/model/generated/ousdStrategyDailyStat.model.ts @@ -0,0 +1,30 @@ +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 {OUSDDailyStat} from "./ousdDailyStat.model" +import {OUSDStrategyHoldingDailyStat} from "./ousdStrategyHoldingDailyStat.model" + +@Entity_() +export class OUSDStrategyDailyStat { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @ManyToOne_(() => OUSDDailyStat, {nullable: true}) + dailyStatId!: OUSDDailyStat + + @Column_("text", {nullable: false}) + name!: string + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + total!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + tvl!: bigint + + @OneToMany_(() => OUSDStrategyHoldingDailyStat, e => e.strategyDailyStatId) + holdings!: OUSDStrategyHoldingDailyStat[] +} diff --git a/src/model/generated/ousdStrategyHoldingDailyStat.model.ts b/src/model/generated/ousdStrategyHoldingDailyStat.model.ts new file mode 100644 index 00000000..aff13b8f --- /dev/null +++ b/src/model/generated/ousdStrategyHoldingDailyStat.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 * as marshal from "./marshal" +import {OUSDStrategyDailyStat} from "./ousdStrategyDailyStat.model" + +@Entity_() +export class OUSDStrategyHoldingDailyStat { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Index_() + @ManyToOne_(() => OUSDStrategyDailyStat, {nullable: true}) + strategyDailyStatId!: OUSDStrategyDailyStat + + @Column_("text", {nullable: false}) + symbol!: string + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + amount!: bigint + + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + value!: bigint +} diff --git a/src/oeth/post-processors/daily-stats/daily-stats.ts b/src/oeth/post-processors/daily-stats/daily-stats.ts index 0040a966..daceafb5 100644 --- a/src/oeth/post-processors/daily-stats/daily-stats.ts +++ b/src/oeth/post-processors/daily-stats/daily-stats.ts @@ -128,7 +128,7 @@ async function updateDailyStats(ctx: Context, date: Date) { lastDripper, lastRethRate, lastSfrxEthRate, - ] + ].filter(Boolean) if (![lastApy, lastOeth].every((entity) => !!entity)) { return null } @@ -146,6 +146,9 @@ async function updateDailyStats(ctx: Context, date: Date) { total_yield: bigint total_fees: bigint total_revenue: bigint + total_yield_converted: bigint + total_fees_converted: bigint + total_revenue_converted: bigint }[] >(yieldStatsQuery, [end]) @@ -182,6 +185,13 @@ async function updateDailyStats(ctx: Context, date: Date) { revenue7DayTotal: yieldStats[1].total_revenue || 0n, revenueAllTime: yieldStats[2].total_revenue || 0n, + yieldConverted: yieldStats[0].total_yield_converted || 0n, + feesConverted: yieldStats[0].total_fees_converted || 0n, + revenueConverted: yieldStats[0].total_revenue_converted || 0n, + revenue7DayAvgConverted: BigInt(yieldStats[1].total_revenue_converted || 0n) / 7n, + revenue7DayTotalConverted: yieldStats[1].total_revenue_converted || 0n, + revenueAllTimeConverted: yieldStats[2].total_revenue_converted || 0n, + pegPrice: 0n, }) @@ -376,21 +386,45 @@ async function updateDailyStats(ctx: Context, date: Date) { const yieldStatsQuery = ` -- Results for 1 day -SELECT '1 day' as period, SUM(fee) as total_fees, SUM(yield - fee) as total_yield, SUM(yield) as total_revenue +SELECT '1 day' as period, + SUM(fee) as total_fees, + SUM(yield - fee) as total_yield, + SUM(yield) as total_revenue, + + SUM(fee_converted) as total_fees_converted, + SUM(yield_converted - fee_converted) as total_yield_converted, + SUM(yield_converted) as total_revenue_converted + FROM oeth_rebase WHERE timestamp BETWEEN ($1::timestamp - interval '1 day') AND $1::timestamp UNION ALL -- Results for 7 days -SELECT '7 days' as period, SUM(fee) as total_fees, SUM(yield - fee) as total_yield, SUM(yield) as total_revenue +SELECT '7 days' as period, + SUM(fee) as total_fees, + SUM(yield - fee) as total_yield, + SUM(yield) as total_revenue, + + SUM(fee_converted) as total_fees_converted, + SUM(yield_converted - fee_converted) as total_yield_converted, + SUM(yield_converted) as total_revenue_converted + FROM oeth_rebase WHERE timestamp BETWEEN ($1::timestamp - interval '7 days') AND $1::timestamp UNION ALL -- Results for all time up to the end date -SELECT 'all time' as period, SUM(fee) as total_fees, SUM(yield - fee) as total_yield, SUM(yield) as total_revenue +SELECT 'all time' as period, + SUM(fee) as total_fees, + SUM(yield - fee) as total_yield, + SUM(yield) as total_revenue, + + SUM(fee_converted) as total_fees_converted, + SUM(yield_converted - fee_converted) as total_yield_converted, + SUM(yield_converted) as total_revenue_converted + FROM oeth_rebase WHERE timestamp <= $1::timestamp ` diff --git a/src/ousd/post-processors/daily-stats/daily-stats.ts b/src/ousd/post-processors/daily-stats/daily-stats.ts new file mode 100644 index 00000000..fa7a5128 --- /dev/null +++ b/src/ousd/post-processors/daily-stats/daily-stats.ts @@ -0,0 +1,245 @@ +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import dayjs from 'dayjs' +import utc from 'dayjs/plugin/utc' +import { EntityManager, FindOptionsOrderValue, LessThanOrEqual } from 'typeorm' + +import { + ExchangeRate, + OUSD, + OUSDAPY, + OUSDCollateralDailyStat, + OUSDDailyStat, + OUSDHistory, + OUSDMorphoAave, + OUSDStrategyDailyStat, + OUSDStrategyHoldingDailyStat, + OUSDVault, +} from '../../../model' +import { Context } from '../../../processor' + +dayjs.extend(utc) + +export const from = 11585978 // OUSDReset + +export const setup = async (processor: EvmBatchProcessor) => { + processor.includeAllBlocks({ from }) +} + +export const process = async (ctx: Context) => { + const firstBlockTimestamp = ctx.blocks.find((b) => b.header.height >= from) + ?.header.timestamp + if (!firstBlockTimestamp) return + + const firstBlock = ctx.blocks[0] + const lastBlock = ctx.blocks[ctx.blocks.length - 1] + const startDate = dayjs.utc(firstBlock.header.timestamp).endOf('day') + const endDate = dayjs.utc(lastBlock.header.timestamp).endOf('day') + + let dates: Date[] = [] + for ( + let date = startDate; + !date.isAfter(endDate); + date = date.add(1, 'day').endOf('day') + ) { + dates.push(date.toDate()) + } + + const dailyStats = [] as OUSDDailyStat[] + const dailyCollateralStats = [] as OUSDCollateralDailyStat[] + const dailyStrategyStats = [] as OUSDStrategyDailyStat[] + const dailyHoldingsStats = [] as OUSDStrategyHoldingDailyStat[] + + for (const date of dates) { + const dailyStatInserts = await updateDailyStats(ctx, date) + if (dailyStatInserts) { + dailyStats.push(dailyStatInserts.dailyStat) + dailyCollateralStats.push(...dailyStatInserts.dailyCollateralStats) + dailyStrategyStats.push(...dailyStatInserts.dailyStrategyStats) + dailyHoldingsStats.push(...dailyStatInserts.dailyStrategyHoldingsStats) + } + } + + await ctx.store.upsert(dailyStats) + await Promise.all([ + ctx.store.upsert(dailyCollateralStats), + ctx.store.upsert(dailyStrategyStats), + ctx.store.upsert(dailyHoldingsStats), + ]) +} + +async function updateDailyStats(ctx: Context, date: Date) { + const queryParams = { + where: { timestamp: LessThanOrEqual(date) }, + order: { timestamp: 'desc' as FindOptionsOrderValue }, + } + + const [lastApy, lastOusd, lastVault, lastMorpho, lastWrappedOUSDHistory] = + await Promise.all([ + ctx.store.findOne(OUSDAPY, queryParams), + ctx.store.findOne(OUSD, queryParams), + ctx.store.findOne(OUSDVault, queryParams), + ctx.store.findOne(OUSDMorphoAave, queryParams), + ctx.store.findOne(OUSDHistory, { + where: { + timestamp: LessThanOrEqual(date), + address: { id: '0xd2af830e8cbdfed6cc11bab697bb25496ed6fa62' }, + }, + order: { timestamp: 'desc' as FindOptionsOrderValue }, + }), + ]) + + // Do we have any useful data yet? + const allEntities = [lastApy, lastOusd, lastVault, lastMorpho].filter(Boolean) + if (![lastApy, lastOusd].every((entity) => !!entity)) { + return null + } + + const entityManager = ( + ctx.store as unknown as { + em: () => EntityManager + } + ).em() + + const end = dayjs.utc(date).endOf('day').toDate() + const yieldStats = await entityManager.query< + { + period: string + total_yield: bigint + total_fees: bigint + total_revenue: bigint + total_yield_converted: bigint + total_fees_converted: bigint + total_revenue_converted: bigint + }[] + >(yieldStatsQuery, [end]) + + const mostRecentEntity = allEntities.reduce((highest, current) => { + if (!highest || !current) return current + return current.blockNumber > highest.blockNumber ? current : highest + }) + + if (!mostRecentEntity?.blockNumber) { + return null + } + + const id = date.toISOString().substring(0, 10) + + const dailyStat = new OUSDDailyStat({ + id, + blockNumber: mostRecentEntity?.blockNumber, + timestamp: mostRecentEntity?.timestamp, + + apr: lastApy?.apr, + apy: lastApy?.apy, + apy7DayAvg: lastApy?.apy7DayAvg, + apy14DayAvg: lastApy?.apy14DayAvg, + apy30DayAvg: lastApy?.apy30DayAvg, + + totalSupply: lastOusd?.totalSupply || 0n, + totalSupplyUSD: 0, + rebasingSupply: lastOusd?.rebasingSupply || 0n, + nonRebasingSupply: lastOusd?.nonRebasingSupply || 0n, + amoSupply: 0n, + dripperWETH: 0n, + wrappedSupply: lastWrappedOUSDHistory?.balance || 0n, + + yield: yieldStats[0].total_yield || 0n, + fees: yieldStats[0].total_fees || 0n, + revenue: yieldStats[0].total_revenue || 0n, + revenue7DayAvg: BigInt(yieldStats[1].total_revenue || 0n) / 7n, + revenue7DayTotal: yieldStats[1].total_revenue || 0n, + revenueAllTime: yieldStats[2].total_revenue || 0n, + + yieldConverted: yieldStats[0].total_yield_converted || 0n, + feesConverted: yieldStats[0].total_fees_converted || 0n, + revenueConverted: yieldStats[0].total_revenue_converted || 0n, + revenue7DayAvgConverted: BigInt(yieldStats[1].total_revenue_converted || 0n) / 7n, + revenue7DayTotalConverted: yieldStats[1].total_revenue_converted || 0n, + revenueAllTimeConverted: yieldStats[2].total_revenue_converted || 0n, + + pegPrice: 0n, + }) + + const dailyStrategyStats: OUSDStrategyDailyStat[] = [ + // new OUSDStrategyDailyStat({ + // id: `${id}-CURVE`, + // name: 'CURVE', + // dailyStatId: id as unknown as OUSDDailyStat, + // tvl: lastCurve?.totalSupplyOwned || 0n, + // total: lastCurve?.totalSupplyOwned || 0n, + // }), + ] + + const dailyStrategyHoldingsStats: OUSDStrategyHoldingDailyStat[] = [ + // new OUSDStrategyHoldingDailyStat({ + // id: `${id}-CURVE-ETH`, + // strategyDailyStatId: `${id}-CURVE` as unknown as OUSDStrategyDailyStat, + // symbol: 'ETH', + // amount: lastCurve?.ethOwned || 0n, + // value: lastCurve?.ethOwned || 0n, + // }), + ] + + const dailyCollateralStats: OUSDCollateralDailyStat[] = [ + // new OUSDCollateralDailyStat({ + // id: `${id}-ETH`, + // dailyStatId: id as unknown as OUSDDailyStat, + // symbol: 'ETH', + // amount: ETH, + // price: 1n, + // value: ETH, + // }), + ] + + return { + dailyStat, + dailyCollateralStats, + dailyStrategyStats, + dailyStrategyHoldingsStats, + } +} + +const yieldStatsQuery = ` +-- Results for 1 day +SELECT '1 day' as period, + SUM(fee) as total_fees, + SUM(yield - fee) as total_yield, + SUM(yield) as total_revenue, + + SUM(fee_converted) as total_fees_converted, + SUM(yield_converted - fee_converted) as total_yield_converted, + SUM(yield_converted) as total_revenue_converted + +FROM oeth_rebase +WHERE timestamp BETWEEN ($1::timestamp - interval '1 day') AND $1::timestamp + +UNION ALL + +-- Results for 7 days +SELECT '7 days' as period, + SUM(fee) as total_fees, + SUM(yield - fee) as total_yield, + SUM(yield) as total_revenue, + + SUM(fee_converted) as total_fees_converted, + SUM(yield_converted - fee_converted) as total_yield_converted, + SUM(yield_converted) as total_revenue_converted + +FROM oeth_rebase +WHERE timestamp BETWEEN ($1::timestamp - interval '7 days') AND $1::timestamp + +UNION ALL + +-- Results for all time up to the end date +SELECT 'all time' as period, + SUM(fee) as total_fees, + SUM(yield - fee) as total_yield, + SUM(yield) as total_revenue, + + SUM(fee_converted) as total_fees_converted, + SUM(yield_converted - fee_converted) as total_yield_converted, + SUM(yield_converted) as total_revenue_converted + +FROM oeth_rebase +WHERE timestamp <= $1::timestamp +` diff --git a/src/ousd/post-processors/daily-stats/index.ts b/src/ousd/post-processors/daily-stats/index.ts new file mode 100644 index 00000000..966fdd9a --- /dev/null +++ b/src/ousd/post-processors/daily-stats/index.ts @@ -0,0 +1 @@ +export * from './daily-stats' diff --git a/src/shared/processor-templates/otoken/otoken.ts b/src/shared/processor-templates/otoken/otoken.ts index f8e32806..49b6bc39 100644 --- a/src/shared/processor-templates/otoken/otoken.ts +++ b/src/shared/processor-templates/otoken/otoken.ts @@ -28,6 +28,7 @@ import { ADDRESS_ZERO } from '../../../utils/addresses' import { DECIMALS_18 } from '../../../utils/constants' import { EntityClassT, InstanceTypeOfConstructor } from '../../../utils/type' import { getLatestEntity } from '../../../utils/utils' +import { ensureExchangeRate } from '../../post-processors/exchange-rates' import { createAddress, createRebaseAPY } from './utils' type OToken = EntityClassT | EntityClassT @@ -364,6 +365,11 @@ export const createOTokenProcessor = (params: { throw new Error('lastYieldDistributionEvent is not set') } + const exchangeRate = await ensureExchangeRate(ctx, block, 'ETH', 'USD') + if (!exchangeRate) { + throw new Error('Could not fetch ETH/USD exchange rate') + } + // Rebase events let rebase = createRebaseAPY( params.OTokenAPY, @@ -374,6 +380,7 @@ export const createOTokenProcessor = (params: { log, data, result.lastYieldDistributionEvent, + exchangeRate, ) for (const address of owners!.values()) { diff --git a/src/shared/processor-templates/otoken/utils.ts b/src/shared/processor-templates/otoken/utils.ts index bb33af5e..7523896e 100644 --- a/src/shared/processor-templates/otoken/utils.ts +++ b/src/shared/processor-templates/otoken/utils.ts @@ -4,6 +4,7 @@ import { LessThan, MoreThanOrEqual } from 'typeorm' import * as otoken from '../../../abi/otoken' import { + ExchangeRate, OETHAPY, OETHAddress, OETHRebase, @@ -61,7 +62,23 @@ export async function createRebaseAPY< fee: bigint yield: bigint }, + exchangeRate: ExchangeRate, ) { + const fee = lastYieldDistributionEvent.fee + const yieldValue = lastYieldDistributionEvent.yield + + let feeConverted = 0n + let yieldConverted = 0n + if (OTokenAPY.name === 'OUSDAPY') { + feeConverted = + (fee * 1000000000000000000n) / exchangeRate.rate / 10000000000n + yieldConverted = + (yieldValue * 1000000000000000000n) / exchangeRate.rate / 10000000000n + } else { + feeConverted = (fee * exchangeRate.rate) / 100000000n + yieldConverted = (yieldValue * exchangeRate.rate) / 100000000n + } + const rebase = new OTokenRebase({ id: log.id, blockNumber: block.header.height, @@ -70,8 +87,10 @@ export async function createRebaseAPY< rebasingCredits: rebaseEvent.rebasingCredits, rebasingCreditsPerToken: rebaseEvent.rebasingCreditsPerToken, totalSupply: rebaseEvent.totalSupply, - fee: lastYieldDistributionEvent.fee, - yield: lastYieldDistributionEvent.yield, + fee, + yield: yieldValue, + feeConverted, + yieldConverted, }) // use date as id for APY From 5e1275bb2b4022ad1c39f014b2e0c218901fc6ac Mon Sep 17 00:00:00 2001 From: Nick Poulden Date: Mon, 4 Dec 2023 12:17:30 -0700 Subject: [PATCH 2/6] Update validators --- src/oeth/validators/validate-oeth/validate-oeth.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/oeth/validators/validate-oeth/validate-oeth.ts b/src/oeth/validators/validate-oeth/validate-oeth.ts index 40576911..574e9028 100644 --- a/src/oeth/validators/validate-oeth/validate-oeth.ts +++ b/src/oeth/validators/validate-oeth/validate-oeth.ts @@ -388,60 +388,70 @@ const expectations = { blockNumber: 17305345, timestamp: '2023-05-21T04:22:11.000000Z', fee: '6000055597516131', + feeConverted: '10916381153008898418', rebasingCredits: '2787113542887662778878885791818', rebasingCreditsPerToken: '973864011520629021168619646', totalSupply: '4100236147122104146565', txHash: '0x7de27a14c9f139d9019e6f067dc926de5a1318d1c8703696d1f87c7e11b405eb', yield: '30000277987580656', + yieldConverted: '54581905765044493913', }, { id: '0017331591-000369-f9f77', blockNumber: 17331591, timestamp: '2023-05-24T21:02:59.000000Z', fee: '6492737577781034', + feeConverted: '11727132294271875807', rebasingCredits: '3677621799805326022027580379682', rebasingCreditsPerToken: '972810711211478539104302424', totalSupply: '5393628338867046745384', txHash: '0x651848930f76eb8677a2d90067841ae1d5419276dafb7828d145eeb482b362cc', yield: '32463687888905171', + yieldConverted: '58635661471359380845', }, { id: '0017583331-000121-dccba', blockNumber: 17583331, timestamp: '2023-06-29T07:00:23.000000Z', fee: '577769460917579313', + feeConverted: '1062477594765164126055', rebasingCredits: '11978493735413759353827056755312', rebasingCreditsPerToken: '963907687618519656276956464', totalSupply: '21187279626610714331049', txHash: '0xe9261579ff7ccbbbe0cc5895a376c8177409a8a0503acf3bf04ee106ccb9c540', yield: '2888847304587896566', + yieldConverted: '5312387973825820632114', }, { id: '0018139997-000303-52abd', blockNumber: 18139997, timestamp: '2023-09-15T06:59:59.000000Z', fee: '1190995054063049444', + feeConverted: '1941953165501424009925', rebasingCredits: '22395831398283302999639860139823', rebasingCreditsPerToken: '948155891702979766036181091', totalSupply: '44971365122525849270172', txHash: '0xb3441c6184326378fe98af3cb3e425c015a5a2cce4d0055f2e8c3b0dc1bcdd98', yield: '5954975270315247221', + yieldConverted: '9709765827507120051257', }, { id: '0018404209-000053-b6b49', blockNumber: 18404209, timestamp: '2023-10-22T06:59:47.000000Z', fee: '885619331985372380', + feeConverted: '1455772085654965614517', rebasingCredits: '29496888949221038689228739185366', rebasingCreditsPerToken: '941672759591769536254510513', totalSupply: '41530447614871349372266', txHash: '0x1eab96d75579c8050869ffadec5d38bccf8a9714f49d6e27ce67088f15be0535', yield: '4428096659926861900', + yieldConverted: '7278860428274828072586', }, ]), oethVaults: e([ From 3481a4303fdbcbf0924c4f3a92ac8d9fc1cfd529 Mon Sep 17 00:00:00 2001 From: Nick Poulden Date: Tue, 5 Dec 2023 12:52:54 -0700 Subject: [PATCH 3/6] Schema --- schema-oeth.graphql | 32 ++++++++++++++------------------ schema-ousd.graphql | 29 ++++++++++++++--------------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/schema-oeth.graphql b/schema-oeth.graphql index 886c77b3..07882573 100644 --- a/schema-oeth.graphql +++ b/schema-oeth.graphql @@ -50,10 +50,10 @@ type OETHRebase @entity { rebasingCredits: BigInt! rebasingCreditsPerToken: BigInt! apy: OETHAPY! - fee: BigInt! - yield: BigInt! - feeConverted: BigInt! - yieldConverted: BigInt! + feeETH: BigInt! + feeUSD: BigInt! + yieldETH: BigInt! + yieldUSD: BigInt! } """ @@ -180,19 +180,16 @@ type OETHDailyStat @entity { dripperWETH: BigInt! wrappedSupply: BigInt! - yield: BigInt! - fees: BigInt! - revenue: BigInt! - revenue7DayAvg: BigInt! - revenue7DayTotal: BigInt! - revenueAllTime: BigInt! + yieldETH: BigInt! + yieldUSD: BigInt! - yieldConverted: BigInt! - feesConverted: BigInt! - revenueConverted: BigInt! - revenue7DayAvgConverted: BigInt! - revenue7DayTotalConverted: BigInt! - revenueAllTimeConverted: BigInt! + feesETH: BigInt! + feesETH7Day: BigInt! + feesETHAllTime: BigInt! + + feesUSD: BigInt! + feesUSD7Day: BigInt! + feesUSDAllTime: BigInt! pegPrice: BigInt! """ @@ -215,7 +212,7 @@ type OETHStrategyDailyStat @entity { Total ETH value """ holdings: [OETHStrategyHoldingDailyStat] - @derivedFrom(field: "strategyDailyStatId") + @derivedFrom(field: "strategyDailyStatId") } type OETHStrategyHoldingDailyStat @entity { @@ -288,4 +285,3 @@ type OETHActivity @entity { toSymbol: String amount: BigInt } - diff --git a/schema-ousd.graphql b/schema-ousd.graphql index a00592c4..4f1f301b 100644 --- a/schema-ousd.graphql +++ b/schema-ousd.graphql @@ -51,9 +51,11 @@ type OUSDRebase @entity { rebasingCreditsPerToken: BigInt! apy: OUSDAPY! fee: BigInt! + feeETH: BigInt! + feeUSD: BigInt! yield: BigInt! - feeConverted: BigInt! - yieldConverted: BigInt! + yieldETH: BigInt! + yieldUSD: BigInt! } """ @@ -213,19 +215,16 @@ type OUSDDailyStat @entity { dripperWETH: BigInt! wrappedSupply: BigInt! - yield: BigInt! - fees: BigInt! - revenue: BigInt! - revenue7DayAvg: BigInt! - revenue7DayTotal: BigInt! - revenueAllTime: BigInt! + yieldETH: BigInt! + yieldUSD: BigInt! + + feesETH: BigInt! + feesETH7Day: BigInt! + feesETHAllTime: BigInt! - yieldConverted: BigInt! - feesConverted: BigInt! - revenueConverted: BigInt! - revenue7DayAvgConverted: BigInt! - revenue7DayTotalConverted: BigInt! - revenueAllTimeConverted: BigInt! + feesUSD: BigInt! + feesUSD7Day: BigInt! + feesUSDAllTime: BigInt! pegPrice: BigInt! strategies: [OUSDStrategyDailyStat] @derivedFrom(field: "dailyStatId") @@ -239,7 +238,7 @@ type OUSDStrategyDailyStat @entity { total: BigInt! tvl: BigInt! holdings: [OUSDStrategyHoldingDailyStat] - @derivedFrom(field: "strategyDailyStatId") + @derivedFrom(field: "strategyDailyStatId") } type OUSDStrategyHoldingDailyStat @entity { From a6a4b0c20eb261b492d0e4db89c77fc5fb238087 Mon Sep 17 00:00:00 2001 From: Nick Poulden Date: Tue, 5 Dec 2023 15:20:36 -0700 Subject: [PATCH 4/6] Daily stat calc --- db/migrations/1701729003798-Data.js | 386 ------------------ ...83939578-Data.js => 1701813557098-Data.js} | 17 +- schema-oeth.graphql | 2 + schema-ousd.graphql | 4 +- schema.graphql | 6 +- src/model/generated/oethDailyStat.model.ts | 6 + src/model/generated/ousdDailyStat.model.ts | 6 + src/model/generated/ousdRebase.model.ts | 6 - .../daily-stats/daily-stats.ts | 66 ++- .../validators/validate-oeth/validate-oeth.ts | 40 +- src/ogv/post-processors/governance.ts | 46 ++- .../daily-stats/daily-stats.ts | 72 ++-- .../processor-templates/otoken/utils.ts | 31 +- 13 files changed, 145 insertions(+), 543 deletions(-) delete mode 100644 db/migrations/1701729003798-Data.js rename db/migrations/{1701383939578-Data.js => 1701813557098-Data.js} (96%) diff --git a/db/migrations/1701729003798-Data.js b/db/migrations/1701729003798-Data.js deleted file mode 100644 index 8e324920..00000000 --- a/db/migrations/1701729003798-Data.js +++ /dev/null @@ -1,386 +0,0 @@ -<<<<<<<< HEAD:db/migrations/1701383939578-Data.js -module.exports = class Data1701383939578 { - name = 'Data1701383939578' -======== -module.exports = class Data1701729003798 { - name = 'Data1701729003798' ->>>>>>>> main:db/migrations/1701729003798-Data.js - - 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 "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 "strategy_yield" ("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, "balance_weight" numeric NOT NULL, "earnings" numeric NOT NULL, "earnings_change" numeric NOT NULL, CONSTRAINT "PK_e87c46575e870fe2202190c2728" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_5108f2a2563d5665892d0c06b0" ON "strategy_yield" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_41c3567c9d43c598e07a0029c5" ON "strategy_yield" ("block_number") `) - await db.query(`CREATE TABLE "strategy_daily_yield" ("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, "balance_weight" numeric NOT NULL, "earnings" numeric NOT NULL, "earnings_change" numeric NOT NULL, "apr" numeric NOT NULL, "apy" numeric NOT NULL, CONSTRAINT "PK_b0dd2686bc95bb032ff532b3a0e" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_0ba1974747f1906e0c102cd2cd" ON "strategy_daily_yield" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_df364fb6e82d1feeed2a5dfffa" ON "strategy_daily_yield" ("block_number") `) - await db.query(`CREATE TABLE "erc20" ("id" character varying NOT NULL, "address" text NOT NULL, "name" text NOT NULL, "decimals" integer NOT NULL, "symbol" text NOT NULL, CONSTRAINT "PK_8d43ce15401ba044c55a72a8ceb" PRIMARY KEY ("id"))`) - await db.query(`CREATE TABLE "erc20_holder" ("id" character varying NOT NULL, "address" text NOT NULL, "account" text NOT NULL, CONSTRAINT "PK_3adce7edbac4bcb03c662c3a1ac" PRIMARY KEY ("id"))`) - await db.query(`CREATE TABLE "erc20_state" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "address" text NOT NULL, "total_supply" numeric NOT NULL, "holder_count" integer NOT NULL, CONSTRAINT "PK_eac1124b07bbdedafd4fff2f7b7" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_c3d08eb2dafe4b5b188924d835" ON "erc20_state" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_29e8edc6ba8cc37c0c16ff0baf" ON "erc20_state" ("block_number") `) - await db.query(`CREATE TABLE "erc20_balance" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "address" text NOT NULL, "account" text NOT NULL, "balance" numeric NOT NULL, CONSTRAINT "PK_069b6549e7a9938cc89f32063a6" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_c9fbe21a3411d93ea586af2a4c" ON "erc20_balance" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_d1f50dc39003331b76fad8a640" ON "erc20_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 "balancer_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, "balance3" numeric NOT NULL, CONSTRAINT "PK_441c7de293266414608c8e9de4c" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_642115282f1c3026edbc4bc2a7" ON "balancer_pool_balance" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_eecdc2d6132041e3806d77c7b4" ON "balancer_pool_balance" ("block_number") `) - await db.query(`CREATE TABLE "balancer_pool_rate" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "address" text NOT NULL, "rate0" numeric NOT NULL, "rate1" numeric NOT NULL, "rate2" numeric NOT NULL, "rate3" numeric NOT NULL, CONSTRAINT "PK_3ca9825db8d15c7850b715d9121" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_b1656f8d048f72b38bb637ea24" ON "balancer_pool_rate" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_c55345ef048232dfe36e60e4c5" ON "balancer_pool_rate" ("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, "fee_converted" numeric NOT NULL, "yield_converted" 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 "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"))`) - 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, "name" text 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, "dripper_weth" numeric NOT NULL, "wrapped_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, "yield_converted" numeric NOT NULL, "fees_converted" numeric NOT NULL, "revenue_converted" numeric NOT NULL, "revenue7_day_avg_converted" numeric NOT NULL, "revenue7_day_total_converted" numeric NOT NULL, "revenue_all_time_converted" 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 "oeth_reward_token_collected" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "strategy" text NOT NULL, "recipient" text NOT NULL, "reward_token" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_47098cc5fbc7cb95c2374fa33cd" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_81a9fa43ae4a6ae63e4103127b" ON "oeth_reward_token_collected" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_d36c78b9c3e9d737f067638bc4" ON "oeth_reward_token_collected" ("block_number") `) - await db.query(`CREATE TABLE "oeth_activity" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "call_data_last4_bytes" text NOT NULL, "address" text, "sighash" text, "action" text, "exchange" text, "interface" text, "from_symbol" text, "to_symbol" text, "amount" numeric, CONSTRAINT "PK_8938e7a05e2377cb6dc46e6980c" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_701369d638018e8f191b7c048d" ON "oeth_activity" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_e3037b99481023edd17b98cd78" ON "oeth_activity" ("block_number") `) - await db.query(`CREATE INDEX "IDX_6537c67233447c5152bc7318f8" ON "oeth_activity" ("tx_hash") `) - 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, "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" 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"))`) - 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, "fee_converted" numeric NOT NULL, "yield_converted" 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(`CREATE TABLE "ousd_activity" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "call_data_last4_bytes" text NOT NULL, "address" text, "sighash" text, "action" text, "exchange" text, "interface" text, "from_symbol" text, "to_symbol" text, "amount" numeric, CONSTRAINT "PK_0f830a098aea9c70d8e8a626933" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_87dcf07f9e54c132535acf47a4" ON "ousd_activity" ("timestamp") `) - await db.query(`CREATE INDEX "IDX_e80a0f99e9f31fe69ac50b5a4c" ON "ousd_activity" ("block_number") `) - await db.query(`CREATE INDEX "IDX_2af2ad9975c024d1aa3535928f" ON "ousd_activity" ("tx_hash") `) - await db.query(`CREATE TABLE "ousd_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_ef2f51867e1d465c554262efd1b" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_e1a93bab3d12271dc114234d3a" ON "ousd_strategy_holding_daily_stat" ("strategy_daily_stat_id_id") `) - await db.query(`CREATE TABLE "ousd_strategy_daily_stat" ("id" character varying NOT NULL, "name" text NOT NULL, "total" numeric NOT NULL, "tvl" numeric NOT NULL, "daily_stat_id_id" character varying, CONSTRAINT "PK_ac65d3f28f290211ddeb950e157" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_3edda581683682257159cb0863" ON "ousd_strategy_daily_stat" ("daily_stat_id_id") `) - await db.query(`CREATE TABLE "ousd_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_85a804677f14a0784914e27b7b9" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_78be9d3f3dc1f31cf17ae810fe" ON "ousd_collateral_daily_stat" ("daily_stat_id_id") `) - await db.query(`CREATE TABLE "ousd_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, "dripper_weth" numeric NOT NULL, "wrapped_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, "yield_converted" numeric NOT NULL, "fees_converted" numeric NOT NULL, "revenue_converted" numeric NOT NULL, "revenue7_day_avg_converted" numeric NOT NULL, "revenue7_day_total_converted" numeric NOT NULL, "revenue_all_time_converted" numeric NOT NULL, "peg_price" numeric NOT NULL, CONSTRAINT "PK_f8adaf321a99f2b4b877c262880" PRIMARY KEY ("id"))`) - await db.query(`CREATE INDEX "IDX_f9020d89932aad2d0de8923490" ON "ousd_daily_stat" ("block_number") `) - await db.query(`CREATE INDEX "IDX_0bb5f72bf5fa59ce8c232caa4c" ON "ousd_daily_stat" ("timestamp") `) - 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`) - await db.query(`ALTER TABLE "ousd_strategy_holding_daily_stat" ADD CONSTRAINT "FK_e1a93bab3d12271dc114234d3ae" FOREIGN KEY ("strategy_daily_stat_id_id") REFERENCES "ousd_strategy_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ousd_strategy_daily_stat" ADD CONSTRAINT "FK_3edda581683682257159cb08638" FOREIGN KEY ("daily_stat_id_id") REFERENCES "ousd_daily_stat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) - await db.query(`ALTER TABLE "ousd_collateral_daily_stat" ADD CONSTRAINT "FK_78be9d3f3dc1f31cf17ae810fee" FOREIGN KEY ("daily_stat_id_id") REFERENCES "ousd_daily_stat"("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 "strategy_balance"`) - await db.query(`DROP INDEX "public"."IDX_0113bf0b63183bea0d22cd0d08"`) - await db.query(`DROP INDEX "public"."IDX_a88065dcd92011698bbe7df7b1"`) - await db.query(`DROP TABLE "strategy_yield"`) - await db.query(`DROP INDEX "public"."IDX_5108f2a2563d5665892d0c06b0"`) - await db.query(`DROP INDEX "public"."IDX_41c3567c9d43c598e07a0029c5"`) - await db.query(`DROP TABLE "strategy_daily_yield"`) - await db.query(`DROP INDEX "public"."IDX_0ba1974747f1906e0c102cd2cd"`) - await db.query(`DROP INDEX "public"."IDX_df364fb6e82d1feeed2a5dfffa"`) - await db.query(`DROP TABLE "erc20"`) - await db.query(`DROP TABLE "erc20_holder"`) - await db.query(`DROP TABLE "erc20_state"`) - await db.query(`DROP INDEX "public"."IDX_c3d08eb2dafe4b5b188924d835"`) - await db.query(`DROP INDEX "public"."IDX_29e8edc6ba8cc37c0c16ff0baf"`) - await db.query(`DROP TABLE "erc20_balance"`) - await db.query(`DROP INDEX "public"."IDX_c9fbe21a3411d93ea586af2a4c"`) - await db.query(`DROP INDEX "public"."IDX_d1f50dc39003331b76fad8a640"`) - 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 "balancer_pool_balance"`) - await db.query(`DROP INDEX "public"."IDX_642115282f1c3026edbc4bc2a7"`) - await db.query(`DROP INDEX "public"."IDX_eecdc2d6132041e3806d77c7b4"`) - await db.query(`DROP TABLE "balancer_pool_rate"`) - await db.query(`DROP INDEX "public"."IDX_b1656f8d048f72b38bb637ea24"`) - await db.query(`DROP INDEX "public"."IDX_c55345ef048232dfe36e60e4c5"`) - 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 "oeth_dripper"`) - await db.query(`DROP INDEX "public"."IDX_16ac742ceeb05d28e530da9649"`) - await db.query(`DROP INDEX "public"."IDX_d356832c14603916a492608e7b"`) - 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 "oeth_reward_token_collected"`) - await db.query(`DROP INDEX "public"."IDX_81a9fa43ae4a6ae63e4103127b"`) - await db.query(`DROP INDEX "public"."IDX_d36c78b9c3e9d737f067638bc4"`) - await db.query(`DROP TABLE "oeth_activity"`) - await db.query(`DROP INDEX "public"."IDX_701369d638018e8f191b7c048d"`) - await db.query(`DROP INDEX "public"."IDX_e3037b99481023edd17b98cd78"`) - await db.query(`DROP INDEX "public"."IDX_6537c67233447c5152bc7318f8"`) - 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(`DROP TABLE "ousd_activity"`) - await db.query(`DROP INDEX "public"."IDX_87dcf07f9e54c132535acf47a4"`) - await db.query(`DROP INDEX "public"."IDX_e80a0f99e9f31fe69ac50b5a4c"`) - await db.query(`DROP INDEX "public"."IDX_2af2ad9975c024d1aa3535928f"`) - await db.query(`DROP TABLE "ousd_strategy_holding_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_e1a93bab3d12271dc114234d3a"`) - await db.query(`DROP TABLE "ousd_strategy_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_3edda581683682257159cb0863"`) - await db.query(`DROP TABLE "ousd_collateral_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_78be9d3f3dc1f31cf17ae810fe"`) - await db.query(`DROP TABLE "ousd_daily_stat"`) - await db.query(`DROP INDEX "public"."IDX_f9020d89932aad2d0de8923490"`) - await db.query(`DROP INDEX "public"."IDX_0bb5f72bf5fa59ce8c232caa4c"`) - 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"`) - await db.query(`ALTER TABLE "ousd_strategy_holding_daily_stat" DROP CONSTRAINT "FK_e1a93bab3d12271dc114234d3ae"`) - await db.query(`ALTER TABLE "ousd_strategy_daily_stat" DROP CONSTRAINT "FK_3edda581683682257159cb08638"`) - await db.query(`ALTER TABLE "ousd_collateral_daily_stat" DROP CONSTRAINT "FK_78be9d3f3dc1f31cf17ae810fee"`) - } -} diff --git a/db/migrations/1701383939578-Data.js b/db/migrations/1701813557098-Data.js similarity index 96% rename from db/migrations/1701383939578-Data.js rename to db/migrations/1701813557098-Data.js index 8e324920..1823b990 100644 --- a/db/migrations/1701383939578-Data.js +++ b/db/migrations/1701813557098-Data.js @@ -1,10 +1,5 @@ -<<<<<<<< HEAD:db/migrations/1701383939578-Data.js -module.exports = class Data1701383939578 { - name = 'Data1701383939578' -======== -module.exports = class Data1701729003798 { - name = 'Data1701729003798' ->>>>>>>> main:db/migrations/1701729003798-Data.js +module.exports = class Data1701813557098 { + name = 'Data1701813557098' 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 +43,7 @@ module.exports = class Data1701729003798 { 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, "fee_converted" numeric NOT NULL, "yield_converted" numeric NOT NULL, "apy_id" character varying, CONSTRAINT "PK_5f8f4dd071caf685b4ac2d54de3" PRIMARY KEY ("id"))`) + 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_eth" numeric NOT NULL, "fee_usd" numeric NOT NULL, "yield_eth" numeric NOT NULL, "yield_usd" 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") `) @@ -82,7 +77,7 @@ module.exports = class Data1701729003798 { 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, "dripper_weth" numeric NOT NULL, "wrapped_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, "yield_converted" numeric NOT NULL, "fees_converted" numeric NOT NULL, "revenue_converted" numeric NOT NULL, "revenue7_day_avg_converted" numeric NOT NULL, "revenue7_day_total_converted" numeric NOT NULL, "revenue_all_time_converted" numeric NOT NULL, "peg_price" numeric NOT NULL, CONSTRAINT "PK_9144a02ab13b1baa818a7d5eae5" PRIMARY KEY ("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, "dripper_weth" numeric NOT NULL, "wrapped_supply" numeric NOT NULL, "yield_eth" numeric NOT NULL, "yield_eth_all_time" numeric NOT NULL, "yield_usd" numeric NOT NULL, "yield_usd_all_time" numeric NOT NULL, "fees_eth" numeric NOT NULL, "fees_eth7_day" numeric NOT NULL, "fees_eth_all_time" numeric NOT NULL, "fees_usd" numeric NOT NULL, "fees_usd7_day" numeric NOT NULL, "fees_usd_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 "oeth_reward_token_collected" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "strategy" text NOT NULL, "recipient" text NOT NULL, "reward_token" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_47098cc5fbc7cb95c2374fa33cd" PRIMARY KEY ("id"))`) @@ -121,7 +116,7 @@ module.exports = class Data1701729003798 { 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, "fee_converted" numeric NOT NULL, "yield_converted" numeric NOT NULL, "apy_id" character varying, CONSTRAINT "PK_04cf0de72399a99798dde61b237" PRIMARY KEY ("id"))`) + 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_eth" numeric NOT NULL, "fee_usd" numeric NOT NULL, "yield_eth" numeric NOT NULL, "yield_usd" 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") `) @@ -171,7 +166,7 @@ module.exports = class Data1701729003798 { await db.query(`CREATE INDEX "IDX_3edda581683682257159cb0863" ON "ousd_strategy_daily_stat" ("daily_stat_id_id") `) await db.query(`CREATE TABLE "ousd_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_85a804677f14a0784914e27b7b9" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_78be9d3f3dc1f31cf17ae810fe" ON "ousd_collateral_daily_stat" ("daily_stat_id_id") `) - await db.query(`CREATE TABLE "ousd_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, "dripper_weth" numeric NOT NULL, "wrapped_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, "yield_converted" numeric NOT NULL, "fees_converted" numeric NOT NULL, "revenue_converted" numeric NOT NULL, "revenue7_day_avg_converted" numeric NOT NULL, "revenue7_day_total_converted" numeric NOT NULL, "revenue_all_time_converted" numeric NOT NULL, "peg_price" numeric NOT NULL, CONSTRAINT "PK_f8adaf321a99f2b4b877c262880" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "ousd_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, "dripper_weth" numeric NOT NULL, "wrapped_supply" numeric NOT NULL, "yield_eth" numeric NOT NULL, "yield_eth_all_time" numeric NOT NULL, "yield_usd" numeric NOT NULL, "yield_usd_all_time" numeric NOT NULL, "fees_eth" numeric NOT NULL, "fees_eth7_day" numeric NOT NULL, "fees_eth_all_time" numeric NOT NULL, "fees_usd" numeric NOT NULL, "fees_usd7_day" numeric NOT NULL, "fees_usd_all_time" numeric NOT NULL, "peg_price" numeric NOT NULL, CONSTRAINT "PK_f8adaf321a99f2b4b877c262880" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_f9020d89932aad2d0de8923490" ON "ousd_daily_stat" ("block_number") `) await db.query(`CREATE INDEX "IDX_0bb5f72bf5fa59ce8c232caa4c" ON "ousd_daily_stat" ("timestamp") `) 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`) diff --git a/schema-oeth.graphql b/schema-oeth.graphql index 07882573..ce7eea15 100644 --- a/schema-oeth.graphql +++ b/schema-oeth.graphql @@ -181,7 +181,9 @@ type OETHDailyStat @entity { wrappedSupply: BigInt! yieldETH: BigInt! + yieldETHAllTime: BigInt! yieldUSD: BigInt! + yieldUSDAllTime: BigInt! feesETH: BigInt! feesETH7Day: BigInt! diff --git a/schema-ousd.graphql b/schema-ousd.graphql index 4f1f301b..0fc46a36 100644 --- a/schema-ousd.graphql +++ b/schema-ousd.graphql @@ -50,10 +50,8 @@ type OUSDRebase @entity { rebasingCredits: BigInt! rebasingCreditsPerToken: BigInt! apy: OUSDAPY! - fee: BigInt! feeETH: BigInt! feeUSD: BigInt! - yield: BigInt! yieldETH: BigInt! yieldUSD: BigInt! } @@ -216,7 +214,9 @@ type OUSDDailyStat @entity { wrappedSupply: BigInt! yieldETH: BigInt! + yieldETHAllTime: BigInt! yieldUSD: BigInt! + yieldUSDAllTime: BigInt! feesETH: BigInt! feesETH7Day: BigInt! diff --git a/schema.graphql b/schema.graphql index c72019a5..5c1a7087 100644 --- a/schema.graphql +++ b/schema.graphql @@ -332,7 +332,9 @@ type OETHDailyStat @entity { wrappedSupply: BigInt! yieldETH: BigInt! + yieldETHAllTime: BigInt! yieldUSD: BigInt! + yieldUSDAllTime: BigInt! feesETH: BigInt! feesETH7Day: BigInt! @@ -587,10 +589,8 @@ type OUSDRebase @entity { rebasingCredits: BigInt! rebasingCreditsPerToken: BigInt! apy: OUSDAPY! - fee: BigInt! feeETH: BigInt! feeUSD: BigInt! - yield: BigInt! yieldETH: BigInt! yieldUSD: BigInt! } @@ -753,7 +753,9 @@ type OUSDDailyStat @entity { wrappedSupply: BigInt! yieldETH: BigInt! + yieldETHAllTime: BigInt! yieldUSD: BigInt! + yieldUSDAllTime: BigInt! feesETH: BigInt! feesETH7Day: BigInt! diff --git a/src/model/generated/oethDailyStat.model.ts b/src/model/generated/oethDailyStat.model.ts index 82ab417f..fb120cde 100644 --- a/src/model/generated/oethDailyStat.model.ts +++ b/src/model/generated/oethDailyStat.model.ts @@ -68,9 +68,15 @@ export class OETHDailyStat { @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) yieldETH!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yieldETHAllTime!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) yieldUSD!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yieldUSDAllTime!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) feesETH!: bigint diff --git a/src/model/generated/ousdDailyStat.model.ts b/src/model/generated/ousdDailyStat.model.ts index b62153f7..649f3160 100644 --- a/src/model/generated/ousdDailyStat.model.ts +++ b/src/model/generated/ousdDailyStat.model.ts @@ -59,9 +59,15 @@ export class OUSDDailyStat { @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) yieldETH!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yieldETHAllTime!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) yieldUSD!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) + yieldUSDAllTime!: bigint + @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) feesETH!: bigint diff --git a/src/model/generated/ousdRebase.model.ts b/src/model/generated/ousdRebase.model.ts index 4b13f269..de18b747 100644 --- a/src/model/generated/ousdRebase.model.ts +++ b/src/model/generated/ousdRebase.model.ts @@ -39,18 +39,12 @@ export class OUSDRebase { @ManyToOne_(() => OUSDAPY, {nullable: true}) apy!: OUSDAPY - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) - fee!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) feeETH!: bigint @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) feeUSD!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) - yield!: bigint - @Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false}) yieldETH!: bigint diff --git a/src/oeth/post-processors/daily-stats/daily-stats.ts b/src/oeth/post-processors/daily-stats/daily-stats.ts index daceafb5..9deb72e4 100644 --- a/src/oeth/post-processors/daily-stats/daily-stats.ts +++ b/src/oeth/post-processors/daily-stats/daily-stats.ts @@ -143,12 +143,10 @@ async function updateDailyStats(ctx: Context, date: Date) { const yieldStats = await entityManager.query< { period: string - total_yield: bigint - total_fees: bigint - total_revenue: bigint - total_yield_converted: bigint - total_fees_converted: bigint - total_revenue_converted: bigint + total_yield_usd: bigint + total_yield_eth: bigint + total_fees_usd: bigint + total_fees_eth: bigint }[] >(yieldStatsQuery, [end]) @@ -178,19 +176,16 @@ async function updateDailyStats(ctx: Context, date: Date) { dripperWETH: lastDripper?.weth || 0n, wrappedSupply: lastWrappedOETHHistory?.balance || 0n, - yield: yieldStats[0].total_yield || 0n, - fees: yieldStats[0].total_fees || 0n, - revenue: yieldStats[0].total_revenue || 0n, - revenue7DayAvg: BigInt(yieldStats[1].total_revenue || 0n) / 7n, - revenue7DayTotal: yieldStats[1].total_revenue || 0n, - revenueAllTime: yieldStats[2].total_revenue || 0n, - - yieldConverted: yieldStats[0].total_yield_converted || 0n, - feesConverted: yieldStats[0].total_fees_converted || 0n, - revenueConverted: yieldStats[0].total_revenue_converted || 0n, - revenue7DayAvgConverted: BigInt(yieldStats[1].total_revenue_converted || 0n) / 7n, - revenue7DayTotalConverted: yieldStats[1].total_revenue_converted || 0n, - revenueAllTimeConverted: yieldStats[2].total_revenue_converted || 0n, + yieldUSD: yieldStats[0].total_yield_usd || 0n, + yieldUSDAllTime: yieldStats[2].total_yield_usd || 0n, + yieldETH: yieldStats[0].total_yield_eth || 0n, + yieldETHAllTime: yieldStats[2].total_yield_eth || 0n, + feesUSD: yieldStats[0].total_fees_usd || 0n, + feesUSD7Day: yieldStats[1].total_fees_usd || 0n, + feesUSDAllTime: yieldStats[2].total_fees_usd || 0n, + feesETH: yieldStats[0].total_fees_eth || 0n, + feesETH7Day: yieldStats[1].total_fees_eth || 0n, + feesETHAllTime: yieldStats[2].total_fees_eth || 0n, pegPrice: 0n, }) @@ -387,13 +382,10 @@ async function updateDailyStats(ctx: Context, date: Date) { const yieldStatsQuery = ` -- Results for 1 day SELECT '1 day' as period, - SUM(fee) as total_fees, - SUM(yield - fee) as total_yield, - SUM(yield) as total_revenue, - - SUM(fee_converted) as total_fees_converted, - SUM(yield_converted - fee_converted) as total_yield_converted, - SUM(yield_converted) as total_revenue_converted + SUM(fee_usd) as total_fees_usd, + SUM(yield_usd - fee_usd) as total_yield_usd, + SUM(fee_eth) as total_fees_eth, + SUM(yield_eth - fee_eth) as total_yield_eth FROM oeth_rebase WHERE timestamp BETWEEN ($1::timestamp - interval '1 day') AND $1::timestamp @@ -402,13 +394,10 @@ UNION ALL -- Results for 7 days SELECT '7 days' as period, - SUM(fee) as total_fees, - SUM(yield - fee) as total_yield, - SUM(yield) as total_revenue, - - SUM(fee_converted) as total_fees_converted, - SUM(yield_converted - fee_converted) as total_yield_converted, - SUM(yield_converted) as total_revenue_converted + SUM(fee_usd) as total_fees_usd, + SUM(yield_usd - fee_usd) as total_yield_usd, + SUM(fee_eth) as total_fees_eth, + SUM(yield_eth - fee_eth) as total_yield_eth FROM oeth_rebase WHERE timestamp BETWEEN ($1::timestamp - interval '7 days') AND $1::timestamp @@ -417,13 +406,10 @@ UNION ALL -- Results for all time up to the end date SELECT 'all time' as period, - SUM(fee) as total_fees, - SUM(yield - fee) as total_yield, - SUM(yield) as total_revenue, - - SUM(fee_converted) as total_fees_converted, - SUM(yield_converted - fee_converted) as total_yield_converted, - SUM(yield_converted) as total_revenue_converted + SUM(fee_usd) as total_fees_usd, + SUM(yield_usd - fee_usd) as total_yield_usd, + SUM(fee_eth) as total_fees_eth, + SUM(yield_eth - fee_eth) as total_yield_eth FROM oeth_rebase WHERE timestamp <= $1::timestamp diff --git a/src/oeth/validators/validate-oeth/validate-oeth.ts b/src/oeth/validators/validate-oeth/validate-oeth.ts index 574e9028..708af262 100644 --- a/src/oeth/validators/validate-oeth/validate-oeth.ts +++ b/src/oeth/validators/validate-oeth/validate-oeth.ts @@ -387,71 +387,71 @@ const expectations = { id: '0017305345-000456-5f62d', blockNumber: 17305345, timestamp: '2023-05-21T04:22:11.000000Z', - fee: '6000055597516131', - feeConverted: '10916381153008898418', + feeETH: '6000055597516131', + feeUSD: '10916381153008898418', rebasingCredits: '2787113542887662778878885791818', rebasingCreditsPerToken: '973864011520629021168619646', totalSupply: '4100236147122104146565', txHash: '0x7de27a14c9f139d9019e6f067dc926de5a1318d1c8703696d1f87c7e11b405eb', - yield: '30000277987580656', - yieldConverted: '54581905765044493913', + yieldETH: '30000277987580656', + yieldUSD: '54581905765044493913', }, { id: '0017331591-000369-f9f77', blockNumber: 17331591, timestamp: '2023-05-24T21:02:59.000000Z', - fee: '6492737577781034', - feeConverted: '11727132294271875807', + feeETH: '6492737577781034', + feeUSD: '11727132294271875807', rebasingCredits: '3677621799805326022027580379682', rebasingCreditsPerToken: '972810711211478539104302424', totalSupply: '5393628338867046745384', txHash: '0x651848930f76eb8677a2d90067841ae1d5419276dafb7828d145eeb482b362cc', - yield: '32463687888905171', - yieldConverted: '58635661471359380845', + yieldETH: '32463687888905171', + yieldUSD: '58635661471359380845', }, { id: '0017583331-000121-dccba', blockNumber: 17583331, timestamp: '2023-06-29T07:00:23.000000Z', - fee: '577769460917579313', - feeConverted: '1062477594765164126055', + feeETH: '577769460917579313', + feeUSD: '1062477594765164126055', rebasingCredits: '11978493735413759353827056755312', rebasingCreditsPerToken: '963907687618519656276956464', totalSupply: '21187279626610714331049', txHash: '0xe9261579ff7ccbbbe0cc5895a376c8177409a8a0503acf3bf04ee106ccb9c540', - yield: '2888847304587896566', - yieldConverted: '5312387973825820632114', + yieldETH: '2888847304587896566', + yieldUSD: '5312387973825820632114', }, { id: '0018139997-000303-52abd', blockNumber: 18139997, timestamp: '2023-09-15T06:59:59.000000Z', - fee: '1190995054063049444', - feeConverted: '1941953165501424009925', + feeETH: '1190995054063049444', + feeUSD: '1941953165501424009925', rebasingCredits: '22395831398283302999639860139823', rebasingCreditsPerToken: '948155891702979766036181091', totalSupply: '44971365122525849270172', txHash: '0xb3441c6184326378fe98af3cb3e425c015a5a2cce4d0055f2e8c3b0dc1bcdd98', - yield: '5954975270315247221', - yieldConverted: '9709765827507120051257', + yieldETH: '5954975270315247221', + yieldUSD: '9709765827507120051257', }, { id: '0018404209-000053-b6b49', blockNumber: 18404209, timestamp: '2023-10-22T06:59:47.000000Z', - fee: '885619331985372380', - feeConverted: '1455772085654965614517', + feeETH: '885619331985372380', + feeUSD: '1455772085654965614517', rebasingCredits: '29496888949221038689228739185366', rebasingCreditsPerToken: '941672759591769536254510513', totalSupply: '41530447614871349372266', txHash: '0x1eab96d75579c8050869ffadec5d38bccf8a9714f49d6e27ce67088f15be0535', - yield: '4428096659926861900', - yieldConverted: '7278860428274828072586', + yieldETH: '4428096659926861900', + yieldUSD: '7278860428274828072586', }, ]), oethVaults: e([ diff --git a/src/ogv/post-processors/governance.ts b/src/ogv/post-processors/governance.ts index a23650b5..e6b906a8 100644 --- a/src/ogv/post-processors/governance.ts +++ b/src/ogv/post-processors/governance.ts @@ -12,6 +12,7 @@ import { } from '../../model' import { Block, Context, Log } from '../../processor' import { GOVERNANCE_ADDRESS } from '../../utils/addresses' +import { env } from '../../utils/env' export const from = 15491391 // https://etherscan.io/tx/0x0e04e429248c384e6b36229edf8eb5a77bec7023c58808c21b702edfcbc0e0d6 @@ -53,25 +54,32 @@ export const process = async (ctx: Context) => { if (log.address !== GOVERNANCE_ADDRESS) continue 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) + try { + 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) + } + } catch (e) { + if (!env.BLOCK_FROM) { + throw e + } + ctx.log.error('Could not process governance event') } } } diff --git a/src/ousd/post-processors/daily-stats/daily-stats.ts b/src/ousd/post-processors/daily-stats/daily-stats.ts index fa7a5128..8ebbca2b 100644 --- a/src/ousd/post-processors/daily-stats/daily-stats.ts +++ b/src/ousd/post-processors/daily-stats/daily-stats.ts @@ -104,12 +104,10 @@ async function updateDailyStats(ctx: Context, date: Date) { const yieldStats = await entityManager.query< { period: string - total_yield: bigint - total_fees: bigint - total_revenue: bigint - total_yield_converted: bigint - total_fees_converted: bigint - total_revenue_converted: bigint + total_yield_usd: bigint + total_yield_eth: bigint + total_fees_usd: bigint + total_fees_eth: bigint }[] >(yieldStatsQuery, [end]) @@ -143,19 +141,16 @@ async function updateDailyStats(ctx: Context, date: Date) { dripperWETH: 0n, wrappedSupply: lastWrappedOUSDHistory?.balance || 0n, - yield: yieldStats[0].total_yield || 0n, - fees: yieldStats[0].total_fees || 0n, - revenue: yieldStats[0].total_revenue || 0n, - revenue7DayAvg: BigInt(yieldStats[1].total_revenue || 0n) / 7n, - revenue7DayTotal: yieldStats[1].total_revenue || 0n, - revenueAllTime: yieldStats[2].total_revenue || 0n, - - yieldConverted: yieldStats[0].total_yield_converted || 0n, - feesConverted: yieldStats[0].total_fees_converted || 0n, - revenueConverted: yieldStats[0].total_revenue_converted || 0n, - revenue7DayAvgConverted: BigInt(yieldStats[1].total_revenue_converted || 0n) / 7n, - revenue7DayTotalConverted: yieldStats[1].total_revenue_converted || 0n, - revenueAllTimeConverted: yieldStats[2].total_revenue_converted || 0n, + yieldUSD: yieldStats[0].total_yield_usd || 0n, + yieldUSDAllTime: yieldStats[2].total_yield_usd || 0n, + yieldETH: yieldStats[0].total_yield_eth || 0n, + yieldETHAllTime: yieldStats[2].total_yield_eth || 0n, + feesUSD: yieldStats[0].total_fees_usd || 0n, + feesUSD7Day: yieldStats[1].total_fees_usd || 0n, + feesUSDAllTime: yieldStats[2].total_fees_usd || 0n, + feesETH: yieldStats[0].total_fees_eth || 0n, + feesETH7Day: yieldStats[1].total_fees_eth || 0n, + feesETHAllTime: yieldStats[2].total_fees_eth || 0n, pegPrice: 0n, }) @@ -202,44 +197,35 @@ async function updateDailyStats(ctx: Context, date: Date) { const yieldStatsQuery = ` -- Results for 1 day SELECT '1 day' as period, - SUM(fee) as total_fees, - SUM(yield - fee) as total_yield, - SUM(yield) as total_revenue, - - SUM(fee_converted) as total_fees_converted, - SUM(yield_converted - fee_converted) as total_yield_converted, - SUM(yield_converted) as total_revenue_converted + SUM(fee_usd) as total_fees_usd, + SUM(yield_usd - fee_usd) as total_yield_usd, + SUM(fee_eth) as total_fees_eth, + SUM(yield_eth - fee_eth) as total_yield_eth -FROM oeth_rebase +FROM ousd_rebase WHERE timestamp BETWEEN ($1::timestamp - interval '1 day') AND $1::timestamp UNION ALL -- Results for 7 days SELECT '7 days' as period, - SUM(fee) as total_fees, - SUM(yield - fee) as total_yield, - SUM(yield) as total_revenue, + SUM(fee_usd) as total_fees_usd, + SUM(yield_usd - fee_usd) as total_yield_usd, + SUM(fee_eth) as total_fees_eth, + SUM(yield_eth - fee_eth) as total_yield_eth - SUM(fee_converted) as total_fees_converted, - SUM(yield_converted - fee_converted) as total_yield_converted, - SUM(yield_converted) as total_revenue_converted - -FROM oeth_rebase +FROM ousd_rebase WHERE timestamp BETWEEN ($1::timestamp - interval '7 days') AND $1::timestamp UNION ALL -- Results for all time up to the end date SELECT 'all time' as period, - SUM(fee) as total_fees, - SUM(yield - fee) as total_yield, - SUM(yield) as total_revenue, - - SUM(fee_converted) as total_fees_converted, - SUM(yield_converted - fee_converted) as total_yield_converted, - SUM(yield_converted) as total_revenue_converted + SUM(fee_usd) as total_fees_usd, + SUM(yield_usd - fee_usd) as total_yield_usd, + SUM(fee_eth) as total_fees_eth, + SUM(yield_eth - fee_eth) as total_yield_eth -FROM oeth_rebase +FROM ousd_rebase WHERE timestamp <= $1::timestamp ` diff --git a/src/shared/processor-templates/otoken/utils.ts b/src/shared/processor-templates/otoken/utils.ts index 7523896e..6c64de46 100644 --- a/src/shared/processor-templates/otoken/utils.ts +++ b/src/shared/processor-templates/otoken/utils.ts @@ -64,19 +64,22 @@ export async function createRebaseAPY< }, exchangeRate: ExchangeRate, ) { - const fee = lastYieldDistributionEvent.fee - const yieldValue = lastYieldDistributionEvent.yield + let feeETH = 0n + let yieldETH = 0n + let feeUSD = 0n + let yieldUSD = 0n + const rate = exchangeRate.rate - let feeConverted = 0n - let yieldConverted = 0n if (OTokenAPY.name === 'OUSDAPY') { - feeConverted = - (fee * 1000000000000000000n) / exchangeRate.rate / 10000000000n - yieldConverted = - (yieldValue * 1000000000000000000n) / exchangeRate.rate / 10000000000n + feeUSD = lastYieldDistributionEvent.fee + yieldUSD = lastYieldDistributionEvent.yield + feeETH = (feeUSD * 1000000000000000000n) / rate / 10000000000n + yieldETH = (yieldUSD * 1000000000000000000n) / rate / 10000000000n } else { - feeConverted = (fee * exchangeRate.rate) / 100000000n - yieldConverted = (yieldValue * exchangeRate.rate) / 100000000n + feeETH = lastYieldDistributionEvent.fee + yieldETH = lastYieldDistributionEvent.yield + feeUSD = (feeETH * exchangeRate.rate) / 100000000n + yieldUSD = (yieldETH * exchangeRate.rate) / 100000000n } const rebase = new OTokenRebase({ @@ -87,10 +90,10 @@ export async function createRebaseAPY< rebasingCredits: rebaseEvent.rebasingCredits, rebasingCreditsPerToken: rebaseEvent.rebasingCreditsPerToken, totalSupply: rebaseEvent.totalSupply, - fee, - yield: yieldValue, - feeConverted, - yieldConverted, + feeUSD, + yieldUSD, + feeETH, + yieldETH, }) // use date as id for APY From d8038e4e43df0524c5febedbc9e73b6f42c3f5a4 Mon Sep 17 00:00:00 2001 From: Nick Poulden Date: Tue, 5 Dec 2023 16:31:18 -0700 Subject: [PATCH 5/6] JSON --- src/oeth/post-processors/daily-stats/daily-stats.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oeth/post-processors/daily-stats/daily-stats.ts b/src/oeth/post-processors/daily-stats/daily-stats.ts index 9deb72e4..ca2dd311 100644 --- a/src/oeth/post-processors/daily-stats/daily-stats.ts +++ b/src/oeth/post-processors/daily-stats/daily-stats.ts @@ -148,7 +148,7 @@ async function updateDailyStats(ctx: Context, date: Date) { total_fees_usd: bigint total_fees_eth: bigint }[] - >(yieldStatsQuery, [end]) + >(yieldStatsQuery, [end.toJSON()]) const mostRecentEntity = allEntities.reduce((highest, current) => { if (!highest || !current) return current From 6e58670066a9e93fe5a0c1bc4f6a405c9b2f84a3 Mon Sep 17 00:00:00 2001 From: Nick Poulden Date: Wed, 6 Dec 2023 09:52:21 -0700 Subject: [PATCH 6/6] Add toJSON to OUSD --- src/ousd/post-processors/daily-stats/daily-stats.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ousd/post-processors/daily-stats/daily-stats.ts b/src/ousd/post-processors/daily-stats/daily-stats.ts index 8ebbca2b..ffe9a066 100644 --- a/src/ousd/post-processors/daily-stats/daily-stats.ts +++ b/src/ousd/post-processors/daily-stats/daily-stats.ts @@ -109,7 +109,7 @@ async function updateDailyStats(ctx: Context, date: Date) { total_fees_usd: bigint total_fees_eth: bigint }[] - >(yieldStatsQuery, [end]) + >(yieldStatsQuery, [end.toJSON()]) const mostRecentEntity = allEntities.reduce((highest, current) => { if (!highest || !current) return current