From 6aa5b8621c4bf53a85d39b727c364ea03d4c7a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Fri, 26 Jan 2024 18:08:59 -0300 Subject: [PATCH 01/20] Apply codegen, typegen and migrations --- db/migrations/1706303296765-Data.js | 861 ++++++++++++++++++++++++++++ src/mappings/prices.ts | 1 - 2 files changed, 861 insertions(+), 1 deletion(-) create mode 100644 db/migrations/1706303296765-Data.js diff --git a/db/migrations/1706303296765-Data.js b/db/migrations/1706303296765-Data.js new file mode 100644 index 00000000..465402a9 --- /dev/null +++ b/db/migrations/1706303296765-Data.js @@ -0,0 +1,861 @@ +module.exports = class Data1706303296765 { + name = 'Data1706303296765' + + async up(db) { + await db.query( + `CREATE TABLE "oracle_price" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "blockchain" text NOT NULL, "timestamp" numeric NOT NULL, "price" text NOT NULL, "supply" text NOT NULL, "decimals" integer NOT NULL, CONSTRAINT "PK_606c938b2474588b154eb625f3b" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_6554f47abd46667280a2523381" ON "oracle_price" ("symbol") ` + ) + await db.query( + `CREATE INDEX "IDX_2026224855490e321e5c0b6911" ON "oracle_price" ("blockchain") ` + ) + await db.query( + `CREATE INDEX "IDX_a77ac6d79f0929522f5a1aefcb" ON "oracle_price" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_f7c9bf3bae39fb0a75f12b87dd" ON "oracle_price" ("price") ` + ) + await db.query( + `CREATE TABLE "transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "amount" numeric NOT NULL, "fee" numeric NOT NULL, "remark" text, CONSTRAINT "PK_fd9ddbdd49a17afcbe014401295" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_d6624eacc30144ea97915fe846" ON "transfer" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_70ff8b624c3118ac3a4862d22c" ON "transfer" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_070c555a86b0b41a534a55a659" ON "transfer" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_f4007436c1b546ede08a4fd7ab" ON "transfer" ("amount") ` + ) + await db.query( + `CREATE TABLE "factory" ("id" character varying NOT NULL, "pair_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_volume_eth" text NOT NULL, "untracked_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_1372e5a7d114a3fa80736ba66bb" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "stable_swap_event" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_8b61dbc9b556ed8fcb4030fee7d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_3a147c85b92441217540579be8" ON "stable_swap_event" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_exchange" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_f06e489da865134dcfac3bbcd22" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_1180a78feea28e278229de7db4" ON "stable_swap_exchange" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_819b3b7bf9c8055e14e0bf1c578" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_648b49eb1a4f2a47f24f13bb51" ON "stable_swap_day_data" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "hourly_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_2aedd41b95c37330a4a8429e192" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_94584d2925c30ae0d4b80aadfc" ON "stable_swap_hour_data" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "token_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_token" text NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "total_liquidity_token" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_liquidity_usd" text NOT NULL, "price_usd" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_73fc06337215e86196b36822116" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_b8950a8bc7b60231137573740e" ON "token_day_data" ("token_id") ` + ) + await db.query( + `CREATE TABLE "pair_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "hourly_volume_token0" text NOT NULL, "hourly_volume_token1" text NOT NULL, "hourly_volume_usd" text NOT NULL, "hourly_txns" integer NOT NULL, "pair_id" character varying, CONSTRAINT "PK_ffc544bb3e72cfd3e48a8b01452" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_cf50c55389e428096a68598ee3" ON "pair_hour_data" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "stable_swap_id" character varying, CONSTRAINT "PK_12f435243c8a739330c0881d720" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_f953aebc7c0752f6b8434c9eef" ON "stable_swap_liquidity_position" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_405e0d7aeca80975d88a63bc6e" ON "stable_swap_liquidity_position" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stake_position" ("id" character varying NOT NULL, "liquidity_staked_balance" numeric NOT NULL, "user_id" character varying, "farm_id" character varying, CONSTRAINT "PK_17615803509bd6065f1ab8b0ced" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_2a2b22d2744b497bbcfb03e6ab" ON "stake_position" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_670629d9904e1f48f4a31abb49" ON "stake_position" ("farm_id") ` + ) + await db.query( + `CREATE TABLE "user" ("id" character varying NOT NULL, "usd_swapped" text NOT NULL, CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_db00d963c96b3914d26abe3c3d2" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_781470585a67fef4e215a59977" ON "liquidity_position" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_5a626c8b8962dc01e0f8801be6" ON "liquidity_position" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "liquidity_position_snapshot" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block" integer NOT NULL, "token0_price_usd" text NOT NULL, "token1_price_usd" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "reserve_usd" text NOT NULL, "liquidity_token_total_supply" text NOT NULL, "liquidity_token_balance" text NOT NULL, "liquidity_position_id" character varying, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_cd4ed3539266b2439349a9fa791" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_eb823fd4d5a47575039e902efa" ON "liquidity_position_snapshot" ("liquidity_position_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ed32a41150bc13f18a01974153" ON "liquidity_position_snapshot" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ce85a847b2952f7e685f150de1" ON "liquidity_position_snapshot" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "transaction" ("id" character varying NOT NULL, "block_number" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "mints" text array NOT NULL, "burns" text array NOT NULL, "swaps" text array NOT NULL, CONSTRAINT "PK_89eadb93a89810556e1cbcd6ab9" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "mint" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "to" text NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "log_index" integer, "amount_usd" text, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_fcaea791104aa41aa11dac29cb2" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_19f4328320501dfd14e2bae085" ON "mint" ("transaction_id") ` + ) + await db.query( + `CREATE INDEX "IDX_81d470127d4c55d09e9213bc4e" ON "mint" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "burn" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "to" text, "log_index" integer, "amount_usd" text, "needs_complete" boolean NOT NULL, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_dcb4f14ee4534154b31116553f0" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_20ec76c5c56dd6b47dec5f0aaa" ON "burn" ("transaction_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ba144ce938b3266a470d4dd70f" ON "burn" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "swap" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "from" text NOT NULL, "amount0_in" text NOT NULL, "amount1_in" text NOT NULL, "amount0_out" text NOT NULL, "amount1_out" text NOT NULL, "to" text NOT NULL, "log_index" integer, "amount_usd" text NOT NULL, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_4a10d0f359339acef77e7f986d9" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_78506c4050ae7cedd50b08c0dc" ON "swap" ("transaction_id") ` + ) + await db.query( + `CREATE INDEX "IDX_3571ab1dad7640a6b93c705b8f" ON "swap" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "pair" ("id" character varying NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_eth" text NOT NULL, "reserve_usd" text NOT NULL, "tracked_reserve_eth" text NOT NULL, "token0_price" text NOT NULL, "token1_price" text NOT NULL, "volume_token0" text NOT NULL, "volume_token1" text NOT NULL, "volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "created_at_timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "created_at_block_number" numeric NOT NULL, "liquidity_provider_count" integer NOT NULL, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_3eaf216329c5c50aedb94fa797e" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_f74dc53460944a424b56b8f7da" ON "pair" ("token0_id") ` + ) + await db.query( + `CREATE INDEX "IDX_4419691fc411b8af754dfa65ce" ON "pair" ("token1_id") ` + ) + await db.query( + `CREATE TABLE "pair_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "pair_address" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "daily_volume_token0" text NOT NULL, "daily_volume_token1" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "pair_id" character varying, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_ac35ed26ab0c71d491a62e2881a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_d8ba7d7d7ad9f0e1c2933a0b7e" ON "pair_day_data" ("pair_id") ` + ) + await db.query( + `CREATE INDEX "IDX_88f6e19c40b47053e6e197db1c" ON "pair_day_data" ("token0_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ce435d6fc7c373d58e7aab156d" ON "pair_day_data" ("token1_id") ` + ) + await db.query( + `CREATE TABLE "token" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "decimals" integer NOT NULL, "total_supply" text NOT NULL, "trade_volume" text NOT NULL, "trade_volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "total_liquidity" text NOT NULL, "derived_eth" text NOT NULL, CONSTRAINT "PK_82fae97f905930df5d62a702fc9" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "single_token_lock_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_87d03adf6b8624eaff434355e53" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_f3bf64f43101176dbe5f11a36b" ON "single_token_lock_day_data" ("single_token_lock_id") ` + ) + await db.query( + `CREATE TABLE "single_token_lock_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_9173bf5d597c5ce35bbce2e664b" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_b2a84dc625103153d651b701dd" ON "single_token_lock_hour_data" ("single_token_lock_id") ` + ) + await db.query( + `CREATE TABLE "single_token_lock" ("id" character varying NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_eth" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_b3d635331ccfacc4f532569364b" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_8ebffe66457859d6e1c37b81ac" ON "single_token_lock" ("token_id") ` + ) + await db.query( + `CREATE TABLE "incentive" ("id" character varying NOT NULL, "reward_per_day" text NOT NULL, "farm_id" character varying, "reward_token_id" character varying, CONSTRAINT "PK_fc2c4e32d8711392ddf918b9f6c" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_35286137967591eaff8dee7ca2" ON "incentive" ("farm_id") ` + ) + await db.query( + `CREATE INDEX "IDX_041db4166864a3841e5efed53c" ON "incentive" ("reward_token_id") ` + ) + await db.query( + `CREATE TABLE "farm" ("id" character varying NOT NULL, "pid" numeric NOT NULL, "stake_token" text NOT NULL, "liquidity_staked" numeric NOT NULL, "created_at_block" numeric NOT NULL, "created_at_timestamp" numeric NOT NULL, "staked_usd" text NOT NULL, "reward_usd_per_day" text NOT NULL, "stake_apr" text NOT NULL, "single_token_lock_id" character varying, "stable_swap_id" character varying, "pair_id" character varying, CONSTRAINT "PK_3bf246b27a3b6678dfc0b7a3f64" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_679106a1febf251d7fe7fe081a" ON "farm" ("single_token_lock_id") ` + ) + await db.query( + `CREATE INDEX "IDX_00b8f5b860927b1b85e866b20d" ON "farm" ("stable_swap_id") ` + ) + await db.query( + `CREATE INDEX "IDX_11da1bf5c406898262d91b41cb" ON "farm" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap" ("id" character varying NOT NULL, "address" text NOT NULL, "base_swap_address" text NOT NULL, "num_tokens" integer NOT NULL, "tokens" text array NOT NULL, "base_tokens" text array NOT NULL, "all_tokens" text array NOT NULL, "balances" text array NOT NULL, "lp_token" text NOT NULL, "lp_total_supply" text NOT NULL, "a" numeric NOT NULL, "swap_fee" numeric NOT NULL, "admin_fee" numeric NOT NULL, "virtual_price" numeric NOT NULL, "tvl_usd" text NOT NULL, "volume_usd" text NOT NULL, "stable_swap_info_id" character varying, CONSTRAINT "PK_37316f6fedc29bf95a6f1804c65" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_88cce14adee6d21f5057551c3e" ON "stable_swap" ("stable_swap_info_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_info" ("id" character varying NOT NULL, "pool_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_21998b071d5e28639e21e9b2da7" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "zenlink_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, "factory_id" character varying, "stable_swap_info_id" character varying, CONSTRAINT "PK_2526d46468e5c4f7c4156840a90" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_9a6b55d2085464668b622dffe6" ON "zenlink_info" ("factory_id") ` + ) + await db.query( + `CREATE INDEX "IDX_0795adc3723792868094ec76c0" ON "zenlink_info" ("stable_swap_info_id") ` + ) + await db.query( + `CREATE TABLE "token_transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, "remark" text, CONSTRAINT "PK_77384b7f5874553f012eba9da41" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_b47f7192b72dd8436ef4e6d253" ON "token_transfer" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_752d6c330729a7b2e283003374" ON "token_transfer" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_2ef35b71d641ec79b7de3ac237" ON "token_transfer" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_aae50046f62ba400c07477fb6c" ON "token_transfer" ("amount") ` + ) + await db.query( + `CREATE TABLE "token_deposit" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_7c5eea7aeab3f0e71da8d2d9f4f" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_395da815b9927f13e2f87c6b54" ON "token_deposit" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_0f87d313517eaa806c75444749" ON "token_deposit" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_7194acc3ea037189ff3da743ec" ON "token_deposit" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_d23ae7a0ea1f640e8e9875b3c2" ON "token_deposit" ("amount") ` + ) + await db.query( + `CREATE TABLE "token_withdrawn" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_658727649cde2e20f8cf69abeb5" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_e7fd99cae9a1df2e8f69d60892" ON "token_withdrawn" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_70e98131fb737e4dce4455ca43" ON "token_withdrawn" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_867e6d004e7a4994b3b2aeba63" ON "token_withdrawn" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_5697bf049746e5102413ebd832" ON "token_withdrawn" ("amount") ` + ) + await db.query( + `CREATE TABLE "bundle" ("id" character varying NOT NULL, "eth_price" text NOT NULL, CONSTRAINT "PK_637e3f87e837d6532109c198dea" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "factory_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_volume_untracked" text NOT NULL, "total_volume_eth" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_4b56c54390ce8e399d8e37e169d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "stable_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, CONSTRAINT "PK_3663f18340bb5fdc0023ecc624a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "zenlink_day_info" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "standard_info_id" character varying, "stable_info_id" character varying, CONSTRAINT "PK_747195cfa3811d6eea0ff6389de" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_9f281ffbf4f668c1671ae24aeb" ON "zenlink_day_info" ("standard_info_id") ` + ) + await db.query( + `CREATE INDEX "IDX_3049b8ac70203e95dfc6b42c02" ON "zenlink_day_info" ("stable_info_id") ` + ) + await db.query( + `CREATE TABLE "zlk_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "burn" numeric NOT NULL, CONSTRAINT "PK_58853b5e24384aba0da2023e91e" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "nabla_token" ("id" character varying NOT NULL, "decimals" integer NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, CONSTRAINT "PK_d036fec883bded17a5c2e09cf0a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "backstop_pool" ("id" character varying NOT NULL, "reserves" numeric NOT NULL, "liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "router_id" character varying, "token_id" character varying, CONSTRAINT "PK_bf2d01d9ce60ad9ee4b1b087d9d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_13ef09b925620aedf12b3342ca" ON "backstop_pool" ("router_id") ` + ) + await db.query( + `CREATE INDEX "IDX_8a7a25fa2d22ff634bd3041d81" ON "backstop_pool" ("token_id") ` + ) + await db.query( + `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "reserves" numeric NOT NULL, "liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_2f5409f002e18e4a6e2fddd858" ON "swap_pool" ("router_id") ` + ) + await db.query( + `CREATE INDEX "IDX_5c3209a88e41d53bdc450605b3" ON "swap_pool" ("backstop_id") ` + ) + await db.query( + `CREATE INDEX "IDX_b66a5cc8d2ce7bba1b48fd8c1a" ON "swap_pool" ("token_id") ` + ) + await db.query( + `CREATE TABLE "router" ("id" character varying NOT NULL, "paused" boolean NOT NULL, CONSTRAINT "PK_510c864aa88ac8eb3a306789801" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "event" ("id" character varying NOT NULL, "index" integer NOT NULL, "phase" text NOT NULL, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "call_id" character varying, CONSTRAINT "PK_30c2f3bbaf6d34a55f8ae6e4614" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_2b0d35d675c4f99751855c4502" ON "event" ("block_id") ` + ) + await db.query( + `CREATE INDEX "IDX_129efedcb305c80256db2d57a5" ON "event" ("extrinsic_id") ` + ) + await db.query( + `CREATE INDEX "IDX_83cf1bd59aa4521ed882fa5145" ON "event" ("call_id") ` + ) + await db.query( + `CREATE INDEX "IDX_7723d04c5a2f56c4373b6a4048" ON "event" ("pallet") ` + ) + await db.query( + `CREATE INDEX "IDX_b535fbe8ec6d832dde22065ebd" ON "event" ("name") ` + ) + await db.query( + `CREATE INDEX "IDX_0a00d817e614a91cda40d734cf" ON "event" ("id", "pallet", "name") ` + ) + await db.query( + `CREATE TABLE "call" ("id" character varying NOT NULL, "address" integer array NOT NULL, "success" boolean NOT NULL, "error" jsonb, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "parent_id" character varying, CONSTRAINT "PK_2098af0169792a34f9cfdd39c47" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_bd3f11fd4110d60ac8b96cd62f" ON "call" ("block_id") ` + ) + await db.query( + `CREATE INDEX "IDX_dde30e4f2c6a80f9236bfdf259" ON "call" ("extrinsic_id") ` + ) + await db.query( + `CREATE INDEX "IDX_11c1e76d5be8f04c472c4a05b9" ON "call" ("parent_id") ` + ) + await db.query( + `CREATE INDEX "IDX_d3a8c3d00494950ad6dc93297d" ON "call" ("success") ` + ) + await db.query( + `CREATE INDEX "IDX_776bccbd3d7b3001c8708cf4e0" ON "call" ("pallet") ` + ) + await db.query( + `CREATE INDEX "IDX_8b212022b7428232091e2f8aa5" ON "call" ("name") ` + ) + await db.query( + `CREATE INDEX "IDX_f1e953379e1b3c453cd896bcd4" ON "call" ("id", "pallet", "name") ` + ) + await db.query( + `CREATE TABLE "extrinsic" ("id" character varying NOT NULL, "index" integer NOT NULL, "version" integer NOT NULL, "signature" jsonb, "tip" numeric, "fee" numeric, "success" boolean, "error" jsonb, "hash" bytea NOT NULL, "block_id" character varying, "call_id" character varying, CONSTRAINT "PK_80d7db0e4b1e83e30336bc76755" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_a3b99daba1259dab0dd040d4f7" ON "extrinsic" ("block_id") ` + ) + await db.query( + `CREATE INDEX "IDX_824d47cc4b2cda726405aa507c" ON "extrinsic" ("call_id") ` + ) + await db.query( + `CREATE INDEX "IDX_21e5db7671dfa1b00dbe6dbbd6" ON "extrinsic" ("success") ` + ) + await db.query( + `CREATE INDEX "IDX_1f45de0713a55049009e8e8127" ON "extrinsic" ("hash") ` + ) + await db.query( + `CREATE TABLE "block" ("id" character varying NOT NULL, "height" integer NOT NULL, "hash" bytea NOT NULL, "parent_hash" bytea NOT NULL, "state_root" bytea NOT NULL, "extrinsicsic_root" bytea NOT NULL, "spec_name" text NOT NULL, "spec_version" integer NOT NULL, "impl_name" text NOT NULL, "impl_version" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "validator" bytea, "extrinsics_count" integer NOT NULL, "calls_count" integer NOT NULL, "events_count" integer NOT NULL, CONSTRAINT "PK_d0925763efb591c2e2ffb267572" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_bce676e2b005104ccb768495db" ON "block" ("height") ` + ) + await db.query( + `CREATE INDEX "IDX_f8fba63d7965bfee9f304c487a" ON "block" ("hash") ` + ) + await db.query( + `CREATE INDEX "IDX_5b79d140fa8e2c64a7ef223598" ON "block" ("spec_version") ` + ) + await db.query( + `CREATE INDEX "IDX_5c67cbcf4960c1a39e5fe25e87" ON "block" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_b7e2f8fe1384a2910825029dcb" ON "block" ("validator") ` + ) + await db.query( + `CREATE TABLE "items_counter" ("id" character varying NOT NULL, "type" character varying(10) NOT NULL, "level" character varying(6) NOT NULL, "total" integer NOT NULL, CONSTRAINT "PK_161dcf46142538463f5d7174793" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_68d2eadecb3eeb540d2004acef" ON "items_counter" ("type") ` + ) + await db.query( + `CREATE INDEX "IDX_1d9be1d79f197d42dd163f86c8" ON "items_counter" ("level") ` + ) + await db.query( + `CREATE INDEX "IDX_e03dd1c60ac7622914f72ac2f1" ON "items_counter" ("total") ` + ) + await db.query( + `ALTER TABLE "stable_swap_event" ADD CONSTRAINT "FK_3a147c85b92441217540579be88" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_exchange" ADD CONSTRAINT "FK_1180a78feea28e278229de7db46" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_day_data" ADD CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_hour_data" ADD CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "token_day_data" ADD CONSTRAINT "FK_b8950a8bc7b60231137573740ea" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_hour_data" ADD CONSTRAINT "FK_cf50c55389e428096a68598ee33" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_670629d9904e1f48f4a31abb495" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_781470585a67fef4e215a599773" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_eb823fd4d5a47575039e902efa7" FOREIGN KEY ("liquidity_position_id") REFERENCES "liquidity_position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ed32a41150bc13f18a019741534" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ce85a847b2952f7e685f150de1d" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "mint" ADD CONSTRAINT "FK_19f4328320501dfd14e2bae0855" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "mint" ADD CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "burn" ADD CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "burn" ADD CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap" ADD CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap" ADD CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair" ADD CONSTRAINT "FK_f74dc53460944a424b56b8f7da5" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair" ADD CONSTRAINT "FK_4419691fc411b8af754dfa65ce4" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "single_token_lock_day_data" ADD CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "single_token_lock_hour_data" ADD CONSTRAINT "FK_b2a84dc625103153d651b701dd1" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "single_token_lock" ADD CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "incentive" ADD CONSTRAINT "FK_35286137967591eaff8dee7ca2a" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "incentive" ADD CONSTRAINT "FK_041db4166864a3841e5efed53c4" FOREIGN KEY ("reward_token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "farm" ADD CONSTRAINT "FK_679106a1febf251d7fe7fe081ad" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "farm" ADD CONSTRAINT "FK_00b8f5b860927b1b85e866b20da" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "farm" ADD CONSTRAINT "FK_11da1bf5c406898262d91b41cbb" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap" ADD CONSTRAINT "FK_88cce14adee6d21f5057551c3ea" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_9a6b55d2085464668b622dffe64" FOREIGN KEY ("factory_id") REFERENCES "factory"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_0795adc3723792868094ec76c07" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0" FOREIGN KEY ("standard_info_id") REFERENCES "factory_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027" FOREIGN KEY ("stable_info_id") REFERENCES "stable_swap_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_13ef09b925620aedf12b3342caa" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b" FOREIGN KEY ("backstop_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "event" ADD CONSTRAINT "FK_2b0d35d675c4f99751855c45021" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "event" ADD CONSTRAINT "FK_129efedcb305c80256db2d57a59" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "event" ADD CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "call" ADD CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "call" ADD CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "call" ADD CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95" FOREIGN KEY ("parent_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_824d47cc4b2cda726405aa507ca" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + } + + async down(db) { + await db.query(`DROP TABLE "oracle_price"`) + await db.query(`DROP INDEX "public"."IDX_6554f47abd46667280a2523381"`) + await db.query(`DROP INDEX "public"."IDX_2026224855490e321e5c0b6911"`) + await db.query(`DROP INDEX "public"."IDX_a77ac6d79f0929522f5a1aefcb"`) + await db.query(`DROP INDEX "public"."IDX_f7c9bf3bae39fb0a75f12b87dd"`) + await db.query(`DROP TABLE "transfer"`) + await db.query(`DROP INDEX "public"."IDX_d6624eacc30144ea97915fe846"`) + await db.query(`DROP INDEX "public"."IDX_70ff8b624c3118ac3a4862d22c"`) + await db.query(`DROP INDEX "public"."IDX_070c555a86b0b41a534a55a659"`) + await db.query(`DROP INDEX "public"."IDX_f4007436c1b546ede08a4fd7ab"`) + await db.query(`DROP TABLE "factory"`) + await db.query(`DROP TABLE "stable_swap_event"`) + await db.query(`DROP INDEX "public"."IDX_3a147c85b92441217540579be8"`) + await db.query(`DROP TABLE "stable_swap_exchange"`) + await db.query(`DROP INDEX "public"."IDX_1180a78feea28e278229de7db4"`) + await db.query(`DROP TABLE "stable_swap_day_data"`) + await db.query(`DROP INDEX "public"."IDX_648b49eb1a4f2a47f24f13bb51"`) + await db.query(`DROP TABLE "stable_swap_hour_data"`) + await db.query(`DROP INDEX "public"."IDX_94584d2925c30ae0d4b80aadfc"`) + await db.query(`DROP TABLE "token_day_data"`) + await db.query(`DROP INDEX "public"."IDX_b8950a8bc7b60231137573740e"`) + await db.query(`DROP TABLE "pair_hour_data"`) + await db.query(`DROP INDEX "public"."IDX_cf50c55389e428096a68598ee3"`) + await db.query(`DROP TABLE "stable_swap_liquidity_position"`) + await db.query(`DROP INDEX "public"."IDX_f953aebc7c0752f6b8434c9eef"`) + await db.query(`DROP INDEX "public"."IDX_405e0d7aeca80975d88a63bc6e"`) + await db.query(`DROP TABLE "stake_position"`) + await db.query(`DROP INDEX "public"."IDX_2a2b22d2744b497bbcfb03e6ab"`) + await db.query(`DROP INDEX "public"."IDX_670629d9904e1f48f4a31abb49"`) + await db.query(`DROP TABLE "user"`) + await db.query(`DROP TABLE "liquidity_position"`) + await db.query(`DROP INDEX "public"."IDX_781470585a67fef4e215a59977"`) + await db.query(`DROP INDEX "public"."IDX_5a626c8b8962dc01e0f8801be6"`) + await db.query(`DROP TABLE "liquidity_position_snapshot"`) + await db.query(`DROP INDEX "public"."IDX_eb823fd4d5a47575039e902efa"`) + await db.query(`DROP INDEX "public"."IDX_ed32a41150bc13f18a01974153"`) + await db.query(`DROP INDEX "public"."IDX_ce85a847b2952f7e685f150de1"`) + await db.query(`DROP TABLE "transaction"`) + await db.query(`DROP TABLE "mint"`) + await db.query(`DROP INDEX "public"."IDX_19f4328320501dfd14e2bae085"`) + await db.query(`DROP INDEX "public"."IDX_81d470127d4c55d09e9213bc4e"`) + await db.query(`DROP TABLE "burn"`) + await db.query(`DROP INDEX "public"."IDX_20ec76c5c56dd6b47dec5f0aaa"`) + await db.query(`DROP INDEX "public"."IDX_ba144ce938b3266a470d4dd70f"`) + await db.query(`DROP TABLE "swap"`) + await db.query(`DROP INDEX "public"."IDX_78506c4050ae7cedd50b08c0dc"`) + await db.query(`DROP INDEX "public"."IDX_3571ab1dad7640a6b93c705b8f"`) + await db.query(`DROP TABLE "pair"`) + await db.query(`DROP INDEX "public"."IDX_f74dc53460944a424b56b8f7da"`) + await db.query(`DROP INDEX "public"."IDX_4419691fc411b8af754dfa65ce"`) + await db.query(`DROP TABLE "pair_day_data"`) + await db.query(`DROP INDEX "public"."IDX_d8ba7d7d7ad9f0e1c2933a0b7e"`) + await db.query(`DROP INDEX "public"."IDX_88f6e19c40b47053e6e197db1c"`) + await db.query(`DROP INDEX "public"."IDX_ce435d6fc7c373d58e7aab156d"`) + await db.query(`DROP TABLE "token"`) + await db.query(`DROP TABLE "single_token_lock_day_data"`) + await db.query(`DROP INDEX "public"."IDX_f3bf64f43101176dbe5f11a36b"`) + await db.query(`DROP TABLE "single_token_lock_hour_data"`) + await db.query(`DROP INDEX "public"."IDX_b2a84dc625103153d651b701dd"`) + await db.query(`DROP TABLE "single_token_lock"`) + await db.query(`DROP INDEX "public"."IDX_8ebffe66457859d6e1c37b81ac"`) + await db.query(`DROP TABLE "incentive"`) + await db.query(`DROP INDEX "public"."IDX_35286137967591eaff8dee7ca2"`) + await db.query(`DROP INDEX "public"."IDX_041db4166864a3841e5efed53c"`) + await db.query(`DROP TABLE "farm"`) + await db.query(`DROP INDEX "public"."IDX_679106a1febf251d7fe7fe081a"`) + await db.query(`DROP INDEX "public"."IDX_00b8f5b860927b1b85e866b20d"`) + await db.query(`DROP INDEX "public"."IDX_11da1bf5c406898262d91b41cb"`) + await db.query(`DROP TABLE "stable_swap"`) + await db.query(`DROP INDEX "public"."IDX_88cce14adee6d21f5057551c3e"`) + await db.query(`DROP TABLE "stable_swap_info"`) + await db.query(`DROP TABLE "zenlink_info"`) + await db.query(`DROP INDEX "public"."IDX_9a6b55d2085464668b622dffe6"`) + await db.query(`DROP INDEX "public"."IDX_0795adc3723792868094ec76c0"`) + await db.query(`DROP TABLE "token_transfer"`) + await db.query(`DROP INDEX "public"."IDX_b47f7192b72dd8436ef4e6d253"`) + await db.query(`DROP INDEX "public"."IDX_752d6c330729a7b2e283003374"`) + await db.query(`DROP INDEX "public"."IDX_2ef35b71d641ec79b7de3ac237"`) + await db.query(`DROP INDEX "public"."IDX_aae50046f62ba400c07477fb6c"`) + await db.query(`DROP TABLE "token_deposit"`) + await db.query(`DROP INDEX "public"."IDX_395da815b9927f13e2f87c6b54"`) + await db.query(`DROP INDEX "public"."IDX_0f87d313517eaa806c75444749"`) + await db.query(`DROP INDEX "public"."IDX_7194acc3ea037189ff3da743ec"`) + await db.query(`DROP INDEX "public"."IDX_d23ae7a0ea1f640e8e9875b3c2"`) + await db.query(`DROP TABLE "token_withdrawn"`) + await db.query(`DROP INDEX "public"."IDX_e7fd99cae9a1df2e8f69d60892"`) + await db.query(`DROP INDEX "public"."IDX_70e98131fb737e4dce4455ca43"`) + await db.query(`DROP INDEX "public"."IDX_867e6d004e7a4994b3b2aeba63"`) + await db.query(`DROP INDEX "public"."IDX_5697bf049746e5102413ebd832"`) + await db.query(`DROP TABLE "bundle"`) + await db.query(`DROP TABLE "factory_day_data"`) + await db.query(`DROP TABLE "stable_day_data"`) + await db.query(`DROP TABLE "zenlink_day_info"`) + await db.query(`DROP INDEX "public"."IDX_9f281ffbf4f668c1671ae24aeb"`) + await db.query(`DROP INDEX "public"."IDX_3049b8ac70203e95dfc6b42c02"`) + await db.query(`DROP TABLE "zlk_info"`) + await db.query(`DROP TABLE "nabla_token"`) + await db.query(`DROP TABLE "backstop_pool"`) + await db.query(`DROP INDEX "public"."IDX_13ef09b925620aedf12b3342ca"`) + await db.query(`DROP INDEX "public"."IDX_8a7a25fa2d22ff634bd3041d81"`) + await db.query(`DROP TABLE "swap_pool"`) + await db.query(`DROP INDEX "public"."IDX_2f5409f002e18e4a6e2fddd858"`) + await db.query(`DROP INDEX "public"."IDX_5c3209a88e41d53bdc450605b3"`) + await db.query(`DROP INDEX "public"."IDX_b66a5cc8d2ce7bba1b48fd8c1a"`) + await db.query(`DROP TABLE "router"`) + await db.query(`DROP TABLE "event"`) + await db.query(`DROP INDEX "public"."IDX_2b0d35d675c4f99751855c4502"`) + await db.query(`DROP INDEX "public"."IDX_129efedcb305c80256db2d57a5"`) + await db.query(`DROP INDEX "public"."IDX_83cf1bd59aa4521ed882fa5145"`) + await db.query(`DROP INDEX "public"."IDX_7723d04c5a2f56c4373b6a4048"`) + await db.query(`DROP INDEX "public"."IDX_b535fbe8ec6d832dde22065ebd"`) + await db.query(`DROP INDEX "public"."IDX_0a00d817e614a91cda40d734cf"`) + await db.query(`DROP TABLE "call"`) + await db.query(`DROP INDEX "public"."IDX_bd3f11fd4110d60ac8b96cd62f"`) + await db.query(`DROP INDEX "public"."IDX_dde30e4f2c6a80f9236bfdf259"`) + await db.query(`DROP INDEX "public"."IDX_11c1e76d5be8f04c472c4a05b9"`) + await db.query(`DROP INDEX "public"."IDX_d3a8c3d00494950ad6dc93297d"`) + await db.query(`DROP INDEX "public"."IDX_776bccbd3d7b3001c8708cf4e0"`) + await db.query(`DROP INDEX "public"."IDX_8b212022b7428232091e2f8aa5"`) + await db.query(`DROP INDEX "public"."IDX_f1e953379e1b3c453cd896bcd4"`) + await db.query(`DROP TABLE "extrinsic"`) + await db.query(`DROP INDEX "public"."IDX_a3b99daba1259dab0dd040d4f7"`) + await db.query(`DROP INDEX "public"."IDX_824d47cc4b2cda726405aa507c"`) + await db.query(`DROP INDEX "public"."IDX_21e5db7671dfa1b00dbe6dbbd6"`) + await db.query(`DROP INDEX "public"."IDX_1f45de0713a55049009e8e8127"`) + await db.query(`DROP TABLE "block"`) + await db.query(`DROP INDEX "public"."IDX_bce676e2b005104ccb768495db"`) + await db.query(`DROP INDEX "public"."IDX_f8fba63d7965bfee9f304c487a"`) + await db.query(`DROP INDEX "public"."IDX_5b79d140fa8e2c64a7ef223598"`) + await db.query(`DROP INDEX "public"."IDX_5c67cbcf4960c1a39e5fe25e87"`) + await db.query(`DROP INDEX "public"."IDX_b7e2f8fe1384a2910825029dcb"`) + await db.query(`DROP TABLE "items_counter"`) + await db.query(`DROP INDEX "public"."IDX_68d2eadecb3eeb540d2004acef"`) + await db.query(`DROP INDEX "public"."IDX_1d9be1d79f197d42dd163f86c8"`) + await db.query(`DROP INDEX "public"."IDX_e03dd1c60ac7622914f72ac2f1"`) + await db.query( + `ALTER TABLE "stable_swap_event" DROP CONSTRAINT "FK_3a147c85b92441217540579be88"` + ) + await db.query( + `ALTER TABLE "stable_swap_exchange" DROP CONSTRAINT "FK_1180a78feea28e278229de7db46"` + ) + await db.query( + `ALTER TABLE "stable_swap_day_data" DROP CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510"` + ) + await db.query( + `ALTER TABLE "stable_swap_hour_data" DROP CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8"` + ) + await db.query( + `ALTER TABLE "token_day_data" DROP CONSTRAINT "FK_b8950a8bc7b60231137573740ea"` + ) + await db.query( + `ALTER TABLE "pair_hour_data" DROP CONSTRAINT "FK_cf50c55389e428096a68598ee33"` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8"` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee"` + ) + await db.query( + `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0"` + ) + await db.query( + `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_670629d9904e1f48f4a31abb495"` + ) + await db.query( + `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_781470585a67fef4e215a599773"` + ) + await db.query( + `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61"` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_eb823fd4d5a47575039e902efa7"` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ed32a41150bc13f18a019741534"` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ce85a847b2952f7e685f150de1d"` + ) + await db.query( + `ALTER TABLE "mint" DROP CONSTRAINT "FK_19f4328320501dfd14e2bae0855"` + ) + await db.query( + `ALTER TABLE "mint" DROP CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1"` + ) + await db.query( + `ALTER TABLE "burn" DROP CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8"` + ) + await db.query( + `ALTER TABLE "burn" DROP CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa"` + ) + await db.query( + `ALTER TABLE "swap" DROP CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5"` + ) + await db.query( + `ALTER TABLE "swap" DROP CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7"` + ) + await db.query( + `ALTER TABLE "pair" DROP CONSTRAINT "FK_f74dc53460944a424b56b8f7da5"` + ) + await db.query( + `ALTER TABLE "pair" DROP CONSTRAINT "FK_4419691fc411b8af754dfa65ce4"` + ) + await db.query( + `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2"` + ) + await db.query( + `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9"` + ) + await db.query( + `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9"` + ) + await db.query( + `ALTER TABLE "single_token_lock_day_data" DROP CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd"` + ) + await db.query( + `ALTER TABLE "single_token_lock_hour_data" DROP CONSTRAINT "FK_b2a84dc625103153d651b701dd1"` + ) + await db.query( + `ALTER TABLE "single_token_lock" DROP CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3"` + ) + await db.query( + `ALTER TABLE "incentive" DROP CONSTRAINT "FK_35286137967591eaff8dee7ca2a"` + ) + await db.query( + `ALTER TABLE "incentive" DROP CONSTRAINT "FK_041db4166864a3841e5efed53c4"` + ) + await db.query( + `ALTER TABLE "farm" DROP CONSTRAINT "FK_679106a1febf251d7fe7fe081ad"` + ) + await db.query( + `ALTER TABLE "farm" DROP CONSTRAINT "FK_00b8f5b860927b1b85e866b20da"` + ) + await db.query( + `ALTER TABLE "farm" DROP CONSTRAINT "FK_11da1bf5c406898262d91b41cbb"` + ) + await db.query( + `ALTER TABLE "stable_swap" DROP CONSTRAINT "FK_88cce14adee6d21f5057551c3ea"` + ) + await db.query( + `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_9a6b55d2085464668b622dffe64"` + ) + await db.query( + `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_0795adc3723792868094ec76c07"` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0"` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027"` + ) + await db.query( + `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_13ef09b925620aedf12b3342caa"` + ) + await db.query( + `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab"` + ) + await db.query( + `ALTER TABLE "event" DROP CONSTRAINT "FK_2b0d35d675c4f99751855c45021"` + ) + await db.query( + `ALTER TABLE "event" DROP CONSTRAINT "FK_129efedcb305c80256db2d57a59"` + ) + await db.query( + `ALTER TABLE "event" DROP CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452"` + ) + await db.query( + `ALTER TABLE "call" DROP CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3"` + ) + await db.query( + `ALTER TABLE "call" DROP CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590"` + ) + await db.query( + `ALTER TABLE "call" DROP CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95"` + ) + await db.query( + `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74"` + ) + await db.query( + `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_824d47cc4b2cda726405aa507ca"` + ) + } +} diff --git a/src/mappings/prices.ts b/src/mappings/prices.ts index 17289328..8f14146b 100644 --- a/src/mappings/prices.ts +++ b/src/mappings/prices.ts @@ -2,7 +2,6 @@ import { EventHandlerContext } from '../processor' import { network } from '../config' import { getOrCreateOraclePrice } from '../entities/oraclePrice' import { hexToString } from '@polkadot/util' -import { decodeFoucocoEvent } from '../types/foucoco/eventsAndStorageSelector' import { decodeEvent } from '../types' export async function handleUpdatedPrices(ctx: EventHandlerContext) { let event = await decodeEvent( From 251955654b0673fb99c06e8d56d225f90c634a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Fri, 26 Jan 2024 18:18:18 -0300 Subject: [PATCH 02/20] Change schema.graphql and nabla-abi to new Nabla version --- nabla-abi/backstop.json | 760 +++++++++++------- nabla-abi/erc20.json | 132 +--- nabla-abi/router.json | 6 +- nabla-abi/swap.json | 353 +++++---- package-lock.json | 862 ++++++++++---------- package.json | 22 +- schema.graphql | 10 +- src/abi/backstop.ts | 917 ++++++++++++---------- src/abi/erc20.ts | 186 +---- src/abi/router.ts | 18 +- src/abi/swap.ts | 455 +++++++---- src/model/generated/backstopPool.model.ts | 15 +- src/model/generated/router.model.ts | 3 - src/model/generated/swapPool.model.ts | 10 +- src/processor.ts | 6 + src/types/pendulum/index.ts | 1 + src/types/pendulum/tokens/events.ts | 47 ++ src/types/pendulum/tokens/storage.ts | 145 ++++ src/types/pendulum/v9.ts | 97 +++ 19 files changed, 2330 insertions(+), 1715 deletions(-) create mode 100644 src/types/pendulum/v9.ts diff --git a/nabla-abi/backstop.json b/nabla-abi/backstop.json index 5c280e4d..c179c30f 100644 --- a/nabla-abi/backstop.json +++ b/nabla-abi/backstop.json @@ -6,9 +6,9 @@ "version": "0.0.1" }, "source": { - "compiler": "solang 0.2.2", - "hash": "0xf10ab2e77c3a3e3927250ee6ba61e01338a509150723f4329e6dda3d9481eb2a", - "language": "Solidity 0.2.2" + "compiler": "solang 0.3.2", + "hash": "0x09e907520a2e0be46d0a350df95c431857cbf88f52094be242f15ae79e524f3c", + "language": "Solidity 0.3.2" }, "spec": { "constructors": [ @@ -17,21 +17,22 @@ { "label": "_router", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "_asset", "type": { - "displayName": ["ink_env", "types", "AccountId"], - "type": 2 - } - }, - { - "label": "_curve", - "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -50,16 +51,44 @@ } } ], + "default": false, "docs": [""], "label": "new", "payable": false, "returnType": null, - "selector": "0x3e6bb716" + "selector": "0xf01fa595" } ], "docs": [ - "The backstop pool takes most of the risk of a set of swap pools\nbacked by it. Whenever a swap pool is low on reserves and a LPer\nwants to withdraw some liquidity, they can conduct an insurance\nwithdrawal (burn swap pool shares, reimbursed in backstop liquidity)\nto avoid paying a high slippage.\nThe backstop pool owns all excess liquidity in its swap pools,\nbut is also liable for potential liquidity gaps.\nIn return, the backstop pool receives a cut of the swap fees.\n\n" + "The backstop pool takes most of the risk of a set of swap pools\nbacked by it. Whenever a swap pool is low on reserves and a LPer\nwants to withdraw some liquidity, they can conduct an insurance\nwithdrawal (burn swap pool shares, reimbursed in backstop liquidity)\nto avoid paying a high slippage.\nThe backstop pool owns all excess liquidity in its swap pools,\nbut is also liable for potential liquidity gaps.\nIn return, the backstop pool receives a cut of the swap fees." ], + "environment": { + "accountId": { + "displayName": ["AccountId"], + "type": 2 + }, + "balance": { + "displayName": ["Balance"], + "type": 10 + }, + "blockNumber": { + "displayName": ["BlockNumber"], + "type": 11 + }, + "chainExtension": { + "displayName": [], + "type": 0 + }, + "hash": { + "displayName": ["Hash"], + "type": 12 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": ["Timestamp"], + "type": 11 + } + }, "events": [ { "args": [ @@ -68,7 +97,11 @@ "indexed": true, "label": "from", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -77,7 +110,11 @@ "indexed": true, "label": "to", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -86,7 +123,7 @@ "indexed": false, "label": "value", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } @@ -101,7 +138,11 @@ "indexed": true, "label": "owner", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -110,7 +151,11 @@ "indexed": true, "label": "spender", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -119,7 +164,7 @@ "indexed": false, "label": "value", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } @@ -134,7 +179,11 @@ "indexed": false, "label": "account", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } } @@ -149,7 +198,11 @@ "indexed": false, "label": "account", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } } @@ -164,7 +217,11 @@ "indexed": true, "label": "previousOwner", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -173,7 +230,11 @@ "indexed": true, "label": "newOwner", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } } @@ -188,7 +249,11 @@ "indexed": true, "label": "sender", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -197,7 +262,7 @@ "indexed": false, "label": "poolSharesMinted", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } }, @@ -206,12 +271,12 @@ "indexed": false, "label": "amountPrincipleDeposited", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], - "docs": ["emitted on every deposit\n\n"], + "docs": ["emitted on every deposit"], "label": "Mint" }, { @@ -221,7 +286,11 @@ "indexed": true, "label": "sender", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -230,7 +299,7 @@ "indexed": false, "label": "poolSharesBurned", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } }, @@ -239,13 +308,13 @@ "indexed": false, "label": "amountPrincipleWithdrawn", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], "docs": [ - "emitted on every withdrawal special case withdrawal using swap liquidiity: amountPrincipleWithdrawn = 0\n\n" + "emitted on every withdrawal special case withdrawal using swap liquidiity: amountPrincipleWithdrawn = 0" ], "label": "Burn" }, @@ -256,7 +325,11 @@ "indexed": true, "label": "owner", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -265,7 +338,11 @@ "indexed": false, "label": "swapPool", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -274,7 +351,7 @@ "indexed": false, "label": "amountSwapShares", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } }, @@ -283,7 +360,7 @@ "indexed": false, "label": "amountSwapTokens", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } }, @@ -292,13 +369,13 @@ "indexed": false, "label": "amountBackstopTokens", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], "docs": [ - "emitted when a swap pool LP withdraws from backstop pool\n\n" + "emitted when a swap pool LP withdraws from backstop pool" ], "label": "CoverSwapWithdrawal" }, @@ -309,7 +386,11 @@ "indexed": true, "label": "owner", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -318,7 +399,11 @@ "indexed": false, "label": "swapPool", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, @@ -327,7 +412,7 @@ "indexed": false, "label": "amountSwapTokens", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } }, @@ -336,24 +421,25 @@ "indexed": false, "label": "amountBackstopTokens", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], "docs": [ - "emitted when a backstop pool LP withdraws liquidity from swap pool\n\n" + "emitted when a backstop pool LP withdraws liquidity from swap pool" ], "label": "WithdrawSwapLiquidity" } ], "lang_error": { - "displayName": [], - "type": 0 + "displayName": ["SolidityError"], + "type": 15 }, "messages": [ { "args": [], + "default": false, "docs": [""], "label": "name", "mutates": false, @@ -366,6 +452,7 @@ }, { "args": [], + "default": false, "docs": [""], "label": "symbol", "mutates": false, @@ -378,24 +465,26 @@ }, { "args": [], + "default": false, "docs": [""], "label": "decimals", "mutates": false, "payable": false, "returnType": { - "displayName": ["u8"], + "displayName": ["uint8"], "type": 0 }, "selector": "0x313ce567" }, { "args": [], + "default": false, "docs": [""], "label": "totalSupply", "mutates": false, "payable": false, "returnType": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 }, "selector": "0x18160ddd" @@ -405,17 +494,22 @@ { "label": "account", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } } ], + "default": false, "docs": [""], "label": "balanceOf", "mutates": false, "payable": false, "returnType": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 }, "selector": "0x70a08231" @@ -425,18 +519,23 @@ { "label": "to", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "amount", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [""], "label": "transfer", "mutates": true, @@ -452,24 +551,33 @@ { "label": "owner", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "spender", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } } ], + "default": false, "docs": [""], "label": "allowance", "mutates": false, "payable": false, "returnType": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 }, "selector": "0xdd62ed3e" @@ -479,18 +587,23 @@ { "label": "spender", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "amount", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [""], "label": "approve", "mutates": true, @@ -506,25 +619,34 @@ { "label": "from", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "to", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "amount", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [""], "label": "transferFrom", "mutates": true, @@ -540,18 +662,23 @@ { "label": "spender", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "addedValue", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [""], "label": "increaseAllowance", "mutates": true, @@ -567,18 +694,23 @@ { "label": "spender", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "subtractedValue", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [""], "label": "decreaseAllowance", "mutates": true, @@ -591,6 +723,7 @@ }, { "args": [], + "default": false, "docs": [""], "label": "paused", "mutates": false, @@ -603,18 +736,20 @@ }, { "args": [], + "default": false, "docs": [""], "label": "owner", "mutates": false, "payable": false, "returnType": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": ["ink_primitives", "types", "AccountId"], "type": 2 }, "selector": "0x8da5cb5b" }, { "args": [], + "default": false, "docs": [""], "label": "renounceOwnership", "mutates": true, @@ -627,11 +762,16 @@ { "label": "newOwner", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } } ], + "default": false, "docs": [""], "label": "transferOwnership", "mutates": true, @@ -641,238 +781,285 @@ }, { "args": [], + "default": false, "docs": [""], "label": "poolCap", "mutates": false, "payable": false, "returnType": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 }, "selector": "0xb954dc57" }, { "args": [], - "docs": ["Returns the pooled token's address\n\n"], + "default": false, + "docs": ["Returns the pooled token's address"], "label": "asset", "mutates": false, "payable": false, "returnType": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": ["ink_primitives", "types", "AccountId"], "type": 2 }, "selector": "0x38d52e0f" }, { - "args": [ - { - "label": "_shares", - "type": { - "displayName": ["u256"], - "type": 3 - } - } - ], - "docs": [ - "Returns the worth of an amount of pool shares (LP tokens) in underlying principle\n\n" - ], - "label": "sharesTargetWorth", + "args": [], + "default": false, + "docs": ["Returns the decimals of the pool asset"], + "label": "assetDecimals", "mutates": false, "payable": false, "returnType": { - "displayName": ["u256"], - "type": 3 + "displayName": ["uint8"], + "type": 0 }, - "selector": "0xcc045745" + "selector": "0xc2d41601" }, { "args": [], + "default": false, "docs": [""], "label": "router", "mutates": false, "payable": false, "returnType": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": ["ink_primitives", "types", "AccountId"], "type": 2 }, "selector": "0xf887ea40" }, - { - "args": [], - "docs": [""], - "label": "slippageCurve", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["ink_env", "types", "AccountId"], - "type": 2 - }, - "selector": "0xebe26b9e" - }, - { - "args": [], - "docs": [""], - "label": "accumulatedSlippage", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["u256"], - "type": 3 - }, - "selector": "0xe4182b09" - }, { "args": [ { - "label": "_amount", + "label": "_maxTokens", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [ - "Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0\n\n" + "Set new upper limit of pool reserves. Will disable deposits when reached. Can always set to an amount < current reserves to temporarily restrict deposits." ], - "label": "deposit", + "label": "setPoolCap", "mutates": true, "payable": false, - "returnType": { - "displayName": ["BackstopPool", "deposit", "return_type"], - "type": 8 - }, - "selector": "0xb6b55f25" + "returnType": null, + "selector": "0xd835f535" }, { "args": [ { - "label": "_maxTokens", + "label": "_swapPool", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + }, + { + "label": "_insuranceFeeBps", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [ - "Set new upper limit of pool reserves. Will disable deposits when reached. Can always set to an amount < current reserves to temporarily restrict deposits.\n\n" + "Make this backstop pool cover another swap pool Beware: Adding a swap pool holding the same token as the backstop pool\ncan easily cause undesirable conditions and must be secured (i.e. long time lock)!" ], - "label": "setPoolCap", + "label": "addSwapPool", "mutates": true, "payable": false, "returnType": null, - "selector": "0xd835f535" + "selector": "0xabb26587" }, { "args": [ { - "label": "_shares", + "label": "_swapPool", "type": { - "displayName": ["u256"], - "type": 3 + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 } }, { - "label": "_minimumAmount", + "label": "_insuranceFeeBps", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], - "docs": [ - "Withdraws liquidity amount of asset ensuring minimum amount required Slippage is applied (withdrawal fee)\n\n" - ], - "label": "withdraw", + "default": false, + "docs": ["Change a swap pool's insurance withdrawal fee"], + "label": "setInsuranceFee", "mutates": true, "payable": false, + "returnType": null, + "selector": "0xc6a78196" + }, + { + "args": [ + { + "label": "_index", + "type": { + "displayName": ["uint256"], + "type": 3 + } + } + ], + "default": false, + "docs": ["enumerate swap pools backed by this backstop pool"], + "label": "getBackedPool", + "mutates": false, + "payable": false, "returnType": { - "displayName": ["BackstopPool", "withdraw", "return_type"], - "type": 9 + "displayName": ["ink_primitives", "types", "AccountId"], + "type": 2 }, - "selector": "0x441a3e70" + "selector": "0xa04345f2" + }, + { + "args": [], + "default": false, + "docs": ["get swap pool count backed by this backstop pool"], + "label": "getBackedPoolCount", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0x5fda8689" }, { "args": [ { "label": "_swapPool", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } - }, + } + ], + "default": false, + "docs": ["get insurance withdrawal fee for a given swap pool"], + "label": "getInsuranceFee", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0x504e0153" + }, + { + "args": [ { - "label": "_insuranceFeeBps", + "label": "_depositAmount", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [ - "Make this backstop pool cover another swap pool Beware: Adding a swap pool holding the same token as the backstop pool\ncan easily cause undesirable conditions and must be secured (i.e. long time lock)!\n\n" + "Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0" ], - "label": "addSwapPool", + "label": "deposit", "mutates": true, "payable": false, - "returnType": null, - "selector": "0xabb26587" + "returnType": { + "displayName": ["BackstopPool", "deposit", "return_type"], + "type": 8 + }, + "selector": "0xb6b55f25" }, { "args": [ { - "label": "_swapPool", + "label": "_sharesToBurn", "type": { - "displayName": ["ink_env", "types", "AccountId"], - "type": 2 + "displayName": ["uint256"], + "type": 3 } }, { - "label": "_insuranceFeeBps", + "label": "_minimumAmount", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], - "docs": ["Change a swap pool's insurance withdrawal fee\n\n"], - "label": "setInsuranceFee", + "default": false, + "docs": [ + "Withdraws liquidity amount of asset ensuring minimum amount required Slippage is applied (withdrawal fee)" + ], + "label": "withdraw", "mutates": true, "payable": false, - "returnType": null, - "selector": "0xc6a78196" + "returnType": { + "displayName": ["BackstopPool", "withdraw", "return_type"], + "type": 9 + }, + "selector": "0x441a3e70" }, { "args": [ { "label": "_swapPool", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "_shares", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } }, { "label": "_minAmount", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [ - "withdraw from a swap pool using backstop liquidity without slippage only possible if swap pool's coverage ratio < 100%\n\n" + "withdraw from a swap pool using backstop liquidity without slippage only possible if swap pool's coverage ratio < 100%" ], "label": "redeemSwapPoolShares", "mutates": true, "payable": false, "returnType": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 }, "selector": "0x6e7e91fd" @@ -882,120 +1069,79 @@ { "label": "_swapPool", "type": { - "displayName": ["ink_env", "types", "AccountId"], + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], "type": 2 } }, { "label": "_shares", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } }, { "label": "_minAmount", "type": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 } } ], + "default": false, "docs": [ - "withdraw from backstop pool, but receive excess liquidity\nof a swap pool without slippage, instead of backstop liquidity\n\n" + "withdraw from backstop pool, but receive excess liquidity\nof a swap pool without slippage, instead of backstop liquidity" ], "label": "withdrawExcessSwapLiquidity", "mutates": true, "payable": false, "returnType": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 }, "selector": "0xcaf8c105" }, { "args": [], - "docs": ["returns pool coverage ratio\n\n"], - "label": "coverage", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["BackstopPool", "coverage", "return_type"], - "type": 10 - }, - "selector": "0xee8f6a0e" - }, - { - "args": [ - { - "label": "_index", - "type": { - "displayName": ["u256"], - "type": 3 - } - } - ], + "default": false, "docs": [ - "enumerate swap pools backed by this backstop pool\n\n" + "return worth of the whole backstop pool in `asset()`, incl. all\nswap pools' excess liquidity and the backstop pool's liabilities" ], - "label": "getBackedPool", + "label": "getTotalPoolWorth", "mutates": false, "payable": false, "returnType": { - "displayName": ["ink_env", "types", "AccountId"], - "type": 2 + "displayName": ["int256"], + "type": 7 }, - "selector": "0xa04345f2" - }, - { - "args": [], - "docs": [ - "get swap pool count backed by this backstop pool\n\n" - ], - "label": "getBackedPoolCount", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["u256"], - "type": 3 - }, - "selector": "0x5fda8689" + "selector": "0x18ba24c4" }, { "args": [ { - "label": "_swapPool", + "label": "_sharesToBurn", "type": { - "displayName": ["ink_env", "types", "AccountId"], - "type": 2 + "displayName": ["uint256"], + "type": 3 } } ], + "default": false, "docs": [ - "get insurance withdrawal fee for a given swap pool\n\n" + "Returns the worth of an amount of pool shares (LP tokens) in underlying principle" ], - "label": "getInsuranceFee", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["u256"], - "type": 3 - }, - "selector": "0x504e0153" - }, - { - "args": [], - "docs": [ - "return worth of the whole backstop pool in `asset()`, incl. all\nswap pools' excess liquidity and the backstop pool's liabilities\n\n" - ], - "label": "getTotalPoolWorth", + "label": "sharesTargetWorth", "mutates": false, "payable": false, "returnType": { - "displayName": ["u256"], + "displayName": ["uint256"], "type": 3 }, - "selector": "0x18ba24c4" + "selector": "0xcc045745" } ] }, @@ -1154,13 +1300,13 @@ "layout": { "leaf": { "key": "0x00000009", - "ty": 3 + "ty": 0 } }, "root_key": "0x00000009" } }, - "name": "poolCap" + "name": "poolAssetDecimals" }, { "layout": { @@ -1174,21 +1320,7 @@ "root_key": "0x0000000a" } }, - "name": "totalLiabilities" - }, - { - "layout": { - "root": { - "layout": { - "leaf": { - "key": "0x0000000b", - "ty": 3 - } - }, - "root_key": "0x0000000b" - } - }, - "name": "poolAssetMantissa" + "name": "poolCap" }, { "layout": { @@ -1199,7 +1331,7 @@ { "layout": { "leaf": { - "key": "0x0000000c", + "key": "0x0000000b", "ty": 1 } }, @@ -1209,59 +1341,21 @@ "name": "AccountId" } }, - "root_key": "0x0000000c" + "root_key": "0x0000000b" } }, "name": "router" }, - { - "layout": { - "root": { - "layout": { - "struct": { - "fields": [ - { - "layout": { - "leaf": { - "key": "0x0000000d", - "ty": 1 - } - }, - "name": "" - } - ], - "name": "AccountId" - } - }, - "root_key": "0x0000000d" - } - }, - "name": "slippageCurve" - }, { "layout": { "root": { "layout": { "leaf": { - "key": "0x0000000e", - "ty": 3 - } - }, - "root_key": "0x0000000e" - } - }, - "name": "accumulatedSlippage" - }, - { - "layout": { - "root": { - "layout": { - "leaf": { - "key": "0x0000000f", + "key": "0x0000000c", "ty": 6 } }, - "root_key": "0x0000000f" + "root_key": "0x0000000c" } }, "name": "swapPools" @@ -1271,11 +1365,11 @@ "root": { "layout": { "leaf": { - "key": "0x00000010", + "key": "0x0000000d", "ty": 3 } }, - "root_key": "0x00000010" + "root_key": "0x0000000d" } }, "name": "swapPoolInsuranceFeeBps" @@ -1285,11 +1379,11 @@ "root": { "layout": { "leaf": { - "key": "0x00000011", + "key": "0x0000000e", "ty": 4 } }, - "root_key": "0x00000011" + "root_key": "0x0000000e" } }, "name": "swapPoolCovered" @@ -1305,7 +1399,7 @@ "def": { "primitive": "u8" }, - "path": ["u8"] + "path": ["uint8"] } }, { @@ -1331,7 +1425,7 @@ ] } }, - "path": ["ink_env", "types", "AccountId"] + "path": ["ink_primitives", "types", "AccountId"] } }, { @@ -1340,7 +1434,7 @@ "def": { "primitive": "u256" }, - "path": ["u256"] + "path": ["uint256"] } }, { @@ -1377,7 +1471,7 @@ "def": { "primitive": "i256" }, - "path": ["i256"] + "path": ["int256"] } }, { @@ -1402,9 +1496,93 @@ "id": 10, "type": { "def": { - "tuple": [3, 3] + "primitive": "u128" + }, + "path": ["uint128"] + } + }, + { + "id": 11, + "type": { + "def": { + "primitive": "u64" + }, + "path": ["uint64"] + } + }, + { + "id": 12, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 1 + } + ] + } + }, + "path": ["ink_primitives", "types", "Hash"] + } + }, + { + "id": 13, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 5 + } + ] + } + }, + "path": ["0x08c379a0"] + } + }, + { + "id": 14, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 3 + } + ] + } + }, + "path": ["0x4e487b71"] + } + }, + { + "id": 15, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 13 + } + ], + "index": 0, + "name": "Error" + }, + { + "fields": [ + { + "type": 14 + } + ], + "index": 1, + "name": "Panic" + } + ] + } }, - "path": ["BackstopPool", "coverage", "return_type"] + "path": ["SolidityError"] } } ], diff --git a/nabla-abi/erc20.json b/nabla-abi/erc20.json index fb66a854..c908ffe9 100644 --- a/nabla-abi/erc20.json +++ b/nabla-abi/erc20.json @@ -1,12 +1,12 @@ { "contract": { "authors": ["unknown"], - "name": "TestableERC20Wrapper", + "name": "ERC20Wrapper", "version": "0.0.1" }, "source": { "compiler": "solang 0.3.2", - "hash": "0xcb7e8effdd0165c396793be92cac69d3a78f35d496a4d9a9423e84aac20c5eb4", + "hash": "0xd070e8f0df66f4f13a8ee42d5bf90220b1867883444c8f73f400f8c57ae2c9cd", "language": "Solidity 0.3.2" }, "spec": { @@ -181,62 +181,6 @@ ], "docs": [""], "label": "Approval" - }, - { - "args": [ - { - "docs": [], - "indexed": true, - "label": "to", - "type": { - "displayName": [ - "ink_primitives", - "types", - "AccountId" - ], - "type": 6 - } - }, - { - "docs": [], - "indexed": false, - "label": "value", - "type": { - "displayName": ["uint256"], - "type": 5 - } - } - ], - "docs": [""], - "label": "Mint" - }, - { - "args": [ - { - "docs": [], - "indexed": true, - "label": "from", - "type": { - "displayName": [ - "ink_primitives", - "types", - "AccountId" - ], - "type": 6 - } - }, - { - "docs": [], - "indexed": false, - "label": "value", - "type": { - "displayName": ["uint256"], - "type": 5 - } - } - ], - "docs": [""], - "label": "Burn" } ], "lang_error": { @@ -288,7 +232,7 @@ "default": false, "docs": [""], "label": "totalSupply", - "mutates": true, + "mutates": false, "payable": false, "returnType": { "displayName": ["uint256"], @@ -313,7 +257,7 @@ "default": false, "docs": [""], "label": "balanceOf", - "mutates": true, + "mutates": false, "payable": false, "returnType": { "displayName": ["uint256"], @@ -381,7 +325,7 @@ "default": false, "docs": [""], "label": "allowance", - "mutates": true, + "mutates": false, "payable": false, "returnType": { "displayName": ["uint256"], @@ -463,70 +407,6 @@ "type": 7 }, "selector": "0x23b872dd" - }, - { - "args": [ - { - "label": "_to", - "type": { - "displayName": [ - "ink_primitives", - "types", - "AccountId" - ], - "type": 6 - } - }, - { - "label": "_amount", - "type": { - "displayName": ["uint256"], - "type": 5 - } - } - ], - "default": false, - "docs": [""], - "label": "mint", - "mutates": true, - "payable": false, - "returnType": { - "displayName": ["bool"], - "type": 7 - }, - "selector": "0x40c10f19" - }, - { - "args": [ - { - "label": "_from", - "type": { - "displayName": [ - "ink_primitives", - "types", - "AccountId" - ], - "type": 6 - } - }, - { - "label": "_amount", - "type": { - "displayName": ["uint256"], - "type": 5 - } - } - ], - "default": false, - "docs": [""], - "label": "burn", - "mutates": true, - "payable": false, - "returnType": { - "displayName": ["bool"], - "type": 7 - }, - "selector": "0x9dc29fac" } ] }, @@ -632,7 +512,7 @@ "name": "_issuer" } ], - "name": "TestableERC20Wrapper" + "name": "ERC20Wrapper" } }, "types": [ diff --git a/nabla-abi/router.json b/nabla-abi/router.json index eec3ad4e..474d76d2 100644 --- a/nabla-abi/router.json +++ b/nabla-abi/router.json @@ -6,7 +6,7 @@ }, "source": { "compiler": "solang 0.3.2", - "hash": "0x6e7bac057718ec67cf2b2995370248e5bfb03fc38a29127a51dbf4ccf12e08ca", + "hash": "0xc3a4799cb3feb885864b7bda2b7340893d52fc4f096024e42c5c59319e9cf4ed", "language": "Solidity 0.3.2" }, "spec": { @@ -295,7 +295,7 @@ { "args": [ { - "label": "", + "label": "assetId", "type": { "displayName": [ "ink_primitives", @@ -320,7 +320,7 @@ { "args": [ { - "label": "", + "label": "assetId", "type": { "displayName": [ "ink_primitives", diff --git a/nabla-abi/swap.json b/nabla-abi/swap.json index c1f8c678..fc4b1991 100644 --- a/nabla-abi/swap.json +++ b/nabla-abi/swap.json @@ -1,13 +1,13 @@ { "contract": { "authors": ["unknown"], - "description": "Swap pool contract. May or may not be covered by a backstop pool. Conceptionally, there are two ways to temporarily disable a pool:\nThe owner can either pause the pool, disabling deposits, swaps & backstop,\nor the owner can set the pool cap to zero which only prevents deposits.\nThe former is for security incidents, the latter for phasing out a pool.", + "description": "Swap pool contract. May or may not be covered by a backstop pool. Conceptionally, there are two ways to temporarily disable a pool: The owner can either pause the pool, disabling deposits, swaps & backstop, or the owner can set the pool cap to zero which only prevents deposits. The former is for security incidents, the latter for phasing out a pool.", "name": "SwapPool", "version": "0.0.1" }, "source": { "compiler": "solang 0.3.2", - "hash": "0x4878e478a0e56c4febd690a37624ba0fb4b0c0ea8b3e6594519a228b7113e4bb", + "hash": "0x480a1345d46a94f8d4a41c5f443c00de2f6d784e8ae1ebc3ea8a8a585990872a", "language": "Solidity 0.3.2" }, "spec": { @@ -93,7 +93,7 @@ } ], "docs": [ - "Swap pool contract. May or may not be covered by a backstop pool. Conceptionally, there are two ways to temporarily disable a pool:\nThe owner can either pause the pool, disabling deposits, swaps & backstop,\nor the owner can set the pool cap to zero which only prevents deposits.\nThe former is for security incidents, the latter for phasing out a pool." + "Swap pool contract. May or may not be covered by a backstop pool. Conceptionally, there are two ways to temporarily disable a pool: The owner can either pause the pool, disabling deposits, swaps & backstop, or the owner can set the pool cap to zero which only prevents deposits. The former is for security incidents, the latter for phasing out a pool." ], "environment": { "accountId": { @@ -790,18 +790,57 @@ }, "selector": "0x38d52e0f" }, + { + "args": [], + "default": false, + "docs": ["Returns the decimals of the pool asset"], + "label": "assetDecimals", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint8"], + "type": 0 + }, + "selector": "0xc2d41601" + }, + { + "args": [], + "default": false, + "docs": [""], + "label": "totalLiabilities", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0xf73579a9" + }, { "args": [], "default": false, "docs": [""], - "label": "accumulatedSlippage", + "label": "reserve", "mutates": false, "payable": false, "returnType": { "displayName": ["uint256"], "type": 3 }, - "selector": "0xe4182b09" + "selector": "0xcd3293de" + }, + { + "args": [], + "default": false, + "docs": [""], + "label": "reserveWithSlippage", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0x0b09d91e" }, { "args": [], @@ -868,29 +907,6 @@ }, "selector": "0xebe26b9e" }, - { - "args": [ - { - "label": "_amount", - "type": { - "displayName": ["uint256"], - "type": 3 - } - } - ], - "default": false, - "docs": [ - "Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0" - ], - "label": "deposit", - "mutates": true, - "payable": false, - "returnType": { - "displayName": ["SwapPool", "deposit", "return_type"], - "type": 9 - }, - "selector": "0xb6b55f25" - }, { "args": [ { @@ -965,10 +981,46 @@ "returnType": null, "selector": "0xeb43434e" }, + { + "args": [], + "default": false, + "docs": ["Return the configured swap fees for this pool"], + "label": "swapFees", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["SwapPool", "swapFees", "return_type"], + "type": 8 + }, + "selector": "0xb9ccf21d" + }, { "args": [ { - "label": "_shares", + "label": "_depositAmount", + "type": { + "displayName": ["uint256"], + "type": 3 + } + } + ], + "default": false, + "docs": [ + "Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0" + ], + "label": "deposit", + "mutates": true, + "payable": false, + "returnType": { + "displayName": ["SwapPool", "deposit", "return_type"], + "type": 10 + }, + "selector": "0xb6b55f25" + }, + { + "args": [ + { + "label": "_sharesToBurn", "type": { "displayName": ["uint256"], "type": 3 @@ -991,7 +1043,7 @@ "payable": false, "returnType": { "displayName": ["SwapPool", "withdraw", "return_type"], - "type": 10 + "type": 11 }, "selector": "0x441a3e70" }, @@ -1009,7 +1061,7 @@ } }, { - "label": "_shares", + "label": "_sharesToBurn", "type": { "displayName": ["uint256"], "type": 3 @@ -1057,7 +1109,10 @@ "label": "backstopDrain", "mutates": true, "payable": false, - "returnType": null, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, "selector": "0xc2cb15de" }, { @@ -1083,6 +1138,29 @@ }, "selector": "0x4d8ea83f" }, + { + "args": [ + { + "label": "_amount", + "type": { + "displayName": ["uint256"], + "type": 3 + } + } + ], + "default": false, + "docs": [ + "Get a quote for the effective amount of tokens for a swap into" + ], + "label": "quoteSwapInto", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0x3c945248" + }, { "args": [ { @@ -1106,6 +1184,29 @@ }, "selector": "0x5f79d44f" }, + { + "args": [ + { + "label": "_amount", + "type": { + "displayName": ["uint256"], + "type": 3 + } + } + ], + "default": false, + "docs": [ + "Get a quote for the effective amount of tokens, incl. slippage and fees" + ], + "label": "quoteSwapOut", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0x8735c246" + }, { "args": [], "default": false, @@ -1135,10 +1236,25 @@ "payable": false, "returnType": { "displayName": ["SwapPool", "coverage", "return_type"], - "type": 11 + "type": 12 }, "selector": "0xee8f6a0e" }, + { + "args": [], + "default": false, + "docs": [ + "Computes the excess liquidity that forms that valuation of the backstop pool is defined as b + C - B - L where - b is reserve - C is the amount of pool tokens in the pool - B is reserveWithSlippage - L is totalLiabilities" + ], + "label": "getExcessLiquidity", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["int256"], + "type": 9 + }, + "selector": "0xace0f0d5" + }, { "args": [ { @@ -1169,53 +1285,7 @@ { "args": [ { - "label": "_amount", - "type": { - "displayName": ["uint256"], - "type": 3 - } - } - ], - "default": false, - "docs": [ - "Get a quote for the effective amount of tokens, incl. slippage and fees" - ], - "label": "quoteSwapInto", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["uint256"], - "type": 3 - }, - "selector": "0x3c945248" - }, - { - "args": [ - { - "label": "_amount", - "type": { - "displayName": ["uint256"], - "type": 3 - } - } - ], - "default": false, - "docs": [ - "Get a quote for the effective amount of tokens, incl. slippage and fees" - ], - "label": "quoteSwapOut", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["uint256"], - "type": 3 - }, - "selector": "0x8735c246" - }, - { - "args": [ - { - "label": "_shares", + "label": "_sharesToBurn", "type": { "displayName": ["uint256"], "type": 3 @@ -1234,19 +1304,6 @@ "type": 3 }, "selector": "0xcc045745" - }, - { - "args": [], - "default": false, - "docs": ["Return the configured swap fees for this pool"], - "label": "swapFees", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["SwapPool", "swapFees", "return_type"], - "type": 12 - }, - "selector": "0xb9ccf21d" } ] }, @@ -1405,13 +1462,13 @@ "layout": { "leaf": { "key": "0x00000009", - "ty": 3 + "ty": 0 } }, "root_key": "0x00000009" } }, - "name": "poolCap" + "name": "poolAssetDecimals" }, { "layout": { @@ -1425,7 +1482,7 @@ "root_key": "0x0000000a" } }, - "name": "accumulatedSlippage" + "name": "poolCap" }, { "layout": { @@ -1439,6 +1496,48 @@ "root_key": "0x0000000b" } }, + "name": "totalLiabilities" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0x0000000c", + "ty": 3 + } + }, + "root_key": "0x0000000c" + } + }, + "name": "reserve" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0x0000000d", + "ty": 3 + } + }, + "root_key": "0x0000000d" + } + }, + "name": "reserveWithSlippage" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0x0000000e", + "ty": 3 + } + }, + "root_key": "0x0000000e" + } + }, "name": "insuranceWithdrawalTimelock" }, { @@ -1450,7 +1549,7 @@ { "layout": { "leaf": { - "key": "0x0000000c", + "key": "0x0000000f", "ty": 1 } }, @@ -1460,7 +1559,7 @@ "name": "AccountId" } }, - "root_key": "0x0000000c" + "root_key": "0x0000000f" } }, "name": "protocolTreasury" @@ -1474,7 +1573,7 @@ { "layout": { "leaf": { - "key": "0x0000000d", + "key": "0x00000010", "ty": 1 } }, @@ -1484,7 +1583,7 @@ "name": "AccountId" } }, - "root_key": "0x0000000d" + "root_key": "0x00000010" } }, "name": "backstop" @@ -1498,7 +1597,7 @@ { "layout": { "leaf": { - "key": "0x0000000e", + "key": "0x00000011", "ty": 1 } }, @@ -1508,7 +1607,7 @@ "name": "AccountId" } }, - "root_key": "0x0000000e" + "root_key": "0x00000011" } }, "name": "router" @@ -1522,7 +1621,7 @@ { "layout": { "leaf": { - "key": "0x0000000f", + "key": "0x00000012", "ty": 1 } }, @@ -1532,7 +1631,7 @@ "name": "AccountId" } }, - "root_key": "0x0000000f" + "root_key": "0x00000012" } }, "name": "slippageCurve" @@ -1542,11 +1641,11 @@ "root": { "layout": { "leaf": { - "key": "0x00000010", + "key": "0x00000013", "ty": 3 } }, - "root_key": "0x00000010" + "root_key": "0x00000013" } }, "name": "latestDepositAtBlockNo" @@ -1560,7 +1659,7 @@ { "layout": { "leaf": { - "key": "0x00000011", + "key": "0x00000014", "ty": 6 } }, @@ -1569,7 +1668,7 @@ { "layout": { "leaf": { - "key": "0x00000011", + "key": "0x00000014", "ty": 6 } }, @@ -1578,7 +1677,7 @@ { "layout": { "leaf": { - "key": "0x00000011", + "key": "0x00000014", "ty": 6 } }, @@ -1588,24 +1687,10 @@ "name": "SwapFees" } }, - "root_key": "0x00000011" - } - }, - "name": "swapFeeConfig" - }, - { - "layout": { - "root": { - "layout": { - "leaf": { - "key": "0x00000014", - "ty": 3 - } - }, "root_key": "0x00000014" } }, - "name": "totalLiabilities" + "name": "swapFeeConfig" } ], "name": "SwapPool" @@ -1711,45 +1796,45 @@ "id": 8, "type": { "def": { - "primitive": "i256" + "tuple": [3, 3, 3] }, - "path": ["int256"] + "path": ["SwapPool", "swapFees", "return_type"] } }, { "id": 9, "type": { "def": { - "tuple": [3, 8] + "primitive": "i256" }, - "path": ["SwapPool", "deposit", "return_type"] + "path": ["int256"] } }, { "id": 10, "type": { "def": { - "tuple": [3, 8] + "tuple": [3, 9] }, - "path": ["SwapPool", "withdraw", "return_type"] + "path": ["SwapPool", "deposit", "return_type"] } }, { "id": 11, "type": { "def": { - "tuple": [3, 3] + "tuple": [3, 9] }, - "path": ["SwapPool", "coverage", "return_type"] + "path": ["SwapPool", "withdraw", "return_type"] } }, { "id": 12, "type": { "def": { - "tuple": [3, 3, 3] + "tuple": [3, 3] }, - "path": ["SwapPool", "swapFees", "return_type"] + "path": ["SwapPool", "coverage", "return_type"] } }, { diff --git a/package-lock.json b/package-lock.json index fff771f9..62e1dd8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,13 +8,13 @@ "dependencies": { "@polkadot/util": "11.1.1", "@subsquid/archive-registry": "3.3.0", - "@subsquid/evm-typegen": "^3.2.3", - "@subsquid/graphql-server": "4.3.1", - "@subsquid/ink-abi": "^3.0.1", - "@subsquid/ss58": "2.0.1", - "@subsquid/substrate-processor": "^7.2.1", - "@subsquid/typeorm-migration": "1.2.2", - "@subsquid/typeorm-store": "^1.2.4", + "@subsquid/evm-typegen": "^3.3.0", + "@subsquid/graphql-server": "4.5.0", + "@subsquid/ink-abi": "^3.0.2", + "@subsquid/ss58": "2.0.2", + "@subsquid/substrate-processor": "^8.1.1", + "@subsquid/typeorm-migration": "1.3.0", + "@subsquid/typeorm-store": "^1.2.6", "axios": "^1.6.2", "big.js": "^6.2.1", "dotenv": "^16.0.0", @@ -24,10 +24,10 @@ "typeorm": "^0.3.17" }, "devDependencies": { - "@subsquid/ink-typegen": "^3.0.2", - "@subsquid/substrate-metadata-explorer": "3.1.1", - "@subsquid/substrate-typegen": "^8.0.1", - "@subsquid/typeorm-codegen": "1.3.2", + "@subsquid/ink-typegen": "^3.0.3", + "@subsquid/substrate-metadata-explorer": "3.1.2", + "@subsquid/substrate-typegen": "^8.0.2", + "@subsquid/typeorm-codegen": "1.3.3", "@types/big.js": "^6.1.6", "@types/lodash": "^4.14.192", "@types/node": "18.11.18", @@ -206,11 +206,11 @@ "dev": true }, "node_modules/@graphql-tools/merge": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-9.0.0.tgz", - "integrity": "sha512-J7/xqjkGTTwOJmaJQJ2C+VDBDOWJL3lKrHJN4yMaRLAJH3PosB7GiPRaSDZdErs0+F77sH2MKs2haMMkywzx7Q==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-9.0.1.tgz", + "integrity": "sha512-hIEExWO9fjA6vzsVjJ3s0cCQ+Q/BEeMVJZtMXd7nbaVefVy0YDyYlEkeoYYNV3NVVvu1G9lr6DM1Qd0DGo9Caw==", "dependencies": { - "@graphql-tools/utils": "^10.0.0", + "@graphql-tools/utils": "^10.0.10", "tslib": "^2.4.0" }, "engines": { @@ -273,12 +273,12 @@ } }, "node_modules/@graphql-tools/schema": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-10.0.0.tgz", - "integrity": "sha512-kf3qOXMFcMs2f/S8Y3A8fm/2w+GaHAkfr3Gnhh2LOug/JgpY/ywgFVxO3jOeSpSEdoYcDKLcXVjMigNbY4AdQg==", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-10.0.2.tgz", + "integrity": "sha512-TbPsIZnWyDCLhgPGnDjt4hosiNU2mF/rNtSk5BVaXWnZqvKJ6gzJV4fcHcvhRIwtscDMW2/YTnK6dLVnk8pc4w==", "dependencies": { - "@graphql-tools/merge": "^9.0.0", - "@graphql-tools/utils": "^10.0.0", + "@graphql-tools/merge": "^9.0.1", + "@graphql-tools/utils": "^10.0.10", "tslib": "^2.4.0", "value-or-promise": "^1.0.12" }, @@ -290,9 +290,9 @@ } }, "node_modules/@graphql-tools/utils": { - "version": "10.0.8", - "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-10.0.8.tgz", - "integrity": "sha512-yjyA8ycSa1WRlJqyX/aLqXeE5DvF/H02+zXMUFnCzIDrj0UvLMUrxhmVFnMK0Q2n3bh4uuTeY3621m5za9ovXw==", + "version": "10.0.13", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-10.0.13.tgz", + "integrity": "sha512-fMILwGr5Dm2zefNItjQ6C2rauigklv69LIwppccICuGTnGaOp3DspLt/6Lxj72cbg5d9z60Sr+Egco3CJKLsNg==", "dependencies": { "@graphql-typed-document-node/core": "^3.1.1", "cross-inspect": "1.0.0", @@ -497,35 +497,35 @@ } }, "node_modules/@subsquid/evm-typegen": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/@subsquid/evm-typegen/-/evm-typegen-3.2.3.tgz", - "integrity": "sha512-9F0ZqkPEashuZoP8Phi03AP5viBKCgSurXtQscn+t4RZhBBcvcuEFdel5uNnusiH4KaMm7zsN3ypHj2E3QQyVA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@subsquid/evm-typegen/-/evm-typegen-3.3.0.tgz", + "integrity": "sha512-xSBa4B5dsvcazXZk2ufzsF94Hz/dcOkwT8zRs2kTcaozLAfI11SasvjaD9ClhqYDr8z7kc/xEgu2Gle0hLRvtg==", "dependencies": { - "@subsquid/http-client": "^1.3.1", - "@subsquid/logger": "^1.3.1", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-code-printer": "^1.2.1", - "@subsquid/util-internal-commander": "^1.3.1", - "commander": "^11.0.0" + "@subsquid/http-client": "^1.3.2", + "@subsquid/logger": "^1.3.2", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-code-printer": "^1.2.2", + "@subsquid/util-internal-commander": "^1.3.2", + "commander": "^11.1.0" }, "bin": { "squid-evm-typegen": "bin/run.js" }, "peerDependencies": { - "ethers": "^6.7.1" + "ethers": "^6.9.0" } }, "node_modules/@subsquid/evm-typegen/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/evm-typegen/node_modules/@subsquid/util-internal-commander": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-commander/-/util-internal-commander-1.3.1.tgz", - "integrity": "sha512-KeGsOghBU20tM1BzqryOf3MKvrDFSfPuhnl9LhhEC00ysp8rRPyejlw6jIJhO2NRJ+oaUi5jHRdf64/o21N7Lw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-commander/-/util-internal-commander-1.3.2.tgz", + "integrity": "sha512-9/1vI1dmGQMp5wjN6hb94VCnSosT+caob33tAesFaIdqLzqQlDtlTSRq1TFFossAgtsEJFi7GiQ8i31L/gaxSQ==", "peerDependencies": { - "commander": "^11.0.0" + "commander": "^11.1.0" } }, "node_modules/@subsquid/evm-typegen/node_modules/commander": { @@ -542,31 +542,32 @@ "integrity": "sha512-C89mus6IXnNi0xMQrZqUFBZwLj8tbuq9lye8Gq/lHmmERAUpi6UsWEyLdJLx2mneZzF3JtY8eNiiZ16jmjtvfw==" }, "node_modules/@subsquid/graphql-server": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/@subsquid/graphql-server/-/graphql-server-4.3.1.tgz", - "integrity": "sha512-EEZXaZf3TSK0JD+kcBgr+ENf2WOAjb7EREQP28+9NRWQhtn1s1w3XQNMjjurfyeb5Us/pRODAmfl8jOcXj3CAQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@subsquid/graphql-server/-/graphql-server-4.5.0.tgz", + "integrity": "sha512-SKCq6qF8FGrsrzFpjLzyDf3Cbcp4e8Z2M+t6Er3en7WLY3jZtdEGf3HbfCH6ukhQoJ72lUSNsESdwEoazOslRA==", "dependencies": { "@apollo/utils.keyvadapter": "~1.1.2", "@apollo/utils.keyvaluecache": "~1.0.2", - "@graphql-tools/merge": "^9.0.0", - "@graphql-tools/schema": "^10.0.0", - "@graphql-tools/utils": "^10.0.6", + "@graphql-tools/merge": "^9.0.1", + "@graphql-tools/schema": "^10.0.2", + "@graphql-tools/utils": "^10.0.11", "@keyv/redis": "~2.5.8", - "@subsquid/logger": "^1.3.1", - "@subsquid/openreader": "^4.4.1", - "@subsquid/typeorm-config": "^3.3.1", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-commander": "^1.3.1", - "@subsquid/util-internal-http-server": "^1.2.1", - "apollo-server-core": "^3.12.1", - "apollo-server-express": "^3.12.1", + "@subsquid/logger": "^1.3.2", + "@subsquid/openreader": "^4.5.0", + "@subsquid/typeorm-config": "^4.1.0", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-commander": "^1.3.2", + "@subsquid/util-internal-http-server": "^1.2.2", + "@subsquid/util-internal-ts-node": "^0.0.0", + "apollo-server-core": "^3.13.0", + "apollo-server-express": "^3.13.0", "apollo-server-plugin-response-cache": "~3.7.1", - "commander": "^11.0.0", + "commander": "^11.1.0", "dotenv": "^16.3.1", "express": "^4.18.2", "graphql": "^15.8.0", - "graphql-ws": "^5.14.1", - "keyv": "~4.5.3", + "graphql-ws": "^5.14.2", + "keyv": "~4.5.4", "pg": "^8.11.3", "ws": "^8.14.2" }, @@ -595,16 +596,16 @@ } }, "node_modules/@subsquid/graphql-server/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/graphql-server/node_modules/@subsquid/util-internal-commander": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-commander/-/util-internal-commander-1.3.1.tgz", - "integrity": "sha512-KeGsOghBU20tM1BzqryOf3MKvrDFSfPuhnl9LhhEC00ysp8rRPyejlw6jIJhO2NRJ+oaUi5jHRdf64/o21N7Lw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-commander/-/util-internal-commander-1.3.2.tgz", + "integrity": "sha512-9/1vI1dmGQMp5wjN6hb94VCnSosT+caob33tAesFaIdqLzqQlDtlTSRq1TFFossAgtsEJFi7GiQ8i31L/gaxSQ==", "peerDependencies": { - "commander": "^11.0.0" + "commander": "^11.1.0" } }, "node_modules/@subsquid/graphql-server/node_modules/commander": { @@ -644,19 +645,19 @@ } }, "node_modules/@subsquid/http-client": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@subsquid/http-client/-/http-client-1.3.1.tgz", - "integrity": "sha512-ZBuYNW9IOvigvpntZvM0tzAY5Llr44NYswOzGwJpCjOnWF7EotzeJRMwDH0Zv5hXSMFvX3UBACP+PxmwDvma5A==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@subsquid/http-client/-/http-client-1.3.2.tgz", + "integrity": "sha512-N9fXB2TCYzzT4CNoTibpgk4lMFNU463/ZQcSstPPMIpZA9QdDjY+mNdjLTi8L+4DzimgjEbwYfLQX5aINYvkMA==", "dependencies": { - "@subsquid/logger": "^1.3.1", - "@subsquid/util-internal": "^2.5.2", + "@subsquid/logger": "^1.3.2", + "@subsquid/util-internal": "^3.0.0", "node-fetch": "^3.3.2" } }, "node_modules/@subsquid/http-client/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/http-client/node_modules/node-fetch": { "version": "3.3.2", @@ -676,47 +677,47 @@ } }, "node_modules/@subsquid/ink-abi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@subsquid/ink-abi/-/ink-abi-3.0.1.tgz", - "integrity": "sha512-KVylF+0M86nS9+GT9bcUdBkcs/yHXJBBULLs8NQpnaP/OQ6Ma/PzBENe4/ez3Kg0gMHjKJFIfNvbgqxflAj8Hw==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@subsquid/ink-abi/-/ink-abi-3.0.2.tgz", + "integrity": "sha512-uw79cNFa5Ds7OILwwPmbVknhPOqf45AAjYFK5L7cyb6QL69ksStXbcUrqDZiDNV6boanl7q4rO6Kq+5dJ8+NzQ==", "dependencies": { - "@subsquid/scale-codec": "^4.0.0", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-hex": "^1.2.1", + "@subsquid/scale-codec": "^4.0.1", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-hex": "^1.2.2", "ajv": "^8.12.0" }, "peerDependencies": { - "@subsquid/substrate-runtime": "^1.0.0" + "@subsquid/substrate-runtime": "^1.0.2" } }, "node_modules/@subsquid/ink-abi/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/ink-typegen": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@subsquid/ink-typegen/-/ink-typegen-3.0.2.tgz", - "integrity": "sha512-LPX3VX3mUOik+6RKS6ln3HwFJ/SCWq7QCaVf9TF7FLNrNy05jK+yv9KdJuOch+A/BhHYHreUb0mPaHZNirimiQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@subsquid/ink-typegen/-/ink-typegen-3.0.3.tgz", + "integrity": "sha512-XSYcjFcSLx0kan0o1cnHZS9IdOtgjEl00HBEXXbNYb3YxNlETjZongwx29zmemQV+n4uOrfmJHzfW6fFwyzTlQ==", "dev": true, "dependencies": { - "@subsquid/ink-abi": "^3.0.1", - "@subsquid/substrate-typegen": "^8.0.0", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-code-printer": "^1.2.1", - "commander": "^11.0.0" + "@subsquid/ink-abi": "^3.0.2", + "@subsquid/substrate-typegen": "^8.0.2", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-code-printer": "^1.2.2", + "commander": "^11.1.0" }, "bin": { "squid-ink-typegen": "bin/run.js" }, "peerDependencies": { - "@subsquid/substrate-runtime": "^1.0.0" + "@subsquid/substrate-runtime": "^1.0.2" } }, "node_modules/@subsquid/ink-typegen/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==", "dev": true }, "node_modules/@subsquid/ink-typegen/node_modules/commander": { @@ -729,36 +730,36 @@ } }, "node_modules/@subsquid/logger": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@subsquid/logger/-/logger-1.3.1.tgz", - "integrity": "sha512-OBhelb0HbhqSygq/IxEm9PPX8thQSDiCPV45UlCqWOoQ9UpiROiQLL+2nwt+HAHQq+LlHTzQmGXV43eabrTfwQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@subsquid/logger/-/logger-1.3.2.tgz", + "integrity": "sha512-5YPdeRu0WD9iBak+r3S8blBeg2uyliPUlmCjj/ZE6dpXmXsSN9T+ZYrNeDr9eAbRV7OXVI49lSfCuAGenFcYjQ==", "dependencies": { - "@subsquid/util-internal-hex": "^1.2.1", - "@subsquid/util-internal-json": "^1.2.1", + "@subsquid/util-internal-hex": "^1.2.2", + "@subsquid/util-internal-json": "^1.2.2", "supports-color": "^8.1.1" } }, "node_modules/@subsquid/openreader": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/@subsquid/openreader/-/openreader-4.4.1.tgz", - "integrity": "sha512-Z2M+scuoJx1H3U+KttIEjrSvZ+5K3ioNdWatUS42k9xgOIEMJzDCJM8ZxhqgP/fMTrR9RPjeFqjy6NBS0kgwtg==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@subsquid/openreader/-/openreader-4.5.0.tgz", + "integrity": "sha512-A07K1TM0YY2iZjJcY2qD0jXco1S7D00OfqAnN4tqxVtj4ddLJVZ3bLIAHn7r3P3JB4iT+3daBNTTa17vH1k2XA==", "dependencies": { - "@graphql-tools/merge": "^9.0.0", + "@graphql-tools/merge": "^9.0.1", "@subsquid/graphiql-console": "^0.3.0", - "@subsquid/logger": "^1.3.1", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-commander": "^1.3.1", - "@subsquid/util-internal-hex": "^1.2.1", - "@subsquid/util-internal-http-server": "^1.2.1", - "@subsquid/util-naming": "^1.2.1", - "apollo-server-core": "^3.12.1", - "apollo-server-express": "^3.12.1", - "commander": "^11.0.0", - "deep-equal": "^2.2.2", + "@subsquid/logger": "^1.3.2", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-commander": "^1.3.2", + "@subsquid/util-internal-hex": "^1.2.2", + "@subsquid/util-internal-http-server": "^1.2.2", + "@subsquid/util-naming": "^1.2.2", + "apollo-server-core": "^3.13.0", + "apollo-server-express": "^3.13.0", + "commander": "^11.1.0", + "deep-equal": "^2.2.3", "express": "^4.18.2", "graphql": "^15.8.0", - "graphql-parse-resolve-info": "^4.13.0", - "graphql-ws": "^5.14.1", + "graphql-parse-resolve-info": "^4.14.0", + "graphql-ws": "^5.14.2", "pg": "^8.11.3", "ws": "^8.14.2" }, @@ -775,16 +776,16 @@ } }, "node_modules/@subsquid/openreader/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/openreader/node_modules/@subsquid/util-internal-commander": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-commander/-/util-internal-commander-1.3.1.tgz", - "integrity": "sha512-KeGsOghBU20tM1BzqryOf3MKvrDFSfPuhnl9LhhEC00ysp8rRPyejlw6jIJhO2NRJ+oaUi5jHRdf64/o21N7Lw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-commander/-/util-internal-commander-1.3.2.tgz", + "integrity": "sha512-9/1vI1dmGQMp5wjN6hb94VCnSosT+caob33tAesFaIdqLzqQlDtlTSRq1TFFossAgtsEJFi7GiQ8i31L/gaxSQ==", "peerDependencies": { - "commander": "^11.0.0" + "commander": "^11.1.0" } }, "node_modules/@subsquid/openreader/node_modules/commander": { @@ -824,63 +825,126 @@ } }, "node_modules/@subsquid/rpc-client": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/@subsquid/rpc-client/-/rpc-client-4.4.2.tgz", - "integrity": "sha512-Zo/KuFNiwKblKCUDpXUNbeshxEpCX44CtBKbzr4f5zFNdwxuH7FjwFnZk4X5YZUVnbcTF6cmqhH5RwRkKBgPfQ==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@subsquid/rpc-client/-/rpc-client-4.6.0.tgz", + "integrity": "sha512-fVTsVOag6Ge7hRqV+st9p+E+BgQa5PPu1uJns5IXSrRtIuAuy++w0OsB3WNA+EC8DZarpllxi7I3snzJpis/xQ==", "dependencies": { - "@subsquid/http-client": "^1.3.1", - "@subsquid/logger": "^1.3.1", - "@subsquid/util-internal": "^2.5.2", + "@subsquid/http-client": "^1.3.2", + "@subsquid/logger": "^1.3.2", + "@subsquid/util-internal": "^3.0.0", "@subsquid/util-internal-binary-heap": "^1.0.0", - "@subsquid/util-internal-counters": "^1.3.1", + "@subsquid/util-internal-counters": "^1.3.2", "websocket": "^1.0.34" } }, "node_modules/@subsquid/rpc-client/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/scale-codec": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@subsquid/scale-codec/-/scale-codec-4.0.0.tgz", - "integrity": "sha512-aVqcy1KeQiYhL3lRLZJcRVuBOmh88zQKqEdxU/7gJCj/gvBF9+Isd16oE0xuA5xwlGcFHbRfUFSON5EP2Lv8Eg==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@subsquid/scale-codec/-/scale-codec-4.0.1.tgz", + "integrity": "sha512-H3mi5GIvlrvOSJVSYQRNnaiulSDktPF4TwUvquAgN86tN4kokyX8XcEM2Htrm1sVWRtMi7SgYpyVR5Yg5iPKUQ==", "dependencies": { - "@subsquid/util-internal-hex": "^1.2.1", - "@subsquid/util-internal-json": "^1.2.1" + "@subsquid/util-internal-hex": "^1.2.2", + "@subsquid/util-internal-json": "^1.2.2" } }, + "node_modules/@subsquid/scale-type-system": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@subsquid/scale-type-system/-/scale-type-system-1.0.2.tgz", + "integrity": "sha512-bZSUGO/Hfnf/+luZ8lWEsGqr9iIiQeaifmXEiOGBpr5Ace6H+pPY3lFmDTPWigoqt7VxrhRO0jvk5RLAyeBJvg==", + "peer": true, + "dependencies": { + "@subsquid/util-internal": "^3.0.0" + }, + "peerDependencies": { + "@subsquid/scale-codec": "^4.0.1" + } + }, + "node_modules/@subsquid/scale-type-system/node_modules/@subsquid/util-internal": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==", + "peer": true + }, "node_modules/@subsquid/ss58": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@subsquid/ss58/-/ss58-2.0.1.tgz", - "integrity": "sha512-VmVgR6E8cwpYiQtL+ZbdW0RCguNmwunbX4JYI08vHErxWdLhX4o6v9LClq3L9+5LcKgspzOci9DNt0xzR1keYQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@subsquid/ss58/-/ss58-2.0.2.tgz", + "integrity": "sha512-2chHMJ7jXvZzYQiXiA5MYYAVBobPcnQxWt3/jsiiZT6vWorjlVElXoQjZ0G/FKRHCcJ4GD10zDd8sG+7sPp2fw==", "dependencies": { - "@subsquid/ss58-codec": "^1.2.2", - "@subsquid/util-internal-hex": "^1.2.1" + "@subsquid/ss58-codec": "^1.2.3", + "@subsquid/util-internal-hex": "^1.2.2" } }, "node_modules/@subsquid/ss58-codec": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@subsquid/ss58-codec/-/ss58-codec-1.2.2.tgz", - "integrity": "sha512-hNYKWqfKd92l2xFSgSiSfK6dHLE/hwWWJ6FIlZ3mS/tgUsEUqTHJabqZ1p+pt0US9P8h+J4Dd58eujPI03peqA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@subsquid/ss58-codec/-/ss58-codec-1.2.3.tgz", + "integrity": "sha512-PFWGOYDVEa1F+u5NoH4pJcBRCe4vv6B0U4nvgmwTA+PShhVB8aC6TjZZmMOE8/BLEDjRIpT7avpz7VR7zI6H0A==", "dependencies": { "base-x": "^4.0.0", "blake2b": "^2.1.4" } }, + "node_modules/@subsquid/substrate-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@subsquid/substrate-data/-/substrate-data-4.0.1.tgz", + "integrity": "sha512-1eluGvrSiXuQZJdg9Ihtbem0Kl72Ahz54Nexi+UM2WviPmSn7XYA2k/OUBK9dD6KBIAFayN7r99S6YtDgJhrqA==", + "dependencies": { + "@subsquid/scale-codec": "^4.0.1", + "@subsquid/substrate-data-raw": "^1.1.0", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-hex": "^1.2.2", + "@subsquid/util-internal-ingest-tools": "^1.1.0", + "@subsquid/util-internal-range": "^0.1.0", + "@subsquid/util-xxhash": "^1.2.2", + "@substrate/calc": "^0.2.8", + "blake2b": "^2.1.4" + }, + "peerDependencies": { + "@subsquid/rpc-client": "^4.6.0", + "@subsquid/substrate-runtime": "^1.0.2" + } + }, + "node_modules/@subsquid/substrate-data-raw": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@subsquid/substrate-data-raw/-/substrate-data-raw-1.1.0.tgz", + "integrity": "sha512-wiFF2sE7enBSfr84voGdQ4o26nxB1lLF2PcuU7QJawebPWNtQCCcBfRCWZekaqhkF+Y/4uFpOI3krTFvqlo5rw==", + "dependencies": { + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-ingest-tools": "^1.1.0", + "@subsquid/util-internal-range": "^0.1.0", + "@subsquid/util-timeout": "^2.3.2" + }, + "peerDependencies": { + "@subsquid/logger": "^1.3.2", + "@subsquid/rpc-client": "^4.6.0" + } + }, + "node_modules/@subsquid/substrate-data-raw/node_modules/@subsquid/util-internal": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" + }, + "node_modules/@subsquid/substrate-data/node_modules/@subsquid/util-internal": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" + }, "node_modules/@subsquid/substrate-metadata-explorer": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@subsquid/substrate-metadata-explorer/-/substrate-metadata-explorer-3.1.1.tgz", - "integrity": "sha512-GzlgUMEIcJvtiEYXxPqC6onncbmPKoBdINuyQSNmU7hVVOn5MEJhXAj2kzOnTztCGhM8GnBDebmLf/f7RndgiQ==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@subsquid/substrate-metadata-explorer/-/substrate-metadata-explorer-3.1.2.tgz", + "integrity": "sha512-wITx+R5REa25uRFKF2fsWC3bOFOde80MEZrgfbjs5aAt4eNKHOL6s61g4xJRNIqXrRG20Drl/gLkBdMYSjnIgQ==", "dev": true, "dependencies": { - "@subsquid/logger": "^1.3.1", - "@subsquid/rpc-client": "^4.4.2", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-commander": "^1.3.1", - "@subsquid/util-internal-hex": "^1.2.1", - "@subsquid/util-internal-read-lines": "^1.2.1", - "commander": "^11.0.0" + "@subsquid/logger": "^1.3.2", + "@subsquid/rpc-client": "^4.5.0", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-commander": "^1.3.2", + "@subsquid/util-internal-hex": "^1.2.2", + "@subsquid/util-internal-read-lines": "^1.2.2", + "commander": "^11.1.0" }, "bin": { "squid-substrate-metadata-explorer": "bin/run.js", @@ -888,18 +952,18 @@ } }, "node_modules/@subsquid/substrate-metadata-explorer/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==", "dev": true }, "node_modules/@subsquid/substrate-metadata-explorer/node_modules/@subsquid/util-internal-commander": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-commander/-/util-internal-commander-1.3.1.tgz", - "integrity": "sha512-KeGsOghBU20tM1BzqryOf3MKvrDFSfPuhnl9LhhEC00ysp8rRPyejlw6jIJhO2NRJ+oaUi5jHRdf64/o21N7Lw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-commander/-/util-internal-commander-1.3.2.tgz", + "integrity": "sha512-9/1vI1dmGQMp5wjN6hb94VCnSosT+caob33tAesFaIdqLzqQlDtlTSRq1TFFossAgtsEJFi7GiQ8i31L/gaxSQ==", "dev": true, "peerDependencies": { - "commander": "^11.0.0" + "commander": "^11.1.0" } }, "node_modules/@subsquid/substrate-metadata-explorer/node_modules/commander": { @@ -912,141 +976,80 @@ } }, "node_modules/@subsquid/substrate-processor": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/substrate-processor/-/substrate-processor-7.2.1.tgz", - "integrity": "sha512-9T/wQIaDt4HfkioFQ8nGMc+/N/mEskiYFhQdvT0FYwdKxr3qbyvsbT2qoZfDS/i9J/d2y/39YKrtCMBKOwf65w==", - "dependencies": { - "@subsquid/http-client": "^1.3.1", - "@subsquid/logger": "^1.3.1", - "@subsquid/rpc-client": "^4.4.2", - "@subsquid/substrate-data": "^3.0.1", - "@subsquid/substrate-data-raw": "^0.1.0", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-archive-client": "^0.0.1", - "@subsquid/util-internal-hex": "^1.2.1", - "@subsquid/util-internal-json": "^1.2.1", - "@subsquid/util-internal-processor-tools": "^3.1.0" - }, - "peerDependencies": { - "@subsquid/substrate-runtime": "^1.0.1" - } - }, - "node_modules/@subsquid/substrate-processor/node_modules/@subsquid/substrate-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@subsquid/substrate-data/-/substrate-data-3.0.1.tgz", - "integrity": "sha512-zmZGtwYwNi50siU5k0r8YRXlJPNsls1E6y1N+Yv7driNdsolKhXdcHKLoRIaiXRlV/QGkuSh/vNaLxebxiL1TQ==", - "dependencies": { - "@subsquid/scale-codec": "^4.0.0", - "@subsquid/substrate-data-raw": "^0.1.0", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-hex": "^1.2.1", - "@subsquid/util-internal-ingest-tools": "^0.0.2", - "@subsquid/util-internal-range": "^0.0.1", - "@subsquid/util-xxhash": "^1.2.1", - "@substrate/calc": "^0.2.8", - "blake2b": "^2.1.4" - }, - "peerDependencies": { - "@subsquid/rpc-client": "^4.4.2", - "@subsquid/substrate-runtime": "^1.0.1" - } - }, - "node_modules/@subsquid/substrate-processor/node_modules/@subsquid/substrate-data-raw": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@subsquid/substrate-data-raw/-/substrate-data-raw-0.1.0.tgz", - "integrity": "sha512-0540hjZzUgeVjqy7UqKcTPKBsun2eisv9JR0ks3WDHPLabyWy4TolbE1WWqCo4B8wBmLEm5+vTL/BtM/AkHrYg==", - "dependencies": { - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-ingest-tools": "^0.0.2", - "@subsquid/util-internal-range": "^0.0.1" + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/@subsquid/substrate-processor/-/substrate-processor-8.1.1.tgz", + "integrity": "sha512-SB4rsNZDihzSy9PuVKi/KuoYhl/apnQaJAIAb7nBOYlk1kOzG3+jEEk3SxR53JYFuTelrwK/AY9lS4e+LwiDCg==", + "dependencies": { + "@subsquid/http-client": "^1.3.2", + "@subsquid/logger": "^1.3.2", + "@subsquid/rpc-client": "^4.6.0", + "@subsquid/substrate-data": "^4.0.0", + "@subsquid/substrate-data-raw": "^1.0.1", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-archive-client": "^0.1.0", + "@subsquid/util-internal-hex": "^1.2.2", + "@subsquid/util-internal-ingest-tools": "^1.1.0", + "@subsquid/util-internal-json": "^1.2.2", + "@subsquid/util-internal-processor-tools": "^4.0.0", + "@subsquid/util-internal-range": "^0.1.0" }, "peerDependencies": { - "@subsquid/rpc-client": "^4.4.2" + "@subsquid/substrate-runtime": "^1.0.2" } }, "node_modules/@subsquid/substrate-processor/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" - }, - "node_modules/@subsquid/substrate-processor/node_modules/@subsquid/util-internal-archive-client": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-archive-client/-/util-internal-archive-client-0.0.1.tgz", - "integrity": "sha512-Sr+m1vxAArPIdsjyKVOpjU57JlVujBpI8NEeHqeA6twSb40wasOLAeq775WyYFynucltNRSgIiwXBIo0t02D6g==", - "dependencies": { - "@subsquid/http-client": "^1.3.1", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-range": "^0.0.1" - }, - "peerDependencies": { - "@subsquid/logger": "^1.3.1" - }, - "peerDependenciesMeta": { - "@subsquid/logger": { - "optional": true - } - } + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/substrate-runtime": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@subsquid/substrate-runtime/-/substrate-runtime-1.0.1.tgz", - "integrity": "sha512-L7ln2EaIfl99uAbkz3Nw6oIXdpj2yfBk5qUyOJ/nOm5WHGBE3NKw0nIfgnC6EbbsNJKZZfJT0Tm+eRZZlUakug==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@subsquid/substrate-runtime/-/substrate-runtime-1.0.3.tgz", + "integrity": "sha512-3uNZqyHKzoMkSHQTZIJl1G7NiKyFl4cmDzVY3dU0o4VZhGNUAmR+HecT3WBkMMYye6uhDAeXsbVECa3ZnMM3gQ==", "peer": true, "dependencies": { - "@subsquid/scale-codec": "^4.0.0", - "@subsquid/scale-type-system": "^1.0.0", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-hex": "^1.2.1", - "@subsquid/util-naming": "^1.2.1", - "@subsquid/util-xxhash": "^1.2.1", + "@subsquid/scale-codec": "^4.0.1", + "@subsquid/scale-type-system": "^1.0.2", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-hex": "^1.2.2", + "@subsquid/util-naming": "^1.2.2", + "@subsquid/util-xxhash": "^1.2.2", "blake2b": "^2.1.4" } }, - "node_modules/@subsquid/substrate-runtime/node_modules/@subsquid/scale-type-system": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@subsquid/scale-type-system/-/scale-type-system-1.0.1.tgz", - "integrity": "sha512-CjY5nBzGrbRcOH//lOwNHbBjHtHD0t27SirdIAFre/Mp4fLIiv6gEkIgNYu+lwAjMvuFkLkcw7JGmwXvLNepNw==", - "peer": true, - "dependencies": { - "@subsquid/util-internal": "^2.5.2" - }, - "peerDependencies": { - "@subsquid/scale-codec": "^4.0.0" - } - }, "node_modules/@subsquid/substrate-runtime/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==", "peer": true }, "node_modules/@subsquid/substrate-typegen": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/@subsquid/substrate-typegen/-/substrate-typegen-8.0.1.tgz", - "integrity": "sha512-/Mx6ITDbVVjgPuhW3/JUvEDzN01hrz0lSmjTzX46L2JGamPeCxZfX/HdbwDUb0Ns7zn+Q3e1JOtQoRkC6MVEhA==", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@subsquid/substrate-typegen/-/substrate-typegen-8.0.2.tgz", + "integrity": "sha512-JraheRh2ZdM1BoVF79DjhU/BIifuIlwyo2/DmL0RuGaslk6F/VGJ0gWSTpCZr6A2F3hlNFzLvzeZPO/xgH/JMg==", "dev": true, "dependencies": { - "@subsquid/http-client": "^1.3.1", - "@subsquid/logger": "^1.3.1", - "@subsquid/substrate-metadata-explorer": "^3.1.1", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-code-printer": "^1.2.1", - "@subsquid/util-internal-config": "^2.2.1", - "@subsquid/util-internal-read-lines": "^1.2.1", - "@subsquid/util-naming": "^1.2.1", - "commander": "^11.0.0" + "@subsquid/http-client": "^1.3.2", + "@subsquid/logger": "^1.3.2", + "@subsquid/substrate-metadata-explorer": "^3.1.2", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-code-printer": "^1.2.2", + "@subsquid/util-internal-config": "^2.2.2", + "@subsquid/util-internal-read-lines": "^1.2.2", + "@subsquid/util-naming": "^1.2.2", + "commander": "^11.1.0" }, "bin": { "squid-substrate-typegen": "bin/run.js" }, "peerDependencies": { - "@subsquid/substrate-runtime": "^1.0.0" + "@subsquid/substrate-runtime": "^1.0.2" } }, "node_modules/@subsquid/substrate-typegen/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==", "dev": true }, "node_modules/@subsquid/substrate-typegen/node_modules/commander": { @@ -1059,25 +1062,25 @@ } }, "node_modules/@subsquid/typeorm-codegen": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@subsquid/typeorm-codegen/-/typeorm-codegen-1.3.2.tgz", - "integrity": "sha512-jSDrMjcCa1NiEQICFXHyYENEnjJxmFd2vmyiSXm+CTyqQRMJutqLcZFHx38CHwz15kyCxKK8whDYQglmLvx0cQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@subsquid/typeorm-codegen/-/typeorm-codegen-1.3.3.tgz", + "integrity": "sha512-6k1oRWnaBNX4GZX737dvZll925uZKt2or/oXNaQRnHAmrCISkIEz7dYkl6PFfppYuardch41FBSFmOQaovPCXw==", "dev": true, "dependencies": { - "@subsquid/openreader": "^4.4.1", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-code-printer": "^1.2.1", - "@subsquid/util-naming": "^1.2.1", - "commander": "^11.0.0" + "@subsquid/openreader": "^4.4.2", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-code-printer": "^1.2.2", + "@subsquid/util-naming": "^1.2.2", + "commander": "^11.1.0" }, "bin": { "squid-typeorm-codegen": "bin/run.js" } }, "node_modules/@subsquid/typeorm-codegen/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==", "dev": true }, "node_modules/@subsquid/typeorm-codegen/node_modules/commander": { @@ -1090,11 +1093,13 @@ } }, "node_modules/@subsquid/typeorm-config": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@subsquid/typeorm-config/-/typeorm-config-3.3.1.tgz", - "integrity": "sha512-d8n+GHAr05A1cQXBr+kbaU0WeSD7oQk+t7KwkGbC9hh80tkYiweKzQwS4+fJcJCbrpZe+B6mV8WY5eVR9ebZMw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@subsquid/typeorm-config/-/typeorm-config-4.1.0.tgz", + "integrity": "sha512-onZsHQIypCTRguOeec1Gmm+6EPlTg63QNE7Y74nrbBb4sabZtrK3K+EQJId4KIdk/kxA2Wi/g5H/VDNZNFSe9A==", "dependencies": { - "@subsquid/util-naming": "^1.2.1" + "@subsquid/logger": "^1.3.2", + "@subsquid/util-internal-ts-node": "^0.0.0", + "@subsquid/util-naming": "^1.2.2" }, "peerDependencies": { "typeorm": "^0.3.17" @@ -1106,14 +1111,15 @@ } }, "node_modules/@subsquid/typeorm-migration": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@subsquid/typeorm-migration/-/typeorm-migration-1.2.2.tgz", - "integrity": "sha512-G22Eh7AuPHjLB7C30XNT+fVe2bGYmYI2EB/8Sf5kYfS0yCKvev2YWJNcvkyD6eswv8HgrekwEoj3BKjR5wH6yg==", - "dependencies": { - "@subsquid/typeorm-config": "^3.3.1", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-code-printer": "^1.2.1", - "commander": "^11.0.0", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@subsquid/typeorm-migration/-/typeorm-migration-1.3.0.tgz", + "integrity": "sha512-+xyOvN5asKdSEUMjKRuuwLDaOSRBBCRc2LIVdsyv5nnXXcmtOShfQsHQNX9EdKD2xx4cH2bnD7ol3PY63Q2xQw==", + "dependencies": { + "@subsquid/typeorm-config": "^4.1.0", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-code-printer": "^1.2.2", + "@subsquid/util-internal-ts-node": "^0.0.0", + "commander": "^11.1.0", "dotenv": "^16.3.1" }, "bin": { @@ -1128,9 +1134,9 @@ } }, "node_modules/@subsquid/typeorm-migration/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/typeorm-migration/node_modules/commander": { "version": "11.1.0", @@ -1141,41 +1147,64 @@ } }, "node_modules/@subsquid/typeorm-store": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@subsquid/typeorm-store/-/typeorm-store-1.2.4.tgz", - "integrity": "sha512-fcHp9cHEe1T1tVjV125CLbNjs/NIQKFW8bdK/stDn9prxuuwfiAGKvpztU52dKVuyQCUFL+8YTtFt2y1i7ZEBA==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@subsquid/typeorm-store/-/typeorm-store-1.2.6.tgz", + "integrity": "sha512-fsQTEf9QUXny1qb3qEoH5U3aPYhOtN7fE+3K62w6qVK0h+/PJAtS0w16MeYtDlEQbzYud8ttmVSagV1A93qnRA==", "dependencies": { - "@subsquid/typeorm-config": "^3.3.1", - "@subsquid/util-internal": "^2.5.2" + "@subsquid/typeorm-config": "^4.0.0", + "@subsquid/util-internal": "^3.0.0" }, "peerDependencies": { "typeorm": "^0.3.17" } }, "node_modules/@subsquid/typeorm-store/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/util-internal": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-1.1.0.tgz", "integrity": "sha512-O6m666RDcWEw4vb3bmeNZKlAa1rGOHQvS0nhZFTBXnxZpqK/pU5N0jrQ7X/3is0pY2RKxFoxTurZjhv4QdxtqA==" }, + "node_modules/@subsquid/util-internal-archive-client": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-archive-client/-/util-internal-archive-client-0.1.0.tgz", + "integrity": "sha512-bXFNZvXduKzG3NjPLmFPU5B+r+UHXT45Yr5YOpgD9sZvrHbNc/n877jSEt1qnzUJKnTl1hxtXlXvpwIBEjKT3Q==", + "dependencies": { + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-range": "^0.1.0" + }, + "peerDependencies": { + "@subsquid/http-client": "^1.3.2", + "@subsquid/logger": "^1.3.2" + }, + "peerDependenciesMeta": { + "@subsquid/logger": { + "optional": true + } + } + }, + "node_modules/@subsquid/util-internal-archive-client/node_modules/@subsquid/util-internal": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" + }, "node_modules/@subsquid/util-internal-binary-heap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@subsquid/util-internal-binary-heap/-/util-internal-binary-heap-1.0.0.tgz", "integrity": "sha512-88auuc8yNFmCZugmJSTYzS7WM/nN2obKGQCgrl8Jty5rJUFbqazGSi8icqftKhv6MPtUMJ3PSTRLiTFXAUGnAA==" }, "node_modules/@subsquid/util-internal-code-printer": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-code-printer/-/util-internal-code-printer-1.2.1.tgz", - "integrity": "sha512-9l0kCm50hQfRjzplIZs9kHooqxczG82fzAexlD6x1SjdLDU1NfYA0uGxgE6pweKydgd7LCb9ICc5gfDvbWtdaw==" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-code-printer/-/util-internal-code-printer-1.2.2.tgz", + "integrity": "sha512-uerf8T/FU4bxxhat09MgRrdmwifLwV+tO7QvlMvZ5ccwaVrJjHs+0/LY/h1e9YowH3+ZtwPqjYrd5tNOHWX8wA==" }, "node_modules/@subsquid/util-internal-config": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-config/-/util-internal-config-2.2.1.tgz", - "integrity": "sha512-yOyIzn5Gx4aawtOEkY/Bxvo57WBqU/vRvpG/nsyFWOEEC/opmxH5Tl3hDPdoeF+/+AN6a9AEprGAMK2Wesj8LQ==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-config/-/util-internal-config-2.2.2.tgz", + "integrity": "sha512-Qc8YH8eoPWrOoPHLnXJ/ksPo2pLpa126bY7qaM22/++Nk8DyexLxgbjYZTBeIHd/DXjTfgJpDDfxmCyy5RWZmA==", "dev": true, "dependencies": { "@exodus/schemasafe": "^1.3.0", @@ -1183,108 +1212,126 @@ } }, "node_modules/@subsquid/util-internal-counters": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-counters/-/util-internal-counters-1.3.1.tgz", - "integrity": "sha512-bc22t8lEvoCBn31F+B763E81+ZDaL7ufpwr0VLXZzcA5wZ6NEqqRfs4bJtPeBNGEjyeLLrItXWxfjSkR7sGKAg==" + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-counters/-/util-internal-counters-1.3.2.tgz", + "integrity": "sha512-GxpOIL36JXSo0KdOT7k6CsI4DY804rn/X7pTdfKhych0ReHaDghnwNyvgb7Njv9euEHWUt4MxXbfQ9YrbpPDng==" }, "node_modules/@subsquid/util-internal-hex": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-hex/-/util-internal-hex-1.2.1.tgz", - "integrity": "sha512-R7TYDsftjguapzWia97WGvcF4s65VKArzSga5i1i4aZSq9Z330kPYpgAUkqDGsJqD/Ki3PTE4cXhuKLRyMHPvg==" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-hex/-/util-internal-hex-1.2.2.tgz", + "integrity": "sha512-E43HVqf23jP5hvtWF9GsiN8luANjnJ1daR2SVTwaIUAYU/uNjv1Bi6tHz2uexlflBhyxAgBDmHgunXZ45wQTIw==" }, "node_modules/@subsquid/util-internal-http-server": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-http-server/-/util-internal-http-server-1.2.1.tgz", - "integrity": "sha512-aQIodM3xWDu8wxllOONU5Fy6hmYYAZzS2PglC2FfdUi6HUxaZ8aCUkjFisG56tglhsoAh/TQSQX1YhCX00MCcg==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-http-server/-/util-internal-http-server-1.2.2.tgz", + "integrity": "sha512-B2SOSz8frUkXarbsELljew25iXFFyATEtS8NV31xKUXmhYfPklqrcF4YNJ/aLlfCtVOiR042YKVZDx2T8RbN6w==", "dependencies": { "stoppable": "^1.1.0" } }, "node_modules/@subsquid/util-internal-ingest-tools": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-ingest-tools/-/util-internal-ingest-tools-0.0.2.tgz", - "integrity": "sha512-Nx5LDWq9B1sVAXg6qDI0zVmzfwP1Mk5Rrn79OJc4eKLvZTrTIk2vyM5SB4n1kwQk6KRuQYI9dfiNWdcm+9rGfA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-ingest-tools/-/util-internal-ingest-tools-1.1.0.tgz", + "integrity": "sha512-Zk5IPrclv+OrAV6EFQWGQS86YfN51/tLKKW137VzFPCWNEBSPCXu5lYe/hCwwW34k+gtf5TYLb3s69d2P1e/lg==", "dependencies": { - "@subsquid/logger": "^1.3.1", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-range": "^0.0.1" + "@subsquid/logger": "^1.3.2", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-range": "^0.1.0" + }, + "peerDependencies": { + "@subsquid/util-internal-archive-client": "^0.1.0" + }, + "peerDependenciesMeta": { + "@subsquid/util-internal-archive-client": { + "optional": true + } } }, "node_modules/@subsquid/util-internal-ingest-tools/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/util-internal-json": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-json/-/util-internal-json-1.2.1.tgz", - "integrity": "sha512-Jtbhur/QaRk727fiZ/w8so0M0o4BIkfvnT6zBnC3s1mQ9fKve0Q6aj22gbimpX7Whj6tAGF0Bz8LFhbAethbkA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-json/-/util-internal-json-1.2.2.tgz", + "integrity": "sha512-+axQnlkIzscdy0T/vR1Dez/2NVCryWgB3OocMGJcx2GjhHVkmuJSLFqOdk9o90OocfQFC57NTZx22oa2yd+4Yw==", "dependencies": { - "@subsquid/util-internal-hex": "^1.2.1" + "@subsquid/util-internal-hex": "^1.2.2" } }, "node_modules/@subsquid/util-internal-processor-tools": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-processor-tools/-/util-internal-processor-tools-3.1.0.tgz", - "integrity": "sha512-uEa8Bw/xvSfiagbK8IFt1OEgR7hacfblPZXH5EV4cAIKoIVOonhnkJEPRWqI3ZaDHl+8Z9p909tlsEd46sXenw==", - "dependencies": { - "@subsquid/logger": "^1.3.1", - "@subsquid/util-internal": "^2.5.2", - "@subsquid/util-internal-counters": "^1.3.1", - "@subsquid/util-internal-prometheus-server": "^1.2.1", - "@subsquid/util-internal-range": "^0.0.1", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-processor-tools/-/util-internal-processor-tools-4.0.1.tgz", + "integrity": "sha512-2+IOze7VkgUuJqRThzq6QDO+xNd6CAbPUgtjgOi6EB3/ImrJXEjENBOFzTVSTP0Ri+kT/CyoyBPniyGBGzogiA==", + "dependencies": { + "@subsquid/logger": "^1.3.2", + "@subsquid/util-internal": "^3.0.0", + "@subsquid/util-internal-counters": "^1.3.2", + "@subsquid/util-internal-prometheus-server": "^1.2.2", + "@subsquid/util-internal-range": "^0.1.0", "prom-client": "^14.2.0" } }, "node_modules/@subsquid/util-internal-processor-tools/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/util-internal-prometheus-server": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-prometheus-server/-/util-internal-prometheus-server-1.2.1.tgz", - "integrity": "sha512-GhbsEmv0xAkaBaxwZGRavMIO0h68V6LctZIvxsrrPr695bI1mrXKSYDvVvUwLXQ3aDPy9PIQiKdbSjNa60JW6Q==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-prometheus-server/-/util-internal-prometheus-server-1.2.2.tgz", + "integrity": "sha512-KOjokVhs+qJOZSkM+NPZ/XE5bGvEGGJkVbMaJJfaZ+UfZQPQDfVJrI2rPV5D9FwzctxKG9b7lPArryBIUsgrZw==", "dependencies": { - "@subsquid/util-internal-http-server": "^1.2.1" + "@subsquid/util-internal-http-server": "^1.2.2" }, "peerDependencies": { "prom-client": "^14.2.0" } }, "node_modules/@subsquid/util-internal-range": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-range/-/util-internal-range-0.0.1.tgz", - "integrity": "sha512-9hqlPdTJeR9j9+1L3ymOPC0/qJ2IemGkrHmkTq+gwkjtGKmiXuXw4WLgt0Ps5aeupWKfP7UFy1hDE9DZQFseog==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-range/-/util-internal-range-0.1.0.tgz", + "integrity": "sha512-+pJeJyH0oetqu2eRwOkP7NCSaCGzLpCCNpS9Fwi968RL+LfWSKn+wGUX6Ulf0afSslvrQ/34ZtyWdjyya1AGxA==", "dependencies": { - "@subsquid/util-internal": "^2.5.2", + "@subsquid/util-internal": "^3.0.0", "@subsquid/util-internal-binary-heap": "^1.0.0" } }, "node_modules/@subsquid/util-internal-range/node_modules/@subsquid/util-internal": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-2.5.2.tgz", - "integrity": "sha512-N7lfZdWEkM35jG5wdGYx25TJKGGLMOx9VInSeRhW9T/3BEmHAuSWI2mIIYnZ8w5L041V8HGo61ijWF6qsXvZjg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal/-/util-internal-3.0.0.tgz", + "integrity": "sha512-aGPTiLF21N9f67DgHS4PBR8d6mdvXHTOIhr2mFQPX7GQCgZhNlCZDM/1Sqn+teJawCy3w6Y9f6KOtVbN4T5SFQ==" }, "node_modules/@subsquid/util-internal-read-lines": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-internal-read-lines/-/util-internal-read-lines-1.2.1.tgz", - "integrity": "sha512-Fh7lGlIwFr88pJ39UdkDeQ2z8JEDk13OuoHJHTmgLtThI4kvmDSpVgMdIUUh9nrzFrP/rzlDsvjACTw4D/mTHw==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-read-lines/-/util-internal-read-lines-1.2.2.tgz", + "integrity": "sha512-D9Cks2KVmVQMsJLFskQlwufykWiLLooDFmAYmgwSkZEVnCqJ1ukX8PZfkI+ADfhT5LB64O9FZL7hI0939qiXBA==", "dev": true }, + "node_modules/@subsquid/util-internal-ts-node": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/@subsquid/util-internal-ts-node/-/util-internal-ts-node-0.0.0.tgz", + "integrity": "sha512-VBnrKrkNcqbT3hMLrjpEPuwMAihFhW9oUmK53bccBCCXrUiATNUblQD2S4IWd9/UBO5Q33ohpbE9sAodDq2DXw==" + }, "node_modules/@subsquid/util-naming": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-naming/-/util-naming-1.2.1.tgz", - "integrity": "sha512-l5rvAXG7TxMPeB5kFTTZWisgN0DNe1mVBHT2V2/nxUx4sOfYfneWIN/+02YqJI/GHX9FoOTB6ru7WLfQEMhvhg==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-naming/-/util-naming-1.2.2.tgz", + "integrity": "sha512-NveXOiAbWiWkWd3Iv2jEwSAKvQHOG/HfIsPmmNab8TPX/XgJ6J5Ngx6lHEiqs746m4sOhZ2yipxKAEDgrERaxA==", "dependencies": { "camelcase": "^6.3.0", "inflected": "^2.1.0" } }, + "node_modules/@subsquid/util-timeout": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-timeout/-/util-timeout-2.3.2.tgz", + "integrity": "sha512-DVUnuiWAX7/4ZvbzuHENUShEEV4G0M38mQ/+R8DpHxwpCSrtEaSRaUMwdyUSn/WVqR7wo9+jkLCxFjE5feCURQ==" + }, "node_modules/@subsquid/util-xxhash": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@subsquid/util-xxhash/-/util-xxhash-1.2.1.tgz", - "integrity": "sha512-wobgbKK0fd+3ufUVjxcx4zaYII9JY7hbIStyO9M9Q5xrdihiWM5APX27sRuoO8X8oSj34v44JpIMxC8Rbpy3xQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@subsquid/util-xxhash/-/util-xxhash-1.2.2.tgz", + "integrity": "sha512-S49O4bxs80y3/oBl1xKBE/zzvDPLr88yE+03zfOXaNj/wesTGzicqBxhzDULmyo6kpdRmc0ZPOZCQ3U6gNQpxQ==", "dependencies": { "xxhash-wasm": "^1.0.2", "xxhashjs": "^0.2.2" @@ -1377,9 +1424,9 @@ "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" }, "node_modules/@types/mime": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.3.tgz", - "integrity": "sha512-i8MBln35l856k5iOhKk2XJ4SeAWg75mLIpZB4v6imOagKL6twsukBZGDMNhdOVk7yRFTMPpfILocMos59Q1otQ==" + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.4.tgz", + "integrity": "sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw==" }, "node_modules/@types/node": { "version": "18.11.18", @@ -1387,9 +1434,9 @@ "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" }, "node_modules/@types/qs": { - "version": "6.9.10", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.10.tgz", - "integrity": "sha512-3Gnx08Ns1sEoCrWssEgTSJs/rsT2vhGP+Ja9cnnk9k4ALxinORlQneLXFeFKOTJMOeZUFD1s7w+w2AphTpvzZw==" + "version": "6.9.11", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.11.tgz", + "integrity": "sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ==" }, "node_modules/@types/range-parser": { "version": "1.2.7", @@ -1397,9 +1444,9 @@ "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==" }, "node_modules/@types/serve-static": { - "version": "1.15.4", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.4.tgz", - "integrity": "sha512-aqqNfs1XTF0HDrFdlY//+SGUxmdSUbjeRXb5iaZc3x0/vMbYmdw9qvOgHWOyyLFxSSRnUuP5+724zBgfw8/WAw==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.5.tgz", + "integrity": "sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ==", "dependencies": { "@types/http-errors": "*", "@types/mime": "*", @@ -1547,10 +1594,9 @@ "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==" }, "node_modules/apollo-server-core": { - "version": "3.12.1", - "resolved": "https://registry.npmjs.org/apollo-server-core/-/apollo-server-core-3.12.1.tgz", - "integrity": "sha512-9SF5WAkkV0FZQ2HVUWI9Jada1U0jg7e8NCN9EklbtvaCeUlOLyXyM+KCWuZ7+dqHxjshbtcwylPHutt3uzoNkw==", - "deprecated": "The `apollo-server-core` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/server` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.", + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/apollo-server-core/-/apollo-server-core-3.13.0.tgz", + "integrity": "sha512-v/g6DR6KuHn9DYSdtQijz8dLOkP78I5JSVJzPkARhDbhpH74QNwrQ2PP2URAPPEDJ2EeZNQDX8PvbYkAKqg+kg==", "dependencies": { "@apollo/utils.keyvaluecache": "^1.0.1", "@apollo/utils.logger": "^1.0.0", @@ -1664,10 +1710,9 @@ } }, "node_modules/apollo-server-express": { - "version": "3.12.1", - "resolved": "https://registry.npmjs.org/apollo-server-express/-/apollo-server-express-3.12.1.tgz", - "integrity": "sha512-5A9efrhEXqDx08BnORWf0zPYCABENqur47VZZW8osQpSSnMINqzJiV5RMrzz8wIznecRRhEcz+BqLdiexqZdgg==", - "deprecated": "The `apollo-server-express` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/server` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.", + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/apollo-server-express/-/apollo-server-express-3.13.0.tgz", + "integrity": "sha512-iSxICNbDUyebOuM8EKb3xOrpIwOQgKxGbR2diSr4HP3IW8T3njKFOoMce50vr+moOCe1ev8BnLcw9SNbuUtf7g==", "dependencies": { "@types/accepts": "^1.3.5", "@types/body-parser": "1.19.2", @@ -1675,7 +1720,7 @@ "@types/express": "4.17.14", "@types/express-serve-static-core": "4.17.31", "accepts": "^1.3.5", - "apollo-server-core": "^3.12.1", + "apollo-server-core": "^3.13.0", "apollo-server-types": "^3.8.0", "body-parser": "^1.19.0", "cors": "^2.8.5", @@ -2533,14 +2578,14 @@ } }, "node_modules/deep-equal": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.2.tgz", - "integrity": "sha512-xjVyBf0w5vH0I42jdAZzOKVldmPgSulmiyPRywoyq7HXC9qdgo17kxJE+rdnif5Tz6+pIrpJI8dCpMNLIGkUiA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz", + "integrity": "sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==", "dependencies": { "array-buffer-byte-length": "^1.0.0", - "call-bind": "^1.0.2", + "call-bind": "^1.0.5", "es-get-iterator": "^1.1.3", - "get-intrinsic": "^1.2.1", + "get-intrinsic": "^1.2.2", "is-arguments": "^1.1.1", "is-array-buffer": "^3.0.2", "is-date-object": "^1.0.5", @@ -2550,11 +2595,14 @@ "object-is": "^1.1.5", "object-keys": "^1.1.1", "object.assign": "^4.1.4", - "regexp.prototype.flags": "^1.5.0", + "regexp.prototype.flags": "^1.5.1", "side-channel": "^1.0.4", "which-boxed-primitive": "^1.0.2", "which-collection": "^1.0.1", - "which-typed-array": "^1.1.9" + "which-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -2805,9 +2853,9 @@ } }, "node_modules/ethers": { - "version": "6.8.1", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.8.1.tgz", - "integrity": "sha512-iEKm6zox5h1lDn6scuRWdIdFJUCGg3+/aQWu0F4K0GVyEZiktFkqrJbRjTn1FlYEPz7RKA707D6g5Kdk6j7Ljg==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.10.0.tgz", + "integrity": "sha512-nMNwYHzs6V1FR3Y4cdfxSQmNgZsRj1RiTU25JwvnJLmyzw9z3SKxNc2XKDuiXXo/v9ds5Mp9m6HBabgYQQ26tA==", "funding": [ { "type": "individual", @@ -3209,9 +3257,9 @@ } }, "node_modules/graphql-parse-resolve-info": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/graphql-parse-resolve-info/-/graphql-parse-resolve-info-4.13.0.tgz", - "integrity": "sha512-VVJ1DdHYcR7hwOGQKNH+QTzuNgsLA8l/y436HtP9YHoX6nmwXRWq3xWthU3autMysXdm0fQUbhTZCx0W9ICozw==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/graphql-parse-resolve-info/-/graphql-parse-resolve-info-4.14.0.tgz", + "integrity": "sha512-5Fbquh3IZMciLYgtiWeFxAeZOwpPyonhbaN05fzL/Gll0HS0hMqJh1Q88NQLHiASD6//cJ3LTXLncuajRqsUcA==", "dependencies": { "debug": "^4.1.1", "tslib": "^2.0.1" @@ -3803,9 +3851,9 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "node_modules/jsonc-parser": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", - "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz", + "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==", "dev": true }, "node_modules/keyv": { @@ -4346,12 +4394,12 @@ } }, "node_modules/object.assign": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", - "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz", + "integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==", "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", + "call-bind": "^1.0.5", + "define-properties": "^1.2.1", "has-symbols": "^1.0.3", "object-keys": "^1.1.1" }, @@ -5536,9 +5584,9 @@ } }, "node_modules/web-streams-polyfill": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.2.tgz", + "integrity": "sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==", "engines": { "node": ">= 8" } diff --git a/package.json b/package.json index 66c44f67..c9d33ecd 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,13 @@ "dependencies": { "@polkadot/util": "11.1.1", "@subsquid/archive-registry": "3.3.0", - "@subsquid/evm-typegen": "^3.2.3", - "@subsquid/graphql-server": "4.3.1", - "@subsquid/ink-abi": "^3.0.1", - "@subsquid/ss58": "2.0.1", - "@subsquid/substrate-processor": "^7.2.1", - "@subsquid/typeorm-migration": "1.2.2", - "@subsquid/typeorm-store": "^1.2.4", + "@subsquid/evm-typegen": "^3.3.0", + "@subsquid/graphql-server": "4.5.0", + "@subsquid/ink-abi": "^3.0.2", + "@subsquid/ss58": "2.0.2", + "@subsquid/substrate-processor": "^8.1.1", + "@subsquid/typeorm-migration": "1.3.0", + "@subsquid/typeorm-store": "^1.2.6", "axios": "^1.6.2", "big.js": "^6.2.1", "dotenv": "^16.0.0", @@ -31,10 +31,10 @@ "typeorm": "^0.3.17" }, "devDependencies": { - "@subsquid/ink-typegen": "^3.0.2", - "@subsquid/substrate-metadata-explorer": "3.1.1", - "@subsquid/substrate-typegen": "^8.0.1", - "@subsquid/typeorm-codegen": "1.3.2", + "@subsquid/ink-typegen": "^3.0.3", + "@subsquid/substrate-metadata-explorer": "3.1.2", + "@subsquid/substrate-typegen": "^8.0.2", + "@subsquid/typeorm-codegen": "1.3.3", "@types/big.js": "^6.1.6", "@types/lodash": "^4.14.192", "@types/node": "18.11.18", diff --git a/schema.graphql b/schema.graphql index eb4abdb9..3d1c7cfa 100644 --- a/schema.graphql +++ b/schema.graphql @@ -744,7 +744,7 @@ type Incentive @entity { type Router @entity { id: ID! # id can be the address of the router contract swapPools: [SwapPool!] @derivedFrom(field: "router") - backstopPools: [BackstopPool!] @derivedFrom(field: "router") + backstopPool: BackstopPool @derivedFrom(field: "router") paused: Boolean! # whether the router is paused } @@ -760,18 +760,18 @@ type SwapPool @entity { router: Router! # link to the Router entity backstop: BackstopPool! # link to the BackstopPool entity token: NablaToken! # link to the Token entity - reserves: BigInt! # current balance of the pool - liabilities: BigInt! # total Liquidity Provider (LP) deposits + reserve: BigInt! # current usable balance of the pool + reserveWithSlippage: BigInt! # current actual balance of the pool + totalLiabilities: BigInt! # total Liquidity Provider (LP) deposits totalSupply: BigInt! # total supply of LP tokens paused: Boolean! # whether the swap pool is paused } type BackstopPool @entity { id: ID! # id can be the address of the backstop pool contract - router: Router! # link to the Router entity + router: Router! @unique # link to the Router entity token: NablaToken! # link to the NablaToken entity reserves: BigInt! # current balance of the pool - liabilities: BigInt! # total Liquidity Provider (LP) deposits totalSupply: BigInt! # total supply of LP tokens paused: Boolean! # whether the backstop pool is paused } diff --git a/src/abi/backstop.ts b/src/abi/backstop.ts index 954df108..8cd37223 100644 --- a/src/abi/backstop.ts +++ b/src/abi/backstop.ts @@ -9,9 +9,9 @@ export const metadata = { version: '0.0.1', }, source: { - compiler: 'solang 0.2.2', - hash: '0xf10ab2e77c3a3e3927250ee6ba61e01338a509150723f4329e6dda3d9481eb2a', - language: 'Solidity 0.2.2', + compiler: 'solang 0.3.2', + hash: '0x09e907520a2e0be46d0a350df95c431857cbf88f52094be242f15ae79e524f3c', + language: 'Solidity 0.3.2', }, spec: { constructors: [ @@ -20,21 +20,22 @@ export const metadata = { { label: '_router', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: '_asset', type: { - displayName: ['ink_env', 'types', 'AccountId'], - type: 2, - }, - }, - { - label: '_curve', - type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -53,16 +54,44 @@ export const metadata = { }, }, ], + default: false, docs: [''], label: 'new', payable: false, returnType: null, - selector: '0x3e6bb716', + selector: '0xf01fa595', }, ], docs: [ - 'The backstop pool takes most of the risk of a set of swap pools\nbacked by it. Whenever a swap pool is low on reserves and a LPer\nwants to withdraw some liquidity, they can conduct an insurance\nwithdrawal (burn swap pool shares, reimbursed in backstop liquidity)\nto avoid paying a high slippage.\nThe backstop pool owns all excess liquidity in its swap pools,\nbut is also liable for potential liquidity gaps.\nIn return, the backstop pool receives a cut of the swap fees.\n\n', + 'The backstop pool takes most of the risk of a set of swap pools\nbacked by it. Whenever a swap pool is low on reserves and a LPer\nwants to withdraw some liquidity, they can conduct an insurance\nwithdrawal (burn swap pool shares, reimbursed in backstop liquidity)\nto avoid paying a high slippage.\nThe backstop pool owns all excess liquidity in its swap pools,\nbut is also liable for potential liquidity gaps.\nIn return, the backstop pool receives a cut of the swap fees.', ], + environment: { + accountId: { + displayName: ['AccountId'], + type: 2, + }, + balance: { + displayName: ['Balance'], + type: 10, + }, + blockNumber: { + displayName: ['BlockNumber'], + type: 11, + }, + chainExtension: { + displayName: [], + type: 0, + }, + hash: { + displayName: ['Hash'], + type: 12, + }, + maxEventTopics: 4, + timestamp: { + displayName: ['Timestamp'], + type: 11, + }, + }, events: [ { args: [ @@ -71,7 +100,11 @@ export const metadata = { indexed: true, label: 'from', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -80,7 +113,11 @@ export const metadata = { indexed: true, label: 'to', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -89,7 +126,7 @@ export const metadata = { indexed: false, label: 'value', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, @@ -104,7 +141,11 @@ export const metadata = { indexed: true, label: 'owner', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -113,7 +154,11 @@ export const metadata = { indexed: true, label: 'spender', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -122,7 +167,7 @@ export const metadata = { indexed: false, label: 'value', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, @@ -137,7 +182,11 @@ export const metadata = { indexed: false, label: 'account', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -152,7 +201,11 @@ export const metadata = { indexed: false, label: 'account', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -167,7 +220,11 @@ export const metadata = { indexed: true, label: 'previousOwner', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -176,7 +233,11 @@ export const metadata = { indexed: true, label: 'newOwner', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -191,7 +252,11 @@ export const metadata = { indexed: true, label: 'sender', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -200,7 +265,7 @@ export const metadata = { indexed: false, label: 'poolSharesMinted', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, @@ -209,12 +274,12 @@ export const metadata = { indexed: false, label: 'amountPrincipleDeposited', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], - docs: ['emitted on every deposit\n\n'], + docs: ['emitted on every deposit'], label: 'Mint', }, { @@ -224,7 +289,11 @@ export const metadata = { indexed: true, label: 'sender', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -233,7 +302,7 @@ export const metadata = { indexed: false, label: 'poolSharesBurned', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, @@ -242,13 +311,13 @@ export const metadata = { indexed: false, label: 'amountPrincipleWithdrawn', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], docs: [ - 'emitted on every withdrawal special case withdrawal using swap liquidiity: amountPrincipleWithdrawn = 0\n\n', + 'emitted on every withdrawal special case withdrawal using swap liquidiity: amountPrincipleWithdrawn = 0', ], label: 'Burn', }, @@ -259,7 +328,11 @@ export const metadata = { indexed: true, label: 'owner', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -268,7 +341,11 @@ export const metadata = { indexed: false, label: 'swapPool', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -277,7 +354,7 @@ export const metadata = { indexed: false, label: 'amountSwapShares', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, @@ -286,7 +363,7 @@ export const metadata = { indexed: false, label: 'amountSwapTokens', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, @@ -295,13 +372,13 @@ export const metadata = { indexed: false, label: 'amountBackstopTokens', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], docs: [ - 'emitted when a swap pool LP withdraws from backstop pool\n\n', + 'emitted when a swap pool LP withdraws from backstop pool', ], label: 'CoverSwapWithdrawal', }, @@ -312,7 +389,11 @@ export const metadata = { indexed: true, label: 'owner', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -321,7 +402,11 @@ export const metadata = { indexed: false, label: 'swapPool', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, @@ -330,7 +415,7 @@ export const metadata = { indexed: false, label: 'amountSwapTokens', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, @@ -339,24 +424,25 @@ export const metadata = { indexed: false, label: 'amountBackstopTokens', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], docs: [ - 'emitted when a backstop pool LP withdraws liquidity from swap pool\n\n', + 'emitted when a backstop pool LP withdraws liquidity from swap pool', ], label: 'WithdrawSwapLiquidity', }, ], lang_error: { - displayName: [], - type: 0, + displayName: ['SolidityError'], + type: 15, }, messages: [ { args: [], + default: false, docs: [''], label: 'name', mutates: false, @@ -369,6 +455,7 @@ export const metadata = { }, { args: [], + default: false, docs: [''], label: 'symbol', mutates: false, @@ -381,24 +468,26 @@ export const metadata = { }, { args: [], + default: false, docs: [''], label: 'decimals', mutates: false, payable: false, returnType: { - displayName: ['u8'], + displayName: ['uint8'], type: 0, }, selector: '0x313ce567', }, { args: [], + default: false, docs: [''], label: 'totalSupply', mutates: false, payable: false, returnType: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, selector: '0x18160ddd', @@ -408,17 +497,22 @@ export const metadata = { { label: 'account', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, ], + default: false, docs: [''], label: 'balanceOf', mutates: false, payable: false, returnType: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, selector: '0x70a08231', @@ -428,18 +522,23 @@ export const metadata = { { label: 'to', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: 'amount', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [''], label: 'transfer', mutates: true, @@ -455,24 +554,33 @@ export const metadata = { { label: 'owner', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: 'spender', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, ], + default: false, docs: [''], label: 'allowance', mutates: false, payable: false, returnType: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, selector: '0xdd62ed3e', @@ -482,18 +590,23 @@ export const metadata = { { label: 'spender', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: 'amount', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [''], label: 'approve', mutates: true, @@ -509,25 +622,34 @@ export const metadata = { { label: 'from', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: 'to', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: 'amount', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [''], label: 'transferFrom', mutates: true, @@ -543,18 +665,23 @@ export const metadata = { { label: 'spender', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: 'addedValue', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [''], label: 'increaseAllowance', mutates: true, @@ -570,18 +697,23 @@ export const metadata = { { label: 'spender', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: 'subtractedValue', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [''], label: 'decreaseAllowance', mutates: true, @@ -594,6 +726,7 @@ export const metadata = { }, { args: [], + default: false, docs: [''], label: 'paused', mutates: false, @@ -606,18 +739,20 @@ export const metadata = { }, { args: [], + default: false, docs: [''], label: 'owner', mutates: false, payable: false, returnType: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: ['ink_primitives', 'types', 'AccountId'], type: 2, }, selector: '0x8da5cb5b', }, { args: [], + default: false, docs: [''], label: 'renounceOwnership', mutates: true, @@ -630,11 +765,16 @@ export const metadata = { { label: 'newOwner', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, ], + default: false, docs: [''], label: 'transferOwnership', mutates: true, @@ -644,238 +784,285 @@ export const metadata = { }, { args: [], + default: false, docs: [''], label: 'poolCap', mutates: false, payable: false, returnType: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, selector: '0xb954dc57', }, { args: [], - docs: ["Returns the pooled token's address\n\n"], + default: false, + docs: ["Returns the pooled token's address"], label: 'asset', mutates: false, payable: false, returnType: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: ['ink_primitives', 'types', 'AccountId'], type: 2, }, selector: '0x38d52e0f', }, { - args: [ - { - label: '_shares', - type: { - displayName: ['u256'], - type: 3, - }, - }, - ], - docs: [ - 'Returns the worth of an amount of pool shares (LP tokens) in underlying principle\n\n', - ], - label: 'sharesTargetWorth', + args: [], + default: false, + docs: ['Returns the decimals of the pool asset'], + label: 'assetDecimals', mutates: false, payable: false, returnType: { - displayName: ['u256'], - type: 3, + displayName: ['uint8'], + type: 0, }, - selector: '0xcc045745', + selector: '0xc2d41601', }, { args: [], + default: false, docs: [''], label: 'router', mutates: false, payable: false, returnType: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: ['ink_primitives', 'types', 'AccountId'], type: 2, }, selector: '0xf887ea40', }, - { - args: [], - docs: [''], - label: 'slippageCurve', - mutates: false, - payable: false, - returnType: { - displayName: ['ink_env', 'types', 'AccountId'], - type: 2, - }, - selector: '0xebe26b9e', - }, - { - args: [], - docs: [''], - label: 'accumulatedSlippage', - mutates: false, - payable: false, - returnType: { - displayName: ['u256'], - type: 3, - }, - selector: '0xe4182b09', - }, { args: [ { - label: '_amount', + label: '_maxTokens', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [ - 'Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0\n\n', + 'Set new upper limit of pool reserves. Will disable deposits when reached. Can always set to an amount < current reserves to temporarily restrict deposits.', ], - label: 'deposit', + label: 'setPoolCap', mutates: true, payable: false, - returnType: { - displayName: ['BackstopPool', 'deposit', 'return_type'], - type: 8, - }, - selector: '0xb6b55f25', + returnType: null, + selector: '0xd835f535', }, { args: [ { - label: '_maxTokens', + label: '_swapPool', type: { - displayName: ['u256'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + { + label: '_insuranceFeeBps', + type: { + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [ - 'Set new upper limit of pool reserves. Will disable deposits when reached. Can always set to an amount < current reserves to temporarily restrict deposits.\n\n', + 'Make this backstop pool cover another swap pool Beware: Adding a swap pool holding the same token as the backstop pool\ncan easily cause undesirable conditions and must be secured (i.e. long time lock)!', ], - label: 'setPoolCap', + label: 'addSwapPool', mutates: true, payable: false, returnType: null, - selector: '0xd835f535', + selector: '0xabb26587', }, { args: [ { - label: '_shares', + label: '_swapPool', type: { - displayName: ['u256'], - type: 3, + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, }, }, { - label: '_minimumAmount', + label: '_insuranceFeeBps', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], - docs: [ - 'Withdraws liquidity amount of asset ensuring minimum amount required Slippage is applied (withdrawal fee)\n\n', - ], - label: 'withdraw', + default: false, + docs: ["Change a swap pool's insurance withdrawal fee"], + label: 'setInsuranceFee', mutates: true, payable: false, + returnType: null, + selector: '0xc6a78196', + }, + { + args: [ + { + label: '_index', + type: { + displayName: ['uint256'], + type: 3, + }, + }, + ], + default: false, + docs: ['enumerate swap pools backed by this backstop pool'], + label: 'getBackedPool', + mutates: false, + payable: false, returnType: { - displayName: ['BackstopPool', 'withdraw', 'return_type'], - type: 9, + displayName: ['ink_primitives', 'types', 'AccountId'], + type: 2, }, - selector: '0x441a3e70', + selector: '0xa04345f2', + }, + { + args: [], + default: false, + docs: ['get swap pool count backed by this backstop pool'], + label: 'getBackedPoolCount', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0x5fda8689', }, { args: [ { label: '_swapPool', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, + ], + default: false, + docs: ['get insurance withdrawal fee for a given swap pool'], + label: 'getInsuranceFee', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0x504e0153', + }, + { + args: [ { - label: '_insuranceFeeBps', + label: '_depositAmount', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [ - 'Make this backstop pool cover another swap pool Beware: Adding a swap pool holding the same token as the backstop pool\ncan easily cause undesirable conditions and must be secured (i.e. long time lock)!\n\n', + 'Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0', ], - label: 'addSwapPool', + label: 'deposit', mutates: true, payable: false, - returnType: null, - selector: '0xabb26587', + returnType: { + displayName: ['BackstopPool', 'deposit', 'return_type'], + type: 8, + }, + selector: '0xb6b55f25', }, { args: [ { - label: '_swapPool', + label: '_sharesToBurn', type: { - displayName: ['ink_env', 'types', 'AccountId'], - type: 2, + displayName: ['uint256'], + type: 3, }, }, { - label: '_insuranceFeeBps', + label: '_minimumAmount', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], - docs: ["Change a swap pool's insurance withdrawal fee\n\n"], - label: 'setInsuranceFee', + default: false, + docs: [ + 'Withdraws liquidity amount of asset ensuring minimum amount required Slippage is applied (withdrawal fee)', + ], + label: 'withdraw', mutates: true, payable: false, - returnType: null, - selector: '0xc6a78196', + returnType: { + displayName: ['BackstopPool', 'withdraw', 'return_type'], + type: 9, + }, + selector: '0x441a3e70', }, { args: [ { label: '_swapPool', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: '_shares', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, { label: '_minAmount', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [ - "withdraw from a swap pool using backstop liquidity without slippage only possible if swap pool's coverage ratio < 100%\n\n", + "withdraw from a swap pool using backstop liquidity without slippage only possible if swap pool's coverage ratio < 100%", ], label: 'redeemSwapPoolShares', mutates: true, payable: false, returnType: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, selector: '0x6e7e91fd', @@ -885,116 +1072,79 @@ export const metadata = { { label: '_swapPool', type: { - displayName: ['ink_env', 'types', 'AccountId'], + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], type: 2, }, }, { label: '_shares', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, { label: '_minAmount', type: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, }, ], + default: false, docs: [ - 'withdraw from backstop pool, but receive excess liquidity\nof a swap pool without slippage, instead of backstop liquidity\n\n', + 'withdraw from backstop pool, but receive excess liquidity\nof a swap pool without slippage, instead of backstop liquidity', ], label: 'withdrawExcessSwapLiquidity', mutates: true, payable: false, returnType: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, selector: '0xcaf8c105', }, { args: [], - docs: ['returns pool coverage ratio\n\n'], - label: 'coverage', - mutates: false, - payable: false, - returnType: { - displayName: ['BackstopPool', 'coverage', 'return_type'], - type: 10, - }, - selector: '0xee8f6a0e', - }, - { - args: [ - { - label: '_index', - type: { - displayName: ['u256'], - type: 3, - }, - }, + default: false, + docs: [ + "return worth of the whole backstop pool in `asset()`, incl. all\nswap pools' excess liquidity and the backstop pool's liabilities", ], - docs: ['enumerate swap pools backed by this backstop pool\n\n'], - label: 'getBackedPool', - mutates: false, - payable: false, - returnType: { - displayName: ['ink_env', 'types', 'AccountId'], - type: 2, - }, - selector: '0xa04345f2', - }, - { - args: [], - docs: ['get swap pool count backed by this backstop pool\n\n'], - label: 'getBackedPoolCount', + label: 'getTotalPoolWorth', mutates: false, payable: false, returnType: { - displayName: ['u256'], - type: 3, + displayName: ['int256'], + type: 7, }, - selector: '0x5fda8689', + selector: '0x18ba24c4', }, { args: [ { - label: '_swapPool', + label: '_sharesToBurn', type: { - displayName: ['ink_env', 'types', 'AccountId'], - type: 2, + displayName: ['uint256'], + type: 3, }, }, ], + default: false, docs: [ - 'get insurance withdrawal fee for a given swap pool\n\n', + 'Returns the worth of an amount of pool shares (LP tokens) in underlying principle', ], - label: 'getInsuranceFee', - mutates: false, - payable: false, - returnType: { - displayName: ['u256'], - type: 3, - }, - selector: '0x504e0153', - }, - { - args: [], - docs: [ - "return worth of the whole backstop pool in `asset()`, incl. all\nswap pools' excess liquidity and the backstop pool's liabilities\n\n", - ], - label: 'getTotalPoolWorth', + label: 'sharesTargetWorth', mutates: false, payable: false, returnType: { - displayName: ['u256'], + displayName: ['uint256'], type: 3, }, - selector: '0x18ba24c4', + selector: '0xcc045745', }, ], }, @@ -1153,13 +1303,13 @@ export const metadata = { layout: { leaf: { key: '0x00000009', - ty: 3, + ty: 0, }, }, root_key: '0x00000009', }, }, - name: 'poolCap', + name: 'poolAssetDecimals', }, { layout: { @@ -1173,21 +1323,7 @@ export const metadata = { root_key: '0x0000000a', }, }, - name: 'totalLiabilities', - }, - { - layout: { - root: { - layout: { - leaf: { - key: '0x0000000b', - ty: 3, - }, - }, - root_key: '0x0000000b', - }, - }, - name: 'poolAssetMantissa', + name: 'poolCap', }, { layout: { @@ -1198,7 +1334,7 @@ export const metadata = { { layout: { leaf: { - key: '0x0000000c', + key: '0x0000000b', ty: 1, }, }, @@ -1208,59 +1344,21 @@ export const metadata = { name: 'AccountId', }, }, - root_key: '0x0000000c', + root_key: '0x0000000b', }, }, name: 'router', }, - { - layout: { - root: { - layout: { - struct: { - fields: [ - { - layout: { - leaf: { - key: '0x0000000d', - ty: 1, - }, - }, - name: '', - }, - ], - name: 'AccountId', - }, - }, - root_key: '0x0000000d', - }, - }, - name: 'slippageCurve', - }, { layout: { root: { layout: { leaf: { - key: '0x0000000e', - ty: 3, - }, - }, - root_key: '0x0000000e', - }, - }, - name: 'accumulatedSlippage', - }, - { - layout: { - root: { - layout: { - leaf: { - key: '0x0000000f', + key: '0x0000000c', ty: 6, }, }, - root_key: '0x0000000f', + root_key: '0x0000000c', }, }, name: 'swapPools', @@ -1270,11 +1368,11 @@ export const metadata = { root: { layout: { leaf: { - key: '0x00000010', + key: '0x0000000d', ty: 3, }, }, - root_key: '0x00000010', + root_key: '0x0000000d', }, }, name: 'swapPoolInsuranceFeeBps', @@ -1284,11 +1382,11 @@ export const metadata = { root: { layout: { leaf: { - key: '0x00000011', + key: '0x0000000e', ty: 4, }, }, - root_key: '0x00000011', + root_key: '0x0000000e', }, }, name: 'swapPoolCovered', @@ -1304,7 +1402,7 @@ export const metadata = { def: { primitive: 'u8', }, - path: ['u8'], + path: ['uint8'], }, }, { @@ -1330,7 +1428,7 @@ export const metadata = { ], }, }, - path: ['ink_env', 'types', 'AccountId'], + path: ['ink_primitives', 'types', 'AccountId'], }, }, { @@ -1339,7 +1437,7 @@ export const metadata = { def: { primitive: 'u256', }, - path: ['u256'], + path: ['uint256'], }, }, { @@ -1376,7 +1474,7 @@ export const metadata = { def: { primitive: 'i256', }, - path: ['i256'], + path: ['int256'], }, }, { @@ -1401,9 +1499,93 @@ export const metadata = { id: 10, type: { def: { - tuple: [3, 3], + primitive: 'u128', + }, + path: ['uint128'], + }, + }, + { + id: 11, + type: { + def: { + primitive: 'u64', + }, + path: ['uint64'], + }, + }, + { + id: 12, + type: { + def: { + composite: { + fields: [ + { + type: 1, + }, + ], + }, }, - path: ['BackstopPool', 'coverage', 'return_type'], + path: ['ink_primitives', 'types', 'Hash'], + }, + }, + { + id: 13, + type: { + def: { + composite: { + fields: [ + { + type: 5, + }, + ], + }, + }, + path: ['0x08c379a0'], + }, + }, + { + id: 14, + type: { + def: { + composite: { + fields: [ + { + type: 3, + }, + ], + }, + }, + path: ['0x4e487b71'], + }, + }, + { + id: 15, + type: { + def: { + variant: { + variants: [ + { + fields: [ + { + type: 13, + }, + ], + index: 0, + name: 'Error', + }, + { + fields: [ + { + type: 14, + }, + ], + index: 1, + name: 'Panic', + }, + ], + }, + }, + path: ['SolidityError'], }, }, ], @@ -1449,19 +1631,19 @@ export class Contract { return this.stateCall('0x95d89b41', []) } - decimals(): Promise { + decimals(): Promise { return this.stateCall('0x313ce567', []) } - totalSupply(): Promise { + totalSupply(): Promise { return this.stateCall('0x18160ddd', []) } - balanceOf(account: AccountId): Promise { + balanceOf(account: AccountId): Promise { return this.stateCall('0x70a08231', [account]) } - allowance(owner: AccountId, spender: AccountId): Promise { + allowance(owner: AccountId, spender: AccountId): Promise { return this.stateCall('0xdd62ed3e', [owner, spender]) } @@ -1473,7 +1655,7 @@ export class Contract { return this.stateCall('0x8da5cb5b', []) } - poolCap(): Promise { + poolCap(): Promise { return this.stateCall('0xb954dc57', []) } @@ -1481,42 +1663,34 @@ export class Contract { return this.stateCall('0x38d52e0f', []) } - sharesTargetWorth(_shares: u256): Promise { - return this.stateCall('0xcc045745', [_shares]) + assetDecimals(): Promise { + return this.stateCall('0xc2d41601', []) } router(): Promise { return this.stateCall('0xf887ea40', []) } - slippageCurve(): Promise { - return this.stateCall('0xebe26b9e', []) - } - - accumulatedSlippage(): Promise { - return this.stateCall('0xe4182b09', []) - } - - coverage(): Promise<[u256, u256]> { - return this.stateCall('0xee8f6a0e', []) - } - - getBackedPool(_index: u256): Promise { + getBackedPool(_index: uint256): Promise { return this.stateCall('0xa04345f2', [_index]) } - getBackedPoolCount(): Promise { + getBackedPoolCount(): Promise { return this.stateCall('0x5fda8689', []) } - getInsuranceFee(_swapPool: AccountId): Promise { + getInsuranceFee(_swapPool: AccountId): Promise { return this.stateCall('0x504e0153', [_swapPool]) } - getTotalPoolWorth(): Promise { + getTotalPoolWorth(): Promise { return this.stateCall('0x18ba24c4', []) } + sharesTargetWorth(_sharesToBurn: uint256): Promise { + return this.stateCall('0xcc045745', [_sharesToBurn]) + } + private async stateCall(selector: string, args: any[]): Promise { let input = _abi.encodeMessageInput(selector, args) let data = encodeCall(this.address, input) @@ -1530,13 +1704,15 @@ export class Contract { } } +export type int256 = bigint + export type bool = boolean export type AccountId = Bytes -export type u256 = bigint +export type uint256 = bigint -export type u8 = number +export type uint8 = number export type Constructor = Constructor_new @@ -1547,19 +1723,17 @@ export interface Constructor_new { __kind: 'new' router: AccountId asset: AccountId - curve: AccountId name: string symbol: string } export type Message = - | Message_accumulatedSlippage | Message_addSwapPool | Message_allowance | Message_approve | Message_asset + | Message_assetDecimals | Message_balanceOf - | Message_coverage | Message_decimals | Message_decreaseAllowance | Message_deposit @@ -1578,7 +1752,6 @@ export type Message = | Message_setInsuranceFee | Message_setPoolCap | Message_sharesTargetWorth - | Message_slippageCurve | Message_symbol | Message_totalSupply | Message_transfer @@ -1587,23 +1760,14 @@ export type Message = | Message_withdraw | Message_withdrawExcessSwapLiquidity -/** - * - */ -export interface Message_accumulatedSlippage { - __kind: 'accumulatedSlippage' -} - /** * Make this backstop pool cover another swap pool Beware: Adding a swap pool holding the same token as the backstop pool can easily cause undesirable conditions and must be secured (i.e. long time lock)! - - */ export interface Message_addSwapPool { __kind: 'addSwapPool' swapPool: AccountId - insuranceFeeBps: u256 + insuranceFeeBps: uint256 } /** @@ -1621,33 +1785,29 @@ export interface Message_allowance { export interface Message_approve { __kind: 'approve' spender: AccountId - amount: u256 + amount: uint256 } /** * Returns the pooled token's address - - */ export interface Message_asset { __kind: 'asset' } /** - * + * Returns the decimals of the pool asset */ -export interface Message_balanceOf { - __kind: 'balanceOf' - account: AccountId +export interface Message_assetDecimals { + __kind: 'assetDecimals' } /** - * returns pool coverage ratio - - + * */ -export interface Message_coverage { - __kind: 'coverage' +export interface Message_balanceOf { + __kind: 'balanceOf' + account: AccountId } /** @@ -1663,33 +1823,27 @@ export interface Message_decimals { export interface Message_decreaseAllowance { __kind: 'decreaseAllowance' spender: AccountId - subtractedValue: u256 + subtractedValue: uint256 } /** * Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0 - - */ export interface Message_deposit { __kind: 'deposit' - amount: u256 + depositAmount: uint256 } /** * enumerate swap pools backed by this backstop pool - - */ export interface Message_getBackedPool { __kind: 'getBackedPool' - index: u256 + index: uint256 } /** * get swap pool count backed by this backstop pool - - */ export interface Message_getBackedPoolCount { __kind: 'getBackedPoolCount' @@ -1697,8 +1851,6 @@ export interface Message_getBackedPoolCount { /** * get insurance withdrawal fee for a given swap pool - - */ export interface Message_getInsuranceFee { __kind: 'getInsuranceFee' @@ -1708,8 +1860,6 @@ export interface Message_getInsuranceFee { /** * return worth of the whole backstop pool in `asset()`, incl. all swap pools' excess liquidity and the backstop pool's liabilities - - */ export interface Message_getTotalPoolWorth { __kind: 'getTotalPoolWorth' @@ -1721,7 +1871,7 @@ export interface Message_getTotalPoolWorth { export interface Message_increaseAllowance { __kind: 'increaseAllowance' spender: AccountId - addedValue: u256 + addedValue: uint256 } /** @@ -1754,14 +1904,12 @@ export interface Message_poolCap { /** * withdraw from a swap pool using backstop liquidity without slippage only possible if swap pool's coverage ratio < 100% - - */ export interface Message_redeemSwapPoolShares { __kind: 'redeemSwapPoolShares' swapPool: AccountId - shares: u256 - minAmount: u256 + shares: uint256 + minAmount: uint256 } /** @@ -1780,40 +1928,27 @@ export interface Message_router { /** * Change a swap pool's insurance withdrawal fee - - */ export interface Message_setInsuranceFee { __kind: 'setInsuranceFee' swapPool: AccountId - insuranceFeeBps: u256 + insuranceFeeBps: uint256 } /** * Set new upper limit of pool reserves. Will disable deposits when reached. Can always set to an amount < current reserves to temporarily restrict deposits. - - */ export interface Message_setPoolCap { __kind: 'setPoolCap' - maxTokens: u256 + maxTokens: uint256 } /** * Returns the worth of an amount of pool shares (LP tokens) in underlying principle - - */ export interface Message_sharesTargetWorth { __kind: 'sharesTargetWorth' - shares: u256 -} - -/** - * - */ -export interface Message_slippageCurve { - __kind: 'slippageCurve' + sharesToBurn: uint256 } /** @@ -1836,7 +1971,7 @@ export interface Message_totalSupply { export interface Message_transfer { __kind: 'transfer' to: AccountId - amount: u256 + amount: uint256 } /** @@ -1846,7 +1981,7 @@ export interface Message_transferFrom { __kind: 'transferFrom' from: AccountId to: AccountId - amount: u256 + amount: uint256 } /** @@ -1859,26 +1994,22 @@ export interface Message_transferOwnership { /** * Withdraws liquidity amount of asset ensuring minimum amount required Slippage is applied (withdrawal fee) - - */ export interface Message_withdraw { __kind: 'withdraw' - shares: u256 - minimumAmount: u256 + sharesToBurn: uint256 + minimumAmount: uint256 } /** * withdraw from backstop pool, but receive excess liquidity of a swap pool without slippage, instead of backstop liquidity - - */ export interface Message_withdrawExcessSwapLiquidity { __kind: 'withdrawExcessSwapLiquidity' swapPool: AccountId - shares: u256 - minAmount: u256 + shares: uint256 + minAmount: uint256 } export type Event = @@ -1896,30 +2027,30 @@ export interface Event_Approval { __kind: 'Approval' owner: AccountId spender: AccountId - value: u256 + value: uint256 } export interface Event_Burn { __kind: 'Burn' sender: AccountId - poolSharesBurned: u256 - amountPrincipleWithdrawn: u256 + poolSharesBurned: uint256 + amountPrincipleWithdrawn: uint256 } export interface Event_CoverSwapWithdrawal { __kind: 'CoverSwapWithdrawal' owner: AccountId swapPool: AccountId - amountSwapShares: u256 - amountSwapTokens: u256 - amountBackstopTokens: u256 + amountSwapShares: uint256 + amountSwapTokens: uint256 + amountBackstopTokens: uint256 } export interface Event_Mint { __kind: 'Mint' sender: AccountId - poolSharesMinted: u256 - amountPrincipleDeposited: u256 + poolSharesMinted: uint256 + amountPrincipleDeposited: uint256 } export interface Event_OwnershipTransferred { @@ -1937,7 +2068,7 @@ export interface Event_Transfer { __kind: 'Transfer' from: AccountId to: AccountId - value: u256 + value: uint256 } export interface Event_Unpaused { @@ -1949,8 +2080,8 @@ export interface Event_WithdrawSwapLiquidity { __kind: 'WithdrawSwapLiquidity' owner: AccountId swapPool: AccountId - amountSwapTokens: u256 - amountBackstopTokens: u256 + amountSwapTokens: uint256 + amountBackstopTokens: uint256 } export type Result = diff --git a/src/abi/erc20.ts b/src/abi/erc20.ts index 6678af0e..93fc16d0 100644 --- a/src/abi/erc20.ts +++ b/src/abi/erc20.ts @@ -3,12 +3,12 @@ import { Abi, Bytes, encodeCall, decodeResult } from '@subsquid/ink-abi' export const metadata = { contract: { authors: ['unknown'], - name: 'TestableERC20Wrapper', + name: 'ERC20Wrapper', version: '0.0.1', }, source: { compiler: 'solang 0.3.2', - hash: '0xcb7e8effdd0165c396793be92cac69d3a78f35d496a4d9a9423e84aac20c5eb4', + hash: '0xd070e8f0df66f4f13a8ee42d5bf90220b1867883444c8f73f400f8c57ae2c9cd', language: 'Solidity 0.3.2', }, spec: { @@ -184,62 +184,6 @@ export const metadata = { docs: [''], label: 'Approval', }, - { - args: [ - { - docs: [], - indexed: true, - label: 'to', - type: { - displayName: [ - 'ink_primitives', - 'types', - 'AccountId', - ], - type: 6, - }, - }, - { - docs: [], - indexed: false, - label: 'value', - type: { - displayName: ['uint256'], - type: 5, - }, - }, - ], - docs: [''], - label: 'Mint', - }, - { - args: [ - { - docs: [], - indexed: true, - label: 'from', - type: { - displayName: [ - 'ink_primitives', - 'types', - 'AccountId', - ], - type: 6, - }, - }, - { - docs: [], - indexed: false, - label: 'value', - type: { - displayName: ['uint256'], - type: 5, - }, - }, - ], - docs: [''], - label: 'Burn', - }, ], lang_error: { displayName: ['SolidityError'], @@ -290,7 +234,7 @@ export const metadata = { default: false, docs: [''], label: 'totalSupply', - mutates: true, + mutates: false, payable: false, returnType: { displayName: ['uint256'], @@ -315,7 +259,7 @@ export const metadata = { default: false, docs: [''], label: 'balanceOf', - mutates: true, + mutates: false, payable: false, returnType: { displayName: ['uint256'], @@ -383,7 +327,7 @@ export const metadata = { default: false, docs: [''], label: 'allowance', - mutates: true, + mutates: false, payable: false, returnType: { displayName: ['uint256'], @@ -466,70 +410,6 @@ export const metadata = { }, selector: '0x23b872dd', }, - { - args: [ - { - label: '_to', - type: { - displayName: [ - 'ink_primitives', - 'types', - 'AccountId', - ], - type: 6, - }, - }, - { - label: '_amount', - type: { - displayName: ['uint256'], - type: 5, - }, - }, - ], - default: false, - docs: [''], - label: 'mint', - mutates: true, - payable: false, - returnType: { - displayName: ['bool'], - type: 7, - }, - selector: '0x40c10f19', - }, - { - args: [ - { - label: '_from', - type: { - displayName: [ - 'ink_primitives', - 'types', - 'AccountId', - ], - type: 6, - }, - }, - { - label: '_amount', - type: { - displayName: ['uint256'], - type: 5, - }, - }, - ], - default: false, - docs: [''], - label: 'burn', - mutates: true, - payable: false, - returnType: { - displayName: ['bool'], - type: 7, - }, - selector: '0x9dc29fac', - }, ], }, storage: { @@ -634,7 +514,7 @@ export const metadata = { name: '_issuer', }, ], - name: 'TestableERC20Wrapper', + name: 'ERC20Wrapper', }, }, types: [ @@ -862,6 +742,18 @@ export class Contract { return this.stateCall('0x313ce567', []) } + totalSupply(): Promise { + return this.stateCall('0x18160ddd', []) + } + + balanceOf(_owner: AccountId): Promise { + return this.stateCall('0x70a08231', [_owner]) + } + + allowance(_owner: AccountId, _spender: AccountId): Promise { + return this.stateCall('0xdd62ed3e', [_owner, _spender]) + } + private async stateCall(selector: string, args: any[]): Promise { let input = _abi.encodeMessageInput(selector, args) let data = encodeCall(this.address, input) @@ -875,6 +767,10 @@ export class Contract { } } +export type AccountId = Bytes + +export type uint256 = bigint + export type uint8 = number export type Constructor = Constructor_new @@ -897,9 +793,7 @@ export type Message = | Message_allowance | Message_approve | Message_balanceOf - | Message_burn | Message_decimals - | Message_mint | Message_name | Message_symbol | Message_totalSupply @@ -932,15 +826,6 @@ export interface Message_balanceOf { owner: AccountId } -/** - * - */ -export interface Message_burn { - __kind: 'burn' - from: AccountId - amount: uint256 -} - /** * */ @@ -948,15 +833,6 @@ export interface Message_decimals { __kind: 'decimals' } -/** - * - */ -export interface Message_mint { - __kind: 'mint' - to: AccountId - amount: uint256 -} - /** * */ @@ -997,11 +873,7 @@ export interface Message_transferFrom { amount: uint256 } -export type uint256 = bigint - -export type AccountId = Bytes - -export type Event = Event_Approval | Event_Burn | Event_Mint | Event_Transfer +export type Event = Event_Approval | Event_Transfer export interface Event_Approval { __kind: 'Approval' @@ -1010,18 +882,6 @@ export interface Event_Approval { value: uint256 } -export interface Event_Burn { - __kind: 'Burn' - from: AccountId - value: uint256 -} - -export interface Event_Mint { - __kind: 'Mint' - to: AccountId - value: uint256 -} - export interface Event_Transfer { __kind: 'Transfer' from: AccountId diff --git a/src/abi/router.ts b/src/abi/router.ts index dd335fc9..98aa2383 100644 --- a/src/abi/router.ts +++ b/src/abi/router.ts @@ -8,7 +8,7 @@ export const metadata = { }, source: { compiler: 'solang 0.3.2', - hash: '0x6e7bac057718ec67cf2b2995370248e5bfb03fc38a29127a51dbf4ccf12e08ca', + hash: '0xc3a4799cb3feb885864b7bda2b7340893d52fc4f096024e42c5c59319e9cf4ed', language: 'Solidity 0.3.2', }, spec: { @@ -297,7 +297,7 @@ export const metadata = { { args: [ { - label: '', + label: 'assetId', type: { displayName: [ 'ink_primitives', @@ -322,7 +322,7 @@ export const metadata = { { args: [ { - label: '', + label: 'assetId', type: { displayName: [ 'ink_primitives', @@ -845,12 +845,12 @@ export class Contract { return this.stateCall('0x8da5cb5b', []) } - poolByAsset(accountId: AccountId): Promise { - return this.stateCall('0x06de94d8', []) + poolByAsset(assetId: AccountId): Promise { + return this.stateCall('0x06de94d8', [assetId]) } - oracleByAsset(accountId: AccountId): Promise { - return this.stateCall('0x38163032', []) + oracleByAsset(assetId: AccountId): Promise { + return this.stateCall('0x38163032', [assetId]) } getAmountOut( @@ -917,7 +917,7 @@ export interface Message_getAmountOut { */ export interface Message_oracleByAsset { __kind: 'oracleByAsset' - accountId: AccountId + assetId: AccountId } /** @@ -946,7 +946,7 @@ export interface Message_paused { */ export interface Message_poolByAsset { __kind: 'poolByAsset' - accountId: AccountId + assetId: AccountId } /** diff --git a/src/abi/swap.ts b/src/abi/swap.ts index 64655416..a61b1782 100644 --- a/src/abi/swap.ts +++ b/src/abi/swap.ts @@ -4,13 +4,13 @@ export const metadata = { contract: { authors: ['unknown'], description: - 'Swap pool contract. May or may not be covered by a backstop pool. Conceptionally, there are two ways to temporarily disable a pool:\nThe owner can either pause the pool, disabling deposits, swaps & backstop,\nor the owner can set the pool cap to zero which only prevents deposits.\nThe former is for security incidents, the latter for phasing out a pool.', + 'Swap pool contract. May or may not be covered by a backstop pool. Conceptionally, there are two ways to temporarily disable a pool: The owner can either pause the pool, disabling deposits, swaps & backstop, or the owner can set the pool cap to zero which only prevents deposits. The former is for security incidents, the latter for phasing out a pool.', name: 'SwapPool', version: '0.0.1', }, source: { compiler: 'solang 0.3.2', - hash: '0x4878e478a0e56c4febd690a37624ba0fb4b0c0ea8b3e6594519a228b7113e4bb', + hash: '0x480a1345d46a94f8d4a41c5f443c00de2f6d784e8ae1ebc3ea8a8a585990872a', language: 'Solidity 0.3.2', }, spec: { @@ -96,7 +96,7 @@ export const metadata = { }, ], docs: [ - 'Swap pool contract. May or may not be covered by a backstop pool. Conceptionally, there are two ways to temporarily disable a pool:\nThe owner can either pause the pool, disabling deposits, swaps & backstop,\nor the owner can set the pool cap to zero which only prevents deposits.\nThe former is for security incidents, the latter for phasing out a pool.', + 'Swap pool contract. May or may not be covered by a backstop pool. Conceptionally, there are two ways to temporarily disable a pool: The owner can either pause the pool, disabling deposits, swaps & backstop, or the owner can set the pool cap to zero which only prevents deposits. The former is for security incidents, the latter for phasing out a pool.', ], environment: { accountId: { @@ -793,18 +793,57 @@ export const metadata = { }, selector: '0x38d52e0f', }, + { + args: [], + default: false, + docs: ['Returns the decimals of the pool asset'], + label: 'assetDecimals', + mutates: false, + payable: false, + returnType: { + displayName: ['uint8'], + type: 0, + }, + selector: '0xc2d41601', + }, + { + args: [], + default: false, + docs: [''], + label: 'totalLiabilities', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0xf73579a9', + }, + { + args: [], + default: false, + docs: [''], + label: 'reserve', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0xcd3293de', + }, { args: [], default: false, docs: [''], - label: 'accumulatedSlippage', + label: 'reserveWithSlippage', mutates: false, payable: false, returnType: { displayName: ['uint256'], type: 3, }, - selector: '0xe4182b09', + selector: '0x0b09d91e', }, { args: [], @@ -871,29 +910,6 @@ export const metadata = { }, selector: '0xebe26b9e', }, - { - args: [ - { - label: '_amount', - type: { - displayName: ['uint256'], - type: 3, - }, - }, - ], - default: false, - docs: [ - 'Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0', - ], - label: 'deposit', - mutates: true, - payable: false, - returnType: { - displayName: ['SwapPool', 'deposit', 'return_type'], - type: 9, - }, - selector: '0xb6b55f25', - }, { args: [ { @@ -968,10 +984,46 @@ export const metadata = { returnType: null, selector: '0xeb43434e', }, + { + args: [], + default: false, + docs: ['Return the configured swap fees for this pool'], + label: 'swapFees', + mutates: false, + payable: false, + returnType: { + displayName: ['SwapPool', 'swapFees', 'return_type'], + type: 8, + }, + selector: '0xb9ccf21d', + }, + { + args: [ + { + label: '_depositAmount', + type: { + displayName: ['uint256'], + type: 3, + }, + }, + ], + default: false, + docs: [ + 'Deposits amount of tokens into pool Will change cov ratio of pool, will increase delta to 0', + ], + label: 'deposit', + mutates: true, + payable: false, + returnType: { + displayName: ['SwapPool', 'deposit', 'return_type'], + type: 10, + }, + selector: '0xb6b55f25', + }, { args: [ { - label: '_shares', + label: '_sharesToBurn', type: { displayName: ['uint256'], type: 3, @@ -994,7 +1046,7 @@ export const metadata = { payable: false, returnType: { displayName: ['SwapPool', 'withdraw', 'return_type'], - type: 10, + type: 11, }, selector: '0x441a3e70', }, @@ -1012,7 +1064,7 @@ export const metadata = { }, }, { - label: '_shares', + label: '_sharesToBurn', type: { displayName: ['uint256'], type: 3, @@ -1060,7 +1112,10 @@ export const metadata = { label: 'backstopDrain', mutates: true, payable: false, - returnType: null, + returnType: { + displayName: ['uint256'], + type: 3, + }, selector: '0xc2cb15de', }, { @@ -1086,6 +1141,29 @@ export const metadata = { }, selector: '0x4d8ea83f', }, + { + args: [ + { + label: '_amount', + type: { + displayName: ['uint256'], + type: 3, + }, + }, + ], + default: false, + docs: [ + 'Get a quote for the effective amount of tokens for a swap into', + ], + label: 'quoteSwapInto', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0x3c945248', + }, { args: [ { @@ -1109,6 +1187,29 @@ export const metadata = { }, selector: '0x5f79d44f', }, + { + args: [ + { + label: '_amount', + type: { + displayName: ['uint256'], + type: 3, + }, + }, + ], + default: false, + docs: [ + 'Get a quote for the effective amount of tokens, incl. slippage and fees', + ], + label: 'quoteSwapOut', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0x8735c246', + }, { args: [], default: false, @@ -1138,10 +1239,25 @@ export const metadata = { payable: false, returnType: { displayName: ['SwapPool', 'coverage', 'return_type'], - type: 11, + type: 12, }, selector: '0xee8f6a0e', }, + { + args: [], + default: false, + docs: [ + 'Computes the excess liquidity that forms that valuation of the backstop pool is defined as b + C - B - L where - b is reserve - C is the amount of pool tokens in the pool - B is reserveWithSlippage - L is totalLiabilities', + ], + label: 'getExcessLiquidity', + mutates: false, + payable: false, + returnType: { + displayName: ['int256'], + type: 9, + }, + selector: '0xace0f0d5', + }, { args: [ { @@ -1172,53 +1288,7 @@ export const metadata = { { args: [ { - label: '_amount', - type: { - displayName: ['uint256'], - type: 3, - }, - }, - ], - default: false, - docs: [ - 'Get a quote for the effective amount of tokens, incl. slippage and fees', - ], - label: 'quoteSwapInto', - mutates: false, - payable: false, - returnType: { - displayName: ['uint256'], - type: 3, - }, - selector: '0x3c945248', - }, - { - args: [ - { - label: '_amount', - type: { - displayName: ['uint256'], - type: 3, - }, - }, - ], - default: false, - docs: [ - 'Get a quote for the effective amount of tokens, incl. slippage and fees', - ], - label: 'quoteSwapOut', - mutates: false, - payable: false, - returnType: { - displayName: ['uint256'], - type: 3, - }, - selector: '0x8735c246', - }, - { - args: [ - { - label: '_shares', + label: '_sharesToBurn', type: { displayName: ['uint256'], type: 3, @@ -1238,19 +1308,6 @@ export const metadata = { }, selector: '0xcc045745', }, - { - args: [], - default: false, - docs: ['Return the configured swap fees for this pool'], - label: 'swapFees', - mutates: false, - payable: false, - returnType: { - displayName: ['SwapPool', 'swapFees', 'return_type'], - type: 12, - }, - selector: '0xb9ccf21d', - }, ], }, storage: { @@ -1408,13 +1465,13 @@ export const metadata = { layout: { leaf: { key: '0x00000009', - ty: 3, + ty: 0, }, }, root_key: '0x00000009', }, }, - name: 'poolCap', + name: 'poolAssetDecimals', }, { layout: { @@ -1428,7 +1485,7 @@ export const metadata = { root_key: '0x0000000a', }, }, - name: 'accumulatedSlippage', + name: 'poolCap', }, { layout: { @@ -1442,6 +1499,48 @@ export const metadata = { root_key: '0x0000000b', }, }, + name: 'totalLiabilities', + }, + { + layout: { + root: { + layout: { + leaf: { + key: '0x0000000c', + ty: 3, + }, + }, + root_key: '0x0000000c', + }, + }, + name: 'reserve', + }, + { + layout: { + root: { + layout: { + leaf: { + key: '0x0000000d', + ty: 3, + }, + }, + root_key: '0x0000000d', + }, + }, + name: 'reserveWithSlippage', + }, + { + layout: { + root: { + layout: { + leaf: { + key: '0x0000000e', + ty: 3, + }, + }, + root_key: '0x0000000e', + }, + }, name: 'insuranceWithdrawalTimelock', }, { @@ -1453,7 +1552,7 @@ export const metadata = { { layout: { leaf: { - key: '0x0000000c', + key: '0x0000000f', ty: 1, }, }, @@ -1463,7 +1562,7 @@ export const metadata = { name: 'AccountId', }, }, - root_key: '0x0000000c', + root_key: '0x0000000f', }, }, name: 'protocolTreasury', @@ -1477,7 +1576,7 @@ export const metadata = { { layout: { leaf: { - key: '0x0000000d', + key: '0x00000010', ty: 1, }, }, @@ -1487,7 +1586,7 @@ export const metadata = { name: 'AccountId', }, }, - root_key: '0x0000000d', + root_key: '0x00000010', }, }, name: 'backstop', @@ -1501,7 +1600,7 @@ export const metadata = { { layout: { leaf: { - key: '0x0000000e', + key: '0x00000011', ty: 1, }, }, @@ -1511,7 +1610,7 @@ export const metadata = { name: 'AccountId', }, }, - root_key: '0x0000000e', + root_key: '0x00000011', }, }, name: 'router', @@ -1525,7 +1624,7 @@ export const metadata = { { layout: { leaf: { - key: '0x0000000f', + key: '0x00000012', ty: 1, }, }, @@ -1535,7 +1634,7 @@ export const metadata = { name: 'AccountId', }, }, - root_key: '0x0000000f', + root_key: '0x00000012', }, }, name: 'slippageCurve', @@ -1545,11 +1644,11 @@ export const metadata = { root: { layout: { leaf: { - key: '0x00000010', + key: '0x00000013', ty: 3, }, }, - root_key: '0x00000010', + root_key: '0x00000013', }, }, name: 'latestDepositAtBlockNo', @@ -1563,7 +1662,7 @@ export const metadata = { { layout: { leaf: { - key: '0x00000011', + key: '0x00000014', ty: 6, }, }, @@ -1572,7 +1671,7 @@ export const metadata = { { layout: { leaf: { - key: '0x00000011', + key: '0x00000014', ty: 6, }, }, @@ -1581,7 +1680,7 @@ export const metadata = { { layout: { leaf: { - key: '0x00000011', + key: '0x00000014', ty: 6, }, }, @@ -1591,24 +1690,10 @@ export const metadata = { name: 'SwapFees', }, }, - root_key: '0x00000011', - }, - }, - name: 'swapFeeConfig', - }, - { - layout: { - root: { - layout: { - leaf: { - key: '0x00000014', - ty: 3, - }, - }, root_key: '0x00000014', }, }, - name: 'totalLiabilities', + name: 'swapFeeConfig', }, ], name: 'SwapPool', @@ -1714,45 +1799,45 @@ export const metadata = { id: 8, type: { def: { - primitive: 'i256', + tuple: [3, 3, 3], }, - path: ['int256'], + path: ['SwapPool', 'swapFees', 'return_type'], }, }, { id: 9, type: { def: { - tuple: [3, 8], + primitive: 'i256', }, - path: ['SwapPool', 'deposit', 'return_type'], + path: ['int256'], }, }, { id: 10, type: { def: { - tuple: [3, 8], + tuple: [3, 9], }, - path: ['SwapPool', 'withdraw', 'return_type'], + path: ['SwapPool', 'deposit', 'return_type'], }, }, { id: 11, type: { def: { - tuple: [3, 3], + tuple: [3, 9], }, - path: ['SwapPool', 'coverage', 'return_type'], + path: ['SwapPool', 'withdraw', 'return_type'], }, }, { id: 12, type: { def: { - tuple: [3, 3, 3], + tuple: [3, 3], }, - path: ['SwapPool', 'swapFees', 'return_type'], + path: ['SwapPool', 'coverage', 'return_type'], }, }, { @@ -1923,8 +2008,20 @@ export class Contract { return this.stateCall('0x38d52e0f', []) } - accumulatedSlippage(): Promise { - return this.stateCall('0xe4182b09', []) + assetDecimals(): Promise { + return this.stateCall('0xc2d41601', []) + } + + totalLiabilities(): Promise { + return this.stateCall('0xf73579a9', []) + } + + reserve(): Promise { + return this.stateCall('0xcd3293de', []) + } + + reserveWithSlippage(): Promise { + return this.stateCall('0x0b09d91e', []) } insuranceWithdrawalTimelock(): Promise { @@ -1947,12 +2044,8 @@ export class Contract { return this.stateCall('0xebe26b9e', []) } - coverage(): Promise<[uint256, uint256]> { - return this.stateCall('0xee8f6a0e', []) - } - - insuranceWithdrawalUnlock(_liquidityProvider: AccountId): Promise { - return this.stateCall('0x5c6f4279', [_liquidityProvider]) + swapFees(): Promise { + return this.stateCall('0xb9ccf21d', []) } quoteSwapInto(_amount: uint256): Promise { @@ -1963,12 +2056,20 @@ export class Contract { return this.stateCall('0x8735c246', [_amount]) } - sharesTargetWorth(_shares: uint256): Promise { - return this.stateCall('0xcc045745', [_shares]) + coverage(): Promise<[uint256, uint256]> { + return this.stateCall('0xee8f6a0e', []) } - swapFees(): Promise<[uint256, uint256, uint256]> { - return this.stateCall('0xb9ccf21d', []) + getExcessLiquidity(): Promise { + return this.stateCall('0xace0f0d5', []) + } + + insuranceWithdrawalUnlock(_liquidityProvider: AccountId): Promise { + return this.stateCall('0x5c6f4279', [_liquidityProvider]) + } + + sharesTargetWorth(_sharesToBurn: uint256): Promise { + return this.stateCall('0xcc045745', [_sharesToBurn]) } private async stateCall(selector: string, args: any[]): Promise { @@ -1984,6 +2085,10 @@ export class Contract { } } +export type int256 = bigint + +export type return_type = [uint256, uint256, uint256] + export type bool = boolean export type AccountId = Bytes @@ -2009,10 +2114,10 @@ export interface Constructor_new { } export type Message = - | Message_accumulatedSlippage | Message_allowance | Message_approve | Message_asset + | Message_assetDecimals | Message_backstop | Message_backstopBurn | Message_backstopDrain @@ -2021,6 +2126,7 @@ export type Message = | Message_decimals | Message_decreaseAllowance | Message_deposit + | Message_getExcessLiquidity | Message_increaseAllowance | Message_insuranceWithdrawalTimelock | Message_insuranceWithdrawalUnlock @@ -2033,6 +2139,8 @@ export type Message = | Message_quoteSwapInto | Message_quoteSwapOut | Message_renounceOwnership + | Message_reserve + | Message_reserveWithSlippage | Message_router | Message_setInsuranceWithdrawalTimelock | Message_setPoolCap @@ -2043,6 +2151,7 @@ export type Message = | Message_swapIntoFromRouter | Message_swapOutFromRouter | Message_symbol + | Message_totalLiabilities | Message_totalSupply | Message_transfer | Message_transferFrom @@ -2050,13 +2159,6 @@ export type Message = | Message_unpause | Message_withdraw -/** - * - */ -export interface Message_accumulatedSlippage { - __kind: 'accumulatedSlippage' -} - /** * */ @@ -2082,6 +2184,13 @@ export interface Message_asset { __kind: 'asset' } +/** + * Returns the decimals of the pool asset + */ +export interface Message_assetDecimals { + __kind: 'assetDecimals' +} + /** * */ @@ -2095,7 +2204,7 @@ export interface Message_backstop { export interface Message_backstopBurn { __kind: 'backstopBurn' owner: AccountId - shares: uint256 + sharesToBurn: uint256 } /** @@ -2143,7 +2252,14 @@ export interface Message_decreaseAllowance { */ export interface Message_deposit { __kind: 'deposit' - amount: uint256 + depositAmount: uint256 +} + +/** + * Computes the excess liquidity that forms that valuation of the backstop pool is defined as b + C - B - L where - b is reserve - C is the amount of pool tokens in the pool - B is reserveWithSlippage - L is totalLiabilities + */ +export interface Message_getExcessLiquidity { + __kind: 'getExcessLiquidity' } /** @@ -2213,7 +2329,7 @@ export interface Message_protocolTreasury { } /** - * Get a quote for the effective amount of tokens, incl. slippage and fees + * Get a quote for the effective amount of tokens for a swap into */ export interface Message_quoteSwapInto { __kind: 'quoteSwapInto' @@ -2235,6 +2351,20 @@ export interface Message_renounceOwnership { __kind: 'renounceOwnership' } +/** + * + */ +export interface Message_reserve { + __kind: 'reserve' +} + +/** + * + */ +export interface Message_reserveWithSlippage { + __kind: 'reserveWithSlippage' +} + /** * */ @@ -2273,7 +2403,7 @@ export interface Message_setSwapFees { */ export interface Message_sharesTargetWorth { __kind: 'sharesTargetWorth' - shares: uint256 + sharesToBurn: uint256 } /** @@ -2313,6 +2443,13 @@ export interface Message_symbol { __kind: 'symbol' } +/** + * + */ +export interface Message_totalLiabilities { + __kind: 'totalLiabilities' +} + /** * */ @@ -2359,7 +2496,7 @@ export interface Message_unpause { */ export interface Message_withdraw { __kind: 'withdraw' - shares: uint256 + sharesToBurn: uint256 minimumAmount: uint256 } diff --git a/src/model/generated/backstopPool.model.ts b/src/model/generated/backstopPool.model.ts index c290bd1a..d79f5398 100644 --- a/src/model/generated/backstopPool.model.ts +++ b/src/model/generated/backstopPool.model.ts @@ -2,8 +2,10 @@ import { Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, - ManyToOne as ManyToOne_, + OneToOne as OneToOne_, Index as Index_, + JoinColumn as JoinColumn_, + ManyToOne as ManyToOne_, } from 'typeorm' import * as marshal from './marshal' import { Router } from './router.model' @@ -18,8 +20,9 @@ export class BackstopPool { @PrimaryColumn_() id!: string - @Index_() - @ManyToOne_(() => Router, { nullable: true }) + @Index_({ unique: true }) + @OneToOne_(() => Router, { nullable: true }) + @JoinColumn_() router!: Router @Index_() @@ -32,12 +35,6 @@ export class BackstopPool { }) reserves!: bigint - @Column_('numeric', { - transformer: marshal.bigintTransformer, - nullable: false, - }) - liabilities!: bigint - @Column_('numeric', { transformer: marshal.bigintTransformer, nullable: false, diff --git a/src/model/generated/router.model.ts b/src/model/generated/router.model.ts index eed9fc1e..6da3adaa 100644 --- a/src/model/generated/router.model.ts +++ b/src/model/generated/router.model.ts @@ -19,9 +19,6 @@ export class Router { @OneToMany_(() => SwapPool, (e) => e.router) swapPools!: SwapPool[] - @OneToMany_(() => BackstopPool, (e) => e.router) - backstopPools!: BackstopPool[] - @Column_('bool', { nullable: false }) paused!: boolean } diff --git a/src/model/generated/swapPool.model.ts b/src/model/generated/swapPool.model.ts index 493947ad..e55e9bd8 100644 --- a/src/model/generated/swapPool.model.ts +++ b/src/model/generated/swapPool.model.ts @@ -35,13 +35,19 @@ export class SwapPool { transformer: marshal.bigintTransformer, nullable: false, }) - reserves!: bigint + reserve!: bigint @Column_('numeric', { transformer: marshal.bigintTransformer, nullable: false, }) - liabilities!: bigint + reserveWithSlippage!: bigint + + @Column_('numeric', { + transformer: marshal.bigintTransformer, + nullable: false, + }) + totalLiabilities!: bigint @Column_('numeric', { transformer: marshal.bigintTransformer, diff --git a/src/processor.ts b/src/processor.ts index d4844017..42fa23e2 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -145,6 +145,12 @@ processor.run(new TypeormDatabase(), async (ctx) => { // Fetch max block height from the archive let maxHeight = await maxHeightPromise + console.log( + 'new blocks', + ctx.blocks.length, + ctx.blocks.map((b) => b.header.height) + ) + for (let { header: block, calls, events, extrinsics } of ctx.blocks) { ctx.log.debug( `block ${block.height}: extrinsics - ${extrinsics.length}, calls - ${calls.length}, events - ${events.length}` diff --git a/src/types/pendulum/index.ts b/src/types/pendulum/index.ts index 99e6db9a..cb2154e9 100644 --- a/src/types/pendulum/index.ts +++ b/src/types/pendulum/index.ts @@ -1,4 +1,5 @@ export * as v1 from './v1' export * as v3 from './v3' +export * as v9 from './v9' export * as events from './events' export * as storage from './storage' diff --git a/src/types/pendulum/tokens/events.ts b/src/types/pendulum/tokens/events.ts index 23729dad..ab67cb35 100644 --- a/src/types/pendulum/tokens/events.ts +++ b/src/types/pendulum/tokens/events.ts @@ -9,6 +9,7 @@ import { } from '../support' import * as v1 from '../v1' import * as v3 from '../v3' +import * as v9 from '../v9' export const transfer = { name: 'Tokens.Transfer', @@ -36,6 +37,18 @@ export const transfer = { amount: sts.bigint(), }) ), + /** + * Transfer succeeded. + */ + v9: new EventType( + 'Tokens.Transfer', + sts.struct({ + currencyId: v9.CurrencyId, + from: v9.AccountId32, + to: v9.AccountId32, + amount: sts.bigint(), + }) + ), } export const balanceSet = { @@ -64,6 +77,18 @@ export const balanceSet = { reserved: sts.bigint(), }) ), + /** + * A balance was set by root. + */ + v9: new EventType( + 'Tokens.BalanceSet', + sts.struct({ + currencyId: v9.CurrencyId, + who: v9.AccountId32, + free: sts.bigint(), + reserved: sts.bigint(), + }) + ), } export const withdrawn = { @@ -90,6 +115,17 @@ export const withdrawn = { amount: sts.bigint(), }) ), + /** + * Some balances were withdrawn (e.g. pay for transaction fee) + */ + v9: new EventType( + 'Tokens.Withdrawn', + sts.struct({ + currencyId: v9.CurrencyId, + who: v9.AccountId32, + amount: sts.bigint(), + }) + ), } export const deposited = { @@ -116,4 +152,15 @@ export const deposited = { amount: sts.bigint(), }) ), + /** + * Deposited some balance into an account + */ + v9: new EventType( + 'Tokens.Deposited', + sts.struct({ + currencyId: v9.CurrencyId, + who: v9.AccountId32, + amount: sts.bigint(), + }) + ), } diff --git a/src/types/pendulum/tokens/storage.ts b/src/types/pendulum/tokens/storage.ts index 1db815b2..65d55123 100644 --- a/src/types/pendulum/tokens/storage.ts +++ b/src/types/pendulum/tokens/storage.ts @@ -9,6 +9,7 @@ import { } from '../support' import * as v1 from '../v1' import * as v3 from '../v3' +import * as v9 from '../v9' export const totalIssuance = { /** @@ -29,6 +30,15 @@ export const totalIssuance = { [v3.CurrencyId], sts.bigint() ) as TotalIssuanceV3, + /** + * The total issuance of a token type. + */ + v9: new StorageType( + 'Tokens.TotalIssuance', + 'Default', + [v9.CurrencyId], + sts.bigint() + ) as TotalIssuanceV9, } /** @@ -101,6 +111,41 @@ export interface TotalIssuanceV3 { ): AsyncIterable<[k: v3.CurrencyId, v: bigint | undefined][]> } +/** + * The total issuance of a token type. + */ +export interface TotalIssuanceV9 { + is(block: RuntimeCtx): boolean + getDefault(block: Block): bigint + get(block: Block, key: v9.CurrencyId): Promise + getMany( + block: Block, + keys: v9.CurrencyId[] + ): Promise<(bigint | undefined)[]> + getKeys(block: Block): Promise + getKeys(block: Block, key: v9.CurrencyId): Promise + getKeysPaged(pageSize: number, block: Block): AsyncIterable + getKeysPaged( + pageSize: number, + block: Block, + key: v9.CurrencyId + ): AsyncIterable + getPairs(block: Block): Promise<[k: v9.CurrencyId, v: bigint | undefined][]> + getPairs( + block: Block, + key: v9.CurrencyId + ): Promise<[k: v9.CurrencyId, v: bigint | undefined][]> + getPairsPaged( + pageSize: number, + block: Block + ): AsyncIterable<[k: v9.CurrencyId, v: bigint | undefined][]> + getPairsPaged( + pageSize: number, + block: Block, + key: v9.CurrencyId + ): AsyncIterable<[k: v9.CurrencyId, v: bigint | undefined][]> +} + export const accounts = { /** * The balance of a token type under an account. @@ -130,6 +175,20 @@ export const accounts = { [v3.AccountId32, v3.CurrencyId], v3.Type_418 ) as AccountsV3, + /** + * The balance of a token type under an account. + * + * NOTE: If the total is ever zero, decrease account ref account. + * + * NOTE: This is only used in the case that this module is used to store + * balances. + */ + v9: new StorageType( + 'Tokens.Accounts', + 'Default', + [v9.AccountId32, v9.CurrencyId], + v9.Type_444 + ) as AccountsV9, } /** @@ -303,3 +362,89 @@ export interface AccountsV3 { [k: [v3.AccountId32, v3.CurrencyId], v: v3.Type_418 | undefined][] > } + +/** + * The balance of a token type under an account. + * + * NOTE: If the total is ever zero, decrease account ref account. + * + * NOTE: This is only used in the case that this module is used to store + * balances. + */ +export interface AccountsV9 { + is(block: RuntimeCtx): boolean + getDefault(block: Block): v9.Type_444 + get( + block: Block, + key1: v9.AccountId32, + key2: v9.CurrencyId + ): Promise + getMany( + block: Block, + keys: [v9.AccountId32, v9.CurrencyId][] + ): Promise<(v9.Type_444 | undefined)[]> + getKeys(block: Block): Promise<[v9.AccountId32, v9.CurrencyId][]> + getKeys( + block: Block, + key1: v9.AccountId32 + ): Promise<[v9.AccountId32, v9.CurrencyId][]> + getKeys( + block: Block, + key1: v9.AccountId32, + key2: v9.CurrencyId + ): Promise<[v9.AccountId32, v9.CurrencyId][]> + getKeysPaged( + pageSize: number, + block: Block + ): AsyncIterable<[v9.AccountId32, v9.CurrencyId][]> + getKeysPaged( + pageSize: number, + block: Block, + key1: v9.AccountId32 + ): AsyncIterable<[v9.AccountId32, v9.CurrencyId][]> + getKeysPaged( + pageSize: number, + block: Block, + key1: v9.AccountId32, + key2: v9.CurrencyId + ): AsyncIterable<[v9.AccountId32, v9.CurrencyId][]> + getPairs( + block: Block + ): Promise< + [k: [v9.AccountId32, v9.CurrencyId], v: v9.Type_444 | undefined][] + > + getPairs( + block: Block, + key1: v9.AccountId32 + ): Promise< + [k: [v9.AccountId32, v9.CurrencyId], v: v9.Type_444 | undefined][] + > + getPairs( + block: Block, + key1: v9.AccountId32, + key2: v9.CurrencyId + ): Promise< + [k: [v9.AccountId32, v9.CurrencyId], v: v9.Type_444 | undefined][] + > + getPairsPaged( + pageSize: number, + block: Block + ): AsyncIterable< + [k: [v9.AccountId32, v9.CurrencyId], v: v9.Type_444 | undefined][] + > + getPairsPaged( + pageSize: number, + block: Block, + key1: v9.AccountId32 + ): AsyncIterable< + [k: [v9.AccountId32, v9.CurrencyId], v: v9.Type_444 | undefined][] + > + getPairsPaged( + pageSize: number, + block: Block, + key1: v9.AccountId32, + key2: v9.CurrencyId + ): AsyncIterable< + [k: [v9.AccountId32, v9.CurrencyId], v: v9.Type_444 | undefined][] + > +} diff --git a/src/types/pendulum/v9.ts b/src/types/pendulum/v9.ts new file mode 100644 index 00000000..727ac810 --- /dev/null +++ b/src/types/pendulum/v9.ts @@ -0,0 +1,97 @@ +import { sts, Result, Option, Bytes, BitSequence } from './support' + +export type AccountId32 = Bytes + +export interface Type_444 { + free: bigint + reserved: bigint + frozen: bigint +} + +export const Type_444: sts.Type = sts.struct(() => { + return { + free: sts.bigint(), + reserved: sts.bigint(), + frozen: sts.bigint(), + } +}) + +export type CurrencyId = + | CurrencyId_Native + | CurrencyId_Stellar + | CurrencyId_Token + | CurrencyId_XCM + | CurrencyId_ZenlinkLPToken + +export interface CurrencyId_Native { + __kind: 'Native' +} + +export interface CurrencyId_Stellar { + __kind: 'Stellar' + value: Asset +} + +export interface CurrencyId_Token { + __kind: 'Token' + value: bigint +} + +export interface CurrencyId_XCM { + __kind: 'XCM' + value: number +} + +export interface CurrencyId_ZenlinkLPToken { + __kind: 'ZenlinkLPToken' + value: [number, number, number, number] +} + +export type Asset = Asset_AlphaNum12 | Asset_AlphaNum4 | Asset_StellarNative + +export interface Asset_AlphaNum12 { + __kind: 'AlphaNum12' + code: Bytes + issuer: Bytes +} + +export interface Asset_AlphaNum4 { + __kind: 'AlphaNum4' + code: Bytes + issuer: Bytes +} + +export interface Asset_StellarNative { + __kind: 'StellarNative' +} + +export const AccountId32 = sts.bytes() + +export const CurrencyId: sts.Type = sts.closedEnum(() => { + return { + Native: sts.unit(), + Stellar: Asset, + Token: sts.bigint(), + XCM: sts.number(), + ZenlinkLPToken: sts.tuple(() => [ + sts.number(), + sts.number(), + sts.number(), + sts.number(), + ]), + } +}) + +export const Asset: sts.Type = sts.closedEnum(() => { + return { + AlphaNum12: sts.enumStruct({ + code: sts.bytes(), + issuer: sts.bytes(), + }), + AlphaNum4: sts.enumStruct({ + code: sts.bytes(), + issuer: sts.bytes(), + }), + StellarNative: sts.unit(), + } +}) From 2106321a45bebf0261d8a702fab9362b03af708d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Sat, 27 Jan 2024 10:04:21 -0300 Subject: [PATCH 03/20] Adopt types from official Nabla indexer --- schema.graphql | 24 ++++++++++++-- src/model/generated/backstopPool.model.ts | 26 +++++++++++---- src/model/generated/index.ts | 1 + src/model/generated/nablaSwapFee.model.ts | 40 +++++++++++++++++++++++ src/model/generated/nablaToken.model.ts | 11 +++++++ src/model/generated/router.model.ts | 3 ++ src/model/generated/swapPool.model.ts | 18 ++++++++++ 7 files changed, 114 insertions(+), 9 deletions(-) create mode 100644 src/model/generated/nablaSwapFee.model.ts diff --git a/schema.graphql b/schema.graphql index 3d1c7cfa..494970cb 100644 --- a/schema.graphql +++ b/schema.graphql @@ -743,8 +743,8 @@ type Incentive @entity { type Router @entity { id: ID! # id can be the address of the router contract - swapPools: [SwapPool!] @derivedFrom(field: "router") - backstopPool: BackstopPool @derivedFrom(field: "router") + swapPools: [SwapPool!]! @derivedFrom(field: "router") + backstopPool: [BackstopPool!]! @derivedFrom(field: "router") paused: Boolean! # whether the router is paused } @@ -753,10 +753,14 @@ type NablaToken @entity { decimals: Int! # number of decimal places the token can be split into name: String! # name of the token symbol: String! # ticker symbol of the token + latestSwapPool: SwapPool # swap pool of the token used by the router + swapPools: [SwapPool!]! @derivedFrom(field: "token") } type SwapPool @entity { id: ID! # id can be the address of the swap pool contract + name: String! # name of the swap pool LP token + symbol: String! # ticker symbol of the swap pool LP token router: Router! # link to the Router entity backstop: BackstopPool! # link to the BackstopPool entity token: NablaToken! # link to the Token entity @@ -765,15 +769,29 @@ type SwapPool @entity { totalLiabilities: BigInt! # total Liquidity Provider (LP) deposits totalSupply: BigInt! # total supply of LP tokens paused: Boolean! # whether the swap pool is paused + apr: BigInt! # annual percentage rate of the swap pool + coveredIndex: BigInt # index of swap pool covered by the backstop pool } type BackstopPool @entity { id: ID! # id can be the address of the backstop pool contract - router: Router! @unique # link to the Router entity + name: String! # name of the backstop pool LP token + symbol: String! # ticker symbol of the backstop pool LP token + router: Router! # link to the Router entity token: NablaToken! # link to the NablaToken entity reserves: BigInt! # current balance of the pool totalSupply: BigInt! # total supply of LP tokens paused: Boolean! # whether the backstop pool is paused + coveredSwapPools: [SwapPool!]! @derivedFrom(field: "backstop") # swap pools that are covered by the backstop pool + apr: BigInt! # annual percentage rate of the backstop pool +} + +type NablaSwapFee @entity { + id: ID! # id is address of the swap pool contract + timestamp + lpFee: BigInt! # LP fee in `asset` + backstopFees: BigInt! # backstop fee in `asset` + protocolFees: BigInt! # protocol fee in `asset` + timestamp: BigInt! # timestamp of the swap event } type Block @entity { diff --git a/src/model/generated/backstopPool.model.ts b/src/model/generated/backstopPool.model.ts index d79f5398..4a27e9e9 100644 --- a/src/model/generated/backstopPool.model.ts +++ b/src/model/generated/backstopPool.model.ts @@ -2,14 +2,14 @@ import { Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, - OneToOne as OneToOne_, - Index as Index_, - JoinColumn as JoinColumn_, ManyToOne as ManyToOne_, + Index as Index_, + OneToMany as OneToMany_, } from 'typeorm' import * as marshal from './marshal' import { Router } from './router.model' import { NablaToken } from './nablaToken.model' +import { SwapPool } from './swapPool.model' @Entity_() export class BackstopPool { @@ -20,9 +20,14 @@ export class BackstopPool { @PrimaryColumn_() id!: string - @Index_({ unique: true }) - @OneToOne_(() => Router, { nullable: true }) - @JoinColumn_() + @Column_('text', { nullable: false }) + name!: string + + @Column_('text', { nullable: false }) + symbol!: string + + @Index_() + @ManyToOne_(() => Router, { nullable: true }) router!: Router @Index_() @@ -43,4 +48,13 @@ export class BackstopPool { @Column_('bool', { nullable: false }) paused!: boolean + + @OneToMany_(() => SwapPool, (e) => e.backstop) + coveredSwapPools!: SwapPool[] + + @Column_('numeric', { + transformer: marshal.bigintTransformer, + nullable: false, + }) + apr!: bigint } diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index d67e70b6..5721586f 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -49,6 +49,7 @@ export * from './router.model' export * from './nablaToken.model' export * from './swapPool.model' export * from './backstopPool.model' +export * from './nablaSwapFee.model' export * from './block.model' export * from './extrinsic.model' export * from './_extrinsicSignature' diff --git a/src/model/generated/nablaSwapFee.model.ts b/src/model/generated/nablaSwapFee.model.ts new file mode 100644 index 00000000..14d250f6 --- /dev/null +++ b/src/model/generated/nablaSwapFee.model.ts @@ -0,0 +1,40 @@ +import { + Entity as Entity_, + Column as Column_, + PrimaryColumn as PrimaryColumn_, +} from 'typeorm' +import * as marshal from './marshal' + +@Entity_() +export class NablaSwapFee { + constructor(props?: Partial) { + Object.assign(this, props) + } + + @PrimaryColumn_() + id!: string + + @Column_('numeric', { + transformer: marshal.bigintTransformer, + nullable: false, + }) + lpFee!: bigint + + @Column_('numeric', { + transformer: marshal.bigintTransformer, + nullable: false, + }) + backstopFees!: bigint + + @Column_('numeric', { + transformer: marshal.bigintTransformer, + nullable: false, + }) + protocolFees!: bigint + + @Column_('numeric', { + transformer: marshal.bigintTransformer, + nullable: false, + }) + timestamp!: bigint +} diff --git a/src/model/generated/nablaToken.model.ts b/src/model/generated/nablaToken.model.ts index 45554c5e..60be0e57 100644 --- a/src/model/generated/nablaToken.model.ts +++ b/src/model/generated/nablaToken.model.ts @@ -2,7 +2,11 @@ import { Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, + ManyToOne as ManyToOne_, + Index as Index_, + OneToMany as OneToMany_, } from 'typeorm' +import { SwapPool } from './swapPool.model' @Entity_() export class NablaToken { @@ -21,4 +25,11 @@ export class NablaToken { @Column_('text', { nullable: false }) symbol!: string + + @Index_() + @ManyToOne_(() => SwapPool, { nullable: true }) + latestSwapPool!: SwapPool | undefined | null + + @OneToMany_(() => SwapPool, (e) => e.token) + swapPools!: SwapPool[] } diff --git a/src/model/generated/router.model.ts b/src/model/generated/router.model.ts index 6da3adaa..793f8789 100644 --- a/src/model/generated/router.model.ts +++ b/src/model/generated/router.model.ts @@ -19,6 +19,9 @@ export class Router { @OneToMany_(() => SwapPool, (e) => e.router) swapPools!: SwapPool[] + @OneToMany_(() => BackstopPool, (e) => e.router) + backstopPool!: BackstopPool[] + @Column_('bool', { nullable: false }) paused!: boolean } diff --git a/src/model/generated/swapPool.model.ts b/src/model/generated/swapPool.model.ts index e55e9bd8..d530a820 100644 --- a/src/model/generated/swapPool.model.ts +++ b/src/model/generated/swapPool.model.ts @@ -19,6 +19,12 @@ export class SwapPool { @PrimaryColumn_() id!: string + @Column_('text', { nullable: false }) + name!: string + + @Column_('text', { nullable: false }) + symbol!: string + @Index_() @ManyToOne_(() => Router, { nullable: true }) router!: Router @@ -57,4 +63,16 @@ export class SwapPool { @Column_('bool', { nullable: false }) paused!: boolean + + @Column_('numeric', { + transformer: marshal.bigintTransformer, + nullable: false, + }) + apr!: bigint + + @Column_('numeric', { + transformer: marshal.bigintTransformer, + nullable: true, + }) + coveredIndex!: bigint | undefined | null } From 42cfd0d4cc32ee7b0b20d00a432ce3671ea8a1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Wed, 31 Jan 2024 17:31:55 -0300 Subject: [PATCH 04/20] Migrate squid logic to new Nabla --- db/migrations/1706303296765-Data.js | 861 ------------------ ...82385470-Data.js => 1706733053259-Data.js} | 44 +- schema.graphql | 8 +- src/mappings/nabla.ts | 303 +++++- src/model/generated/backstopPool.model.ts | 4 + src/model/generated/nablaSwapFee.model.ts | 14 +- src/model/generated/swapPool.model.ts | 7 +- 7 files changed, 330 insertions(+), 911 deletions(-) delete mode 100644 db/migrations/1706303296765-Data.js rename db/migrations/{1701282385470-Data.js => 1706733053259-Data.js} (94%) diff --git a/db/migrations/1706303296765-Data.js b/db/migrations/1706303296765-Data.js deleted file mode 100644 index 465402a9..00000000 --- a/db/migrations/1706303296765-Data.js +++ /dev/null @@ -1,861 +0,0 @@ -module.exports = class Data1706303296765 { - name = 'Data1706303296765' - - async up(db) { - await db.query( - `CREATE TABLE "oracle_price" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "blockchain" text NOT NULL, "timestamp" numeric NOT NULL, "price" text NOT NULL, "supply" text NOT NULL, "decimals" integer NOT NULL, CONSTRAINT "PK_606c938b2474588b154eb625f3b" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_6554f47abd46667280a2523381" ON "oracle_price" ("symbol") ` - ) - await db.query( - `CREATE INDEX "IDX_2026224855490e321e5c0b6911" ON "oracle_price" ("blockchain") ` - ) - await db.query( - `CREATE INDEX "IDX_a77ac6d79f0929522f5a1aefcb" ON "oracle_price" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_f7c9bf3bae39fb0a75f12b87dd" ON "oracle_price" ("price") ` - ) - await db.query( - `CREATE TABLE "transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "amount" numeric NOT NULL, "fee" numeric NOT NULL, "remark" text, CONSTRAINT "PK_fd9ddbdd49a17afcbe014401295" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_d6624eacc30144ea97915fe846" ON "transfer" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_70ff8b624c3118ac3a4862d22c" ON "transfer" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_070c555a86b0b41a534a55a659" ON "transfer" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_f4007436c1b546ede08a4fd7ab" ON "transfer" ("amount") ` - ) - await db.query( - `CREATE TABLE "factory" ("id" character varying NOT NULL, "pair_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_volume_eth" text NOT NULL, "untracked_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_1372e5a7d114a3fa80736ba66bb" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "stable_swap_event" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_8b61dbc9b556ed8fcb4030fee7d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_3a147c85b92441217540579be8" ON "stable_swap_event" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_exchange" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_f06e489da865134dcfac3bbcd22" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_1180a78feea28e278229de7db4" ON "stable_swap_exchange" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_819b3b7bf9c8055e14e0bf1c578" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_648b49eb1a4f2a47f24f13bb51" ON "stable_swap_day_data" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "hourly_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_2aedd41b95c37330a4a8429e192" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_94584d2925c30ae0d4b80aadfc" ON "stable_swap_hour_data" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "token_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_token" text NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "total_liquidity_token" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_liquidity_usd" text NOT NULL, "price_usd" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_73fc06337215e86196b36822116" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_b8950a8bc7b60231137573740e" ON "token_day_data" ("token_id") ` - ) - await db.query( - `CREATE TABLE "pair_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "hourly_volume_token0" text NOT NULL, "hourly_volume_token1" text NOT NULL, "hourly_volume_usd" text NOT NULL, "hourly_txns" integer NOT NULL, "pair_id" character varying, CONSTRAINT "PK_ffc544bb3e72cfd3e48a8b01452" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_cf50c55389e428096a68598ee3" ON "pair_hour_data" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "stable_swap_id" character varying, CONSTRAINT "PK_12f435243c8a739330c0881d720" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_f953aebc7c0752f6b8434c9eef" ON "stable_swap_liquidity_position" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_405e0d7aeca80975d88a63bc6e" ON "stable_swap_liquidity_position" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stake_position" ("id" character varying NOT NULL, "liquidity_staked_balance" numeric NOT NULL, "user_id" character varying, "farm_id" character varying, CONSTRAINT "PK_17615803509bd6065f1ab8b0ced" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_2a2b22d2744b497bbcfb03e6ab" ON "stake_position" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_670629d9904e1f48f4a31abb49" ON "stake_position" ("farm_id") ` - ) - await db.query( - `CREATE TABLE "user" ("id" character varying NOT NULL, "usd_swapped" text NOT NULL, CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_db00d963c96b3914d26abe3c3d2" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_781470585a67fef4e215a59977" ON "liquidity_position" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_5a626c8b8962dc01e0f8801be6" ON "liquidity_position" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "liquidity_position_snapshot" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block" integer NOT NULL, "token0_price_usd" text NOT NULL, "token1_price_usd" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "reserve_usd" text NOT NULL, "liquidity_token_total_supply" text NOT NULL, "liquidity_token_balance" text NOT NULL, "liquidity_position_id" character varying, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_cd4ed3539266b2439349a9fa791" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_eb823fd4d5a47575039e902efa" ON "liquidity_position_snapshot" ("liquidity_position_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ed32a41150bc13f18a01974153" ON "liquidity_position_snapshot" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ce85a847b2952f7e685f150de1" ON "liquidity_position_snapshot" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "transaction" ("id" character varying NOT NULL, "block_number" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "mints" text array NOT NULL, "burns" text array NOT NULL, "swaps" text array NOT NULL, CONSTRAINT "PK_89eadb93a89810556e1cbcd6ab9" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "mint" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "to" text NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "log_index" integer, "amount_usd" text, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_fcaea791104aa41aa11dac29cb2" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_19f4328320501dfd14e2bae085" ON "mint" ("transaction_id") ` - ) - await db.query( - `CREATE INDEX "IDX_81d470127d4c55d09e9213bc4e" ON "mint" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "burn" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "to" text, "log_index" integer, "amount_usd" text, "needs_complete" boolean NOT NULL, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_dcb4f14ee4534154b31116553f0" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_20ec76c5c56dd6b47dec5f0aaa" ON "burn" ("transaction_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ba144ce938b3266a470d4dd70f" ON "burn" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "swap" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "from" text NOT NULL, "amount0_in" text NOT NULL, "amount1_in" text NOT NULL, "amount0_out" text NOT NULL, "amount1_out" text NOT NULL, "to" text NOT NULL, "log_index" integer, "amount_usd" text NOT NULL, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_4a10d0f359339acef77e7f986d9" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_78506c4050ae7cedd50b08c0dc" ON "swap" ("transaction_id") ` - ) - await db.query( - `CREATE INDEX "IDX_3571ab1dad7640a6b93c705b8f" ON "swap" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "pair" ("id" character varying NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_eth" text NOT NULL, "reserve_usd" text NOT NULL, "tracked_reserve_eth" text NOT NULL, "token0_price" text NOT NULL, "token1_price" text NOT NULL, "volume_token0" text NOT NULL, "volume_token1" text NOT NULL, "volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "created_at_timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "created_at_block_number" numeric NOT NULL, "liquidity_provider_count" integer NOT NULL, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_3eaf216329c5c50aedb94fa797e" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_f74dc53460944a424b56b8f7da" ON "pair" ("token0_id") ` - ) - await db.query( - `CREATE INDEX "IDX_4419691fc411b8af754dfa65ce" ON "pair" ("token1_id") ` - ) - await db.query( - `CREATE TABLE "pair_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "pair_address" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "daily_volume_token0" text NOT NULL, "daily_volume_token1" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "pair_id" character varying, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_ac35ed26ab0c71d491a62e2881a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_d8ba7d7d7ad9f0e1c2933a0b7e" ON "pair_day_data" ("pair_id") ` - ) - await db.query( - `CREATE INDEX "IDX_88f6e19c40b47053e6e197db1c" ON "pair_day_data" ("token0_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ce435d6fc7c373d58e7aab156d" ON "pair_day_data" ("token1_id") ` - ) - await db.query( - `CREATE TABLE "token" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "decimals" integer NOT NULL, "total_supply" text NOT NULL, "trade_volume" text NOT NULL, "trade_volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "total_liquidity" text NOT NULL, "derived_eth" text NOT NULL, CONSTRAINT "PK_82fae97f905930df5d62a702fc9" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "single_token_lock_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_87d03adf6b8624eaff434355e53" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_f3bf64f43101176dbe5f11a36b" ON "single_token_lock_day_data" ("single_token_lock_id") ` - ) - await db.query( - `CREATE TABLE "single_token_lock_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_9173bf5d597c5ce35bbce2e664b" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_b2a84dc625103153d651b701dd" ON "single_token_lock_hour_data" ("single_token_lock_id") ` - ) - await db.query( - `CREATE TABLE "single_token_lock" ("id" character varying NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_eth" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_b3d635331ccfacc4f532569364b" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_8ebffe66457859d6e1c37b81ac" ON "single_token_lock" ("token_id") ` - ) - await db.query( - `CREATE TABLE "incentive" ("id" character varying NOT NULL, "reward_per_day" text NOT NULL, "farm_id" character varying, "reward_token_id" character varying, CONSTRAINT "PK_fc2c4e32d8711392ddf918b9f6c" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_35286137967591eaff8dee7ca2" ON "incentive" ("farm_id") ` - ) - await db.query( - `CREATE INDEX "IDX_041db4166864a3841e5efed53c" ON "incentive" ("reward_token_id") ` - ) - await db.query( - `CREATE TABLE "farm" ("id" character varying NOT NULL, "pid" numeric NOT NULL, "stake_token" text NOT NULL, "liquidity_staked" numeric NOT NULL, "created_at_block" numeric NOT NULL, "created_at_timestamp" numeric NOT NULL, "staked_usd" text NOT NULL, "reward_usd_per_day" text NOT NULL, "stake_apr" text NOT NULL, "single_token_lock_id" character varying, "stable_swap_id" character varying, "pair_id" character varying, CONSTRAINT "PK_3bf246b27a3b6678dfc0b7a3f64" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_679106a1febf251d7fe7fe081a" ON "farm" ("single_token_lock_id") ` - ) - await db.query( - `CREATE INDEX "IDX_00b8f5b860927b1b85e866b20d" ON "farm" ("stable_swap_id") ` - ) - await db.query( - `CREATE INDEX "IDX_11da1bf5c406898262d91b41cb" ON "farm" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap" ("id" character varying NOT NULL, "address" text NOT NULL, "base_swap_address" text NOT NULL, "num_tokens" integer NOT NULL, "tokens" text array NOT NULL, "base_tokens" text array NOT NULL, "all_tokens" text array NOT NULL, "balances" text array NOT NULL, "lp_token" text NOT NULL, "lp_total_supply" text NOT NULL, "a" numeric NOT NULL, "swap_fee" numeric NOT NULL, "admin_fee" numeric NOT NULL, "virtual_price" numeric NOT NULL, "tvl_usd" text NOT NULL, "volume_usd" text NOT NULL, "stable_swap_info_id" character varying, CONSTRAINT "PK_37316f6fedc29bf95a6f1804c65" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_88cce14adee6d21f5057551c3e" ON "stable_swap" ("stable_swap_info_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_info" ("id" character varying NOT NULL, "pool_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_21998b071d5e28639e21e9b2da7" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "zenlink_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, "factory_id" character varying, "stable_swap_info_id" character varying, CONSTRAINT "PK_2526d46468e5c4f7c4156840a90" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_9a6b55d2085464668b622dffe6" ON "zenlink_info" ("factory_id") ` - ) - await db.query( - `CREATE INDEX "IDX_0795adc3723792868094ec76c0" ON "zenlink_info" ("stable_swap_info_id") ` - ) - await db.query( - `CREATE TABLE "token_transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, "remark" text, CONSTRAINT "PK_77384b7f5874553f012eba9da41" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_b47f7192b72dd8436ef4e6d253" ON "token_transfer" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_752d6c330729a7b2e283003374" ON "token_transfer" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_2ef35b71d641ec79b7de3ac237" ON "token_transfer" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_aae50046f62ba400c07477fb6c" ON "token_transfer" ("amount") ` - ) - await db.query( - `CREATE TABLE "token_deposit" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_7c5eea7aeab3f0e71da8d2d9f4f" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_395da815b9927f13e2f87c6b54" ON "token_deposit" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_0f87d313517eaa806c75444749" ON "token_deposit" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_7194acc3ea037189ff3da743ec" ON "token_deposit" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_d23ae7a0ea1f640e8e9875b3c2" ON "token_deposit" ("amount") ` - ) - await db.query( - `CREATE TABLE "token_withdrawn" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_658727649cde2e20f8cf69abeb5" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_e7fd99cae9a1df2e8f69d60892" ON "token_withdrawn" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_70e98131fb737e4dce4455ca43" ON "token_withdrawn" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_867e6d004e7a4994b3b2aeba63" ON "token_withdrawn" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_5697bf049746e5102413ebd832" ON "token_withdrawn" ("amount") ` - ) - await db.query( - `CREATE TABLE "bundle" ("id" character varying NOT NULL, "eth_price" text NOT NULL, CONSTRAINT "PK_637e3f87e837d6532109c198dea" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "factory_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_volume_untracked" text NOT NULL, "total_volume_eth" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_4b56c54390ce8e399d8e37e169d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "stable_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, CONSTRAINT "PK_3663f18340bb5fdc0023ecc624a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "zenlink_day_info" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "standard_info_id" character varying, "stable_info_id" character varying, CONSTRAINT "PK_747195cfa3811d6eea0ff6389de" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_9f281ffbf4f668c1671ae24aeb" ON "zenlink_day_info" ("standard_info_id") ` - ) - await db.query( - `CREATE INDEX "IDX_3049b8ac70203e95dfc6b42c02" ON "zenlink_day_info" ("stable_info_id") ` - ) - await db.query( - `CREATE TABLE "zlk_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "burn" numeric NOT NULL, CONSTRAINT "PK_58853b5e24384aba0da2023e91e" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "nabla_token" ("id" character varying NOT NULL, "decimals" integer NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, CONSTRAINT "PK_d036fec883bded17a5c2e09cf0a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "backstop_pool" ("id" character varying NOT NULL, "reserves" numeric NOT NULL, "liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "router_id" character varying, "token_id" character varying, CONSTRAINT "PK_bf2d01d9ce60ad9ee4b1b087d9d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_13ef09b925620aedf12b3342ca" ON "backstop_pool" ("router_id") ` - ) - await db.query( - `CREATE INDEX "IDX_8a7a25fa2d22ff634bd3041d81" ON "backstop_pool" ("token_id") ` - ) - await db.query( - `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "reserves" numeric NOT NULL, "liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_2f5409f002e18e4a6e2fddd858" ON "swap_pool" ("router_id") ` - ) - await db.query( - `CREATE INDEX "IDX_5c3209a88e41d53bdc450605b3" ON "swap_pool" ("backstop_id") ` - ) - await db.query( - `CREATE INDEX "IDX_b66a5cc8d2ce7bba1b48fd8c1a" ON "swap_pool" ("token_id") ` - ) - await db.query( - `CREATE TABLE "router" ("id" character varying NOT NULL, "paused" boolean NOT NULL, CONSTRAINT "PK_510c864aa88ac8eb3a306789801" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "event" ("id" character varying NOT NULL, "index" integer NOT NULL, "phase" text NOT NULL, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "call_id" character varying, CONSTRAINT "PK_30c2f3bbaf6d34a55f8ae6e4614" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_2b0d35d675c4f99751855c4502" ON "event" ("block_id") ` - ) - await db.query( - `CREATE INDEX "IDX_129efedcb305c80256db2d57a5" ON "event" ("extrinsic_id") ` - ) - await db.query( - `CREATE INDEX "IDX_83cf1bd59aa4521ed882fa5145" ON "event" ("call_id") ` - ) - await db.query( - `CREATE INDEX "IDX_7723d04c5a2f56c4373b6a4048" ON "event" ("pallet") ` - ) - await db.query( - `CREATE INDEX "IDX_b535fbe8ec6d832dde22065ebd" ON "event" ("name") ` - ) - await db.query( - `CREATE INDEX "IDX_0a00d817e614a91cda40d734cf" ON "event" ("id", "pallet", "name") ` - ) - await db.query( - `CREATE TABLE "call" ("id" character varying NOT NULL, "address" integer array NOT NULL, "success" boolean NOT NULL, "error" jsonb, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "parent_id" character varying, CONSTRAINT "PK_2098af0169792a34f9cfdd39c47" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_bd3f11fd4110d60ac8b96cd62f" ON "call" ("block_id") ` - ) - await db.query( - `CREATE INDEX "IDX_dde30e4f2c6a80f9236bfdf259" ON "call" ("extrinsic_id") ` - ) - await db.query( - `CREATE INDEX "IDX_11c1e76d5be8f04c472c4a05b9" ON "call" ("parent_id") ` - ) - await db.query( - `CREATE INDEX "IDX_d3a8c3d00494950ad6dc93297d" ON "call" ("success") ` - ) - await db.query( - `CREATE INDEX "IDX_776bccbd3d7b3001c8708cf4e0" ON "call" ("pallet") ` - ) - await db.query( - `CREATE INDEX "IDX_8b212022b7428232091e2f8aa5" ON "call" ("name") ` - ) - await db.query( - `CREATE INDEX "IDX_f1e953379e1b3c453cd896bcd4" ON "call" ("id", "pallet", "name") ` - ) - await db.query( - `CREATE TABLE "extrinsic" ("id" character varying NOT NULL, "index" integer NOT NULL, "version" integer NOT NULL, "signature" jsonb, "tip" numeric, "fee" numeric, "success" boolean, "error" jsonb, "hash" bytea NOT NULL, "block_id" character varying, "call_id" character varying, CONSTRAINT "PK_80d7db0e4b1e83e30336bc76755" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_a3b99daba1259dab0dd040d4f7" ON "extrinsic" ("block_id") ` - ) - await db.query( - `CREATE INDEX "IDX_824d47cc4b2cda726405aa507c" ON "extrinsic" ("call_id") ` - ) - await db.query( - `CREATE INDEX "IDX_21e5db7671dfa1b00dbe6dbbd6" ON "extrinsic" ("success") ` - ) - await db.query( - `CREATE INDEX "IDX_1f45de0713a55049009e8e8127" ON "extrinsic" ("hash") ` - ) - await db.query( - `CREATE TABLE "block" ("id" character varying NOT NULL, "height" integer NOT NULL, "hash" bytea NOT NULL, "parent_hash" bytea NOT NULL, "state_root" bytea NOT NULL, "extrinsicsic_root" bytea NOT NULL, "spec_name" text NOT NULL, "spec_version" integer NOT NULL, "impl_name" text NOT NULL, "impl_version" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "validator" bytea, "extrinsics_count" integer NOT NULL, "calls_count" integer NOT NULL, "events_count" integer NOT NULL, CONSTRAINT "PK_d0925763efb591c2e2ffb267572" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_bce676e2b005104ccb768495db" ON "block" ("height") ` - ) - await db.query( - `CREATE INDEX "IDX_f8fba63d7965bfee9f304c487a" ON "block" ("hash") ` - ) - await db.query( - `CREATE INDEX "IDX_5b79d140fa8e2c64a7ef223598" ON "block" ("spec_version") ` - ) - await db.query( - `CREATE INDEX "IDX_5c67cbcf4960c1a39e5fe25e87" ON "block" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_b7e2f8fe1384a2910825029dcb" ON "block" ("validator") ` - ) - await db.query( - `CREATE TABLE "items_counter" ("id" character varying NOT NULL, "type" character varying(10) NOT NULL, "level" character varying(6) NOT NULL, "total" integer NOT NULL, CONSTRAINT "PK_161dcf46142538463f5d7174793" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_68d2eadecb3eeb540d2004acef" ON "items_counter" ("type") ` - ) - await db.query( - `CREATE INDEX "IDX_1d9be1d79f197d42dd163f86c8" ON "items_counter" ("level") ` - ) - await db.query( - `CREATE INDEX "IDX_e03dd1c60ac7622914f72ac2f1" ON "items_counter" ("total") ` - ) - await db.query( - `ALTER TABLE "stable_swap_event" ADD CONSTRAINT "FK_3a147c85b92441217540579be88" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_exchange" ADD CONSTRAINT "FK_1180a78feea28e278229de7db46" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_day_data" ADD CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_hour_data" ADD CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "token_day_data" ADD CONSTRAINT "FK_b8950a8bc7b60231137573740ea" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_hour_data" ADD CONSTRAINT "FK_cf50c55389e428096a68598ee33" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_670629d9904e1f48f4a31abb495" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_781470585a67fef4e215a599773" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_eb823fd4d5a47575039e902efa7" FOREIGN KEY ("liquidity_position_id") REFERENCES "liquidity_position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ed32a41150bc13f18a019741534" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ce85a847b2952f7e685f150de1d" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "mint" ADD CONSTRAINT "FK_19f4328320501dfd14e2bae0855" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "mint" ADD CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "burn" ADD CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "burn" ADD CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap" ADD CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap" ADD CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair" ADD CONSTRAINT "FK_f74dc53460944a424b56b8f7da5" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair" ADD CONSTRAINT "FK_4419691fc411b8af754dfa65ce4" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "single_token_lock_day_data" ADD CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "single_token_lock_hour_data" ADD CONSTRAINT "FK_b2a84dc625103153d651b701dd1" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "single_token_lock" ADD CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "incentive" ADD CONSTRAINT "FK_35286137967591eaff8dee7ca2a" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "incentive" ADD CONSTRAINT "FK_041db4166864a3841e5efed53c4" FOREIGN KEY ("reward_token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "farm" ADD CONSTRAINT "FK_679106a1febf251d7fe7fe081ad" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "farm" ADD CONSTRAINT "FK_00b8f5b860927b1b85e866b20da" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "farm" ADD CONSTRAINT "FK_11da1bf5c406898262d91b41cbb" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap" ADD CONSTRAINT "FK_88cce14adee6d21f5057551c3ea" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_9a6b55d2085464668b622dffe64" FOREIGN KEY ("factory_id") REFERENCES "factory"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_0795adc3723792868094ec76c07" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0" FOREIGN KEY ("standard_info_id") REFERENCES "factory_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027" FOREIGN KEY ("stable_info_id") REFERENCES "stable_swap_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_13ef09b925620aedf12b3342caa" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b" FOREIGN KEY ("backstop_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "event" ADD CONSTRAINT "FK_2b0d35d675c4f99751855c45021" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "event" ADD CONSTRAINT "FK_129efedcb305c80256db2d57a59" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "event" ADD CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "call" ADD CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "call" ADD CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "call" ADD CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95" FOREIGN KEY ("parent_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_824d47cc4b2cda726405aa507ca" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - } - - async down(db) { - await db.query(`DROP TABLE "oracle_price"`) - await db.query(`DROP INDEX "public"."IDX_6554f47abd46667280a2523381"`) - await db.query(`DROP INDEX "public"."IDX_2026224855490e321e5c0b6911"`) - await db.query(`DROP INDEX "public"."IDX_a77ac6d79f0929522f5a1aefcb"`) - await db.query(`DROP INDEX "public"."IDX_f7c9bf3bae39fb0a75f12b87dd"`) - await db.query(`DROP TABLE "transfer"`) - await db.query(`DROP INDEX "public"."IDX_d6624eacc30144ea97915fe846"`) - await db.query(`DROP INDEX "public"."IDX_70ff8b624c3118ac3a4862d22c"`) - await db.query(`DROP INDEX "public"."IDX_070c555a86b0b41a534a55a659"`) - await db.query(`DROP INDEX "public"."IDX_f4007436c1b546ede08a4fd7ab"`) - await db.query(`DROP TABLE "factory"`) - await db.query(`DROP TABLE "stable_swap_event"`) - await db.query(`DROP INDEX "public"."IDX_3a147c85b92441217540579be8"`) - await db.query(`DROP TABLE "stable_swap_exchange"`) - await db.query(`DROP INDEX "public"."IDX_1180a78feea28e278229de7db4"`) - await db.query(`DROP TABLE "stable_swap_day_data"`) - await db.query(`DROP INDEX "public"."IDX_648b49eb1a4f2a47f24f13bb51"`) - await db.query(`DROP TABLE "stable_swap_hour_data"`) - await db.query(`DROP INDEX "public"."IDX_94584d2925c30ae0d4b80aadfc"`) - await db.query(`DROP TABLE "token_day_data"`) - await db.query(`DROP INDEX "public"."IDX_b8950a8bc7b60231137573740e"`) - await db.query(`DROP TABLE "pair_hour_data"`) - await db.query(`DROP INDEX "public"."IDX_cf50c55389e428096a68598ee3"`) - await db.query(`DROP TABLE "stable_swap_liquidity_position"`) - await db.query(`DROP INDEX "public"."IDX_f953aebc7c0752f6b8434c9eef"`) - await db.query(`DROP INDEX "public"."IDX_405e0d7aeca80975d88a63bc6e"`) - await db.query(`DROP TABLE "stake_position"`) - await db.query(`DROP INDEX "public"."IDX_2a2b22d2744b497bbcfb03e6ab"`) - await db.query(`DROP INDEX "public"."IDX_670629d9904e1f48f4a31abb49"`) - await db.query(`DROP TABLE "user"`) - await db.query(`DROP TABLE "liquidity_position"`) - await db.query(`DROP INDEX "public"."IDX_781470585a67fef4e215a59977"`) - await db.query(`DROP INDEX "public"."IDX_5a626c8b8962dc01e0f8801be6"`) - await db.query(`DROP TABLE "liquidity_position_snapshot"`) - await db.query(`DROP INDEX "public"."IDX_eb823fd4d5a47575039e902efa"`) - await db.query(`DROP INDEX "public"."IDX_ed32a41150bc13f18a01974153"`) - await db.query(`DROP INDEX "public"."IDX_ce85a847b2952f7e685f150de1"`) - await db.query(`DROP TABLE "transaction"`) - await db.query(`DROP TABLE "mint"`) - await db.query(`DROP INDEX "public"."IDX_19f4328320501dfd14e2bae085"`) - await db.query(`DROP INDEX "public"."IDX_81d470127d4c55d09e9213bc4e"`) - await db.query(`DROP TABLE "burn"`) - await db.query(`DROP INDEX "public"."IDX_20ec76c5c56dd6b47dec5f0aaa"`) - await db.query(`DROP INDEX "public"."IDX_ba144ce938b3266a470d4dd70f"`) - await db.query(`DROP TABLE "swap"`) - await db.query(`DROP INDEX "public"."IDX_78506c4050ae7cedd50b08c0dc"`) - await db.query(`DROP INDEX "public"."IDX_3571ab1dad7640a6b93c705b8f"`) - await db.query(`DROP TABLE "pair"`) - await db.query(`DROP INDEX "public"."IDX_f74dc53460944a424b56b8f7da"`) - await db.query(`DROP INDEX "public"."IDX_4419691fc411b8af754dfa65ce"`) - await db.query(`DROP TABLE "pair_day_data"`) - await db.query(`DROP INDEX "public"."IDX_d8ba7d7d7ad9f0e1c2933a0b7e"`) - await db.query(`DROP INDEX "public"."IDX_88f6e19c40b47053e6e197db1c"`) - await db.query(`DROP INDEX "public"."IDX_ce435d6fc7c373d58e7aab156d"`) - await db.query(`DROP TABLE "token"`) - await db.query(`DROP TABLE "single_token_lock_day_data"`) - await db.query(`DROP INDEX "public"."IDX_f3bf64f43101176dbe5f11a36b"`) - await db.query(`DROP TABLE "single_token_lock_hour_data"`) - await db.query(`DROP INDEX "public"."IDX_b2a84dc625103153d651b701dd"`) - await db.query(`DROP TABLE "single_token_lock"`) - await db.query(`DROP INDEX "public"."IDX_8ebffe66457859d6e1c37b81ac"`) - await db.query(`DROP TABLE "incentive"`) - await db.query(`DROP INDEX "public"."IDX_35286137967591eaff8dee7ca2"`) - await db.query(`DROP INDEX "public"."IDX_041db4166864a3841e5efed53c"`) - await db.query(`DROP TABLE "farm"`) - await db.query(`DROP INDEX "public"."IDX_679106a1febf251d7fe7fe081a"`) - await db.query(`DROP INDEX "public"."IDX_00b8f5b860927b1b85e866b20d"`) - await db.query(`DROP INDEX "public"."IDX_11da1bf5c406898262d91b41cb"`) - await db.query(`DROP TABLE "stable_swap"`) - await db.query(`DROP INDEX "public"."IDX_88cce14adee6d21f5057551c3e"`) - await db.query(`DROP TABLE "stable_swap_info"`) - await db.query(`DROP TABLE "zenlink_info"`) - await db.query(`DROP INDEX "public"."IDX_9a6b55d2085464668b622dffe6"`) - await db.query(`DROP INDEX "public"."IDX_0795adc3723792868094ec76c0"`) - await db.query(`DROP TABLE "token_transfer"`) - await db.query(`DROP INDEX "public"."IDX_b47f7192b72dd8436ef4e6d253"`) - await db.query(`DROP INDEX "public"."IDX_752d6c330729a7b2e283003374"`) - await db.query(`DROP INDEX "public"."IDX_2ef35b71d641ec79b7de3ac237"`) - await db.query(`DROP INDEX "public"."IDX_aae50046f62ba400c07477fb6c"`) - await db.query(`DROP TABLE "token_deposit"`) - await db.query(`DROP INDEX "public"."IDX_395da815b9927f13e2f87c6b54"`) - await db.query(`DROP INDEX "public"."IDX_0f87d313517eaa806c75444749"`) - await db.query(`DROP INDEX "public"."IDX_7194acc3ea037189ff3da743ec"`) - await db.query(`DROP INDEX "public"."IDX_d23ae7a0ea1f640e8e9875b3c2"`) - await db.query(`DROP TABLE "token_withdrawn"`) - await db.query(`DROP INDEX "public"."IDX_e7fd99cae9a1df2e8f69d60892"`) - await db.query(`DROP INDEX "public"."IDX_70e98131fb737e4dce4455ca43"`) - await db.query(`DROP INDEX "public"."IDX_867e6d004e7a4994b3b2aeba63"`) - await db.query(`DROP INDEX "public"."IDX_5697bf049746e5102413ebd832"`) - await db.query(`DROP TABLE "bundle"`) - await db.query(`DROP TABLE "factory_day_data"`) - await db.query(`DROP TABLE "stable_day_data"`) - await db.query(`DROP TABLE "zenlink_day_info"`) - await db.query(`DROP INDEX "public"."IDX_9f281ffbf4f668c1671ae24aeb"`) - await db.query(`DROP INDEX "public"."IDX_3049b8ac70203e95dfc6b42c02"`) - await db.query(`DROP TABLE "zlk_info"`) - await db.query(`DROP TABLE "nabla_token"`) - await db.query(`DROP TABLE "backstop_pool"`) - await db.query(`DROP INDEX "public"."IDX_13ef09b925620aedf12b3342ca"`) - await db.query(`DROP INDEX "public"."IDX_8a7a25fa2d22ff634bd3041d81"`) - await db.query(`DROP TABLE "swap_pool"`) - await db.query(`DROP INDEX "public"."IDX_2f5409f002e18e4a6e2fddd858"`) - await db.query(`DROP INDEX "public"."IDX_5c3209a88e41d53bdc450605b3"`) - await db.query(`DROP INDEX "public"."IDX_b66a5cc8d2ce7bba1b48fd8c1a"`) - await db.query(`DROP TABLE "router"`) - await db.query(`DROP TABLE "event"`) - await db.query(`DROP INDEX "public"."IDX_2b0d35d675c4f99751855c4502"`) - await db.query(`DROP INDEX "public"."IDX_129efedcb305c80256db2d57a5"`) - await db.query(`DROP INDEX "public"."IDX_83cf1bd59aa4521ed882fa5145"`) - await db.query(`DROP INDEX "public"."IDX_7723d04c5a2f56c4373b6a4048"`) - await db.query(`DROP INDEX "public"."IDX_b535fbe8ec6d832dde22065ebd"`) - await db.query(`DROP INDEX "public"."IDX_0a00d817e614a91cda40d734cf"`) - await db.query(`DROP TABLE "call"`) - await db.query(`DROP INDEX "public"."IDX_bd3f11fd4110d60ac8b96cd62f"`) - await db.query(`DROP INDEX "public"."IDX_dde30e4f2c6a80f9236bfdf259"`) - await db.query(`DROP INDEX "public"."IDX_11c1e76d5be8f04c472c4a05b9"`) - await db.query(`DROP INDEX "public"."IDX_d3a8c3d00494950ad6dc93297d"`) - await db.query(`DROP INDEX "public"."IDX_776bccbd3d7b3001c8708cf4e0"`) - await db.query(`DROP INDEX "public"."IDX_8b212022b7428232091e2f8aa5"`) - await db.query(`DROP INDEX "public"."IDX_f1e953379e1b3c453cd896bcd4"`) - await db.query(`DROP TABLE "extrinsic"`) - await db.query(`DROP INDEX "public"."IDX_a3b99daba1259dab0dd040d4f7"`) - await db.query(`DROP INDEX "public"."IDX_824d47cc4b2cda726405aa507c"`) - await db.query(`DROP INDEX "public"."IDX_21e5db7671dfa1b00dbe6dbbd6"`) - await db.query(`DROP INDEX "public"."IDX_1f45de0713a55049009e8e8127"`) - await db.query(`DROP TABLE "block"`) - await db.query(`DROP INDEX "public"."IDX_bce676e2b005104ccb768495db"`) - await db.query(`DROP INDEX "public"."IDX_f8fba63d7965bfee9f304c487a"`) - await db.query(`DROP INDEX "public"."IDX_5b79d140fa8e2c64a7ef223598"`) - await db.query(`DROP INDEX "public"."IDX_5c67cbcf4960c1a39e5fe25e87"`) - await db.query(`DROP INDEX "public"."IDX_b7e2f8fe1384a2910825029dcb"`) - await db.query(`DROP TABLE "items_counter"`) - await db.query(`DROP INDEX "public"."IDX_68d2eadecb3eeb540d2004acef"`) - await db.query(`DROP INDEX "public"."IDX_1d9be1d79f197d42dd163f86c8"`) - await db.query(`DROP INDEX "public"."IDX_e03dd1c60ac7622914f72ac2f1"`) - await db.query( - `ALTER TABLE "stable_swap_event" DROP CONSTRAINT "FK_3a147c85b92441217540579be88"` - ) - await db.query( - `ALTER TABLE "stable_swap_exchange" DROP CONSTRAINT "FK_1180a78feea28e278229de7db46"` - ) - await db.query( - `ALTER TABLE "stable_swap_day_data" DROP CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510"` - ) - await db.query( - `ALTER TABLE "stable_swap_hour_data" DROP CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8"` - ) - await db.query( - `ALTER TABLE "token_day_data" DROP CONSTRAINT "FK_b8950a8bc7b60231137573740ea"` - ) - await db.query( - `ALTER TABLE "pair_hour_data" DROP CONSTRAINT "FK_cf50c55389e428096a68598ee33"` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8"` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee"` - ) - await db.query( - `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0"` - ) - await db.query( - `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_670629d9904e1f48f4a31abb495"` - ) - await db.query( - `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_781470585a67fef4e215a599773"` - ) - await db.query( - `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61"` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_eb823fd4d5a47575039e902efa7"` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ed32a41150bc13f18a019741534"` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ce85a847b2952f7e685f150de1d"` - ) - await db.query( - `ALTER TABLE "mint" DROP CONSTRAINT "FK_19f4328320501dfd14e2bae0855"` - ) - await db.query( - `ALTER TABLE "mint" DROP CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1"` - ) - await db.query( - `ALTER TABLE "burn" DROP CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8"` - ) - await db.query( - `ALTER TABLE "burn" DROP CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa"` - ) - await db.query( - `ALTER TABLE "swap" DROP CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5"` - ) - await db.query( - `ALTER TABLE "swap" DROP CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7"` - ) - await db.query( - `ALTER TABLE "pair" DROP CONSTRAINT "FK_f74dc53460944a424b56b8f7da5"` - ) - await db.query( - `ALTER TABLE "pair" DROP CONSTRAINT "FK_4419691fc411b8af754dfa65ce4"` - ) - await db.query( - `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2"` - ) - await db.query( - `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9"` - ) - await db.query( - `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9"` - ) - await db.query( - `ALTER TABLE "single_token_lock_day_data" DROP CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd"` - ) - await db.query( - `ALTER TABLE "single_token_lock_hour_data" DROP CONSTRAINT "FK_b2a84dc625103153d651b701dd1"` - ) - await db.query( - `ALTER TABLE "single_token_lock" DROP CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3"` - ) - await db.query( - `ALTER TABLE "incentive" DROP CONSTRAINT "FK_35286137967591eaff8dee7ca2a"` - ) - await db.query( - `ALTER TABLE "incentive" DROP CONSTRAINT "FK_041db4166864a3841e5efed53c4"` - ) - await db.query( - `ALTER TABLE "farm" DROP CONSTRAINT "FK_679106a1febf251d7fe7fe081ad"` - ) - await db.query( - `ALTER TABLE "farm" DROP CONSTRAINT "FK_00b8f5b860927b1b85e866b20da"` - ) - await db.query( - `ALTER TABLE "farm" DROP CONSTRAINT "FK_11da1bf5c406898262d91b41cbb"` - ) - await db.query( - `ALTER TABLE "stable_swap" DROP CONSTRAINT "FK_88cce14adee6d21f5057551c3ea"` - ) - await db.query( - `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_9a6b55d2085464668b622dffe64"` - ) - await db.query( - `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_0795adc3723792868094ec76c07"` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0"` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027"` - ) - await db.query( - `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_13ef09b925620aedf12b3342caa"` - ) - await db.query( - `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab"` - ) - await db.query( - `ALTER TABLE "event" DROP CONSTRAINT "FK_2b0d35d675c4f99751855c45021"` - ) - await db.query( - `ALTER TABLE "event" DROP CONSTRAINT "FK_129efedcb305c80256db2d57a59"` - ) - await db.query( - `ALTER TABLE "event" DROP CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452"` - ) - await db.query( - `ALTER TABLE "call" DROP CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3"` - ) - await db.query( - `ALTER TABLE "call" DROP CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590"` - ) - await db.query( - `ALTER TABLE "call" DROP CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95"` - ) - await db.query( - `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74"` - ) - await db.query( - `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_824d47cc4b2cda726405aa507ca"` - ) - } -} diff --git a/db/migrations/1701282385470-Data.js b/db/migrations/1706733053259-Data.js similarity index 94% rename from db/migrations/1701282385470-Data.js rename to db/migrations/1706733053259-Data.js index 6965c7f3..b8a5001c 100644 --- a/db/migrations/1701282385470-Data.js +++ b/db/migrations/1706733053259-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1701282385470 { - name = 'Data1701282385470' +module.exports = class Data1706733053259 { + name = 'Data1706733053259' async up(db) { await db.query( @@ -291,10 +291,22 @@ module.exports = class Data1701282385470 { `CREATE TABLE "zlk_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "burn" numeric NOT NULL, CONSTRAINT "PK_58853b5e24384aba0da2023e91e" PRIMARY KEY ("id"))` ) await db.query( - `CREATE TABLE "nabla_token" ("id" character varying NOT NULL, "decimals" integer NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, CONSTRAINT "PK_d036fec883bded17a5c2e09cf0a" PRIMARY KEY ("id"))` + `CREATE TABLE "nabla_token" ("id" character varying NOT NULL, "decimals" integer NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "latest_swap_pool_id" character varying, CONSTRAINT "PK_d036fec883bded17a5c2e09cf0a" PRIMARY KEY ("id"))` ) await db.query( - `CREATE TABLE "backstop_pool" ("id" character varying NOT NULL, "reserves" numeric NOT NULL, "liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "router_id" character varying, "token_id" character varying, CONSTRAINT "PK_bf2d01d9ce60ad9ee4b1b087d9d" PRIMARY KEY ("id"))` + `CREATE INDEX "IDX_03f6f92a4dd0116a68bd46ef66" ON "nabla_token" ("latest_swap_pool_id") ` + ) + await db.query( + `CREATE TABLE "nabla_swap_fee" ("id" character varying NOT NULL, "lp_fees" numeric NOT NULL, "backstop_fees" numeric NOT NULL, "protocol_fees" numeric NOT NULL, "timestamp" numeric NOT NULL, "swap_pool_id" character varying, "backstop_pool_id" character varying, CONSTRAINT "PK_8824e4a63ae77ecf8a55aa5359a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_208d304702d154e73e4f85c978" ON "nabla_swap_fee" ("swap_pool_id") ` + ) + await db.query( + `CREATE INDEX "IDX_86080eda96a6de9c3c60be41d8" ON "nabla_swap_fee" ("backstop_pool_id") ` + ) + await db.query( + `CREATE TABLE "backstop_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "reserves" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "router_id" character varying, "token_id" character varying, CONSTRAINT "PK_bf2d01d9ce60ad9ee4b1b087d9d" PRIMARY KEY ("id"))` ) await db.query( `CREATE INDEX "IDX_13ef09b925620aedf12b3342ca" ON "backstop_pool" ("router_id") ` @@ -303,7 +315,7 @@ module.exports = class Data1701282385470 { `CREATE INDEX "IDX_8a7a25fa2d22ff634bd3041d81" ON "backstop_pool" ("token_id") ` ) await db.query( - `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "reserves" numeric NOT NULL, "liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` + `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "reserve" numeric NOT NULL, "reserve_with_slippage" numeric NOT NULL, "total_liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "covered_index" numeric, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` ) await db.query( `CREATE INDEX "IDX_2f5409f002e18e4a6e2fddd858" ON "swap_pool" ("router_id") ` @@ -524,6 +536,15 @@ module.exports = class Data1701282385470 { await db.query( `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027" FOREIGN KEY ("stable_info_id") REFERENCES "stable_swap_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` ) + await db.query( + `ALTER TABLE "nabla_token" ADD CONSTRAINT "FK_03f6f92a4dd0116a68bd46ef66b" FOREIGN KEY ("latest_swap_pool_id") REFERENCES "swap_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_208d304702d154e73e4f85c978b" FOREIGN KEY ("swap_pool_id") REFERENCES "swap_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_86080eda96a6de9c3c60be41d86" FOREIGN KEY ("backstop_pool_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) await db.query( `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_13ef09b925620aedf12b3342caa" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` ) @@ -663,6 +684,10 @@ module.exports = class Data1701282385470 { await db.query(`DROP INDEX "public"."IDX_3049b8ac70203e95dfc6b42c02"`) await db.query(`DROP TABLE "zlk_info"`) await db.query(`DROP TABLE "nabla_token"`) + await db.query(`DROP INDEX "public"."IDX_03f6f92a4dd0116a68bd46ef66"`) + await db.query(`DROP TABLE "nabla_swap_fee"`) + await db.query(`DROP INDEX "public"."IDX_208d304702d154e73e4f85c978"`) + await db.query(`DROP INDEX "public"."IDX_86080eda96a6de9c3c60be41d8"`) await db.query(`DROP TABLE "backstop_pool"`) await db.query(`DROP INDEX "public"."IDX_13ef09b925620aedf12b3342ca"`) await db.query(`DROP INDEX "public"."IDX_8a7a25fa2d22ff634bd3041d81"`) @@ -818,6 +843,15 @@ module.exports = class Data1701282385470 { await db.query( `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027"` ) + await db.query( + `ALTER TABLE "nabla_token" DROP CONSTRAINT "FK_03f6f92a4dd0116a68bd46ef66b"` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_208d304702d154e73e4f85c978b"` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_86080eda96a6de9c3c60be41d86"` + ) await db.query( `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_13ef09b925620aedf12b3342caa"` ) diff --git a/schema.graphql b/schema.graphql index 494970cb..c39e0c61 100644 --- a/schema.graphql +++ b/schema.graphql @@ -761,7 +761,7 @@ type SwapPool @entity { id: ID! # id can be the address of the swap pool contract name: String! # name of the swap pool LP token symbol: String! # ticker symbol of the swap pool LP token - router: Router! # link to the Router entity + router: Router # link to the Router entity backstop: BackstopPool! # link to the BackstopPool entity token: NablaToken! # link to the Token entity reserve: BigInt! # current usable balance of the pool @@ -769,6 +769,7 @@ type SwapPool @entity { totalLiabilities: BigInt! # total Liquidity Provider (LP) deposits totalSupply: BigInt! # total supply of LP tokens paused: Boolean! # whether the swap pool is paused + feesHistory: [NablaSwapFee!]! @derivedFrom(field: "swapPool") # history of swap fees apr: BigInt! # annual percentage rate of the swap pool coveredIndex: BigInt # index of swap pool covered by the backstop pool } @@ -783,15 +784,18 @@ type BackstopPool @entity { totalSupply: BigInt! # total supply of LP tokens paused: Boolean! # whether the backstop pool is paused coveredSwapPools: [SwapPool!]! @derivedFrom(field: "backstop") # swap pools that are covered by the backstop pool + feesHistory: [NablaSwapFee!]! @derivedFrom(field: "backstopPool") # history of swap fees apr: BigInt! # annual percentage rate of the backstop pool } type NablaSwapFee @entity { id: ID! # id is address of the swap pool contract + timestamp - lpFee: BigInt! # LP fee in `asset` + lpFees: BigInt! # LP fee in `asset` backstopFees: BigInt! # backstop fee in `asset` protocolFees: BigInt! # protocol fee in `asset` timestamp: BigInt! # timestamp of the swap event + swapPool: SwapPool! # link to the SwapPool entity + backstopPool: BackstopPool # link to the BackstopPool entity } type Block @entity { diff --git a/src/mappings/nabla.ts b/src/mappings/nabla.ts index 71e96ffc..e192f7cd 100644 --- a/src/mappings/nabla.ts +++ b/src/mappings/nabla.ts @@ -1,6 +1,11 @@ import { EventHandlerContext } from '../processor' -import { toHex } from '@subsquid/util-internal-hex' -import { BackstopPool, Router, NablaToken, SwapPool } from '../model' +import { + BackstopPool, + Router, + NablaToken, + SwapPool, + NablaSwapFee, +} from '../model' import * as backstopPoolAbi from '../abi/backstop' import * as erc20Abi from '../abi/erc20' import * as swapPoolAbi from '../abi/swap' @@ -21,6 +26,8 @@ type Event = | swapPoolAbi.Event | routerAbi.Event +const SWAP_FEE_PRUNE_INTERVAL_SECONDS = 7 * 24 * 60 * 60 + interface Decoder { decodeEvent(hex: string): Event } @@ -34,7 +41,7 @@ async function isSwapPoolEvent(ctx: EventHandlerContext) { const contract = new swapPoolAbi.Contract(ctx, ctx.event.args.contract) await contract.router() await contract.backstop() - await contract.accumulatedSlippage() + await contract.reserveWithSlippage() await contract.poolCap() return swapPoolAbi.decodeEvent(ctx.event.args.data) } catch { @@ -100,21 +107,21 @@ export async function handleContractEvent(ctx: EventHandlerContext) { if (eventType === EventType.BackstopPoolEvent) { if (event.__kind == 'Burn') { - await backstophandleBurn(ctx) + await backstopHandleBurn(ctx) } else if (event.__kind == 'CoverSwapWithdrawal') { await backstopHandleCoverSwapWithdrawal(ctx, event) - } else if (event.__kind == 'WithdrawSwapLiquidity') { - await backstopHandleWithdrawSwapLiquidity(ctx, event) } else if (event.__kind == 'Mint') { await backstopHandleMint(ctx) } else if (event.__kind == 'OwnershipTransferred') { await backstopHandleOwnershipTransferred(ctx) } else if (event.__kind == 'Paused') { await backstopHandlePaused(ctx) - } else if (event.__kind == 'Unpaused') { - await backstopHandleUnpaused(ctx) } else if (event.__kind == 'Transfer') { await backstopHandleTransfer(ctx) + } else if (event.__kind == 'Unpaused') { + await backstopHandleUnpaused(ctx) + } else if (event.__kind == 'WithdrawSwapLiquidity') { + await backstopHandleWithdrawSwapLiquidity(ctx, event) } } else if (eventType === EventType.RouterEvent) { if (event.__kind == 'OwnershipTransferred') { @@ -122,34 +129,34 @@ export async function handleContractEvent(ctx: EventHandlerContext) { } else if (event.__kind == 'Paused') { await routerHandlePaused(ctx) } else if (event.__kind == 'Swap') { - await routerHandleSwap(ctx) - } else if (event.__kind == 'Unpaused') { - await routerHandleUnpaused(ctx) + await routerHandleSwap(ctx, event) } else if (event.__kind == 'SwapPoolRegistered') { await routerHandleSwapPoolRegistered(ctx, event) + } else if (event.__kind == 'Unpaused') { + await routerHandleUnpaused(ctx) } } else if (eventType === EventType.SwapPoolEvent) { if (event.__kind == 'BackstopDrain') { await swapHandleBackstopDrain(ctx) } else if (event.__kind == 'Burn') { await swapHandleBurn(ctx) + } else if (event.__kind == 'ChargedSwapFees') { + await swapHandleChargedSwapFees(ctx, event) } else if (event.__kind == 'Mint') { await swapHandleMint(ctx) - } else if (event.__kind == 'ChargedSwapFees') { - await swapHandleChargedSwapFees(ctx) } else if (event.__kind == 'OwnershipTransferred') { await swapHandleOwnershipTransferred(ctx) } else if (event.__kind == 'Paused') { await swapHandlePaused(ctx) - } else if (event.__kind == 'Unpaused') { - await swapHandleUnpaused(ctx) } else if (event.__kind == 'Transfer') { await swapHandleTransfer(ctx) + } else if (event.__kind == 'Unpaused') { + await swapHandleUnpaused(ctx) } } } -export async function backstophandleBurn(ctx: EventHandlerContext) { +export async function backstopHandleBurn(ctx: EventHandlerContext) { const backstop = await getOrCreateBackstopPool(ctx, ctx.event.args.contract) await updateBackstopCoverageAndSupply(ctx, backstop) @@ -235,8 +242,26 @@ export async function swapHandleBurn(ctx: EventHandlerContext) { ctx.store.save(pool) } -export function swapHandleChargedSwapFees(ctx: EventHandlerContext) { - // TODO +export async function swapHandleChargedSwapFees( + ctx: EventHandlerContext, + event: swapPoolAbi.Event_ChargedSwapFees +) { + const swapPool = await getOrCreateSwapPool(ctx, ctx.event.args.contract) + const backstopPoolAddress = ss58ToHex(swapPool.backstop.id) + const backstopPool = await getOrCreateBackstopPool(ctx, backstopPoolAddress) + const swapFee = await createSwapFee( + ctx, + ctx.event.block.height, + ctx.event.extrinsicIndex, + event.lpFees, + event.backstopFees, + event.protocolFees, + ctx.event.block.timestamp, + swapPool, + backstopPool + ) + + updateAprAfterSwap(ctx, swapPool, swapFee) } export async function swapHandleMint(ctx: EventHandlerContext) { @@ -290,8 +315,30 @@ export async function routerHandleUnpaused(ctx: EventHandlerContext) { ctx.store.save(router) } -export async function routerHandleSwap(ctx: EventHandlerContext) { +export async function routerHandleSwap( + ctx: EventHandlerContext, + event: routerAbi.Event_Swap +) { await getOrCreateRouter(ctx, ctx.event.args.contract) + + const tokenIn = await getOrCreateNablaToken(ctx, event.tokenIn) + const tokenOut = await getOrCreateNablaToken(ctx, event.tokenOut) + + const swapPoolInAddress = tokenIn.latestSwapPool?.id ?? '' + const swapPoolIn = await ctx.store.get(SwapPool, swapPoolInAddress) + + const swapPoolOutAddress = tokenOut.latestSwapPool?.id ?? '' + const swapPoolOut = await ctx.store.get(SwapPool, swapPoolOutAddress) + + if (swapPoolIn !== undefined) { + await updateSwapPoolCoverageAndSupply(ctx, swapPoolIn) + ctx.store.save(swapPoolIn) + } + + if (swapPoolOut !== undefined) { + await updateSwapPoolCoverageAndSupply(ctx, swapPoolOut) + ctx.store.save(swapPoolOut) + } } export async function routerHandleSwapPoolRegistered( @@ -299,19 +346,36 @@ export async function routerHandleSwapPoolRegistered( event: routerAbi.Event_SwapPoolRegistered ) { await getOrCreateRouter(ctx, ctx.event.args.contract) - await getOrCreateSwapPool(ctx, event.pool) + const swapPool = await getOrCreateSwapPool(ctx, event.pool) + const token = await getOrCreateNablaToken(ctx, ss58ToHex(swapPool.token.id)) + + if (token.latestSwapPool && token.latestSwapPool.id !== swapPool.id) { + const replacedSwapPool = await ctx.store.get( + SwapPool, + token.latestSwapPool.id + ) + + if (replacedSwapPool !== undefined) { + replacedSwapPool.router = undefined // Unregister the existing pool + ctx.store.save(replacedSwapPool) + } + } + + token.latestSwapPool = swapPool + ctx.store.save(token) } export async function updateBackstopCoverageAndSupply( ctx: EventHandlerContext, backstop: BackstopPool ) { - const contract = new backstopPoolAbi.Contract(ctx, ss58ToHex(backstop.id)) - const coverage = await contract.coverage() + const contractHexAddress = ss58ToHex(backstop.id) + const contract = new backstopPoolAbi.Contract(ctx, contractHexAddress) + const poolTokenAddress = await contract.asset() + const poolTokenContract = new erc20Abi.Contract(ctx, poolTokenAddress) backstop.totalSupply = await contract.totalSupply() - backstop.reserves = coverage[0] - backstop.liabilities = coverage[1] + backstop.reserves = await poolTokenContract.balanceOf(contractHexAddress) } export async function updateSwapPoolCoverageAndSupply( @@ -322,28 +386,151 @@ export async function updateSwapPoolCoverageAndSupply( const coverage = await contract.coverage() pool.totalSupply = await contract.totalSupply() - pool.reserves = coverage[0] - pool.liabilities = coverage[1] + pool.reserve = coverage[0] + pool.totalLiabilities = coverage[1] + pool.reserveWithSlippage = await contract.reserveWithSlippage() +} + +async function updateAndPruneSwapFeeHistory( + ctx: EventHandlerContext, + pool: SwapPool, + newSwapFee: NablaSwapFee +): Promise { + // Prune fee events older than 7 days + const sevenDaysAgo = + newSwapFee.timestamp - BigInt(SWAP_FEE_PRUNE_INTERVAL_SECONDS) + + /* + * Swap Pool fees history + */ + // Add the swapFee to the pool's fee history + const poolFeesHistory = pool.feesHistory + await filterSwapFeeHistory(ctx, poolFeesHistory, sevenDaysAgo) +} + +async function filterSwapFeeHistory( + ctx: EventHandlerContext, + feesHistory: NablaSwapFee[], + pastPeriodInSeconds: bigint +) { + const filteredFeeHistory: string[] = [] + + for (const swapFee of feesHistory) { + if (swapFee.timestamp > pastPeriodInSeconds) { + await ctx.store.remove(swapFee) + } + } +} + +export async function updateAprAfterSwap( + ctx: EventHandlerContext, + pool: SwapPool, + newSwapFee: NablaSwapFee +): Promise { + // Update the fee history (swapFee, backstopFee) + await updateAndPruneSwapFeeHistory(ctx, pool, newSwapFee) + const updatedSwapPool = await ctx.store.get(SwapPool, pool.id) + + if (updatedSwapPool === undefined) return + + const swapPoolContract = new swapPoolAbi.Contract( + ctx, + ss58ToHex(updatedSwapPool.id) + ) + const swapPoolTokenAddress = await swapPoolContract.asset() + const swapPoolTokenContract = new erc20Abi.Contract( + ctx, + swapPoolTokenAddress + ) + const swapPoolTokenDecimals = await swapPoolTokenContract.decimals() + + /* + * Swap Pool fees history & APR + */ + const totalLpFees = updatedSwapPool.feesHistory.reduce( + (a, b) => a + b.lpFees, + 0n + ) + + const poolTotalSupply = updatedSwapPool.totalSupply + updatedSwapPool.apr = calculateApr( + totalLpFees, + poolTotalSupply, + BigInt(swapPoolTokenDecimals) + ) + ctx.store.save(updatedSwapPool) + + /* + * Backstop Pool fees history + */ + const backstop = await ctx.store.get( + BackstopPool, + updatedSwapPool.backstop.id + ) + + if (backstop !== undefined) { + const backstopPoolContract = new backstopPoolAbi.Contract( + ctx, + ss58ToHex(backstop.id) + ) + const backstopPoolTokenAddress = await backstopPoolContract.asset() + const backstopPoolTokenContract = new erc20Abi.Contract( + ctx, + backstopPoolTokenAddress + ) + const backstopPoolTokenDecimals = + await backstopPoolTokenContract.decimals() + + const totalBackstopFees = backstop.feesHistory.reduce( + (a, b) => a + b.backstopFees, + 0n + ) + + const backstopTotalSupply = backstop.totalSupply + backstop.apr = calculateApr( + totalBackstopFees, + backstopTotalSupply, + BigInt(backstopPoolTokenDecimals) + ) + ctx.store.save(backstop) + } +} + +function calculateApr( + totalFees: bigint, + totalSupply: bigint, + poolTokenDecimals: bigint +): bigint { + if (totalSupply > 0n) { + return (totalFees * 365n * 10n ** poolTokenDecimals) / totalSupply / 7n + } else { + return 0n + } } export async function getOrCreateBackstopPool( ctx: EventHandlerContext, hexAddress: string ) { - let address = codec(config.prefix).encode(hexAddress) + const address = codec(config.prefix).encode(hexAddress) let backstop = await ctx.store.get(BackstopPool, address) if (!backstop) { const contract = new backstopPoolAbi.Contract(ctx, hexAddress) - let router = await getOrCreateRouter(ctx, await contract.router()) - let coverage = await contract.coverage() + const poolTokenAddress = await contract.asset() + const poolTokenContract = new erc20Abi.Contract(ctx, poolTokenAddress) + const router = await getOrCreateRouter(ctx, await contract.router()) + const token = await getOrCreateNablaToken(ctx, poolTokenAddress) + backstop = new BackstopPool({ id: address, + name: await contract.name(), + symbol: await contract.symbol(), router: router, - token: await getOrCreateNablaToken(ctx, await contract.asset()), + token: token, + reserves: await poolTokenContract.balanceOf(hexAddress), totalSupply: await contract.totalSupply(), - reserves: coverage[0], - liabilities: coverage[1], paused: false, + apr: 0n, }) ctx.store.save(backstop) } @@ -354,7 +541,7 @@ export async function getOrCreateRouter( ctx: EventHandlerContext, hexAddress: string ) { - let address = codec(config.prefix).encode(hexAddress) + const address = codec(config.prefix).encode(hexAddress) let router = await ctx.store.get(Router, address) if (!router) { router = new Router({ @@ -370,7 +557,7 @@ export async function getOrCreateNablaToken( ctx: EventHandlerContext, hexAddress: string ) { - let address = codec(config.prefix).encode(hexAddress) + const address = codec(config.prefix).encode(hexAddress) let nablaToken = await ctx.store.get(NablaToken, address) if (!nablaToken) { const contract = new erc20Abi.Contract(ctx, hexAddress) @@ -379,6 +566,7 @@ export async function getOrCreateNablaToken( decimals: await contract.decimals(), name: await contract.name(), symbol: await contract.symbol(), + latestSwapPool: null, }) ctx.store.save(nablaToken) } @@ -389,28 +577,61 @@ export async function getOrCreateSwapPool( ctx: EventHandlerContext, hexAddress: string ) { - let address = codec(config.prefix).encode(hexAddress) + const address = codec(config.prefix).encode(hexAddress) let swapPool = await ctx.store.get(SwapPool, address) if (!swapPool) { const contract = new swapPoolAbi.Contract(ctx, hexAddress) - let router = await getOrCreateRouter(ctx, await contract.router()) - let backstop = await getOrCreateBackstopPool( + const backstop = await getOrCreateBackstopPool( ctx, await contract.backstop() ) - let token = await getOrCreateNablaToken(ctx, await contract.asset()) - let coverage = await contract.coverage() + const router = await getOrCreateRouter(ctx, await contract.router()) + const token = await getOrCreateNablaToken(ctx, await contract.asset()) + + const coverage = await contract.coverage() + swapPool = new SwapPool({ id: address, + name: await contract.name(), + symbol: await contract.symbol(), router: router, backstop: backstop, token: token, + reserve: coverage[0], + reserveWithSlippage: await contract.reserveWithSlippage(), + totalLiabilities: coverage[1], totalSupply: await contract.totalSupply(), - reserves: coverage[0], - liabilities: coverage[1], paused: false, + apr: 0n, + coveredIndex: null, }) ctx.store.save(swapPool) } return swapPool } + +export async function createSwapFee( + ctx: EventHandlerContext, + blockNumber: number, + extrinsicIndex: number | undefined, + lpFees: bigint, + backstopFees: bigint, + protocolFees: bigint, + timestamp: number | undefined, + swapPool: SwapPool, + backstopPool: BackstopPool +): Promise { + const swapFeeId = `${blockNumber}-${extrinsicIndex ?? ''}` + const swapFee = new NablaSwapFee({ + id: swapFeeId, + lpFees, + backstopFees, + protocolFees, + timestamp: BigInt(timestamp ?? Date.now() / 1000), + swapPool, + backstopPool, + }) + + ctx.store.save(swapFee) + return swapFee +} diff --git a/src/model/generated/backstopPool.model.ts b/src/model/generated/backstopPool.model.ts index 4a27e9e9..77cfced0 100644 --- a/src/model/generated/backstopPool.model.ts +++ b/src/model/generated/backstopPool.model.ts @@ -10,6 +10,7 @@ import * as marshal from './marshal' import { Router } from './router.model' import { NablaToken } from './nablaToken.model' import { SwapPool } from './swapPool.model' +import { NablaSwapFee } from './nablaSwapFee.model' @Entity_() export class BackstopPool { @@ -52,6 +53,9 @@ export class BackstopPool { @OneToMany_(() => SwapPool, (e) => e.backstop) coveredSwapPools!: SwapPool[] + @OneToMany_(() => NablaSwapFee, (e) => e.backstopPool) + feesHistory!: NablaSwapFee[] + @Column_('numeric', { transformer: marshal.bigintTransformer, nullable: false, diff --git a/src/model/generated/nablaSwapFee.model.ts b/src/model/generated/nablaSwapFee.model.ts index 14d250f6..190451d6 100644 --- a/src/model/generated/nablaSwapFee.model.ts +++ b/src/model/generated/nablaSwapFee.model.ts @@ -2,8 +2,12 @@ import { Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, + ManyToOne as ManyToOne_, + Index as Index_, } from 'typeorm' import * as marshal from './marshal' +import { SwapPool } from './swapPool.model' +import { BackstopPool } from './backstopPool.model' @Entity_() export class NablaSwapFee { @@ -18,7 +22,7 @@ export class NablaSwapFee { transformer: marshal.bigintTransformer, nullable: false, }) - lpFee!: bigint + lpFees!: bigint @Column_('numeric', { transformer: marshal.bigintTransformer, @@ -37,4 +41,12 @@ export class NablaSwapFee { nullable: false, }) timestamp!: bigint + + @Index_() + @ManyToOne_(() => SwapPool, { nullable: true }) + swapPool!: SwapPool + + @Index_() + @ManyToOne_(() => BackstopPool, { nullable: true }) + backstopPool!: BackstopPool | undefined | null } diff --git a/src/model/generated/swapPool.model.ts b/src/model/generated/swapPool.model.ts index d530a820..712c6bdc 100644 --- a/src/model/generated/swapPool.model.ts +++ b/src/model/generated/swapPool.model.ts @@ -4,11 +4,13 @@ import { PrimaryColumn as PrimaryColumn_, ManyToOne as ManyToOne_, Index as Index_, + OneToMany as OneToMany_, } from 'typeorm' import * as marshal from './marshal' import { Router } from './router.model' import { BackstopPool } from './backstopPool.model' import { NablaToken } from './nablaToken.model' +import { NablaSwapFee } from './nablaSwapFee.model' @Entity_() export class SwapPool { @@ -27,7 +29,7 @@ export class SwapPool { @Index_() @ManyToOne_(() => Router, { nullable: true }) - router!: Router + router!: Router | undefined | null @Index_() @ManyToOne_(() => BackstopPool, { nullable: true }) @@ -64,6 +66,9 @@ export class SwapPool { @Column_('bool', { nullable: false }) paused!: boolean + @OneToMany_(() => NablaSwapFee, (e) => e.swapPool) + feesHistory!: NablaSwapFee[] + @Column_('numeric', { transformer: marshal.bigintTransformer, nullable: false, From 46cd3e2f81c2a5675ff9f88e0f8a4caa5f5e2bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:20:08 -0300 Subject: [PATCH 05/20] Implement properly working Nabla indexer --- db/migrations/1708373922157-Data.js | 27 + nabla-abi/backstop.json | 82 ++- nabla-abi/router.json | 83 ++- nabla-abi/swap.json | 97 ++- schema.graphql | 2 - src/abi/abi.support.ts | 132 ---- src/abi/backstop.ts | 112 ++- src/abi/mockOracle.ts | 396 ----------- src/abi/router.ts | 114 +++- src/abi/swap.ts | 143 +++- src/config.ts | 7 +- src/mappings/block-details.ts | 1 - src/mappings/farming/handle.ts | 3 - src/mappings/nabla.ts | 637 ------------------ src/mappings/nabla/addresses.ts | 11 + .../nabla/backstopPoolEventHandler.ts | 145 ++++ src/mappings/nabla/creation.ts | 213 ++++++ src/mappings/nabla/handleEvent.ts | 79 +++ src/mappings/nabla/routerEventHandler.ts | 154 +++++ src/mappings/nabla/swapPoolEventHandler.ts | 258 +++++++ src/mappings/prices.ts | 1 + src/mappings/token.ts | 4 +- src/model/generated/nablaToken.model.ts | 6 - src/model/generated/swapPool.model.ts | 6 - src/processor.ts | 19 +- 25 files changed, 1405 insertions(+), 1327 deletions(-) create mode 100644 db/migrations/1708373922157-Data.js delete mode 100644 src/abi/abi.support.ts delete mode 100644 src/abi/mockOracle.ts delete mode 100644 src/mappings/nabla.ts create mode 100644 src/mappings/nabla/addresses.ts create mode 100644 src/mappings/nabla/backstopPoolEventHandler.ts create mode 100644 src/mappings/nabla/creation.ts create mode 100644 src/mappings/nabla/handleEvent.ts create mode 100644 src/mappings/nabla/routerEventHandler.ts create mode 100644 src/mappings/nabla/swapPoolEventHandler.ts diff --git a/db/migrations/1708373922157-Data.js b/db/migrations/1708373922157-Data.js new file mode 100644 index 00000000..7e7fba64 --- /dev/null +++ b/db/migrations/1708373922157-Data.js @@ -0,0 +1,27 @@ +module.exports = class Data1708373922157 { + name = 'Data1708373922157' + + async up(db) { + await db.query( + `ALTER TABLE "nabla_token" DROP CONSTRAINT "FK_03f6f92a4dd0116a68bd46ef66b"` + ) + await db.query(`DROP INDEX "public"."IDX_03f6f92a4dd0116a68bd46ef66"`) + await db.query( + `ALTER TABLE "nabla_token" DROP COLUMN "latest_swap_pool_id"` + ) + await db.query(`ALTER TABLE "swap_pool" DROP COLUMN "covered_index"`) + } + + async down(db) { + await db.query( + `ALTER TABLE "nabla_token" ADD CONSTRAINT "FK_03f6f92a4dd0116a68bd46ef66b" FOREIGN KEY ("latest_swap_pool_id") REFERENCES "swap_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `CREATE INDEX "IDX_03f6f92a4dd0116a68bd46ef66" ON "nabla_token" ("latest_swap_pool_id") ` + ) + await db.query( + `ALTER TABLE "nabla_token" ADD "latest_swap_pool_id" character varying` + ) + await db.query(`ALTER TABLE "swap_pool" ADD "covered_index" numeric`) + } +} diff --git a/nabla-abi/backstop.json b/nabla-abi/backstop.json index c179c30f..0adea1dd 100644 --- a/nabla-abi/backstop.json +++ b/nabla-abi/backstop.json @@ -7,7 +7,7 @@ }, "source": { "compiler": "solang 0.3.2", - "hash": "0x09e907520a2e0be46d0a350df95c431857cbf88f52094be242f15ae79e524f3c", + "hash": "0x026ff1b46ca6ae1d60aed9cea110e48ee635da3087675e463bc717a9c23ffbe1", "language": "Solidity 0.3.2" }, "spec": { @@ -69,11 +69,11 @@ }, "balance": { "displayName": ["Balance"], - "type": 10 + "type": 11 }, "blockNumber": { "displayName": ["BlockNumber"], - "type": 11 + "type": 12 }, "chainExtension": { "displayName": [], @@ -81,12 +81,12 @@ }, "hash": { "displayName": ["Hash"], - "type": 12 + "type": 13 }, "maxEventTopics": 4, "timestamp": { "displayName": ["Timestamp"], - "type": 11 + "type": 12 } }, "events": [ @@ -434,7 +434,7 @@ ], "lang_error": { "displayName": ["SolidityError"], - "type": 15 + "type": 16 }, "messages": [ { @@ -463,19 +463,6 @@ }, "selector": "0x95d89b41" }, - { - "args": [], - "default": false, - "docs": [""], - "label": "decimals", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["uint8"], - "type": 0 - }, - "selector": "0x313ce567" - }, { "args": [], "default": false, @@ -818,6 +805,21 @@ }, "selector": "0xc2d41601" }, + { + "args": [], + "default": false, + "docs": [ + "Returns the decimals of the LP token of this pool\nThis is defined to have the same decimals as the pool token itself\nin order to greatly simplify calculations that involve pool token amounts\nand LP token amounts" + ], + "label": "decimals", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint8"], + "type": 0 + }, + "selector": "0x313ce567" + }, { "args": [], "default": false, @@ -1109,7 +1111,7 @@ "args": [], "default": false, "docs": [ - "return worth of the whole backstop pool in `asset()`, incl. all\nswap pools' excess liquidity and the backstop pool's liabilities" + "return worth of the whole backstop pool in `asset()`, incl. all\nswap pools' excess liquidity and the backstop pool's liabilities\nthis is a fixed point number, using the backstop pool decimals" ], "label": "getTotalPoolWorth", "mutates": false, @@ -1142,6 +1144,23 @@ "type": 3 }, "selector": "0xcc045745" + }, + { + "args": [], + "default": false, + "docs": ["returns the backstop pool state"], + "label": "getPoolState", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "BackstopPool", + "getPoolState", + "return_type" + ], + "type": 10 + }, + "selector": "0x217ac237" } ] }, @@ -1494,6 +1513,15 @@ }, { "id": 10, + "type": { + "def": { + "tuple": [3, 7, 3] + }, + "path": ["BackstopPool", "getPoolState", "return_type"] + } + }, + { + "id": 11, "type": { "def": { "primitive": "u128" @@ -1502,7 +1530,7 @@ } }, { - "id": 11, + "id": 12, "type": { "def": { "primitive": "u64" @@ -1511,7 +1539,7 @@ } }, { - "id": 12, + "id": 13, "type": { "def": { "composite": { @@ -1526,7 +1554,7 @@ } }, { - "id": 13, + "id": 14, "type": { "def": { "composite": { @@ -1541,7 +1569,7 @@ } }, { - "id": 14, + "id": 15, "type": { "def": { "composite": { @@ -1556,7 +1584,7 @@ } }, { - "id": 15, + "id": 16, "type": { "def": { "variant": { @@ -1564,7 +1592,7 @@ { "fields": [ { - "type": 13 + "type": 14 } ], "index": 0, @@ -1573,7 +1601,7 @@ { "fields": [ { - "type": 14 + "type": 15 } ], "index": 1, diff --git a/nabla-abi/router.json b/nabla-abi/router.json index 474d76d2..eb45a5db 100644 --- a/nabla-abi/router.json +++ b/nabla-abi/router.json @@ -6,7 +6,7 @@ }, "source": { "compiler": "solang 0.3.2", - "hash": "0xc3a4799cb3feb885864b7bda2b7340893d52fc4f096024e42c5c59319e9cf4ed", + "hash": "0xe2399cb35f8b6165c02038216d66719e2f91be30096c0324fc759c0826684bcc", "language": "Solidity 0.3.2" }, "spec": { @@ -122,6 +122,19 @@ }, { "args": [ + { + "docs": [], + "indexed": true, + "label": "sender", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + }, { "docs": [], "indexed": false, @@ -152,6 +165,38 @@ "docs": ["Emitted when a new pool is registered"], "label": "SwapPoolRegistered" }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "sender", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + }, + { + "docs": [], + "indexed": false, + "label": "asset", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + } + ], + "docs": ["Emitted when pool is unregistered"], + "label": "SwapPoolUnregistered" + }, { "args": [ { @@ -295,7 +340,7 @@ { "args": [ { - "label": "assetId", + "label": "asset", "type": { "displayName": [ "ink_primitives", @@ -320,7 +365,7 @@ { "args": [ { - "label": "assetId", + "label": "asset", "type": { "displayName": [ "ink_primitives", @@ -403,13 +448,41 @@ } ], "default": false, - "docs": ["Registers a newly created swap pool."], + "docs": ["Registers a newly created swap pool"], "label": "registerPool", "mutates": true, "payable": false, - "returnType": null, + "returnType": { + "displayName": ["bool"], + "type": 4 + }, "selector": "0x7286e5e5" }, + { + "args": [ + { + "label": "_asset", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + } + ], + "default": false, + "docs": ["Unregisters a swap pool"], + "label": "unregisterPool", + "mutates": true, + "payable": false, + "returnType": { + "displayName": ["bool"], + "type": 4 + }, + "selector": "0xada61cc3" + }, { "args": [], "default": false, diff --git a/nabla-abi/swap.json b/nabla-abi/swap.json index fc4b1991..81e9d943 100644 --- a/nabla-abi/swap.json +++ b/nabla-abi/swap.json @@ -7,7 +7,7 @@ }, "source": { "compiler": "solang 0.3.2", - "hash": "0x480a1345d46a94f8d4a41c5f443c00de2f6d784e8ae1ebc3ea8a8a585990872a", + "hash": "0xc473b9f6f31f711534a19a44c15935f3e1ffe0f031cf98b3f5701111dc793f49", "language": "Solidity 0.3.2" }, "spec": { @@ -448,19 +448,6 @@ }, "selector": "0x95d89b41" }, - { - "args": [], - "default": false, - "docs": [""], - "label": "decimals", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["uint8"], - "type": 0 - }, - "selector": "0x313ce567" - }, { "args": [], "default": false, @@ -803,6 +790,21 @@ }, "selector": "0xc2d41601" }, + { + "args": [], + "default": false, + "docs": [ + "Returns the decimals of the LP token of this pool\nThis is defined to have the same decimals as the pool token itself\nin order to greatly simplify calculations that involve pool token amounts\nand LP token amounts" + ], + "label": "decimals", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint8"], + "type": 0 + }, + "selector": "0x313ce567" + }, { "args": [], "default": false, @@ -907,6 +909,19 @@ }, "selector": "0xebe26b9e" }, + { + "args": [], + "default": false, + "docs": [""], + "label": "maxCoverageRatioForSwapIn", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0xb2f3447a" + }, { "args": [ { @@ -950,21 +965,41 @@ { "args": [ { - "label": "_lpFeeBps", + "label": "_maxCoverageRatio", + "type": { + "displayName": ["uint256"], + "type": 3 + } + } + ], + "default": false, + "docs": [ + "Set new upper limit of pool coverage ratio (reserves / liabilities) for swap-in" + ], + "label": "setMaxCoverageRatioForSwapIn", + "mutates": true, + "payable": false, + "returnType": null, + "selector": "0x0668d07c" + }, + { + "args": [ + { + "label": "_lpFee", "type": { "displayName": ["uint256"], "type": 3 } }, { - "label": "_backstopFeeBps", + "label": "_backstopFee", "type": { "displayName": ["uint256"], "type": 3 } }, { - "label": "_protocolFeeBps", + "label": "_protocolFee", "type": { "displayName": ["uint256"], "type": 3 @@ -1244,7 +1279,7 @@ "args": [], "default": false, "docs": [ - "Computes the excess liquidity that forms that valuation of the backstop pool is defined as b + C - B - L where - b is reserve - C is the amount of pool tokens in the pool - B is reserveWithSlippage - L is totalLiabilities" + "Computes the excess liquidity that forms that valuation of the backstop pool is defined as b + C - B - L where - b is reserve - C is the amount of `asset()` tokens in the pool - B is reserveWithSlippage - L is totalLiabilities The excess liquidity is a fixed point number using the decimals of this pool" ], "label": "getExcessLiquidity", "mutates": false, @@ -1663,7 +1698,7 @@ "ty": 6 } }, - "name": "lpFeeBps" + "name": "lpFee" }, { "layout": { @@ -1672,7 +1707,7 @@ "ty": 6 } }, - "name": "backstopFeeBps" + "name": "backstopFee" }, { "layout": { @@ -1681,7 +1716,7 @@ "ty": 6 } }, - "name": "protocolFeeBps" + "name": "protocolFee" } ], "name": "SwapFees" @@ -1691,6 +1726,20 @@ } }, "name": "swapFeeConfig" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0x00000017", + "ty": 3 + } + }, + "root_key": "0x00000017" + } + }, + "name": "maxCoverageRatioForSwapIn" } ], "name": "SwapPool" @@ -1775,15 +1824,15 @@ "composite": { "fields": [ { - "name": "lpFeeBps", + "name": "lpFee", "type": 6 }, { - "name": "backstopFeeBps", + "name": "backstopFee", "type": 6 }, { - "name": "protocolFeeBps", + "name": "protocolFee", "type": 6 } ] diff --git a/schema.graphql b/schema.graphql index c39e0c61..fd0d106d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -753,7 +753,6 @@ type NablaToken @entity { decimals: Int! # number of decimal places the token can be split into name: String! # name of the token symbol: String! # ticker symbol of the token - latestSwapPool: SwapPool # swap pool of the token used by the router swapPools: [SwapPool!]! @derivedFrom(field: "token") } @@ -771,7 +770,6 @@ type SwapPool @entity { paused: Boolean! # whether the swap pool is paused feesHistory: [NablaSwapFee!]! @derivedFrom(field: "swapPool") # history of swap fees apr: BigInt! # annual percentage rate of the swap pool - coveredIndex: BigInt # index of swap pool covered by the backstop pool } type BackstopPool @entity { diff --git a/src/abi/abi.support.ts b/src/abi/abi.support.ts deleted file mode 100644 index c814c98f..00000000 --- a/src/abi/abi.support.ts +++ /dev/null @@ -1,132 +0,0 @@ -import assert from 'assert' -import * as ethers from 'ethers' - -export interface LogRecord { - topics: string[] - data: string -} - -export class LogEvent { - private fragment: ethers.EventFragment - - constructor(private abi: ethers.Interface, public readonly topic: string) { - let fragment = abi.getEvent(topic) - assert(fragment != null, 'Missing fragment') - this.fragment = fragment - } - - decode(rec: LogRecord): Args { - return this.abi.decodeEventLog( - this.fragment, - rec.data, - rec.topics - ) as any as Args - } -} - -export class Func { - private fragment: ethers.FunctionFragment - - constructor( - private abi: ethers.Interface, - public readonly sighash: string - ) { - let fragment = abi.getFunction(sighash) - assert(fragment != null, 'Missing fragment') - this.fragment = fragment - } - - decode(input: ethers.BytesLike): Args & FieldArgs { - return this.abi.decodeFunctionData( - this.fragment, - input - ) as any as Args & FieldArgs - } - - encode(args: Args): string { - return this.abi.encodeFunctionData(this.fragment, args) - } - - decodeResult(output: ethers.BytesLike): Result { - const decoded = this.abi.decodeFunctionResult(this.fragment, output) - return decoded.length > 1 ? decoded : decoded[0] - } - - tryDecodeResult(output: ethers.BytesLike): Result | undefined { - try { - return this.decodeResult(output) - } catch (err: any) { - return undefined - } - } -} - -export function isFunctionResultDecodingError( - val: unknown -): val is Error & { data: string } { - if (!(val instanceof Error)) return false - let err = val as any - return ( - err.code == 'CALL_EXCEPTION' && - typeof err.data == 'string' && - !err.errorArgs && - !err.errorName - ) -} - -export interface ChainContext { - _chain: Chain -} - -export interface BlockContext { - _chain: Chain - block: Block -} - -export interface Block { - height: number -} - -export interface Chain { - client: { - call: (method: string, params?: unknown[]) => Promise - } -} - -export class ContractBase { - private readonly _chain: Chain - private readonly blockHeight: number - readonly address: string - - constructor(ctx: BlockContext, address: string) - constructor(ctx: ChainContext, block: Block, address: string) - constructor( - ctx: BlockContext, - blockOrAddress: Block | string, - address?: string - ) { - this._chain = ctx._chain - if (typeof blockOrAddress === 'string') { - this.blockHeight = ctx.block.height - this.address = ethers.getAddress(blockOrAddress) - } else { - if (address == null) { - throw new Error('missing contract address') - } - this.blockHeight = blockOrAddress.height - this.address = ethers.getAddress(address) - } - } - - async eth_call( - func: Func, - args: Args - ): Promise { - let data = func.encode(args) - let result = await this._chain.client.call('eth_call', [ - { to: this.address, data }, - '0x' + this.blockHeight.toString(16), - ]) - return func.decodeResult(result) - } -} diff --git a/src/abi/backstop.ts b/src/abi/backstop.ts index 8cd37223..4858086d 100644 --- a/src/abi/backstop.ts +++ b/src/abi/backstop.ts @@ -10,7 +10,7 @@ export const metadata = { }, source: { compiler: 'solang 0.3.2', - hash: '0x09e907520a2e0be46d0a350df95c431857cbf88f52094be242f15ae79e524f3c', + hash: '0x026ff1b46ca6ae1d60aed9cea110e48ee635da3087675e463bc717a9c23ffbe1', language: 'Solidity 0.3.2', }, spec: { @@ -72,11 +72,11 @@ export const metadata = { }, balance: { displayName: ['Balance'], - type: 10, + type: 11, }, blockNumber: { displayName: ['BlockNumber'], - type: 11, + type: 12, }, chainExtension: { displayName: [], @@ -84,12 +84,12 @@ export const metadata = { }, hash: { displayName: ['Hash'], - type: 12, + type: 13, }, maxEventTopics: 4, timestamp: { displayName: ['Timestamp'], - type: 11, + type: 12, }, }, events: [ @@ -437,7 +437,7 @@ export const metadata = { ], lang_error: { displayName: ['SolidityError'], - type: 15, + type: 16, }, messages: [ { @@ -466,19 +466,6 @@ export const metadata = { }, selector: '0x95d89b41', }, - { - args: [], - default: false, - docs: [''], - label: 'decimals', - mutates: false, - payable: false, - returnType: { - displayName: ['uint8'], - type: 0, - }, - selector: '0x313ce567', - }, { args: [], default: false, @@ -821,6 +808,21 @@ export const metadata = { }, selector: '0xc2d41601', }, + { + args: [], + default: false, + docs: [ + 'Returns the decimals of the LP token of this pool\nThis is defined to have the same decimals as the pool token itself\nin order to greatly simplify calculations that involve pool token amounts\nand LP token amounts', + ], + label: 'decimals', + mutates: false, + payable: false, + returnType: { + displayName: ['uint8'], + type: 0, + }, + selector: '0x313ce567', + }, { args: [], default: false, @@ -1112,7 +1114,7 @@ export const metadata = { args: [], default: false, docs: [ - "return worth of the whole backstop pool in `asset()`, incl. all\nswap pools' excess liquidity and the backstop pool's liabilities", + "return worth of the whole backstop pool in `asset()`, incl. all\nswap pools' excess liquidity and the backstop pool's liabilities\nthis is a fixed point number, using the backstop pool decimals", ], label: 'getTotalPoolWorth', mutates: false, @@ -1146,6 +1148,23 @@ export const metadata = { }, selector: '0xcc045745', }, + { + args: [], + default: false, + docs: ['returns the backstop pool state'], + label: 'getPoolState', + mutates: false, + payable: false, + returnType: { + displayName: [ + 'BackstopPool', + 'getPoolState', + 'return_type', + ], + type: 10, + }, + selector: '0x217ac237', + }, ], }, storage: { @@ -1497,6 +1516,15 @@ export const metadata = { }, { id: 10, + type: { + def: { + tuple: [3, 7, 3], + }, + path: ['BackstopPool', 'getPoolState', 'return_type'], + }, + }, + { + id: 11, type: { def: { primitive: 'u128', @@ -1505,7 +1533,7 @@ export const metadata = { }, }, { - id: 11, + id: 12, type: { def: { primitive: 'u64', @@ -1514,7 +1542,7 @@ export const metadata = { }, }, { - id: 12, + id: 13, type: { def: { composite: { @@ -1529,7 +1557,7 @@ export const metadata = { }, }, { - id: 13, + id: 14, type: { def: { composite: { @@ -1544,7 +1572,7 @@ export const metadata = { }, }, { - id: 14, + id: 15, type: { def: { composite: { @@ -1559,7 +1587,7 @@ export const metadata = { }, }, { - id: 15, + id: 16, type: { def: { variant: { @@ -1567,7 +1595,7 @@ export const metadata = { { fields: [ { - type: 13, + type: 14, }, ], index: 0, @@ -1576,7 +1604,7 @@ export const metadata = { { fields: [ { - type: 14, + type: 15, }, ], index: 1, @@ -1631,10 +1659,6 @@ export class Contract { return this.stateCall('0x95d89b41', []) } - decimals(): Promise { - return this.stateCall('0x313ce567', []) - } - totalSupply(): Promise { return this.stateCall('0x18160ddd', []) } @@ -1667,6 +1691,10 @@ export class Contract { return this.stateCall('0xc2d41601', []) } + decimals(): Promise { + return this.stateCall('0x313ce567', []) + } + router(): Promise { return this.stateCall('0xf887ea40', []) } @@ -1691,6 +1719,10 @@ export class Contract { return this.stateCall('0xcc045745', [_sharesToBurn]) } + getPoolState(): Promise<[uint256, int256, uint256]> { + return this.stateCall('0x217ac237', []) + } + private async stateCall(selector: string, args: any[]): Promise { let input = _abi.encodeMessageInput(selector, args) let data = encodeCall(this.address, input) @@ -1706,14 +1738,14 @@ export class Contract { export type int256 = bigint +export type uint8 = number + export type bool = boolean export type AccountId = Bytes export type uint256 = bigint -export type uint8 = number - export type Constructor = Constructor_new /** @@ -1740,6 +1772,7 @@ export type Message = | Message_getBackedPool | Message_getBackedPoolCount | Message_getInsuranceFee + | Message_getPoolState | Message_getTotalPoolWorth | Message_increaseAllowance | Message_name @@ -1811,7 +1844,10 @@ export interface Message_balanceOf { } /** - * + * Returns the decimals of the LP token of this pool +This is defined to have the same decimals as the pool token itself +in order to greatly simplify calculations that involve pool token amounts +and LP token amounts */ export interface Message_decimals { __kind: 'decimals' @@ -1857,9 +1893,17 @@ export interface Message_getInsuranceFee { swapPool: AccountId } +/** + * returns the backstop pool state + */ +export interface Message_getPoolState { + __kind: 'getPoolState' +} + /** * return worth of the whole backstop pool in `asset()`, incl. all swap pools' excess liquidity and the backstop pool's liabilities +this is a fixed point number, using the backstop pool decimals */ export interface Message_getTotalPoolWorth { __kind: 'getTotalPoolWorth' diff --git a/src/abi/mockOracle.ts b/src/abi/mockOracle.ts deleted file mode 100644 index cad82a2e..00000000 --- a/src/abi/mockOracle.ts +++ /dev/null @@ -1,396 +0,0 @@ -import { Abi, Bytes, encodeCall, decodeResult } from '@subsquid/ink-abi' - -export const metadata = { - contract: { - authors: ['unknown'], - name: 'MockOracle', - version: '0.0.1', - }, - source: { - compiler: 'solang 0.3.2', - hash: '0x8d16a4bd1f3071e0fb0965b6e6ca421975da6269e77340d5f080f81f2cb54023', - language: 'Solidity 0.3.2', - }, - spec: { - constructors: [ - { - args: [ - { - label: '_asset', - type: { - displayName: [ - 'ink_primitives', - 'types', - 'AccountId', - ], - type: 2, - }, - }, - { - label: '_price', - type: { - displayName: ['uint256'], - type: 3, - }, - }, - ], - default: false, - docs: [''], - label: 'new', - payable: false, - returnType: null, - selector: '0x7d669750', - }, - ], - docs: [''], - environment: { - accountId: { - displayName: ['AccountId'], - type: 2, - }, - balance: { - displayName: ['Balance'], - type: 4, - }, - blockNumber: { - displayName: ['BlockNumber'], - type: 5, - }, - chainExtension: { - displayName: [], - type: 0, - }, - hash: { - displayName: ['Hash'], - type: 6, - }, - maxEventTopics: 4, - timestamp: { - displayName: ['Timestamp'], - type: 5, - }, - }, - events: [], - lang_error: { - displayName: ['SolidityError'], - type: 10, - }, - messages: [ - { - args: [ - { - label: '_asset', - type: { - displayName: [ - 'ink_primitives', - 'types', - 'AccountId', - ], - type: 2, - }, - }, - { - label: '_price', - type: { - displayName: ['uint256'], - type: 3, - }, - }, - ], - default: false, - docs: [''], - label: 'updateCurrentPrices', - mutates: true, - payable: false, - returnType: { - displayName: ['uint256'], - type: 3, - }, - selector: '0xf97a7796', - }, - { - args: [ - { - label: '_asset', - type: { - displayName: [ - 'ink_primitives', - 'types', - 'AccountId', - ], - type: 2, - }, - }, - ], - default: false, - docs: [''], - label: 'getAssetPrice', - mutates: false, - payable: false, - returnType: { - displayName: ['uint256'], - type: 3, - }, - selector: '0xb3596f07', - }, - ], - }, - storage: { - struct: { - fields: [ - { - layout: { - root: { - layout: { - leaf: { - key: '0x00000000', - ty: 3, - }, - }, - root_key: '0x00000000', - }, - }, - name: 'currentPrices', - }, - ], - name: 'MockOracle', - }, - }, - types: [ - { - id: 0, - type: { - def: { - primitive: 'u8', - }, - path: ['uint8'], - }, - }, - { - id: 1, - type: { - def: { - array: { - len: 32, - type: 0, - }, - }, - }, - }, - { - id: 2, - type: { - def: { - composite: { - fields: [ - { - type: 1, - }, - ], - }, - }, - path: ['ink_primitives', 'types', 'AccountId'], - }, - }, - { - id: 3, - type: { - def: { - primitive: 'u256', - }, - path: ['uint256'], - }, - }, - { - id: 4, - type: { - def: { - primitive: 'u128', - }, - path: ['uint128'], - }, - }, - { - id: 5, - type: { - def: { - primitive: 'u64', - }, - path: ['uint64'], - }, - }, - { - id: 6, - type: { - def: { - composite: { - fields: [ - { - type: 1, - }, - ], - }, - }, - path: ['ink_primitives', 'types', 'Hash'], - }, - }, - { - id: 7, - type: { - def: { - primitive: 'str', - }, - path: ['string'], - }, - }, - { - id: 8, - type: { - def: { - composite: { - fields: [ - { - type: 7, - }, - ], - }, - }, - path: ['0x08c379a0'], - }, - }, - { - id: 9, - type: { - def: { - composite: { - fields: [ - { - type: 3, - }, - ], - }, - }, - path: ['0x4e487b71'], - }, - }, - { - id: 10, - type: { - def: { - variant: { - variants: [ - { - fields: [ - { - type: 8, - }, - ], - index: 0, - name: 'Error', - }, - { - fields: [ - { - type: 9, - }, - ], - index: 1, - name: 'Panic', - }, - ], - }, - }, - path: ['SolidityError'], - }, - }, - ], - version: '4', -} - -const _abi = new Abi(metadata) - -export function decodeEvent(bytes: Bytes): Event { - return _abi.decodeEvent(bytes) -} - -export function decodeMessage(bytes: Bytes): Message { - return _abi.decodeMessage(bytes) -} - -export function decodeConstructor(bytes: Bytes): Constructor { - return _abi.decodeConstructor(bytes) -} - -export interface Chain { - rpc: { - call(method: string, params?: unknown[]): Promise - } -} - -export interface ChainContext { - _chain: Chain -} - -export class Contract { - constructor( - private ctx: ChainContext, - private address: Bytes, - private blockHash?: Bytes - ) {} - - getAssetPrice(_asset: AccountId): Promise { - return this.stateCall('0xb3596f07', [_asset]) - } - - private async stateCall(selector: string, args: any[]): Promise { - let input = _abi.encodeMessageInput(selector, args) - let data = encodeCall(this.address, input) - let result = await this.ctx._chain.rpc.call('state_call', [ - 'ContractsApi_call', - data, - this.blockHash, - ]) - let value = decodeResult(result) - return _abi.decodeMessageOutput(selector, value) - } -} - -export type uint256 = bigint - -export type AccountId = Bytes - -export type Constructor = Constructor_new - -/** - * - */ -export interface Constructor_new { - __kind: 'new' - asset: AccountId - price: uint256 -} - -export type Message = Message_getAssetPrice | Message_updateCurrentPrices - -/** - * - */ -export interface Message_getAssetPrice { - __kind: 'getAssetPrice' - asset: AccountId -} - -/** - * - */ -export interface Message_updateCurrentPrices { - __kind: 'updateCurrentPrices' - asset: AccountId - price: uint256 -} - -export type Event = never - -export type Result = - | { __kind: 'Ok'; value: T } - | { __kind: 'Err'; value: E } diff --git a/src/abi/router.ts b/src/abi/router.ts index 98aa2383..231e9e7d 100644 --- a/src/abi/router.ts +++ b/src/abi/router.ts @@ -8,7 +8,7 @@ export const metadata = { }, source: { compiler: 'solang 0.3.2', - hash: '0xc3a4799cb3feb885864b7bda2b7340893d52fc4f096024e42c5c59319e9cf4ed', + hash: '0xe2399cb35f8b6165c02038216d66719e2f91be30096c0324fc759c0826684bcc', language: 'Solidity 0.3.2', }, spec: { @@ -124,6 +124,19 @@ export const metadata = { }, { args: [ + { + docs: [], + indexed: true, + label: 'sender', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, { docs: [], indexed: false, @@ -154,6 +167,38 @@ export const metadata = { docs: ['Emitted when a new pool is registered'], label: 'SwapPoolRegistered', }, + { + args: [ + { + docs: [], + indexed: true, + label: 'sender', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + { + docs: [], + indexed: false, + label: 'asset', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + ], + docs: ['Emitted when pool is unregistered'], + label: 'SwapPoolUnregistered', + }, { args: [ { @@ -297,7 +342,7 @@ export const metadata = { { args: [ { - label: 'assetId', + label: 'asset', type: { displayName: [ 'ink_primitives', @@ -322,7 +367,7 @@ export const metadata = { { args: [ { - label: 'assetId', + label: 'asset', type: { displayName: [ 'ink_primitives', @@ -405,13 +450,41 @@ export const metadata = { }, ], default: false, - docs: ['Registers a newly created swap pool.'], + docs: ['Registers a newly created swap pool'], label: 'registerPool', mutates: true, payable: false, - returnType: null, + returnType: { + displayName: ['bool'], + type: 4, + }, selector: '0x7286e5e5', }, + { + args: [ + { + label: '_asset', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + ], + default: false, + docs: ['Unregisters a swap pool'], + label: 'unregisterPool', + mutates: true, + payable: false, + returnType: { + displayName: ['bool'], + type: 4, + }, + selector: '0xada61cc3', + }, { args: [], default: false, @@ -845,12 +918,12 @@ export class Contract { return this.stateCall('0x8da5cb5b', []) } - poolByAsset(assetId: AccountId): Promise { - return this.stateCall('0x06de94d8', [assetId]) + poolByAsset(asset: AccountId): Promise { + return this.stateCall('0x06de94d8', [asset]) } - oracleByAsset(assetId: AccountId): Promise { - return this.stateCall('0x38163032', [assetId]) + oracleByAsset(asset: AccountId): Promise { + return this.stateCall('0x38163032', [asset]) } getAmountOut( @@ -901,6 +974,7 @@ export type Message = | Message_swapExactTokensForTokens | Message_transferOwnership | Message_unpause + | Message_unregisterPool /** * Get a quote for how many `_toToken` tokens `_amountIn` many `tokenIn` @@ -917,7 +991,7 @@ export interface Message_getAmountOut { */ export interface Message_oracleByAsset { __kind: 'oracleByAsset' - assetId: AccountId + asset: AccountId } /** @@ -946,11 +1020,11 @@ export interface Message_paused { */ export interface Message_poolByAsset { __kind: 'poolByAsset' - assetId: AccountId + asset: AccountId } /** - * Registers a newly created swap pool. + * Registers a newly created swap pool */ export interface Message_registerPool { __kind: 'registerPool' @@ -1002,11 +1076,20 @@ export interface Message_unpause { __kind: 'unpause' } +/** + * Unregisters a swap pool + */ +export interface Message_unregisterPool { + __kind: 'unregisterPool' + asset: AccountId +} + export type Event = | Event_OwnershipTransferred | Event_Paused | Event_Swap | Event_SwapPoolRegistered + | Event_SwapPoolUnregistered | Event_Unpaused export interface Event_OwnershipTransferred { @@ -1032,10 +1115,17 @@ export interface Event_Swap { export interface Event_SwapPoolRegistered { __kind: 'SwapPoolRegistered' + sender: AccountId pool: AccountId asset: AccountId } +export interface Event_SwapPoolUnregistered { + __kind: 'SwapPoolUnregistered' + sender: AccountId + asset: AccountId +} + export interface Event_Unpaused { __kind: 'Unpaused' account: AccountId diff --git a/src/abi/swap.ts b/src/abi/swap.ts index a61b1782..e91b5621 100644 --- a/src/abi/swap.ts +++ b/src/abi/swap.ts @@ -10,7 +10,7 @@ export const metadata = { }, source: { compiler: 'solang 0.3.2', - hash: '0x480a1345d46a94f8d4a41c5f443c00de2f6d784e8ae1ebc3ea8a8a585990872a', + hash: '0xc473b9f6f31f711534a19a44c15935f3e1ffe0f031cf98b3f5701111dc793f49', language: 'Solidity 0.3.2', }, spec: { @@ -451,19 +451,6 @@ export const metadata = { }, selector: '0x95d89b41', }, - { - args: [], - default: false, - docs: [''], - label: 'decimals', - mutates: false, - payable: false, - returnType: { - displayName: ['uint8'], - type: 0, - }, - selector: '0x313ce567', - }, { args: [], default: false, @@ -806,6 +793,21 @@ export const metadata = { }, selector: '0xc2d41601', }, + { + args: [], + default: false, + docs: [ + 'Returns the decimals of the LP token of this pool\nThis is defined to have the same decimals as the pool token itself\nin order to greatly simplify calculations that involve pool token amounts\nand LP token amounts', + ], + label: 'decimals', + mutates: false, + payable: false, + returnType: { + displayName: ['uint8'], + type: 0, + }, + selector: '0x313ce567', + }, { args: [], default: false, @@ -910,6 +912,19 @@ export const metadata = { }, selector: '0xebe26b9e', }, + { + args: [], + default: false, + docs: [''], + label: 'maxCoverageRatioForSwapIn', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0xb2f3447a', + }, { args: [ { @@ -953,21 +968,41 @@ export const metadata = { { args: [ { - label: '_lpFeeBps', + label: '_maxCoverageRatio', type: { displayName: ['uint256'], type: 3, }, }, + ], + default: false, + docs: [ + 'Set new upper limit of pool coverage ratio (reserves / liabilities) for swap-in', + ], + label: 'setMaxCoverageRatioForSwapIn', + mutates: true, + payable: false, + returnType: null, + selector: '0x0668d07c', + }, + { + args: [ { - label: '_backstopFeeBps', + label: '_lpFee', type: { displayName: ['uint256'], type: 3, }, }, { - label: '_protocolFeeBps', + label: '_backstopFee', + type: { + displayName: ['uint256'], + type: 3, + }, + }, + { + label: '_protocolFee', type: { displayName: ['uint256'], type: 3, @@ -1247,7 +1282,7 @@ export const metadata = { args: [], default: false, docs: [ - 'Computes the excess liquidity that forms that valuation of the backstop pool is defined as b + C - B - L where - b is reserve - C is the amount of pool tokens in the pool - B is reserveWithSlippage - L is totalLiabilities', + 'Computes the excess liquidity that forms that valuation of the backstop pool is defined as b + C - B - L where - b is reserve - C is the amount of `asset()` tokens in the pool - B is reserveWithSlippage - L is totalLiabilities The excess liquidity is a fixed point number using the decimals of this pool', ], label: 'getExcessLiquidity', mutates: false, @@ -1666,7 +1701,7 @@ export const metadata = { ty: 6, }, }, - name: 'lpFeeBps', + name: 'lpFee', }, { layout: { @@ -1675,7 +1710,7 @@ export const metadata = { ty: 6, }, }, - name: 'backstopFeeBps', + name: 'backstopFee', }, { layout: { @@ -1684,7 +1719,7 @@ export const metadata = { ty: 6, }, }, - name: 'protocolFeeBps', + name: 'protocolFee', }, ], name: 'SwapFees', @@ -1695,6 +1730,20 @@ export const metadata = { }, name: 'swapFeeConfig', }, + { + layout: { + root: { + layout: { + leaf: { + key: '0x00000017', + ty: 3, + }, + }, + root_key: '0x00000017', + }, + }, + name: 'maxCoverageRatioForSwapIn', + }, ], name: 'SwapPool', }, @@ -1778,15 +1827,15 @@ export const metadata = { composite: { fields: [ { - name: 'lpFeeBps', + name: 'lpFee', type: 6, }, { - name: 'backstopFeeBps', + name: 'backstopFee', type: 6, }, { - name: 'protocolFeeBps', + name: 'protocolFee', type: 6, }, ], @@ -1976,10 +2025,6 @@ export class Contract { return this.stateCall('0x95d89b41', []) } - decimals(): Promise { - return this.stateCall('0x313ce567', []) - } - totalSupply(): Promise { return this.stateCall('0x18160ddd', []) } @@ -2012,6 +2057,10 @@ export class Contract { return this.stateCall('0xc2d41601', []) } + decimals(): Promise { + return this.stateCall('0x313ce567', []) + } + totalLiabilities(): Promise { return this.stateCall('0xf73579a9', []) } @@ -2044,6 +2093,10 @@ export class Contract { return this.stateCall('0xebe26b9e', []) } + maxCoverageRatioForSwapIn(): Promise { + return this.stateCall('0xb2f3447a', []) + } + swapFees(): Promise { return this.stateCall('0xb9ccf21d', []) } @@ -2089,14 +2142,14 @@ export type int256 = bigint export type return_type = [uint256, uint256, uint256] +export type uint8 = number + export type bool = boolean export type AccountId = Bytes export type uint256 = bigint -export type uint8 = number - export type Constructor = Constructor_new /** @@ -2130,6 +2183,7 @@ export type Message = | Message_increaseAllowance | Message_insuranceWithdrawalTimelock | Message_insuranceWithdrawalUnlock + | Message_maxCoverageRatioForSwapIn | Message_name | Message_owner | Message_pause @@ -2143,6 +2197,7 @@ export type Message = | Message_reserveWithSlippage | Message_router | Message_setInsuranceWithdrawalTimelock + | Message_setMaxCoverageRatioForSwapIn | Message_setPoolCap | Message_setSwapFees | Message_sharesTargetWorth @@ -2232,7 +2287,10 @@ export interface Message_coverage { } /** - * + * Returns the decimals of the LP token of this pool +This is defined to have the same decimals as the pool token itself +in order to greatly simplify calculations that involve pool token amounts +and LP token amounts */ export interface Message_decimals { __kind: 'decimals' @@ -2256,7 +2314,7 @@ export interface Message_deposit { } /** - * Computes the excess liquidity that forms that valuation of the backstop pool is defined as b + C - B - L where - b is reserve - C is the amount of pool tokens in the pool - B is reserveWithSlippage - L is totalLiabilities + * Computes the excess liquidity that forms that valuation of the backstop pool is defined as b + C - B - L where - b is reserve - C is the amount of `asset()` tokens in the pool - B is reserveWithSlippage - L is totalLiabilities The excess liquidity is a fixed point number using the decimals of this pool */ export interface Message_getExcessLiquidity { __kind: 'getExcessLiquidity' @@ -2286,6 +2344,13 @@ export interface Message_insuranceWithdrawalUnlock { liquidityProvider: AccountId } +/** + * + */ +export interface Message_maxCoverageRatioForSwapIn { + __kind: 'maxCoverageRatioForSwapIn' +} + /** * */ @@ -2380,6 +2445,14 @@ export interface Message_setInsuranceWithdrawalTimelock { durationInBlocks: uint256 } +/** + * Set new upper limit of pool coverage ratio (reserves / liabilities) for swap-in + */ +export interface Message_setMaxCoverageRatioForSwapIn { + __kind: 'setMaxCoverageRatioForSwapIn' + maxCoverageRatio: uint256 +} + /** * Set new upper limit of pool reserves. Will disable deposits when reached. Can always set to an amount < current reserves to temporarily restrict deposits. */ @@ -2393,9 +2466,9 @@ export interface Message_setPoolCap { */ export interface Message_setSwapFees { __kind: 'setSwapFees' - lpFeeBps: uint256 - backstopFeeBps: uint256 - protocolFeeBps: uint256 + lpFee: uint256 + backstopFee: uint256 + protocolFee: uint256 } /** diff --git a/src/config.ts b/src/config.ts index 8c5dbf8e..4ad758da 100644 --- a/src/config.ts +++ b/src/config.ts @@ -30,8 +30,9 @@ const foucocoConfig: ProcessorConfig = { chainName: 'foucoco', prefix: 'amplitude', dataSource: { - archive: lookupArchive('foucoco', { release: 'ArrowSquid' }), - chain: 'wss://pencol-roa-00.pendulumchain.tech', + archive: undefined, // lookupArchive('foucoco', { release: 'ArrowSquid' }), + chain: 'ws://127.0.0.1:9944', + //chain: 'wss://pencol-roa-00.pendulumchain.tech', }, } @@ -58,5 +59,5 @@ export const maxHeightPromise = axios 'Error getting block height from archive, using default value instead:', error ) - return Number.MAX_SAFE_INTEGER + return 0 }) diff --git a/src/mappings/block-details.ts b/src/mappings/block-details.ts index 1f9f2c2c..114c47f2 100644 --- a/src/mappings/block-details.ts +++ b/src/mappings/block-details.ts @@ -2,7 +2,6 @@ import { Ctx, BlockHeader_, Call_, Event_, Extrinsic_ } from '../processor' import { decodeHex } from '@subsquid/substrate-processor' import * as model from '../model' -import { In } from 'typeorm/find-options/operator/In' import { blockRetentionNumber } from '../config' export async function saveBlock(ctx: Ctx, block: BlockHeader_) { diff --git a/src/mappings/farming/handle.ts b/src/mappings/farming/handle.ts index 0539740b..26083fe3 100644 --- a/src/mappings/farming/handle.ts +++ b/src/mappings/farming/handle.ts @@ -13,14 +13,11 @@ import { formatFarmingPoolEditedEvent, formatFarmingPoolKilledEvent, formatFarmingPoolResetEvent, - formatFarmingRetireLimitSetEvent, formatFarmingWithdrawClaimedEvent, formatFarmingWithdrawnEvent, - getFamingPoolInfo, killFarmingPoolInfo, updateFarmingPoolInfo, } from '../../utils/farming' -import { getStakePosition } from '../../entities/farming' import { getUser } from '../../entities/user' import { Farm } from '../../model' import { updateStakePosition } from '../farming/update' diff --git a/src/mappings/nabla.ts b/src/mappings/nabla.ts deleted file mode 100644 index e192f7cd..00000000 --- a/src/mappings/nabla.ts +++ /dev/null @@ -1,637 +0,0 @@ -import { EventHandlerContext } from '../processor' -import { - BackstopPool, - Router, - NablaToken, - SwapPool, - NablaSwapFee, -} from '../model' -import * as backstopPoolAbi from '../abi/backstop' -import * as erc20Abi from '../abi/erc20' -import * as swapPoolAbi from '../abi/swap' -import * as routerAbi from '../abi/router' -import { codec } from '@subsquid/ss58' -import { config } from '../config' -import * as ss58 from '@subsquid/ss58' - -enum EventType { - BackstopPoolEvent = 1, - RouterEvent, - SwapPoolEvent, -} - -type Event = - | erc20Abi.Event - | backstopPoolAbi.Event - | swapPoolAbi.Event - | routerAbi.Event - -const SWAP_FEE_PRUNE_INTERVAL_SECONDS = 7 * 24 * 60 * 60 - -interface Decoder { - decodeEvent(hex: string): Event -} - -function ss58ToHex(address: string) { - return ss58.decode(address).bytes -} - -async function isSwapPoolEvent(ctx: EventHandlerContext) { - try { - const contract = new swapPoolAbi.Contract(ctx, ctx.event.args.contract) - await contract.router() - await contract.backstop() - await contract.reserveWithSlippage() - await contract.poolCap() - return swapPoolAbi.decodeEvent(ctx.event.args.data) - } catch { - return undefined - } -} - -async function isRouterEvent(ctx: EventHandlerContext) { - try { - const contract = new routerAbi.Contract(ctx, ctx.event.args.contract) - return routerAbi.decodeEvent(ctx.event.args.data) - } catch { - return undefined - } -} - -async function isBackstopPoolEvent(ctx: EventHandlerContext) { - try { - const contract = new backstopPoolAbi.Contract( - ctx, - ctx.event.args.contract - ) - await contract.getBackedPool(0n) - return backstopPoolAbi.decodeEvent(ctx.event.args.data) - } catch { - return undefined - } -} - -async function verifyEvent(verifier: Function, ctx: EventHandlerContext) { - return verifier(ctx) -} - -// Iterates over all decoders and returns the first successfully decoded event -async function getEventAndEventType(ctx: EventHandlerContext): Promise<{ - event: Event | null - eventType: EventType | null -}> { - const verifiers = [isBackstopPoolEvent, isRouterEvent, isSwapPoolEvent] - const eventTypes = [ - EventType.BackstopPoolEvent, - EventType.RouterEvent, - EventType.SwapPoolEvent, - ] - - // Iterate over all verifiers and try to decode the event to the given type - for (let i = 0; i < verifiers.length; i++) { - const event = await verifyEvent(verifiers[i], ctx) - if (event != undefined) { - const eventType = eventTypes[i] - return { event, eventType } - } - } - - return { event: null, eventType: null } -} - -export async function handleContractEvent(ctx: EventHandlerContext) { - const { event, eventType } = await getEventAndEventType(ctx) - if (!event || !eventType) { - return - } - - if (eventType === EventType.BackstopPoolEvent) { - if (event.__kind == 'Burn') { - await backstopHandleBurn(ctx) - } else if (event.__kind == 'CoverSwapWithdrawal') { - await backstopHandleCoverSwapWithdrawal(ctx, event) - } else if (event.__kind == 'Mint') { - await backstopHandleMint(ctx) - } else if (event.__kind == 'OwnershipTransferred') { - await backstopHandleOwnershipTransferred(ctx) - } else if (event.__kind == 'Paused') { - await backstopHandlePaused(ctx) - } else if (event.__kind == 'Transfer') { - await backstopHandleTransfer(ctx) - } else if (event.__kind == 'Unpaused') { - await backstopHandleUnpaused(ctx) - } else if (event.__kind == 'WithdrawSwapLiquidity') { - await backstopHandleWithdrawSwapLiquidity(ctx, event) - } - } else if (eventType === EventType.RouterEvent) { - if (event.__kind == 'OwnershipTransferred') { - await routerHandleOwnershipTransferred(ctx) - } else if (event.__kind == 'Paused') { - await routerHandlePaused(ctx) - } else if (event.__kind == 'Swap') { - await routerHandleSwap(ctx, event) - } else if (event.__kind == 'SwapPoolRegistered') { - await routerHandleSwapPoolRegistered(ctx, event) - } else if (event.__kind == 'Unpaused') { - await routerHandleUnpaused(ctx) - } - } else if (eventType === EventType.SwapPoolEvent) { - if (event.__kind == 'BackstopDrain') { - await swapHandleBackstopDrain(ctx) - } else if (event.__kind == 'Burn') { - await swapHandleBurn(ctx) - } else if (event.__kind == 'ChargedSwapFees') { - await swapHandleChargedSwapFees(ctx, event) - } else if (event.__kind == 'Mint') { - await swapHandleMint(ctx) - } else if (event.__kind == 'OwnershipTransferred') { - await swapHandleOwnershipTransferred(ctx) - } else if (event.__kind == 'Paused') { - await swapHandlePaused(ctx) - } else if (event.__kind == 'Transfer') { - await swapHandleTransfer(ctx) - } else if (event.__kind == 'Unpaused') { - await swapHandleUnpaused(ctx) - } - } -} - -export async function backstopHandleBurn(ctx: EventHandlerContext) { - const backstop = await getOrCreateBackstopPool(ctx, ctx.event.args.contract) - - await updateBackstopCoverageAndSupply(ctx, backstop) - ctx.store.save(backstop) -} - -export async function backstopHandleCoverSwapWithdrawal( - ctx: EventHandlerContext, - event: backstopPoolAbi.Event_CoverSwapWithdrawal -) { - const backstop = await getOrCreateBackstopPool(ctx, ctx.event.args.contract) - const pool = await getOrCreateSwapPool(ctx, event.swapPool) - - updateBackstopCoverageAndSupply(ctx, backstop) - updateSwapPoolCoverageAndSupply(ctx, pool) - - ctx.store.save(backstop) - ctx.store.save(pool) -} - -export async function backstopHandleMint(ctx: EventHandlerContext) { - const backstop = await getOrCreateBackstopPool(ctx, ctx.event.args.contract) - - updateBackstopCoverageAndSupply(ctx, backstop) - ctx.store.save(backstop) -} - -export async function backstopHandleOwnershipTransferred( - ctx: EventHandlerContext -) { - // This event will always be emitted on pool creation - const backstop = await getOrCreateBackstopPool(ctx, ctx.event.args.contract) - ctx.store.save(backstop) -} - -export async function backstopHandlePaused(ctx: EventHandlerContext) { - const backstop = await getOrCreateBackstopPool(ctx, ctx.event.args.contract) - - backstop.paused = true - ctx.store.save(backstop) -} - -export async function backstopHandleTransfer(ctx: EventHandlerContext) { - const backstop = await getOrCreateBackstopPool(ctx, ctx.event.args.contract) - ctx.store.save(backstop) -} - -export async function backstopHandleUnpaused(ctx: EventHandlerContext) { - const backstop = await getOrCreateBackstopPool(ctx, ctx.event.args.contract) - - backstop.paused = false - ctx.store.save(backstop) -} - -export async function backstopHandleWithdrawSwapLiquidity( - ctx: EventHandlerContext, - event: backstopPoolAbi.Event_WithdrawSwapLiquidity -) { - const backstop = await getOrCreateBackstopPool(ctx, ctx.event.args.contract) - const pool = await getOrCreateSwapPool(ctx, event.swapPool) - await updateBackstopCoverageAndSupply(ctx, backstop) - await updateSwapPoolCoverageAndSupply(ctx, pool) - - ctx.store.save(backstop) - ctx.store.save(pool) -} - -export async function swapHandleBackstopDrain(ctx: EventHandlerContext) { - const pool = await getOrCreateSwapPool(ctx, ctx.event.args.contract) - const backstop = await getOrCreateBackstopPool(ctx, pool.backstop.id) - - await updateSwapPoolCoverageAndSupply(ctx, pool) - await updateBackstopCoverageAndSupply(ctx, backstop) - - ctx.store.save(pool) - ctx.store.save(backstop) -} - -export async function swapHandleBurn(ctx: EventHandlerContext) { - const pool = await getOrCreateSwapPool(ctx, ctx.event.args.contract) - - await updateSwapPoolCoverageAndSupply(ctx, pool) - ctx.store.save(pool) -} - -export async function swapHandleChargedSwapFees( - ctx: EventHandlerContext, - event: swapPoolAbi.Event_ChargedSwapFees -) { - const swapPool = await getOrCreateSwapPool(ctx, ctx.event.args.contract) - const backstopPoolAddress = ss58ToHex(swapPool.backstop.id) - const backstopPool = await getOrCreateBackstopPool(ctx, backstopPoolAddress) - const swapFee = await createSwapFee( - ctx, - ctx.event.block.height, - ctx.event.extrinsicIndex, - event.lpFees, - event.backstopFees, - event.protocolFees, - ctx.event.block.timestamp, - swapPool, - backstopPool - ) - - updateAprAfterSwap(ctx, swapPool, swapFee) -} - -export async function swapHandleMint(ctx: EventHandlerContext) { - const pool = await getOrCreateSwapPool(ctx, ctx.event.args.contract) - - await updateSwapPoolCoverageAndSupply(ctx, pool) - ctx.store.save(pool) -} - -export async function swapHandleOwnershipTransferred(ctx: EventHandlerContext) { - // This event will always be emitted on pool creation - const pool = await getOrCreateSwapPool(ctx, ctx.event.args.contract) - ctx.store.save(pool) -} - -export async function swapHandlePaused(ctx: EventHandlerContext) { - const pool = await getOrCreateSwapPool(ctx, ctx.event.args.contract) - - pool.paused = true - ctx.store.save(pool) -} - -export async function swapHandleTransfer(ctx: EventHandlerContext) {} - -export async function swapHandleUnpaused(ctx: EventHandlerContext) { - const pool = await getOrCreateSwapPool(ctx, ctx.event.args.contract) - - pool.paused = false - ctx.store.save(pool) -} - -export async function routerHandleOwnershipTransferred( - ctx: EventHandlerContext -) { - // This event will always be emitted on router creation - const router = await getOrCreateRouter(ctx, ctx.event.args.contract) - ctx.store.save(router) -} - -export async function routerHandlePaused(ctx: EventHandlerContext) { - const router = await getOrCreateRouter(ctx, ctx.event.args.contract) - // Set the 'paused' property to true - router.paused = true - ctx.store.save(router) -} - -export async function routerHandleUnpaused(ctx: EventHandlerContext) { - const router = await getOrCreateRouter(ctx, ctx.event.args.contract) - // Set the 'paused' property to false - router.paused = false - ctx.store.save(router) -} - -export async function routerHandleSwap( - ctx: EventHandlerContext, - event: routerAbi.Event_Swap -) { - await getOrCreateRouter(ctx, ctx.event.args.contract) - - const tokenIn = await getOrCreateNablaToken(ctx, event.tokenIn) - const tokenOut = await getOrCreateNablaToken(ctx, event.tokenOut) - - const swapPoolInAddress = tokenIn.latestSwapPool?.id ?? '' - const swapPoolIn = await ctx.store.get(SwapPool, swapPoolInAddress) - - const swapPoolOutAddress = tokenOut.latestSwapPool?.id ?? '' - const swapPoolOut = await ctx.store.get(SwapPool, swapPoolOutAddress) - - if (swapPoolIn !== undefined) { - await updateSwapPoolCoverageAndSupply(ctx, swapPoolIn) - ctx.store.save(swapPoolIn) - } - - if (swapPoolOut !== undefined) { - await updateSwapPoolCoverageAndSupply(ctx, swapPoolOut) - ctx.store.save(swapPoolOut) - } -} - -export async function routerHandleSwapPoolRegistered( - ctx: EventHandlerContext, - event: routerAbi.Event_SwapPoolRegistered -) { - await getOrCreateRouter(ctx, ctx.event.args.contract) - const swapPool = await getOrCreateSwapPool(ctx, event.pool) - const token = await getOrCreateNablaToken(ctx, ss58ToHex(swapPool.token.id)) - - if (token.latestSwapPool && token.latestSwapPool.id !== swapPool.id) { - const replacedSwapPool = await ctx.store.get( - SwapPool, - token.latestSwapPool.id - ) - - if (replacedSwapPool !== undefined) { - replacedSwapPool.router = undefined // Unregister the existing pool - ctx.store.save(replacedSwapPool) - } - } - - token.latestSwapPool = swapPool - ctx.store.save(token) -} - -export async function updateBackstopCoverageAndSupply( - ctx: EventHandlerContext, - backstop: BackstopPool -) { - const contractHexAddress = ss58ToHex(backstop.id) - const contract = new backstopPoolAbi.Contract(ctx, contractHexAddress) - const poolTokenAddress = await contract.asset() - const poolTokenContract = new erc20Abi.Contract(ctx, poolTokenAddress) - - backstop.totalSupply = await contract.totalSupply() - backstop.reserves = await poolTokenContract.balanceOf(contractHexAddress) -} - -export async function updateSwapPoolCoverageAndSupply( - ctx: EventHandlerContext, - pool: SwapPool -) { - const contract = new swapPoolAbi.Contract(ctx, ss58ToHex(pool.id)) - const coverage = await contract.coverage() - - pool.totalSupply = await contract.totalSupply() - pool.reserve = coverage[0] - pool.totalLiabilities = coverage[1] - pool.reserveWithSlippage = await contract.reserveWithSlippage() -} - -async function updateAndPruneSwapFeeHistory( - ctx: EventHandlerContext, - pool: SwapPool, - newSwapFee: NablaSwapFee -): Promise { - // Prune fee events older than 7 days - const sevenDaysAgo = - newSwapFee.timestamp - BigInt(SWAP_FEE_PRUNE_INTERVAL_SECONDS) - - /* - * Swap Pool fees history - */ - // Add the swapFee to the pool's fee history - const poolFeesHistory = pool.feesHistory - await filterSwapFeeHistory(ctx, poolFeesHistory, sevenDaysAgo) -} - -async function filterSwapFeeHistory( - ctx: EventHandlerContext, - feesHistory: NablaSwapFee[], - pastPeriodInSeconds: bigint -) { - const filteredFeeHistory: string[] = [] - - for (const swapFee of feesHistory) { - if (swapFee.timestamp > pastPeriodInSeconds) { - await ctx.store.remove(swapFee) - } - } -} - -export async function updateAprAfterSwap( - ctx: EventHandlerContext, - pool: SwapPool, - newSwapFee: NablaSwapFee -): Promise { - // Update the fee history (swapFee, backstopFee) - await updateAndPruneSwapFeeHistory(ctx, pool, newSwapFee) - const updatedSwapPool = await ctx.store.get(SwapPool, pool.id) - - if (updatedSwapPool === undefined) return - - const swapPoolContract = new swapPoolAbi.Contract( - ctx, - ss58ToHex(updatedSwapPool.id) - ) - const swapPoolTokenAddress = await swapPoolContract.asset() - const swapPoolTokenContract = new erc20Abi.Contract( - ctx, - swapPoolTokenAddress - ) - const swapPoolTokenDecimals = await swapPoolTokenContract.decimals() - - /* - * Swap Pool fees history & APR - */ - const totalLpFees = updatedSwapPool.feesHistory.reduce( - (a, b) => a + b.lpFees, - 0n - ) - - const poolTotalSupply = updatedSwapPool.totalSupply - updatedSwapPool.apr = calculateApr( - totalLpFees, - poolTotalSupply, - BigInt(swapPoolTokenDecimals) - ) - ctx.store.save(updatedSwapPool) - - /* - * Backstop Pool fees history - */ - const backstop = await ctx.store.get( - BackstopPool, - updatedSwapPool.backstop.id - ) - - if (backstop !== undefined) { - const backstopPoolContract = new backstopPoolAbi.Contract( - ctx, - ss58ToHex(backstop.id) - ) - const backstopPoolTokenAddress = await backstopPoolContract.asset() - const backstopPoolTokenContract = new erc20Abi.Contract( - ctx, - backstopPoolTokenAddress - ) - const backstopPoolTokenDecimals = - await backstopPoolTokenContract.decimals() - - const totalBackstopFees = backstop.feesHistory.reduce( - (a, b) => a + b.backstopFees, - 0n - ) - - const backstopTotalSupply = backstop.totalSupply - backstop.apr = calculateApr( - totalBackstopFees, - backstopTotalSupply, - BigInt(backstopPoolTokenDecimals) - ) - ctx.store.save(backstop) - } -} - -function calculateApr( - totalFees: bigint, - totalSupply: bigint, - poolTokenDecimals: bigint -): bigint { - if (totalSupply > 0n) { - return (totalFees * 365n * 10n ** poolTokenDecimals) / totalSupply / 7n - } else { - return 0n - } -} - -export async function getOrCreateBackstopPool( - ctx: EventHandlerContext, - hexAddress: string -) { - const address = codec(config.prefix).encode(hexAddress) - let backstop = await ctx.store.get(BackstopPool, address) - if (!backstop) { - const contract = new backstopPoolAbi.Contract(ctx, hexAddress) - const poolTokenAddress = await contract.asset() - const poolTokenContract = new erc20Abi.Contract(ctx, poolTokenAddress) - const router = await getOrCreateRouter(ctx, await contract.router()) - const token = await getOrCreateNablaToken(ctx, poolTokenAddress) - - backstop = new BackstopPool({ - id: address, - name: await contract.name(), - symbol: await contract.symbol(), - router: router, - token: token, - reserves: await poolTokenContract.balanceOf(hexAddress), - totalSupply: await contract.totalSupply(), - paused: false, - apr: 0n, - }) - ctx.store.save(backstop) - } - return backstop -} - -export async function getOrCreateRouter( - ctx: EventHandlerContext, - hexAddress: string -) { - const address = codec(config.prefix).encode(hexAddress) - let router = await ctx.store.get(Router, address) - if (!router) { - router = new Router({ - id: address, - paused: false, - }) - ctx.store.save(router) - } - return router -} - -export async function getOrCreateNablaToken( - ctx: EventHandlerContext, - hexAddress: string -) { - const address = codec(config.prefix).encode(hexAddress) - let nablaToken = await ctx.store.get(NablaToken, address) - if (!nablaToken) { - const contract = new erc20Abi.Contract(ctx, hexAddress) - nablaToken = new NablaToken({ - id: address, - decimals: await contract.decimals(), - name: await contract.name(), - symbol: await contract.symbol(), - latestSwapPool: null, - }) - ctx.store.save(nablaToken) - } - return nablaToken -} - -export async function getOrCreateSwapPool( - ctx: EventHandlerContext, - hexAddress: string -) { - const address = codec(config.prefix).encode(hexAddress) - let swapPool = await ctx.store.get(SwapPool, address) - if (!swapPool) { - const contract = new swapPoolAbi.Contract(ctx, hexAddress) - const backstop = await getOrCreateBackstopPool( - ctx, - await contract.backstop() - ) - const router = await getOrCreateRouter(ctx, await contract.router()) - const token = await getOrCreateNablaToken(ctx, await contract.asset()) - - const coverage = await contract.coverage() - - swapPool = new SwapPool({ - id: address, - name: await contract.name(), - symbol: await contract.symbol(), - router: router, - backstop: backstop, - token: token, - reserve: coverage[0], - reserveWithSlippage: await contract.reserveWithSlippage(), - totalLiabilities: coverage[1], - totalSupply: await contract.totalSupply(), - paused: false, - apr: 0n, - coveredIndex: null, - }) - ctx.store.save(swapPool) - } - return swapPool -} - -export async function createSwapFee( - ctx: EventHandlerContext, - blockNumber: number, - extrinsicIndex: number | undefined, - lpFees: bigint, - backstopFees: bigint, - protocolFees: bigint, - timestamp: number | undefined, - swapPool: SwapPool, - backstopPool: BackstopPool -): Promise { - const swapFeeId = `${blockNumber}-${extrinsicIndex ?? ''}` - const swapFee = new NablaSwapFee({ - id: swapFeeId, - lpFees, - backstopFees, - protocolFees, - timestamp: BigInt(timestamp ?? Date.now() / 1000), - swapPool, - backstopPool, - }) - - ctx.store.save(swapFee) - return swapFee -} diff --git a/src/mappings/nabla/addresses.ts b/src/mappings/nabla/addresses.ts new file mode 100644 index 00000000..41b315fb --- /dev/null +++ b/src/mappings/nabla/addresses.ts @@ -0,0 +1,11 @@ +import { codec, decode } from '@subsquid/ss58' + +import { config } from '../../config' + +export function ss58ToHex(ss58Address: string): string { + return decode(ss58Address).bytes +} + +export function hexToSs58(hexAddress: string): string { + return codec(config.prefix).encode(hexAddress) +} diff --git a/src/mappings/nabla/backstopPoolEventHandler.ts b/src/mappings/nabla/backstopPoolEventHandler.ts new file mode 100644 index 00000000..8135041d --- /dev/null +++ b/src/mappings/nabla/backstopPoolEventHandler.ts @@ -0,0 +1,145 @@ +import { EventHandlerContext } from '../../processor' +import { BackstopPool } from '../../model' + +import { + decodeEvent, + Event_CoverSwapWithdrawal, + Event_WithdrawSwapLiquidity, + Contract as BackstopPoolContract, +} from '../../abi/backstop' +import { Contract as Erc20Contract } from '../../abi/erc20' +import { hexToSs58, ss58ToHex } from './addresses' +import { getSwapPool } from './creation' +import { updateSwapPoolCoverageAndSupply } from './swapPoolEventHandler' + +export async function handleBackstopPoolEvent( + ctx: EventHandlerContext, + backstopPool: BackstopPool +) { + console.log('Raw backstopPool event', ctx.event.args.data) + const event = decodeEvent(ctx.event.args.data) + + console.log('Process backstopPool event', backstopPool.id, event.__kind) + + switch (event.__kind) { + case 'Burn': + await handleBurn(ctx, backstopPool) + break + + case 'CoverSwapWithdrawal': + await handleCoverSwapWithdrawal(ctx, event, backstopPool) + break + + case 'Mint': + await handleMint(ctx, backstopPool) + break + + case 'OwnershipTransferred': + // This event will always be emitted on pool creation + // No action required + break + + case 'Paused': + await handlePaused(ctx, backstopPool) + break + + case 'Transfer': + // No action required + break + + case 'Unpaused': + await handleUnpaused(ctx, backstopPool) + break + + case 'WithdrawSwapLiquidity': + await handleWithdrawSwapLiquidity(ctx, event, backstopPool) + break + } +} + +export async function handleBurn( + ctx: EventHandlerContext, + backstopPool: BackstopPool +) { + await updateBackstopCoverageAndSupply(ctx, backstopPool) + await ctx.store.save(backstopPool) +} + +export async function handleCoverSwapWithdrawal( + ctx: EventHandlerContext, + event: Event_CoverSwapWithdrawal, + backstopPool: BackstopPool +) { + const swapPoolSs58Address = hexToSs58(event.swapPool) + const pool = await getSwapPool(ctx, swapPoolSs58Address) + if (pool === undefined) { + // this is a non-standard or malicious swap pool, ignore + return + } + + await updateBackstopCoverageAndSupply(ctx, backstopPool) + await updateSwapPoolCoverageAndSupply(ctx, pool) + + await ctx.store.save(backstopPool) + await ctx.store.save(pool) +} + +export async function handleMint( + ctx: EventHandlerContext, + backstopPool: BackstopPool +) { + await updateBackstopCoverageAndSupply(ctx, backstopPool) + await ctx.store.save(backstopPool) +} + +export async function handlePaused( + ctx: EventHandlerContext, + backstopPool: BackstopPool +) { + backstopPool.paused = true + await ctx.store.save(backstopPool) +} + +export async function handleUnpaused( + ctx: EventHandlerContext, + backstopPool: BackstopPool +) { + backstopPool.paused = false + await ctx.store.save(backstopPool) +} + +export async function handleWithdrawSwapLiquidity( + ctx: EventHandlerContext, + event: Event_WithdrawSwapLiquidity, + backstopPool: BackstopPool +) { + const swapPoolSs58Address = hexToSs58(event.swapPool) + const pool = await getSwapPool(ctx, swapPoolSs58Address) + if (pool === undefined) { + // this is a non-standard or malicious swap pool, ignore + return + } + + await updateBackstopCoverageAndSupply(ctx, backstopPool) + await updateSwapPoolCoverageAndSupply(ctx, pool) + + await ctx.store.save(backstopPool) + await ctx.store.save(pool) +} + +export async function updateBackstopCoverageAndSupply( + ctx: EventHandlerContext, + backstopPool: BackstopPool +) { + const contractHexAddress = ss58ToHex(backstopPool.id) + const contract = new BackstopPoolContract(ctx, contractHexAddress) + const poolTokenAddress = await contract.asset() + const poolTokenContract = new Erc20Contract(ctx, poolTokenAddress) + + backstopPool.totalSupply = await contract.totalSupply() + backstopPool.reserves = await poolTokenContract.balanceOf( + contractHexAddress + ) + + console.log('Updated backstopPool', backstopPool) +} diff --git a/src/mappings/nabla/creation.ts b/src/mappings/nabla/creation.ts new file mode 100644 index 00000000..06b90c2b --- /dev/null +++ b/src/mappings/nabla/creation.ts @@ -0,0 +1,213 @@ +import { EventHandlerContext } from '../../processor' +import { + BackstopPool, + Router, + NablaToken, + SwapPool, + NablaSwapFee, +} from '../../model' +import * as backstopPoolAbi from '../../abi/backstop' +import * as erc20Abi from '../../abi/erc20' +import * as swapPoolAbi from '../../abi/swap' +import { hexToSs58 } from './addresses' + +export const ZERO_ADDRESS = + '0x0000000000000000000000000000000000000000000000000000000000000000' + +export async function getBackstopPool( + ctx: EventHandlerContext, + ss58Address: string, + withFeeHistory: boolean = false +) { + return await ctx.store.findOne(BackstopPool, { + where: { id: ss58Address }, + relations: { token: true, router: true, feesHistory: withFeeHistory }, + }) +} + +export async function getRouter(ctx: EventHandlerContext, ss58Address: string) { + return await ctx.store.get(Router, ss58Address) +} + +export async function getSwapPool( + ctx: EventHandlerContext, + ss58Address: string, + withFeeHistory: boolean = false +) { + return await ctx.store.findOne(SwapPool, { + where: { id: ss58Address }, + relations: { token: true, backstop: true, feesHistory: withFeeHistory }, + }) +} + +export async function getSwapPoolsOfRouterForToken( + ctx: EventHandlerContext, + routerSs58Address: string, + tokenSs58Address: string +) { + return await ctx.store.findOne(SwapPool, { + where: { + router: { id: routerSs58Address }, + token: { id: tokenSs58Address }, + }, + relations: { token: true }, + }) +} + +export async function createBackstopPool( + ctx: EventHandlerContext, + hexAddress: string +) { + const ss58Address = hexToSs58(hexAddress) + if (await getBackstopPool(ctx, ss58Address)) { + // Unexpected error: backstop pool already exists at that address + return + } + + const contract = new backstopPoolAbi.Contract(ctx, hexAddress) + + const routerAddress = await contract.router() + const tokenAddress = await contract.asset() + + if (routerAddress === ZERO_ADDRESS || tokenAddress === ZERO_ADDRESS) { + return undefined + } + + const router = await getRouter(ctx, hexToSs58(routerAddress)) + if (router === undefined) { + return undefined + } + + const token = await getOrCreateNablaToken(ctx, tokenAddress) + const tokenContract = new erc20Abi.Contract(ctx, tokenAddress) + + const backstop = new BackstopPool({ + id: ss58Address, + name: await contract.name(), + symbol: await contract.symbol(), + router: router, + token: token, + reserves: await tokenContract.balanceOf(hexAddress), + totalSupply: await contract.totalSupply(), + paused: false, + apr: 0n, + }) + await ctx.store.save(backstop) +} + +export async function createRouter( + ctx: EventHandlerContext, + hexAddress: string +) { + const ss58Address = hexToSs58(hexAddress) + if (await getRouter(ctx, ss58Address)) { + // Unexpected error: router already exists at that address + return + } + + const router = new Router({ + id: ss58Address, + paused: false, + }) + await ctx.store.save(router) +} + +export async function getOrCreateNablaToken( + ctx: EventHandlerContext, + hexAddress: string +) { + const ss58Address = hexToSs58(hexAddress) + let nablaToken = await ctx.store.get(NablaToken, ss58Address) + if (!nablaToken) { + const contract = new erc20Abi.Contract(ctx, hexAddress) + nablaToken = new NablaToken({ + id: ss58Address, + decimals: await contract.decimals(), + name: await contract.name(), + symbol: await contract.symbol(), + }) + await ctx.store.save(nablaToken) + } + return nablaToken +} + +export async function createSwapPool( + ctx: EventHandlerContext, + hexAddress: string +) { + const ss58Address = hexToSs58(hexAddress) + console.log('createSwapPool', hexAddress, ss58Address) + if (await getSwapPool(ctx, ss58Address)) { + // Unexpected error: swap pool already exists at that address + return + } + + const contract = new swapPoolAbi.Contract(ctx, hexAddress) + + const backstopPoolAddress = await contract.backstop() + const routerAddress = await contract.router() + const tokenAddress = await contract.asset() + + if ( + backstopPoolAddress === ZERO_ADDRESS || + routerAddress === ZERO_ADDRESS || + tokenAddress === ZERO_ADDRESS + ) { + return undefined + } + + const backstopPoolSs58Address = hexToSs58(backstopPoolAddress) + const routerSs58Address = hexToSs58(routerAddress) + const backstop = await getBackstopPool(ctx, backstopPoolSs58Address) + const router = await getRouter(ctx, routerSs58Address) + + if (backstop === undefined || router === undefined) { + return undefined + } + + const token = await getOrCreateNablaToken(ctx, tokenAddress) + const coverage = await contract.coverage() + + const swapPool = new SwapPool({ + id: ss58Address, + name: await contract.name(), + symbol: await contract.symbol(), + router: undefined, // only register router when owner adds this swap pool + backstop: backstop, + token: token, + reserve: coverage[0], + reserveWithSlippage: await contract.reserveWithSlippage(), + totalLiabilities: coverage[1], + totalSupply: await contract.totalSupply(), + paused: false, + apr: 0n, + }) + await ctx.store.save(swapPool) +} + +export async function createSwapFee( + ctx: EventHandlerContext, + blockNumber: number, + extrinsicIndex: number | undefined, + lpFees: bigint, + backstopFees: bigint, + protocolFees: bigint, + timestamp: number | undefined, + swapPool: SwapPool, + backstopPool: BackstopPool | undefined +): Promise { + const swapFeeId = `${blockNumber}-${extrinsicIndex ?? ''}` + console.log('Create new swap fee', swapFeeId) + const swapFee = new NablaSwapFee({ + id: swapFeeId, + lpFees, + backstopFees, + protocolFees, + timestamp: BigInt(timestamp ?? Date.now() / 1000), + swapPool, + backstopPool, + }) + + await ctx.store.save(swapFee) + return swapFee +} diff --git a/src/mappings/nabla/handleEvent.ts b/src/mappings/nabla/handleEvent.ts new file mode 100644 index 00000000..33aeaf59 --- /dev/null +++ b/src/mappings/nabla/handleEvent.ts @@ -0,0 +1,79 @@ +import { EventHandlerContext } from '../../processor' +import * as backstopPoolAbi from '../../abi/backstop' +import * as swapPoolAbi from '../../abi/swap' +import * as routerAbi from '../../abi/router' +import { + ZERO_ADDRESS, + getBackstopPool, + getRouter, + getSwapPool, +} from './creation' +import { createBackstopPool, createRouter, createSwapPool } from './creation' +import { handleBackstopPoolEvent } from './backstopPoolEventHandler' +import { handleRouterEvent } from './routerEventHandler' +import { handleSwapPoolEvent } from './swapPoolEventHandler' +import { hexToSs58 } from './addresses' + +export async function handleContractInstantiated(ctx: EventHandlerContext) { + const contractHexAddress = ctx.event.args.contract + if (contractHexAddress === ZERO_ADDRESS) { + return + } + + const contractInfo = await ctx.block._runtime.queryStorage( + ctx.block.hash, + 'Contracts.ContractInfoOf', + [contractHexAddress] + ) + const contractCodeHash = contractInfo[0].codeHash as string + + switch (contractCodeHash) { + case backstopPoolAbi.metadata.source.hash: + console.log( + 'New backstopPool created', + hexToSs58(contractHexAddress), + await createBackstopPool(ctx, contractHexAddress) + ) + break + + case routerAbi.metadata.source.hash: + console.log( + 'New router created', + hexToSs58(contractHexAddress), + await createRouter(ctx, contractHexAddress) + ) + break + + case swapPoolAbi.metadata.source.hash: + console.log( + 'New swapPool created', + hexToSs58(contractHexAddress), + await createSwapPool(ctx, contractHexAddress) + ) + break + } +} + +export async function handleContractEvent(ctx: EventHandlerContext) { + const contractSs58Address = hexToSs58(ctx.event.args.contract) + + const [maybeBackstopPool, maybeRouter, maybeSwapPool] = await Promise.all([ + getBackstopPool(ctx, contractSs58Address), + getRouter(ctx, contractSs58Address), + getSwapPool(ctx, contractSs58Address), + ]) + + switch (true) { + case maybeBackstopPool !== undefined: + await handleBackstopPoolEvent(ctx, maybeBackstopPool!) + break + + case maybeRouter !== undefined: + await handleRouterEvent(ctx, maybeRouter!) + break + + case maybeSwapPool !== undefined: + await handleSwapPoolEvent(ctx, maybeSwapPool!) + break + } +} diff --git a/src/mappings/nabla/routerEventHandler.ts b/src/mappings/nabla/routerEventHandler.ts new file mode 100644 index 00000000..7364a322 --- /dev/null +++ b/src/mappings/nabla/routerEventHandler.ts @@ -0,0 +1,154 @@ +import { EventHandlerContext } from '../../processor' +import { Router } from '../../model' +import { + decodeEvent, + Event_Swap, + Event_SwapPoolRegistered, + Event_SwapPoolUnregistered, +} from '../../abi/router' +import * as swapPoolAbi from '../../abi/swap' +import { + getSwapPoolsOfRouterForToken, + getOrCreateNablaToken, + getSwapPool, +} from './creation' +import { updateSwapPoolCoverageAndSupply } from './swapPoolEventHandler' +import { hexToSs58, ss58ToHex } from './addresses' + +export async function handleRouterEvent( + ctx: EventHandlerContext, + router: Router +) { + const event = decodeEvent(ctx.event.args.data) + + console.log('Process router event', router.id, event.__kind) + + switch (event.__kind) { + case 'OwnershipTransferred': + // This event will always be emitted on router creation + // no action required + break + + case 'Paused': + await handlePaused(ctx, router) + break + + case 'Swap': + await handleSwap(ctx, event, router) + break + + case 'SwapPoolRegistered': + await handleSwapPoolRegistered(ctx, event, router) + break + + case 'SwapPoolUnregistered': + await handleSwapPoolUnregistered(ctx, event, router) + break + + case 'Unpaused': + await handleUnpaused(ctx, router) + break + } +} + +export async function handlePaused(ctx: EventHandlerContext, router: Router) { + // Set the 'paused' property to true + router.paused = true + await ctx.store.save(router) +} + +export async function handleUnpaused(ctx: EventHandlerContext, router: Router) { + // Set the 'paused' property to false + router.paused = false + await ctx.store.save(router) +} + +export async function handleSwap( + ctx: EventHandlerContext, + event: Event_Swap, + router: Router +) { + const tokenIn = await getOrCreateNablaToken(ctx, event.tokenIn) + const tokenOut = await getOrCreateNablaToken(ctx, event.tokenOut) + + const swapPoolIn = await getSwapPoolsOfRouterForToken( + ctx, + router.id, + tokenIn.id + ) + const swapPoolOut = await getSwapPoolsOfRouterForToken( + ctx, + router.id, + tokenOut.id + ) + + if (swapPoolIn !== undefined) { + await updateSwapPoolCoverageAndSupply(ctx, swapPoolIn) + await ctx.store.save(swapPoolIn) + } + + if (swapPoolOut !== undefined) { + await updateSwapPoolCoverageAndSupply(ctx, swapPoolOut) + await ctx.store.save(swapPoolOut) + } +} + +export async function handleSwapPoolRegistered( + ctx: EventHandlerContext, + event: Event_SwapPoolRegistered, + router: Router +) { + const swapPoolSs58Address = hexToSs58(event.pool) + const swapPool = await getSwapPool(ctx, swapPoolSs58Address) + + console.log('SwapPool', swapPool) + if (swapPool === undefined) { + // this is a non-standard or malicious swap pool, ignore + return + } + + console.log('Token', swapPool.token) + const token = await getOrCreateNablaToken(ctx, ss58ToHex(swapPool.token.id)) + + const registeredSwapPool = await getSwapPoolsOfRouterForToken( + ctx, + router.id, + swapPool.token.id + ) + + if (registeredSwapPool) { + if (registeredSwapPool.id === swapPool.id) { + // this swap pool is already registered, no action required + return + } + + registeredSwapPool.router = null + await ctx.store.save(registeredSwapPool) + } + + const swapPoolContract = new swapPoolAbi.Contract(ctx, event.pool) + const routerOfSwapPool = await swapPoolContract.router() + if (routerOfSwapPool === ss58ToHex(router.id)) { + swapPool.router = router + await ctx.store.save(swapPool) + } +} + +export async function handleSwapPoolUnregistered( + ctx: EventHandlerContext, + event: Event_SwapPoolUnregistered, + router: Router +) { + const token = await getOrCreateNablaToken(ctx, event.asset) + + const unregisteredSwapPool = await getSwapPoolsOfRouterForToken( + ctx, + router.id, + token.id + ) + + if (unregisteredSwapPool) { + unregisteredSwapPool.router = null + await ctx.store.save(unregisteredSwapPool) + } +} diff --git a/src/mappings/nabla/swapPoolEventHandler.ts b/src/mappings/nabla/swapPoolEventHandler.ts new file mode 100644 index 00000000..a56611ff --- /dev/null +++ b/src/mappings/nabla/swapPoolEventHandler.ts @@ -0,0 +1,258 @@ +import { EventHandlerContext } from '../../processor' +import { createSwapFee, getBackstopPool, getSwapPool } from './creation' +import { NablaSwapFee, SwapPool } from '../../model' +import { + decodeEvent, + Contract as SwapPoolContract, + Event_ChargedSwapFees, +} from '../../abi/swap' +import { Contract as Erc20Contract } from '../../abi/erc20' +import { Contract as BackstopPoolContract } from '../../abi/backstop' +import { ss58ToHex } from './addresses' +import { updateBackstopCoverageAndSupply } from './backstopPoolEventHandler' + +const SWAP_FEE_PRUNE_INTERVAL_MILLI_SECONDS = 7 * 24 * 60 * 60 * 1000 + +export async function handleSwapPoolEvent( + ctx: EventHandlerContext, + swapPool: SwapPool +) { + const event = decodeEvent(ctx.event.args.data) + + console.log('Process swapPool event', swapPool.id, event.__kind) + + switch (event.__kind) { + case 'BackstopDrain': + await handleBackstopDrain(ctx, swapPool) + break + + case 'Burn': + await handleBurn(ctx, swapPool) + break + + case 'ChargedSwapFees': + await handleChargedSwapFees(ctx, event, swapPool) + break + + case 'Mint': + await handleMint(ctx, swapPool) + break + + case 'OwnershipTransferred': + // This event will always be emitted on pool creation + // No action required + break + + case 'Paused': + await handlePaused(ctx, swapPool) + break + + case 'Transfer': + // No action required + break + + case 'Unpaused': + await handleUnpaused(ctx, swapPool) + break + } +} + +export async function handleBackstopDrain( + ctx: EventHandlerContext, + swapPool: SwapPool +) { + console.log('handleBackstopDrain', swapPool) + + await updateSwapPoolCoverageAndSupply(ctx, swapPool) + await ctx.store.save(swapPool) + + if (swapPool.backstop) { + const backstop = (await getBackstopPool(ctx, swapPool.backstop.id))! + await updateBackstopCoverageAndSupply(ctx, backstop) + await ctx.store.save(backstop) + } +} + +export async function handleBurn(ctx: EventHandlerContext, swapPool: SwapPool) { + await updateSwapPoolCoverageAndSupply(ctx, swapPool) + await ctx.store.save(swapPool) +} + +export async function handleChargedSwapFees( + ctx: EventHandlerContext, + event: Event_ChargedSwapFees, + swapPool: SwapPool +) { + const backstopPool = (await getBackstopPool(ctx, swapPool.backstop.id))! + + const swapFee = await createSwapFee( + ctx, + ctx.event.block.height, + ctx.event.extrinsicIndex, + event.lpFees, + event.backstopFees, + event.protocolFees, + ctx.event.block.timestamp, + swapPool, + backstopPool + ) + + // load swap pool with complete fee history + swapPool = (await getSwapPool(ctx, swapPool.id, true))! + await updateAprAfterSwap(ctx, swapPool, swapFee) +} + +export async function handleMint(ctx: EventHandlerContext, swapPool: SwapPool) { + await updateSwapPoolCoverageAndSupply(ctx, swapPool) + await ctx.store.save(swapPool) +} + +export async function handlePaused( + ctx: EventHandlerContext, + swapPool: SwapPool +) { + swapPool.paused = true + await ctx.store.save(swapPool) +} + +export async function handleUnpaused( + ctx: EventHandlerContext, + swapPool: SwapPool +) { + swapPool.paused = false + await ctx.store.save(swapPool) +} + +export async function updateSwapPoolCoverageAndSupply( + ctx: EventHandlerContext, + swapPool: SwapPool +) { + const contract = new SwapPoolContract(ctx, ss58ToHex(swapPool.id)) + const coverage = await contract.coverage() + + swapPool.totalSupply = await contract.totalSupply() + swapPool.reserve = coverage[0] + swapPool.totalLiabilities = coverage[1] + swapPool.reserveWithSlippage = await contract.reserveWithSlippage() +} + +async function updateAndPruneSwapFeeHistory( + ctx: EventHandlerContext, + swapPoolWithFeeHistory: SwapPool, + newSwapFee: NablaSwapFee +): Promise { + // Prune fee events older than 7 days + const sevenDaysAgo = + newSwapFee.timestamp - BigInt(SWAP_FEE_PRUNE_INTERVAL_MILLI_SECONDS) + + /* + * Swap Pool fees history + */ + // Add the swapFee to the pool's fee history + const poolFeesHistory = swapPoolWithFeeHistory.feesHistory + await filterSwapFeeHistory(ctx, poolFeesHistory, sevenDaysAgo) +} + +async function filterSwapFeeHistory( + ctx: EventHandlerContext, + feesHistory: NablaSwapFee[], + pastPeriodInSeconds: bigint +) { + const filteredFeeHistory: string[] = [] + + for (const swapFee of feesHistory) { + if (swapFee.timestamp < pastPeriodInSeconds) { + console.log( + 'Remove swap fee', + swapFee.id, + swapFee.timestamp, + pastPeriodInSeconds + ) + await ctx.store.remove(swapFee) + } + } +} + +export async function updateAprAfterSwap( + ctx: EventHandlerContext, + swapPoolWithFeeHistory: SwapPool, + newSwapFee: NablaSwapFee +): Promise { + // Update the fee history (swapFee, backstopFee) + await updateAndPruneSwapFeeHistory(ctx, swapPoolWithFeeHistory, newSwapFee) + const updatedSwapPool = (await getSwapPool( + ctx, + swapPoolWithFeeHistory.id, + true + ))! + + const swapPoolContract = new SwapPoolContract( + ctx, + ss58ToHex(updatedSwapPool.id) + ) + const swapPoolLpTokenDecimals = await swapPoolContract.decimals() + + /* + * Swap Pool fees history & APR + */ + const totalLpFees = updatedSwapPool.feesHistory.reduce( + (a, b) => a + b.lpFees, + 0n + ) + + const poolTotalSupply = updatedSwapPool.totalSupply + updatedSwapPool.apr = calculateApr( + totalLpFees, + poolTotalSupply, + BigInt(swapPoolLpTokenDecimals) + ) + await ctx.store.save(updatedSwapPool) + + /* + * Backstop Pool fees history + */ + const backstop = updatedSwapPool.backstop + ? await getBackstopPool(ctx, updatedSwapPool.backstop.id, true) + : undefined + + if (backstop !== undefined) { + const backstopPoolContract = new BackstopPoolContract( + ctx, + ss58ToHex(backstop.id) + ) + const backstopPoolLpTokenDecimals = + await backstopPoolContract.decimals() + + const totalBackstopFees = backstop.feesHistory.reduce( + (a, b) => a + b.backstopFees, + 0n + ) + + const backstopTotalSupply = backstop.totalSupply + backstop.apr = calculateApr( + totalBackstopFees, + backstopTotalSupply, + BigInt(backstopPoolLpTokenDecimals) + ) + console.log( + 'backstop apr', + backstop.apr, + totalBackstopFees, + backstopTotalSupply, + backstopPoolLpTokenDecimals + ) + await ctx.store.save(backstop) + } +} + +function calculateApr( + totalFees: bigint, + totalSupply: bigint, + poolTokenDecimals: bigint +): bigint { + if (totalSupply > 0n) { + return (totalFees * 365n * 10n ** poolTokenDecimals) / totalSupply / 7n + } else { + return 0n + } +} diff --git a/src/mappings/prices.ts b/src/mappings/prices.ts index 8f14146b..57af0b18 100644 --- a/src/mappings/prices.ts +++ b/src/mappings/prices.ts @@ -3,6 +3,7 @@ import { network } from '../config' import { getOrCreateOraclePrice } from '../entities/oraclePrice' import { hexToString } from '@polkadot/util' import { decodeEvent } from '../types' + export async function handleUpdatedPrices(ctx: EventHandlerContext) { let event = await decodeEvent( network, diff --git a/src/mappings/token.ts b/src/mappings/token.ts index ca1d06a0..961baa0a 100644 --- a/src/mappings/token.ts +++ b/src/mappings/token.ts @@ -146,7 +146,7 @@ export async function handleTokenDeposited(ctx: EventHandlerContext) { currencyId: currencyId, }) - ctx.store.save(tokenDeposit) + await ctx.store.save(tokenDeposit) if (event?.currencyId.__kind !== 'ZenlinkLPToken') return @@ -285,7 +285,7 @@ export async function handleTokenWithdrawn(ctx: EventHandlerContext) { currencyId: currencyId, }) - ctx.store.save(tokenWithdrawn) + await ctx.store.save(tokenWithdrawn) if (event?.currencyId.__kind !== 'ZenlinkLPToken') return diff --git a/src/model/generated/nablaToken.model.ts b/src/model/generated/nablaToken.model.ts index 60be0e57..f7385fbe 100644 --- a/src/model/generated/nablaToken.model.ts +++ b/src/model/generated/nablaToken.model.ts @@ -2,8 +2,6 @@ import { Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, - ManyToOne as ManyToOne_, - Index as Index_, OneToMany as OneToMany_, } from 'typeorm' import { SwapPool } from './swapPool.model' @@ -26,10 +24,6 @@ export class NablaToken { @Column_('text', { nullable: false }) symbol!: string - @Index_() - @ManyToOne_(() => SwapPool, { nullable: true }) - latestSwapPool!: SwapPool | undefined | null - @OneToMany_(() => SwapPool, (e) => e.token) swapPools!: SwapPool[] } diff --git a/src/model/generated/swapPool.model.ts b/src/model/generated/swapPool.model.ts index 712c6bdc..1431dd56 100644 --- a/src/model/generated/swapPool.model.ts +++ b/src/model/generated/swapPool.model.ts @@ -74,10 +74,4 @@ export class SwapPool { nullable: false, }) apr!: bigint - - @Column_('numeric', { - transformer: marshal.bigintTransformer, - nullable: true, - }) - coveredIndex!: bigint | undefined | null } diff --git a/src/processor.ts b/src/processor.ts index 42fa23e2..d4193773 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -36,7 +36,6 @@ import { handleTokenWithdrawn, } from './mappings/token' import { handleBalanceTransfer } from './mappings/balances' -import { handleContractEvent } from './mappings/nabla' import { handleUpdatedPrices } from './mappings/prices' import { handleBatchWithRemark } from './mappings/remark' import { @@ -45,8 +44,12 @@ import { saveEvent, saveExtrinsic, } from './mappings/block-details' +import { + handleContractEvent, + handleContractInstantiated, +} from './mappings/nabla/handleEvent' -const DataSelection = { data: { event: true } } as const +Error.stackTraceLimit = 100 const processor = new SubstrateBatchProcessor() .setDataSource(config.dataSource) @@ -117,6 +120,7 @@ const processor = new SubstrateBatchProcessor() 'Tokens.BalanceSet', // Contracts 'Contracts.ContractEmitted', + 'Contracts.Instantiated', ], call: true, extrinsic: true, @@ -180,7 +184,10 @@ processor.run(new TypeormDatabase(), async (ctx) => { } } + // console.log('Process events', events.length) + let i = 1 for (let event of events) { + // console.log(`Process event ${i++}/${events.length}`, event) try { switch (event.name) { case 'Tokens.Deposited': @@ -320,6 +327,13 @@ processor.run(new TypeormDatabase(), async (ctx) => { event, }) break + case 'Contracts.Instantiated': + await handleContractInstantiated({ + ...ctx, + block, + event, + }) + break // price oracle case 'DiaOracleModule.UpdatedPrices': // Only processing these events if the current block is the 'head' of the chain @@ -340,6 +354,7 @@ processor.run(new TypeormDatabase(), async (ctx) => { e ) } + // console.log('Done processing event', event) } // It's important to process the calls after the events, // because for the system.remark call we need to have From a4ae1cb92a50ba320c18ded7c35411b5a84d5d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:35:44 -0300 Subject: [PATCH 06/20] Clean up debugging instructions --- src/config.ts | 24 +++++++++++++++++------- src/processor.ts | 12 ------------ src/types.ts | 4 ++-- src/types/events.ts | 2 +- src/types/storage.ts | 2 +- src/types/support.ts | 2 +- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/config.ts b/src/config.ts index 4ad758da..c8215fd4 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,9 +1,9 @@ import { ProcessorConfig } from './types' import { lookupArchive } from '@subsquid/archive-registry' import axios from 'axios' -export type Network = 'foucoco' | 'amplitude' | 'pendulum' -export const network: Network = - <'foucoco' | 'amplitude' | 'pendulum'>process.env.NETWORK || 'amplitude' +export type Network = 'foucoco' | 'amplitude' | 'pendulum' | 'local' +export const network = (process.env.NETWORK as Network) || 'amplitude' + export const blockRetentionNumber = process.env.BLOCK_RETENTION_NUMBER ? parseInt(process.env.BLOCK_RETENTION_NUMBER, 10) : 7200 @@ -30,14 +30,24 @@ const foucocoConfig: ProcessorConfig = { chainName: 'foucoco', prefix: 'amplitude', dataSource: { - archive: undefined, // lookupArchive('foucoco', { release: 'ArrowSquid' }), + archive: lookupArchive('foucoco', { release: 'ArrowSquid' }), + chain: 'wss://pencol-roa-00.pendulumchain.tech', + }, +} + +const localConfig: ProcessorConfig = { + chainName: 'local', + prefix: 'amplitude', + dataSource: { + archive: undefined, chain: 'ws://127.0.0.1:9944', - //chain: 'wss://pencol-roa-00.pendulumchain.tech', }, } export const config: ProcessorConfig = - network === 'foucoco' + network === 'local' + ? localConfig + : network === 'foucoco' ? foucocoConfig : network === 'amplitude' ? amplitudeConfig @@ -59,5 +69,5 @@ export const maxHeightPromise = axios 'Error getting block height from archive, using default value instead:', error ) - return 0 + return network === 'local' ? 0 : Number.MAX_SAFE_INTEGER }) diff --git a/src/processor.ts b/src/processor.ts index d4193773..3f0bd60c 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -49,8 +49,6 @@ import { handleContractInstantiated, } from './mappings/nabla/handleEvent' -Error.stackTraceLimit = 100 - const processor = new SubstrateBatchProcessor() .setDataSource(config.dataSource) .setFields({ @@ -149,12 +147,6 @@ processor.run(new TypeormDatabase(), async (ctx) => { // Fetch max block height from the archive let maxHeight = await maxHeightPromise - console.log( - 'new blocks', - ctx.blocks.length, - ctx.blocks.map((b) => b.header.height) - ) - for (let { header: block, calls, events, extrinsics } of ctx.blocks) { ctx.log.debug( `block ${block.height}: extrinsics - ${extrinsics.length}, calls - ${calls.length}, events - ${events.length}` @@ -184,10 +176,7 @@ processor.run(new TypeormDatabase(), async (ctx) => { } } - // console.log('Process events', events.length) - let i = 1 for (let event of events) { - // console.log(`Process event ${i++}/${events.length}`, event) try { switch (event.name) { case 'Tokens.Deposited': @@ -354,7 +343,6 @@ processor.run(new TypeormDatabase(), async (ctx) => { e ) } - // console.log('Done processing event', event) } // It's important to process the calls after the events, // because for the system.remark call we need to have diff --git a/src/types.ts b/src/types.ts index ef564c9b..106db735 100644 --- a/src/types.ts +++ b/src/types.ts @@ -42,7 +42,7 @@ export async function getVersionedStorage( storageEntity: string ) { let versionedStorage - if (network === 'foucoco') { + if (network === 'foucoco' || network === 'local') { versionedStorage = await getFoucocoStorage( moduleName, storageEntity, @@ -76,7 +76,7 @@ export function decodeEvent( eventName: string ) { let event - if (network === 'foucoco') { + if (network === 'foucoco' || network === 'local') { event = decodeFoucocoEvent(moduleName, eventName, ctx) } else if (network === 'pendulum') { event = decodePendulumEvent(moduleName, eventName, ctx) diff --git a/src/types/events.ts b/src/types/events.ts index f8800085..9c800318 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -5,7 +5,7 @@ import * as pendulumEvents from './pendulum/events' import { network } from '../config' const events = - network === 'foucoco' + network === 'foucoco' || network === 'local' ? foucocoEvents : network === 'amplitude' ? amplitudeEvents diff --git a/src/types/storage.ts b/src/types/storage.ts index 39e25fb1..a983195d 100644 --- a/src/types/storage.ts +++ b/src/types/storage.ts @@ -4,7 +4,7 @@ import * as pendulumStorage from './pendulum/storage' import { network } from '../config' const storage = - network === 'foucoco' + network === 'foucoco' || network === 'local' ? foucocoStorage : network === 'amplitude' ? amplitudeStorage diff --git a/src/types/support.ts b/src/types/support.ts index 37da54d1..1632014f 100644 --- a/src/types/support.ts +++ b/src/types/support.ts @@ -5,7 +5,7 @@ import * as pendulumSupport from './pendulum/support' import { network } from '../config' const support = - network === 'foucoco' + network === 'foucoco' || network === 'local' ? foucocoSupport : network === 'amplitude' ? amplitudeSupport From 6f127b51e8304e4639c70c51dc1c2302e1c707c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:53:03 -0300 Subject: [PATCH 07/20] Clean up output --- commands.json | 8 +++++ src/config.ts | 31 ++++++++++--------- .../nabla/backstopPoolEventHandler.ts | 5 --- src/mappings/nabla/creation.ts | 2 -- src/mappings/nabla/handleEvent.ts | 18 ++--------- src/mappings/nabla/routerEventHandler.ts | 4 --- src/mappings/nabla/swapPoolEventHandler.ts | 17 ---------- 7 files changed, 28 insertions(+), 57 deletions(-) diff --git a/commands.json b/commands.json index 821f3461..023bfcb2 100644 --- a/commands.json +++ b/commands.json @@ -56,6 +56,14 @@ "description": "Generate the abi files for all ink! .contract files", "cmd": ["node", "./generate-abi.js"] }, + "process:local": { + "description": "Load .env and start the squid processor for a locally deployed Foucoco", + "deps": ["build", "migration:apply"], + "cmd": ["node", "--require=dotenv/config", "lib/processor.js"], + "env": { + "NETWORK": "local" + } + }, "process:foucoco": { "description": "Load .env and start the squid processor for Foucoco", "deps": ["build", "migration:apply"], diff --git a/src/config.ts b/src/config.ts index c8215fd4..e041f09f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -57,17 +57,20 @@ console.log('Using ProcessorConfig: ', config) // Fetch max height from the archive and export it as a promise -export const maxHeightPromise = axios - .get(config.dataSource.archive + '/height') - .then((response) => { - const data = response.data - console.log('Max height:', data) - return data - }) - .catch((error) => { - console.error( - 'Error getting block height from archive, using default value instead:', - error - ) - return network === 'local' ? 0 : Number.MAX_SAFE_INTEGER - }) +export const maxHeightPromise = + network === 'local' + ? Promise.resolve(0) + : axios + .get(config.dataSource.archive + '/height') + .then((response) => { + const data = response.data + console.log('Max height:', data) + return data + }) + .catch((error) => { + console.error( + 'Error getting block height from archive, using default value instead:', + error + ) + return Number.MAX_SAFE_INTEGER + }) diff --git a/src/mappings/nabla/backstopPoolEventHandler.ts b/src/mappings/nabla/backstopPoolEventHandler.ts index 8135041d..aedd319e 100644 --- a/src/mappings/nabla/backstopPoolEventHandler.ts +++ b/src/mappings/nabla/backstopPoolEventHandler.ts @@ -16,11 +16,8 @@ export async function handleBackstopPoolEvent( ctx: EventHandlerContext, backstopPool: BackstopPool ) { - console.log('Raw backstopPool event', ctx.event.args.data) const event = decodeEvent(ctx.event.args.data) - console.log('Process backstopPool event', backstopPool.id, event.__kind) - switch (event.__kind) { case 'Burn': await handleBurn(ctx, backstopPool) @@ -140,6 +137,4 @@ export async function updateBackstopCoverageAndSupply( backstopPool.reserves = await poolTokenContract.balanceOf( contractHexAddress ) - - console.log('Updated backstopPool', backstopPool) } diff --git a/src/mappings/nabla/creation.ts b/src/mappings/nabla/creation.ts index 06b90c2b..26b1450b 100644 --- a/src/mappings/nabla/creation.ts +++ b/src/mappings/nabla/creation.ts @@ -136,7 +136,6 @@ export async function createSwapPool( hexAddress: string ) { const ss58Address = hexToSs58(hexAddress) - console.log('createSwapPool', hexAddress, ss58Address) if (await getSwapPool(ctx, ss58Address)) { // Unexpected error: swap pool already exists at that address return @@ -197,7 +196,6 @@ export async function createSwapFee( backstopPool: BackstopPool | undefined ): Promise { const swapFeeId = `${blockNumber}-${extrinsicIndex ?? ''}` - console.log('Create new swap fee', swapFeeId) const swapFee = new NablaSwapFee({ id: swapFeeId, lpFees, diff --git a/src/mappings/nabla/handleEvent.ts b/src/mappings/nabla/handleEvent.ts index 33aeaf59..ce8a10e4 100644 --- a/src/mappings/nabla/handleEvent.ts +++ b/src/mappings/nabla/handleEvent.ts @@ -29,27 +29,15 @@ export async function handleContractInstantiated(ctx: EventHandlerContext) { switch (contractCodeHash) { case backstopPoolAbi.metadata.source.hash: - console.log( - 'New backstopPool created', - hexToSs58(contractHexAddress), - await createBackstopPool(ctx, contractHexAddress) - ) + await createBackstopPool(ctx, contractHexAddress) break case routerAbi.metadata.source.hash: - console.log( - 'New router created', - hexToSs58(contractHexAddress), - await createRouter(ctx, contractHexAddress) - ) + await createRouter(ctx, contractHexAddress) break case swapPoolAbi.metadata.source.hash: - console.log( - 'New swapPool created', - hexToSs58(contractHexAddress), - await createSwapPool(ctx, contractHexAddress) - ) + await createSwapPool(ctx, contractHexAddress) break } } diff --git a/src/mappings/nabla/routerEventHandler.ts b/src/mappings/nabla/routerEventHandler.ts index 7364a322..4fa49f66 100644 --- a/src/mappings/nabla/routerEventHandler.ts +++ b/src/mappings/nabla/routerEventHandler.ts @@ -21,8 +21,6 @@ export async function handleRouterEvent( ) { const event = decodeEvent(ctx.event.args.data) - console.log('Process router event', router.id, event.__kind) - switch (event.__kind) { case 'OwnershipTransferred': // This event will always be emitted on router creation @@ -101,13 +99,11 @@ export async function handleSwapPoolRegistered( const swapPoolSs58Address = hexToSs58(event.pool) const swapPool = await getSwapPool(ctx, swapPoolSs58Address) - console.log('SwapPool', swapPool) if (swapPool === undefined) { // this is a non-standard or malicious swap pool, ignore return } - console.log('Token', swapPool.token) const token = await getOrCreateNablaToken(ctx, ss58ToHex(swapPool.token.id)) const registeredSwapPool = await getSwapPoolsOfRouterForToken( diff --git a/src/mappings/nabla/swapPoolEventHandler.ts b/src/mappings/nabla/swapPoolEventHandler.ts index a56611ff..ce420732 100644 --- a/src/mappings/nabla/swapPoolEventHandler.ts +++ b/src/mappings/nabla/swapPoolEventHandler.ts @@ -19,8 +19,6 @@ export async function handleSwapPoolEvent( ) { const event = decodeEvent(ctx.event.args.data) - console.log('Process swapPool event', swapPool.id, event.__kind) - switch (event.__kind) { case 'BackstopDrain': await handleBackstopDrain(ctx, swapPool) @@ -61,8 +59,6 @@ export async function handleBackstopDrain( ctx: EventHandlerContext, swapPool: SwapPool ) { - console.log('handleBackstopDrain', swapPool) - await updateSwapPoolCoverageAndSupply(ctx, swapPool) await ctx.store.save(swapPool) @@ -162,12 +158,6 @@ async function filterSwapFeeHistory( for (const swapFee of feesHistory) { if (swapFee.timestamp < pastPeriodInSeconds) { - console.log( - 'Remove swap fee', - swapFee.id, - swapFee.timestamp, - pastPeriodInSeconds - ) await ctx.store.remove(swapFee) } } @@ -234,13 +224,6 @@ export async function updateAprAfterSwap( backstopTotalSupply, BigInt(backstopPoolLpTokenDecimals) ) - console.log( - 'backstop apr', - backstop.apr, - totalBackstopFees, - backstopTotalSupply, - backstopPoolLpTokenDecimals - ) await ctx.store.save(backstop) } } From 09de98c0fa9d0eed5d59ee4d3f628656953adc56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Mon, 19 Feb 2024 18:42:07 -0300 Subject: [PATCH 08/20] Bump squid version --- squid-amplitude.yaml | 2 +- squid-foucoco.yaml | 2 +- squid-pendulum.yaml | 2 +- src/mappings/protocol.ts | 1 - src/mappings/remark.ts | 1 - 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/squid-amplitude.yaml b/squid-amplitude.yaml index 35ad4c83..e992ed06 100644 --- a/squid-amplitude.yaml +++ b/squid-amplitude.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: amplitude-squid -version: 15 +version: 17 description: 'Amplitude Kusama Squid' build: deploy: diff --git a/squid-foucoco.yaml b/squid-foucoco.yaml index 7c828c16..0b85c690 100644 --- a/squid-foucoco.yaml +++ b/squid-foucoco.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: foucoco-squid -version: 15 +version: 16 description: 'Foucoco Squid' build: deploy: diff --git a/squid-pendulum.yaml b/squid-pendulum.yaml index 58c76143..d78e8eaf 100644 --- a/squid-pendulum.yaml +++ b/squid-pendulum.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: pendulum-squid -version: 15 +version: 16 description: 'Pendulum Squid' build: deploy: diff --git a/src/mappings/protocol.ts b/src/mappings/protocol.ts index 5285a903..b44e3a7a 100644 --- a/src/mappings/protocol.ts +++ b/src/mappings/protocol.ts @@ -9,7 +9,6 @@ import { assetIdFromAddress, getPairStatusFromAssets, getTokenBalance, - getTokenBurned, zenlinkAssetIdToCurrencyId, } from '../utils/token' import { ZERO_BD } from '../constants' diff --git a/src/mappings/remark.ts b/src/mappings/remark.ts index 4b5312a5..78a833be 100644 --- a/src/mappings/remark.ts +++ b/src/mappings/remark.ts @@ -1,6 +1,5 @@ import { codec } from '@subsquid/ss58' import { CallHandlerContext } from '../processor' -import events from '../types/events' import { config } from '../config' import { TokenTransfer, Transfer } from '../model' import { Call } from '@subsquid/substrate-processor' From 5b4b527ab02dc018094610dc4d96876c96bfcd86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:22:19 -0300 Subject: [PATCH 09/20] Additionally track lp token decimals --- db/migrations/1708525160246-Data.js | 21 +++++++++++++++++++++ schema.graphql | 2 ++ squid-amplitude.yaml | 2 +- squid-foucoco.yaml | 2 +- squid-pendulum.yaml | 2 +- src/mappings/nabla/creation.ts | 2 ++ src/model/generated/backstopPool.model.ts | 3 +++ src/model/generated/swapPool.model.ts | 3 +++ 8 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 db/migrations/1708525160246-Data.js diff --git a/db/migrations/1708525160246-Data.js b/db/migrations/1708525160246-Data.js new file mode 100644 index 00000000..25f44142 --- /dev/null +++ b/db/migrations/1708525160246-Data.js @@ -0,0 +1,21 @@ +module.exports = class Data1708525160246 { + name = 'Data1708525160246' + + async up(db) { + await db.query( + `ALTER TABLE "backstop_pool" ADD "lp_token_decimals" integer NOT NULL` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD "lp_token_decimals" integer NOT NULL` + ) + } + + async down(db) { + await db.query( + `ALTER TABLE "backstop_pool" DROP COLUMN "lp_token_decimals"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP COLUMN "lp_token_decimals"` + ) + } +} diff --git a/schema.graphql b/schema.graphql index fd0d106d..34c63455 100644 --- a/schema.graphql +++ b/schema.graphql @@ -760,6 +760,7 @@ type SwapPool @entity { id: ID! # id can be the address of the swap pool contract name: String! # name of the swap pool LP token symbol: String! # ticker symbol of the swap pool LP token + lpTokenDecimals: Int! # the decimals of the LP token router: Router # link to the Router entity backstop: BackstopPool! # link to the BackstopPool entity token: NablaToken! # link to the Token entity @@ -776,6 +777,7 @@ type BackstopPool @entity { id: ID! # id can be the address of the backstop pool contract name: String! # name of the backstop pool LP token symbol: String! # ticker symbol of the backstop pool LP token + lpTokenDecimals: Int! # the decimals of the LP token router: Router! # link to the Router entity token: NablaToken! # link to the NablaToken entity reserves: BigInt! # current balance of the pool diff --git a/squid-amplitude.yaml b/squid-amplitude.yaml index e992ed06..a637029d 100644 --- a/squid-amplitude.yaml +++ b/squid-amplitude.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: amplitude-squid -version: 17 +version: 18 description: 'Amplitude Kusama Squid' build: deploy: diff --git a/squid-foucoco.yaml b/squid-foucoco.yaml index 47455306..188af4df 100644 --- a/squid-foucoco.yaml +++ b/squid-foucoco.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: foucoco-squid -version: 17 +version: 18 description: 'Foucoco Squid' build: deploy: diff --git a/squid-pendulum.yaml b/squid-pendulum.yaml index 6abf7b6f..9f13f294 100644 --- a/squid-pendulum.yaml +++ b/squid-pendulum.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: pendulum-squid -version: 17 +version: 18 description: 'Pendulum Squid' build: deploy: diff --git a/src/mappings/nabla/creation.ts b/src/mappings/nabla/creation.ts index 26b1450b..301c8d2a 100644 --- a/src/mappings/nabla/creation.ts +++ b/src/mappings/nabla/creation.ts @@ -85,6 +85,7 @@ export async function createBackstopPool( id: ss58Address, name: await contract.name(), symbol: await contract.symbol(), + lpTokenDecimals: await contract.decimals(), router: router, token: token, reserves: await tokenContract.balanceOf(hexAddress), @@ -171,6 +172,7 @@ export async function createSwapPool( id: ss58Address, name: await contract.name(), symbol: await contract.symbol(), + lpTokenDecimals: await contract.decimals(), router: undefined, // only register router when owner adds this swap pool backstop: backstop, token: token, diff --git a/src/model/generated/backstopPool.model.ts b/src/model/generated/backstopPool.model.ts index 77cfced0..622501de 100644 --- a/src/model/generated/backstopPool.model.ts +++ b/src/model/generated/backstopPool.model.ts @@ -27,6 +27,9 @@ export class BackstopPool { @Column_('text', { nullable: false }) symbol!: string + @Column_('int4', { nullable: false }) + lpTokenDecimals!: number + @Index_() @ManyToOne_(() => Router, { nullable: true }) router!: Router diff --git a/src/model/generated/swapPool.model.ts b/src/model/generated/swapPool.model.ts index 1431dd56..ebd947e1 100644 --- a/src/model/generated/swapPool.model.ts +++ b/src/model/generated/swapPool.model.ts @@ -27,6 +27,9 @@ export class SwapPool { @Column_('text', { nullable: false }) symbol!: string + @Column_('int4', { nullable: false }) + lpTokenDecimals!: number + @Index_() @ManyToOne_(() => Router, { nullable: true }) router!: Router | undefined | null From 3aa56fb1fa2764d670981e27ac57f978f62cfa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Thu, 25 Apr 2024 03:48:15 -0300 Subject: [PATCH 10/20] Incorporate new Nabla metadata --- db/migrations/1714027551702-Data.js | 885 ++++++++++++++++++++++++++ nabla-abi/backstop.json | 89 ++- nabla-abi/erc20.json | 2 +- nabla-abi/router.json | 43 +- nabla-abi/swap.json | 354 +++++++---- squid-foucoco.yaml | 2 +- src/abi/backstop.ts | 102 ++- src/abi/erc20.ts | 2 +- src/abi/router.ts | 47 +- src/abi/swap.ts | 432 +++++++++---- src/types/amplitude/index.ts | 1 + src/types/amplitude/system/storage.ts | 53 ++ src/types/amplitude/v15.ts | 43 ++ src/types/foucoco/index.ts | 1 + src/types/foucoco/system/storage.ts | 53 ++ src/types/foucoco/v13.ts | 43 ++ src/types/pendulum/index.ts | 1 + src/types/pendulum/system/storage.ts | 53 ++ src/types/pendulum/v15.ts | 43 ++ 19 files changed, 1943 insertions(+), 306 deletions(-) create mode 100644 db/migrations/1714027551702-Data.js create mode 100644 src/types/amplitude/v15.ts create mode 100644 src/types/foucoco/v13.ts create mode 100644 src/types/pendulum/v15.ts diff --git a/db/migrations/1714027551702-Data.js b/db/migrations/1714027551702-Data.js new file mode 100644 index 00000000..329e8763 --- /dev/null +++ b/db/migrations/1714027551702-Data.js @@ -0,0 +1,885 @@ +module.exports = class Data1714027551702 { + name = 'Data1714027551702' + + async up(db) { + await db.query( + `CREATE TABLE "oracle_price" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "blockchain" text NOT NULL, "timestamp" numeric NOT NULL, "price" text NOT NULL, "supply" text NOT NULL, "decimals" integer NOT NULL, CONSTRAINT "PK_606c938b2474588b154eb625f3b" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_6554f47abd46667280a2523381" ON "oracle_price" ("symbol") ` + ) + await db.query( + `CREATE INDEX "IDX_2026224855490e321e5c0b6911" ON "oracle_price" ("blockchain") ` + ) + await db.query( + `CREATE INDEX "IDX_a77ac6d79f0929522f5a1aefcb" ON "oracle_price" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_f7c9bf3bae39fb0a75f12b87dd" ON "oracle_price" ("price") ` + ) + await db.query( + `CREATE TABLE "transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "amount" numeric NOT NULL, "fee" numeric NOT NULL, "remark" text, CONSTRAINT "PK_fd9ddbdd49a17afcbe014401295" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_d6624eacc30144ea97915fe846" ON "transfer" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_70ff8b624c3118ac3a4862d22c" ON "transfer" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_070c555a86b0b41a534a55a659" ON "transfer" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_f4007436c1b546ede08a4fd7ab" ON "transfer" ("amount") ` + ) + await db.query( + `CREATE TABLE "factory" ("id" character varying NOT NULL, "pair_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_volume_eth" text NOT NULL, "untracked_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_1372e5a7d114a3fa80736ba66bb" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "stable_swap_event" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_8b61dbc9b556ed8fcb4030fee7d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_3a147c85b92441217540579be8" ON "stable_swap_event" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_exchange" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_f06e489da865134dcfac3bbcd22" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_1180a78feea28e278229de7db4" ON "stable_swap_exchange" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_819b3b7bf9c8055e14e0bf1c578" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_648b49eb1a4f2a47f24f13bb51" ON "stable_swap_day_data" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "hourly_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_2aedd41b95c37330a4a8429e192" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_94584d2925c30ae0d4b80aadfc" ON "stable_swap_hour_data" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "token_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_token" text NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "total_liquidity_token" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_liquidity_usd" text NOT NULL, "price_usd" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_73fc06337215e86196b36822116" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_b8950a8bc7b60231137573740e" ON "token_day_data" ("token_id") ` + ) + await db.query( + `CREATE TABLE "pair_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "hourly_volume_token0" text NOT NULL, "hourly_volume_token1" text NOT NULL, "hourly_volume_usd" text NOT NULL, "hourly_txns" integer NOT NULL, "pair_id" character varying, CONSTRAINT "PK_ffc544bb3e72cfd3e48a8b01452" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_cf50c55389e428096a68598ee3" ON "pair_hour_data" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "stable_swap_id" character varying, CONSTRAINT "PK_12f435243c8a739330c0881d720" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_f953aebc7c0752f6b8434c9eef" ON "stable_swap_liquidity_position" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_405e0d7aeca80975d88a63bc6e" ON "stable_swap_liquidity_position" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stake_position" ("id" character varying NOT NULL, "liquidity_staked_balance" numeric NOT NULL, "user_id" character varying, "farm_id" character varying, CONSTRAINT "PK_17615803509bd6065f1ab8b0ced" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_2a2b22d2744b497bbcfb03e6ab" ON "stake_position" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_670629d9904e1f48f4a31abb49" ON "stake_position" ("farm_id") ` + ) + await db.query( + `CREATE TABLE "user" ("id" character varying NOT NULL, "usd_swapped" text NOT NULL, CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_db00d963c96b3914d26abe3c3d2" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_781470585a67fef4e215a59977" ON "liquidity_position" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_5a626c8b8962dc01e0f8801be6" ON "liquidity_position" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "liquidity_position_snapshot" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block" integer NOT NULL, "token0_price_usd" text NOT NULL, "token1_price_usd" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "reserve_usd" text NOT NULL, "liquidity_token_total_supply" text NOT NULL, "liquidity_token_balance" text NOT NULL, "liquidity_position_id" character varying, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_cd4ed3539266b2439349a9fa791" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_eb823fd4d5a47575039e902efa" ON "liquidity_position_snapshot" ("liquidity_position_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ed32a41150bc13f18a01974153" ON "liquidity_position_snapshot" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ce85a847b2952f7e685f150de1" ON "liquidity_position_snapshot" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "transaction" ("id" character varying NOT NULL, "block_number" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "mints" text array NOT NULL, "burns" text array NOT NULL, "swaps" text array NOT NULL, CONSTRAINT "PK_89eadb93a89810556e1cbcd6ab9" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "mint" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "to" text NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "log_index" integer, "amount_usd" text, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_fcaea791104aa41aa11dac29cb2" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_19f4328320501dfd14e2bae085" ON "mint" ("transaction_id") ` + ) + await db.query( + `CREATE INDEX "IDX_81d470127d4c55d09e9213bc4e" ON "mint" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "burn" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "to" text, "log_index" integer, "amount_usd" text, "needs_complete" boolean NOT NULL, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_dcb4f14ee4534154b31116553f0" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_20ec76c5c56dd6b47dec5f0aaa" ON "burn" ("transaction_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ba144ce938b3266a470d4dd70f" ON "burn" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "swap" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "from" text NOT NULL, "amount0_in" text NOT NULL, "amount1_in" text NOT NULL, "amount0_out" text NOT NULL, "amount1_out" text NOT NULL, "to" text NOT NULL, "log_index" integer, "amount_usd" text NOT NULL, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_4a10d0f359339acef77e7f986d9" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_78506c4050ae7cedd50b08c0dc" ON "swap" ("transaction_id") ` + ) + await db.query( + `CREATE INDEX "IDX_3571ab1dad7640a6b93c705b8f" ON "swap" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "pair" ("id" character varying NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_eth" text NOT NULL, "reserve_usd" text NOT NULL, "tracked_reserve_eth" text NOT NULL, "token0_price" text NOT NULL, "token1_price" text NOT NULL, "volume_token0" text NOT NULL, "volume_token1" text NOT NULL, "volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "created_at_timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "created_at_block_number" numeric NOT NULL, "liquidity_provider_count" integer NOT NULL, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_3eaf216329c5c50aedb94fa797e" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_f74dc53460944a424b56b8f7da" ON "pair" ("token0_id") ` + ) + await db.query( + `CREATE INDEX "IDX_4419691fc411b8af754dfa65ce" ON "pair" ("token1_id") ` + ) + await db.query( + `CREATE TABLE "pair_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "pair_address" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "daily_volume_token0" text NOT NULL, "daily_volume_token1" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "pair_id" character varying, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_ac35ed26ab0c71d491a62e2881a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_d8ba7d7d7ad9f0e1c2933a0b7e" ON "pair_day_data" ("pair_id") ` + ) + await db.query( + `CREATE INDEX "IDX_88f6e19c40b47053e6e197db1c" ON "pair_day_data" ("token0_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ce435d6fc7c373d58e7aab156d" ON "pair_day_data" ("token1_id") ` + ) + await db.query( + `CREATE TABLE "token" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "decimals" integer NOT NULL, "total_supply" text NOT NULL, "trade_volume" text NOT NULL, "trade_volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "total_liquidity" text NOT NULL, "derived_eth" text NOT NULL, CONSTRAINT "PK_82fae97f905930df5d62a702fc9" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "single_token_lock_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_87d03adf6b8624eaff434355e53" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_f3bf64f43101176dbe5f11a36b" ON "single_token_lock_day_data" ("single_token_lock_id") ` + ) + await db.query( + `CREATE TABLE "single_token_lock_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_9173bf5d597c5ce35bbce2e664b" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_b2a84dc625103153d651b701dd" ON "single_token_lock_hour_data" ("single_token_lock_id") ` + ) + await db.query( + `CREATE TABLE "single_token_lock" ("id" character varying NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_eth" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_b3d635331ccfacc4f532569364b" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_8ebffe66457859d6e1c37b81ac" ON "single_token_lock" ("token_id") ` + ) + await db.query( + `CREATE TABLE "incentive" ("id" character varying NOT NULL, "reward_per_day" text NOT NULL, "farm_id" character varying, "reward_token_id" character varying, CONSTRAINT "PK_fc2c4e32d8711392ddf918b9f6c" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_35286137967591eaff8dee7ca2" ON "incentive" ("farm_id") ` + ) + await db.query( + `CREATE INDEX "IDX_041db4166864a3841e5efed53c" ON "incentive" ("reward_token_id") ` + ) + await db.query( + `CREATE TABLE "farm" ("id" character varying NOT NULL, "pid" numeric NOT NULL, "stake_token" text NOT NULL, "liquidity_staked" numeric NOT NULL, "created_at_block" numeric NOT NULL, "created_at_timestamp" numeric NOT NULL, "staked_usd" text NOT NULL, "reward_usd_per_day" text NOT NULL, "stake_apr" text NOT NULL, "single_token_lock_id" character varying, "stable_swap_id" character varying, "pair_id" character varying, CONSTRAINT "PK_3bf246b27a3b6678dfc0b7a3f64" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_679106a1febf251d7fe7fe081a" ON "farm" ("single_token_lock_id") ` + ) + await db.query( + `CREATE INDEX "IDX_00b8f5b860927b1b85e866b20d" ON "farm" ("stable_swap_id") ` + ) + await db.query( + `CREATE INDEX "IDX_11da1bf5c406898262d91b41cb" ON "farm" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap" ("id" character varying NOT NULL, "address" text NOT NULL, "base_swap_address" text NOT NULL, "num_tokens" integer NOT NULL, "tokens" text array NOT NULL, "base_tokens" text array NOT NULL, "all_tokens" text array NOT NULL, "balances" text array NOT NULL, "lp_token" text NOT NULL, "lp_total_supply" text NOT NULL, "a" numeric NOT NULL, "swap_fee" numeric NOT NULL, "admin_fee" numeric NOT NULL, "virtual_price" numeric NOT NULL, "tvl_usd" text NOT NULL, "volume_usd" text NOT NULL, "stable_swap_info_id" character varying, CONSTRAINT "PK_37316f6fedc29bf95a6f1804c65" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_88cce14adee6d21f5057551c3e" ON "stable_swap" ("stable_swap_info_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_info" ("id" character varying NOT NULL, "pool_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_21998b071d5e28639e21e9b2da7" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "zenlink_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, "factory_id" character varying, "stable_swap_info_id" character varying, CONSTRAINT "PK_2526d46468e5c4f7c4156840a90" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_9a6b55d2085464668b622dffe6" ON "zenlink_info" ("factory_id") ` + ) + await db.query( + `CREATE INDEX "IDX_0795adc3723792868094ec76c0" ON "zenlink_info" ("stable_swap_info_id") ` + ) + await db.query( + `CREATE TABLE "token_transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, "remark" text, CONSTRAINT "PK_77384b7f5874553f012eba9da41" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_b47f7192b72dd8436ef4e6d253" ON "token_transfer" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_752d6c330729a7b2e283003374" ON "token_transfer" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_2ef35b71d641ec79b7de3ac237" ON "token_transfer" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_aae50046f62ba400c07477fb6c" ON "token_transfer" ("amount") ` + ) + await db.query( + `CREATE TABLE "token_deposit" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_7c5eea7aeab3f0e71da8d2d9f4f" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_395da815b9927f13e2f87c6b54" ON "token_deposit" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_0f87d313517eaa806c75444749" ON "token_deposit" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_7194acc3ea037189ff3da743ec" ON "token_deposit" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_d23ae7a0ea1f640e8e9875b3c2" ON "token_deposit" ("amount") ` + ) + await db.query( + `CREATE TABLE "token_withdrawn" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_658727649cde2e20f8cf69abeb5" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_e7fd99cae9a1df2e8f69d60892" ON "token_withdrawn" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_70e98131fb737e4dce4455ca43" ON "token_withdrawn" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_867e6d004e7a4994b3b2aeba63" ON "token_withdrawn" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_5697bf049746e5102413ebd832" ON "token_withdrawn" ("amount") ` + ) + await db.query( + `CREATE TABLE "bundle" ("id" character varying NOT NULL, "eth_price" text NOT NULL, CONSTRAINT "PK_637e3f87e837d6532109c198dea" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "factory_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_volume_untracked" text NOT NULL, "total_volume_eth" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_4b56c54390ce8e399d8e37e169d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "stable_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, CONSTRAINT "PK_3663f18340bb5fdc0023ecc624a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "zenlink_day_info" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "standard_info_id" character varying, "stable_info_id" character varying, CONSTRAINT "PK_747195cfa3811d6eea0ff6389de" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_9f281ffbf4f668c1671ae24aeb" ON "zenlink_day_info" ("standard_info_id") ` + ) + await db.query( + `CREATE INDEX "IDX_3049b8ac70203e95dfc6b42c02" ON "zenlink_day_info" ("stable_info_id") ` + ) + await db.query( + `CREATE TABLE "zlk_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "burn" numeric NOT NULL, CONSTRAINT "PK_58853b5e24384aba0da2023e91e" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "nabla_token" ("id" character varying NOT NULL, "decimals" integer NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, CONSTRAINT "PK_d036fec883bded17a5c2e09cf0a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "nabla_swap_fee" ("id" character varying NOT NULL, "lp_fees" numeric NOT NULL, "backstop_fees" numeric NOT NULL, "protocol_fees" numeric NOT NULL, "timestamp" numeric NOT NULL, "swap_pool_id" character varying, "backstop_pool_id" character varying, CONSTRAINT "PK_8824e4a63ae77ecf8a55aa5359a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_208d304702d154e73e4f85c978" ON "nabla_swap_fee" ("swap_pool_id") ` + ) + await db.query( + `CREATE INDEX "IDX_86080eda96a6de9c3c60be41d8" ON "nabla_swap_fee" ("backstop_pool_id") ` + ) + await db.query( + `CREATE TABLE "backstop_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "lp_token_decimals" integer NOT NULL, "reserves" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "router_id" character varying, "token_id" character varying, CONSTRAINT "PK_bf2d01d9ce60ad9ee4b1b087d9d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_13ef09b925620aedf12b3342ca" ON "backstop_pool" ("router_id") ` + ) + await db.query( + `CREATE INDEX "IDX_8a7a25fa2d22ff634bd3041d81" ON "backstop_pool" ("token_id") ` + ) + await db.query( + `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "lp_token_decimals" integer NOT NULL, "reserve" numeric NOT NULL, "reserve_with_slippage" numeric NOT NULL, "total_liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_2f5409f002e18e4a6e2fddd858" ON "swap_pool" ("router_id") ` + ) + await db.query( + `CREATE INDEX "IDX_5c3209a88e41d53bdc450605b3" ON "swap_pool" ("backstop_id") ` + ) + await db.query( + `CREATE INDEX "IDX_b66a5cc8d2ce7bba1b48fd8c1a" ON "swap_pool" ("token_id") ` + ) + await db.query( + `CREATE TABLE "router" ("id" character varying NOT NULL, "paused" boolean NOT NULL, CONSTRAINT "PK_510c864aa88ac8eb3a306789801" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "event" ("id" character varying NOT NULL, "index" integer NOT NULL, "phase" text NOT NULL, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "call_id" character varying, CONSTRAINT "PK_30c2f3bbaf6d34a55f8ae6e4614" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_2b0d35d675c4f99751855c4502" ON "event" ("block_id") ` + ) + await db.query( + `CREATE INDEX "IDX_129efedcb305c80256db2d57a5" ON "event" ("extrinsic_id") ` + ) + await db.query( + `CREATE INDEX "IDX_83cf1bd59aa4521ed882fa5145" ON "event" ("call_id") ` + ) + await db.query( + `CREATE INDEX "IDX_7723d04c5a2f56c4373b6a4048" ON "event" ("pallet") ` + ) + await db.query( + `CREATE INDEX "IDX_b535fbe8ec6d832dde22065ebd" ON "event" ("name") ` + ) + await db.query( + `CREATE INDEX "IDX_0a00d817e614a91cda40d734cf" ON "event" ("id", "pallet", "name") ` + ) + await db.query( + `CREATE TABLE "call" ("id" character varying NOT NULL, "address" integer array NOT NULL, "success" boolean NOT NULL, "error" jsonb, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "parent_id" character varying, CONSTRAINT "PK_2098af0169792a34f9cfdd39c47" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_bd3f11fd4110d60ac8b96cd62f" ON "call" ("block_id") ` + ) + await db.query( + `CREATE INDEX "IDX_dde30e4f2c6a80f9236bfdf259" ON "call" ("extrinsic_id") ` + ) + await db.query( + `CREATE INDEX "IDX_11c1e76d5be8f04c472c4a05b9" ON "call" ("parent_id") ` + ) + await db.query( + `CREATE INDEX "IDX_d3a8c3d00494950ad6dc93297d" ON "call" ("success") ` + ) + await db.query( + `CREATE INDEX "IDX_776bccbd3d7b3001c8708cf4e0" ON "call" ("pallet") ` + ) + await db.query( + `CREATE INDEX "IDX_8b212022b7428232091e2f8aa5" ON "call" ("name") ` + ) + await db.query( + `CREATE INDEX "IDX_f1e953379e1b3c453cd896bcd4" ON "call" ("id", "pallet", "name") ` + ) + await db.query( + `CREATE TABLE "extrinsic" ("id" character varying NOT NULL, "index" integer NOT NULL, "version" integer NOT NULL, "signature" jsonb, "tip" numeric, "fee" numeric, "success" boolean, "error" jsonb, "hash" bytea NOT NULL, "block_id" character varying, "call_id" character varying, CONSTRAINT "PK_80d7db0e4b1e83e30336bc76755" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_a3b99daba1259dab0dd040d4f7" ON "extrinsic" ("block_id") ` + ) + await db.query( + `CREATE INDEX "IDX_824d47cc4b2cda726405aa507c" ON "extrinsic" ("call_id") ` + ) + await db.query( + `CREATE INDEX "IDX_21e5db7671dfa1b00dbe6dbbd6" ON "extrinsic" ("success") ` + ) + await db.query( + `CREATE INDEX "IDX_1f45de0713a55049009e8e8127" ON "extrinsic" ("hash") ` + ) + await db.query( + `CREATE TABLE "block" ("id" character varying NOT NULL, "height" integer NOT NULL, "hash" bytea NOT NULL, "parent_hash" bytea NOT NULL, "state_root" bytea NOT NULL, "extrinsicsic_root" bytea NOT NULL, "spec_name" text NOT NULL, "spec_version" integer NOT NULL, "impl_name" text NOT NULL, "impl_version" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "validator" bytea, "extrinsics_count" integer NOT NULL, "calls_count" integer NOT NULL, "events_count" integer NOT NULL, CONSTRAINT "PK_d0925763efb591c2e2ffb267572" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_bce676e2b005104ccb768495db" ON "block" ("height") ` + ) + await db.query( + `CREATE INDEX "IDX_f8fba63d7965bfee9f304c487a" ON "block" ("hash") ` + ) + await db.query( + `CREATE INDEX "IDX_5b79d140fa8e2c64a7ef223598" ON "block" ("spec_version") ` + ) + await db.query( + `CREATE INDEX "IDX_5c67cbcf4960c1a39e5fe25e87" ON "block" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_b7e2f8fe1384a2910825029dcb" ON "block" ("validator") ` + ) + await db.query( + `CREATE TABLE "items_counter" ("id" character varying NOT NULL, "type" character varying(10) NOT NULL, "level" character varying(6) NOT NULL, "total" integer NOT NULL, CONSTRAINT "PK_161dcf46142538463f5d7174793" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_68d2eadecb3eeb540d2004acef" ON "items_counter" ("type") ` + ) + await db.query( + `CREATE INDEX "IDX_1d9be1d79f197d42dd163f86c8" ON "items_counter" ("level") ` + ) + await db.query( + `CREATE INDEX "IDX_e03dd1c60ac7622914f72ac2f1" ON "items_counter" ("total") ` + ) + await db.query( + `ALTER TABLE "stable_swap_event" ADD CONSTRAINT "FK_3a147c85b92441217540579be88" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_exchange" ADD CONSTRAINT "FK_1180a78feea28e278229de7db46" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_day_data" ADD CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_hour_data" ADD CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "token_day_data" ADD CONSTRAINT "FK_b8950a8bc7b60231137573740ea" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_hour_data" ADD CONSTRAINT "FK_cf50c55389e428096a68598ee33" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_670629d9904e1f48f4a31abb495" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_781470585a67fef4e215a599773" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_eb823fd4d5a47575039e902efa7" FOREIGN KEY ("liquidity_position_id") REFERENCES "liquidity_position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ed32a41150bc13f18a019741534" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ce85a847b2952f7e685f150de1d" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "mint" ADD CONSTRAINT "FK_19f4328320501dfd14e2bae0855" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "mint" ADD CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "burn" ADD CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "burn" ADD CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap" ADD CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap" ADD CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair" ADD CONSTRAINT "FK_f74dc53460944a424b56b8f7da5" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair" ADD CONSTRAINT "FK_4419691fc411b8af754dfa65ce4" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "single_token_lock_day_data" ADD CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "single_token_lock_hour_data" ADD CONSTRAINT "FK_b2a84dc625103153d651b701dd1" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "single_token_lock" ADD CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "incentive" ADD CONSTRAINT "FK_35286137967591eaff8dee7ca2a" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "incentive" ADD CONSTRAINT "FK_041db4166864a3841e5efed53c4" FOREIGN KEY ("reward_token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "farm" ADD CONSTRAINT "FK_679106a1febf251d7fe7fe081ad" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "farm" ADD CONSTRAINT "FK_00b8f5b860927b1b85e866b20da" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "farm" ADD CONSTRAINT "FK_11da1bf5c406898262d91b41cbb" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap" ADD CONSTRAINT "FK_88cce14adee6d21f5057551c3ea" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_9a6b55d2085464668b622dffe64" FOREIGN KEY ("factory_id") REFERENCES "factory"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_0795adc3723792868094ec76c07" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0" FOREIGN KEY ("standard_info_id") REFERENCES "factory_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027" FOREIGN KEY ("stable_info_id") REFERENCES "stable_swap_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_208d304702d154e73e4f85c978b" FOREIGN KEY ("swap_pool_id") REFERENCES "swap_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_86080eda96a6de9c3c60be41d86" FOREIGN KEY ("backstop_pool_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_13ef09b925620aedf12b3342caa" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b" FOREIGN KEY ("backstop_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "event" ADD CONSTRAINT "FK_2b0d35d675c4f99751855c45021" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "event" ADD CONSTRAINT "FK_129efedcb305c80256db2d57a59" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "event" ADD CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "call" ADD CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "call" ADD CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "call" ADD CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95" FOREIGN KEY ("parent_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_824d47cc4b2cda726405aa507ca" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + } + + async down(db) { + await db.query(`DROP TABLE "oracle_price"`) + await db.query(`DROP INDEX "public"."IDX_6554f47abd46667280a2523381"`) + await db.query(`DROP INDEX "public"."IDX_2026224855490e321e5c0b6911"`) + await db.query(`DROP INDEX "public"."IDX_a77ac6d79f0929522f5a1aefcb"`) + await db.query(`DROP INDEX "public"."IDX_f7c9bf3bae39fb0a75f12b87dd"`) + await db.query(`DROP TABLE "transfer"`) + await db.query(`DROP INDEX "public"."IDX_d6624eacc30144ea97915fe846"`) + await db.query(`DROP INDEX "public"."IDX_70ff8b624c3118ac3a4862d22c"`) + await db.query(`DROP INDEX "public"."IDX_070c555a86b0b41a534a55a659"`) + await db.query(`DROP INDEX "public"."IDX_f4007436c1b546ede08a4fd7ab"`) + await db.query(`DROP TABLE "factory"`) + await db.query(`DROP TABLE "stable_swap_event"`) + await db.query(`DROP INDEX "public"."IDX_3a147c85b92441217540579be8"`) + await db.query(`DROP TABLE "stable_swap_exchange"`) + await db.query(`DROP INDEX "public"."IDX_1180a78feea28e278229de7db4"`) + await db.query(`DROP TABLE "stable_swap_day_data"`) + await db.query(`DROP INDEX "public"."IDX_648b49eb1a4f2a47f24f13bb51"`) + await db.query(`DROP TABLE "stable_swap_hour_data"`) + await db.query(`DROP INDEX "public"."IDX_94584d2925c30ae0d4b80aadfc"`) + await db.query(`DROP TABLE "token_day_data"`) + await db.query(`DROP INDEX "public"."IDX_b8950a8bc7b60231137573740e"`) + await db.query(`DROP TABLE "pair_hour_data"`) + await db.query(`DROP INDEX "public"."IDX_cf50c55389e428096a68598ee3"`) + await db.query(`DROP TABLE "stable_swap_liquidity_position"`) + await db.query(`DROP INDEX "public"."IDX_f953aebc7c0752f6b8434c9eef"`) + await db.query(`DROP INDEX "public"."IDX_405e0d7aeca80975d88a63bc6e"`) + await db.query(`DROP TABLE "stake_position"`) + await db.query(`DROP INDEX "public"."IDX_2a2b22d2744b497bbcfb03e6ab"`) + await db.query(`DROP INDEX "public"."IDX_670629d9904e1f48f4a31abb49"`) + await db.query(`DROP TABLE "user"`) + await db.query(`DROP TABLE "liquidity_position"`) + await db.query(`DROP INDEX "public"."IDX_781470585a67fef4e215a59977"`) + await db.query(`DROP INDEX "public"."IDX_5a626c8b8962dc01e0f8801be6"`) + await db.query(`DROP TABLE "liquidity_position_snapshot"`) + await db.query(`DROP INDEX "public"."IDX_eb823fd4d5a47575039e902efa"`) + await db.query(`DROP INDEX "public"."IDX_ed32a41150bc13f18a01974153"`) + await db.query(`DROP INDEX "public"."IDX_ce85a847b2952f7e685f150de1"`) + await db.query(`DROP TABLE "transaction"`) + await db.query(`DROP TABLE "mint"`) + await db.query(`DROP INDEX "public"."IDX_19f4328320501dfd14e2bae085"`) + await db.query(`DROP INDEX "public"."IDX_81d470127d4c55d09e9213bc4e"`) + await db.query(`DROP TABLE "burn"`) + await db.query(`DROP INDEX "public"."IDX_20ec76c5c56dd6b47dec5f0aaa"`) + await db.query(`DROP INDEX "public"."IDX_ba144ce938b3266a470d4dd70f"`) + await db.query(`DROP TABLE "swap"`) + await db.query(`DROP INDEX "public"."IDX_78506c4050ae7cedd50b08c0dc"`) + await db.query(`DROP INDEX "public"."IDX_3571ab1dad7640a6b93c705b8f"`) + await db.query(`DROP TABLE "pair"`) + await db.query(`DROP INDEX "public"."IDX_f74dc53460944a424b56b8f7da"`) + await db.query(`DROP INDEX "public"."IDX_4419691fc411b8af754dfa65ce"`) + await db.query(`DROP TABLE "pair_day_data"`) + await db.query(`DROP INDEX "public"."IDX_d8ba7d7d7ad9f0e1c2933a0b7e"`) + await db.query(`DROP INDEX "public"."IDX_88f6e19c40b47053e6e197db1c"`) + await db.query(`DROP INDEX "public"."IDX_ce435d6fc7c373d58e7aab156d"`) + await db.query(`DROP TABLE "token"`) + await db.query(`DROP TABLE "single_token_lock_day_data"`) + await db.query(`DROP INDEX "public"."IDX_f3bf64f43101176dbe5f11a36b"`) + await db.query(`DROP TABLE "single_token_lock_hour_data"`) + await db.query(`DROP INDEX "public"."IDX_b2a84dc625103153d651b701dd"`) + await db.query(`DROP TABLE "single_token_lock"`) + await db.query(`DROP INDEX "public"."IDX_8ebffe66457859d6e1c37b81ac"`) + await db.query(`DROP TABLE "incentive"`) + await db.query(`DROP INDEX "public"."IDX_35286137967591eaff8dee7ca2"`) + await db.query(`DROP INDEX "public"."IDX_041db4166864a3841e5efed53c"`) + await db.query(`DROP TABLE "farm"`) + await db.query(`DROP INDEX "public"."IDX_679106a1febf251d7fe7fe081a"`) + await db.query(`DROP INDEX "public"."IDX_00b8f5b860927b1b85e866b20d"`) + await db.query(`DROP INDEX "public"."IDX_11da1bf5c406898262d91b41cb"`) + await db.query(`DROP TABLE "stable_swap"`) + await db.query(`DROP INDEX "public"."IDX_88cce14adee6d21f5057551c3e"`) + await db.query(`DROP TABLE "stable_swap_info"`) + await db.query(`DROP TABLE "zenlink_info"`) + await db.query(`DROP INDEX "public"."IDX_9a6b55d2085464668b622dffe6"`) + await db.query(`DROP INDEX "public"."IDX_0795adc3723792868094ec76c0"`) + await db.query(`DROP TABLE "token_transfer"`) + await db.query(`DROP INDEX "public"."IDX_b47f7192b72dd8436ef4e6d253"`) + await db.query(`DROP INDEX "public"."IDX_752d6c330729a7b2e283003374"`) + await db.query(`DROP INDEX "public"."IDX_2ef35b71d641ec79b7de3ac237"`) + await db.query(`DROP INDEX "public"."IDX_aae50046f62ba400c07477fb6c"`) + await db.query(`DROP TABLE "token_deposit"`) + await db.query(`DROP INDEX "public"."IDX_395da815b9927f13e2f87c6b54"`) + await db.query(`DROP INDEX "public"."IDX_0f87d313517eaa806c75444749"`) + await db.query(`DROP INDEX "public"."IDX_7194acc3ea037189ff3da743ec"`) + await db.query(`DROP INDEX "public"."IDX_d23ae7a0ea1f640e8e9875b3c2"`) + await db.query(`DROP TABLE "token_withdrawn"`) + await db.query(`DROP INDEX "public"."IDX_e7fd99cae9a1df2e8f69d60892"`) + await db.query(`DROP INDEX "public"."IDX_70e98131fb737e4dce4455ca43"`) + await db.query(`DROP INDEX "public"."IDX_867e6d004e7a4994b3b2aeba63"`) + await db.query(`DROP INDEX "public"."IDX_5697bf049746e5102413ebd832"`) + await db.query(`DROP TABLE "bundle"`) + await db.query(`DROP TABLE "factory_day_data"`) + await db.query(`DROP TABLE "stable_day_data"`) + await db.query(`DROP TABLE "zenlink_day_info"`) + await db.query(`DROP INDEX "public"."IDX_9f281ffbf4f668c1671ae24aeb"`) + await db.query(`DROP INDEX "public"."IDX_3049b8ac70203e95dfc6b42c02"`) + await db.query(`DROP TABLE "zlk_info"`) + await db.query(`DROP TABLE "nabla_token"`) + await db.query(`DROP TABLE "nabla_swap_fee"`) + await db.query(`DROP INDEX "public"."IDX_208d304702d154e73e4f85c978"`) + await db.query(`DROP INDEX "public"."IDX_86080eda96a6de9c3c60be41d8"`) + await db.query(`DROP TABLE "backstop_pool"`) + await db.query(`DROP INDEX "public"."IDX_13ef09b925620aedf12b3342ca"`) + await db.query(`DROP INDEX "public"."IDX_8a7a25fa2d22ff634bd3041d81"`) + await db.query(`DROP TABLE "swap_pool"`) + await db.query(`DROP INDEX "public"."IDX_2f5409f002e18e4a6e2fddd858"`) + await db.query(`DROP INDEX "public"."IDX_5c3209a88e41d53bdc450605b3"`) + await db.query(`DROP INDEX "public"."IDX_b66a5cc8d2ce7bba1b48fd8c1a"`) + await db.query(`DROP TABLE "router"`) + await db.query(`DROP TABLE "event"`) + await db.query(`DROP INDEX "public"."IDX_2b0d35d675c4f99751855c4502"`) + await db.query(`DROP INDEX "public"."IDX_129efedcb305c80256db2d57a5"`) + await db.query(`DROP INDEX "public"."IDX_83cf1bd59aa4521ed882fa5145"`) + await db.query(`DROP INDEX "public"."IDX_7723d04c5a2f56c4373b6a4048"`) + await db.query(`DROP INDEX "public"."IDX_b535fbe8ec6d832dde22065ebd"`) + await db.query(`DROP INDEX "public"."IDX_0a00d817e614a91cda40d734cf"`) + await db.query(`DROP TABLE "call"`) + await db.query(`DROP INDEX "public"."IDX_bd3f11fd4110d60ac8b96cd62f"`) + await db.query(`DROP INDEX "public"."IDX_dde30e4f2c6a80f9236bfdf259"`) + await db.query(`DROP INDEX "public"."IDX_11c1e76d5be8f04c472c4a05b9"`) + await db.query(`DROP INDEX "public"."IDX_d3a8c3d00494950ad6dc93297d"`) + await db.query(`DROP INDEX "public"."IDX_776bccbd3d7b3001c8708cf4e0"`) + await db.query(`DROP INDEX "public"."IDX_8b212022b7428232091e2f8aa5"`) + await db.query(`DROP INDEX "public"."IDX_f1e953379e1b3c453cd896bcd4"`) + await db.query(`DROP TABLE "extrinsic"`) + await db.query(`DROP INDEX "public"."IDX_a3b99daba1259dab0dd040d4f7"`) + await db.query(`DROP INDEX "public"."IDX_824d47cc4b2cda726405aa507c"`) + await db.query(`DROP INDEX "public"."IDX_21e5db7671dfa1b00dbe6dbbd6"`) + await db.query(`DROP INDEX "public"."IDX_1f45de0713a55049009e8e8127"`) + await db.query(`DROP TABLE "block"`) + await db.query(`DROP INDEX "public"."IDX_bce676e2b005104ccb768495db"`) + await db.query(`DROP INDEX "public"."IDX_f8fba63d7965bfee9f304c487a"`) + await db.query(`DROP INDEX "public"."IDX_5b79d140fa8e2c64a7ef223598"`) + await db.query(`DROP INDEX "public"."IDX_5c67cbcf4960c1a39e5fe25e87"`) + await db.query(`DROP INDEX "public"."IDX_b7e2f8fe1384a2910825029dcb"`) + await db.query(`DROP TABLE "items_counter"`) + await db.query(`DROP INDEX "public"."IDX_68d2eadecb3eeb540d2004acef"`) + await db.query(`DROP INDEX "public"."IDX_1d9be1d79f197d42dd163f86c8"`) + await db.query(`DROP INDEX "public"."IDX_e03dd1c60ac7622914f72ac2f1"`) + await db.query( + `ALTER TABLE "stable_swap_event" DROP CONSTRAINT "FK_3a147c85b92441217540579be88"` + ) + await db.query( + `ALTER TABLE "stable_swap_exchange" DROP CONSTRAINT "FK_1180a78feea28e278229de7db46"` + ) + await db.query( + `ALTER TABLE "stable_swap_day_data" DROP CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510"` + ) + await db.query( + `ALTER TABLE "stable_swap_hour_data" DROP CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8"` + ) + await db.query( + `ALTER TABLE "token_day_data" DROP CONSTRAINT "FK_b8950a8bc7b60231137573740ea"` + ) + await db.query( + `ALTER TABLE "pair_hour_data" DROP CONSTRAINT "FK_cf50c55389e428096a68598ee33"` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8"` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee"` + ) + await db.query( + `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0"` + ) + await db.query( + `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_670629d9904e1f48f4a31abb495"` + ) + await db.query( + `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_781470585a67fef4e215a599773"` + ) + await db.query( + `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61"` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_eb823fd4d5a47575039e902efa7"` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ed32a41150bc13f18a019741534"` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ce85a847b2952f7e685f150de1d"` + ) + await db.query( + `ALTER TABLE "mint" DROP CONSTRAINT "FK_19f4328320501dfd14e2bae0855"` + ) + await db.query( + `ALTER TABLE "mint" DROP CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1"` + ) + await db.query( + `ALTER TABLE "burn" DROP CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8"` + ) + await db.query( + `ALTER TABLE "burn" DROP CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa"` + ) + await db.query( + `ALTER TABLE "swap" DROP CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5"` + ) + await db.query( + `ALTER TABLE "swap" DROP CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7"` + ) + await db.query( + `ALTER TABLE "pair" DROP CONSTRAINT "FK_f74dc53460944a424b56b8f7da5"` + ) + await db.query( + `ALTER TABLE "pair" DROP CONSTRAINT "FK_4419691fc411b8af754dfa65ce4"` + ) + await db.query( + `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2"` + ) + await db.query( + `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9"` + ) + await db.query( + `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9"` + ) + await db.query( + `ALTER TABLE "single_token_lock_day_data" DROP CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd"` + ) + await db.query( + `ALTER TABLE "single_token_lock_hour_data" DROP CONSTRAINT "FK_b2a84dc625103153d651b701dd1"` + ) + await db.query( + `ALTER TABLE "single_token_lock" DROP CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3"` + ) + await db.query( + `ALTER TABLE "incentive" DROP CONSTRAINT "FK_35286137967591eaff8dee7ca2a"` + ) + await db.query( + `ALTER TABLE "incentive" DROP CONSTRAINT "FK_041db4166864a3841e5efed53c4"` + ) + await db.query( + `ALTER TABLE "farm" DROP CONSTRAINT "FK_679106a1febf251d7fe7fe081ad"` + ) + await db.query( + `ALTER TABLE "farm" DROP CONSTRAINT "FK_00b8f5b860927b1b85e866b20da"` + ) + await db.query( + `ALTER TABLE "farm" DROP CONSTRAINT "FK_11da1bf5c406898262d91b41cbb"` + ) + await db.query( + `ALTER TABLE "stable_swap" DROP CONSTRAINT "FK_88cce14adee6d21f5057551c3ea"` + ) + await db.query( + `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_9a6b55d2085464668b622dffe64"` + ) + await db.query( + `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_0795adc3723792868094ec76c07"` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0"` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027"` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_208d304702d154e73e4f85c978b"` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_86080eda96a6de9c3c60be41d86"` + ) + await db.query( + `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_13ef09b925620aedf12b3342caa"` + ) + await db.query( + `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab"` + ) + await db.query( + `ALTER TABLE "event" DROP CONSTRAINT "FK_2b0d35d675c4f99751855c45021"` + ) + await db.query( + `ALTER TABLE "event" DROP CONSTRAINT "FK_129efedcb305c80256db2d57a59"` + ) + await db.query( + `ALTER TABLE "event" DROP CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452"` + ) + await db.query( + `ALTER TABLE "call" DROP CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3"` + ) + await db.query( + `ALTER TABLE "call" DROP CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590"` + ) + await db.query( + `ALTER TABLE "call" DROP CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95"` + ) + await db.query( + `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74"` + ) + await db.query( + `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_824d47cc4b2cda726405aa507ca"` + ) + } +} diff --git a/nabla-abi/backstop.json b/nabla-abi/backstop.json index 0adea1dd..09c6efbc 100644 --- a/nabla-abi/backstop.json +++ b/nabla-abi/backstop.json @@ -7,7 +7,7 @@ }, "source": { "compiler": "solang 0.3.2", - "hash": "0x026ff1b46ca6ae1d60aed9cea110e48ee635da3087675e463bc717a9c23ffbe1", + "hash": "0xe07d252b0830943a932a082d3b7a46249af166287420ec4cfbc49b3384e48b6c", "language": "Solidity 0.3.2" }, "spec": { @@ -242,6 +242,83 @@ "docs": [""], "label": "OwnershipTransferred" }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "sender", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + }, + { + "docs": [], + "indexed": false, + "label": "swapPool", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + } + ], + "docs": [ + "emitted when a new swap pool is added to the backstop pool for coverage" + ], + "label": "SwapPoolAdded" + }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "sender", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + }, + { + "docs": [], + "indexed": true, + "label": "swapPool", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + }, + { + "docs": [], + "indexed": false, + "label": "insuranceFeeBps", + "type": { + "displayName": ["uint256"], + "type": 3 + } + } + ], + "docs": [ + "emitted when the insurance fee is set for a swap pool" + ], + "label": "InsuranceFeeSet" + }, { "args": [ { @@ -881,7 +958,10 @@ "label": "addSwapPool", "mutates": true, "payable": false, - "returnType": null, + "returnType": { + "displayName": ["bool"], + "type": 4 + }, "selector": "0xabb26587" }, { @@ -910,7 +990,10 @@ "label": "setInsuranceFee", "mutates": true, "payable": false, - "returnType": null, + "returnType": { + "displayName": ["bool"], + "type": 4 + }, "selector": "0xc6a78196" }, { diff --git a/nabla-abi/erc20.json b/nabla-abi/erc20.json index c908ffe9..6a4da62c 100644 --- a/nabla-abi/erc20.json +++ b/nabla-abi/erc20.json @@ -6,7 +6,7 @@ }, "source": { "compiler": "solang 0.3.2", - "hash": "0xd070e8f0df66f4f13a8ee42d5bf90220b1867883444c8f73f400f8c57ae2c9cd", + "hash": "0xfd052826432f969b18f912400fc92fbb97ed4122dd6fa1ee3828bfc81b93e316", "language": "Solidity 0.3.2" }, "spec": { diff --git a/nabla-abi/router.json b/nabla-abi/router.json index eb45a5db..8e06ae68 100644 --- a/nabla-abi/router.json +++ b/nabla-abi/router.json @@ -6,7 +6,7 @@ }, "source": { "compiler": "solang 0.3.2", - "hash": "0xe2399cb35f8b6165c02038216d66719e2f91be30096c0324fc759c0826684bcc", + "hash": "0x1461e0f01fe866142df918dc0c65f8a185e5079d6a642da2b79436f6839db44e", "language": "Solidity 0.3.2" }, "spec": { @@ -29,11 +29,11 @@ }, "balance": { "displayName": ["Balance"], - "type": 7 + "type": 8 }, "blockNumber": { "displayName": ["BlockNumber"], - "type": 8 + "type": 9 }, "chainExtension": { "displayName": [], @@ -41,12 +41,12 @@ }, "hash": { "displayName": ["Hash"], - "type": 9 + "type": 10 }, "maxEventTopics": 4, "timestamp": { "displayName": ["Timestamp"], - "type": 8 + "type": 9 } }, "events": [ @@ -276,7 +276,7 @@ ], "lang_error": { "displayName": ["SolidityError"], - "type": 13 + "type": 14 }, "messages": [ { @@ -583,8 +583,8 @@ "mutates": false, "payable": false, "returnType": { - "displayName": ["uint256"], - "type": 3 + "displayName": ["Router", "getAmountOut", "return_type"], + "type": 7 }, "selector": "0xb8239ebb" } @@ -773,6 +773,15 @@ }, { "id": 7, + "type": { + "def": { + "tuple": [3, 3] + }, + "path": ["Router", "getAmountOut", "return_type"] + } + }, + { + "id": 8, "type": { "def": { "primitive": "u128" @@ -781,7 +790,7 @@ } }, { - "id": 8, + "id": 9, "type": { "def": { "primitive": "u64" @@ -790,7 +799,7 @@ } }, { - "id": 9, + "id": 10, "type": { "def": { "composite": { @@ -805,7 +814,7 @@ } }, { - "id": 10, + "id": 11, "type": { "def": { "primitive": "str" @@ -814,13 +823,13 @@ } }, { - "id": 11, + "id": 12, "type": { "def": { "composite": { "fields": [ { - "type": 10 + "type": 11 } ] } @@ -829,7 +838,7 @@ } }, { - "id": 12, + "id": 13, "type": { "def": { "composite": { @@ -844,7 +853,7 @@ } }, { - "id": 13, + "id": 14, "type": { "def": { "variant": { @@ -852,7 +861,7 @@ { "fields": [ { - "type": 11 + "type": 12 } ], "index": 0, @@ -861,7 +870,7 @@ { "fields": [ { - "type": 12 + "type": 13 } ], "index": 1, diff --git a/nabla-abi/swap.json b/nabla-abi/swap.json index 81e9d943..7366d328 100644 --- a/nabla-abi/swap.json +++ b/nabla-abi/swap.json @@ -7,7 +7,7 @@ }, "source": { "compiler": "solang 0.3.2", - "hash": "0xc473b9f6f31f711534a19a44c15935f3e1ffe0f031cf98b3f5701111dc793f49", + "hash": "0x42108ada7515f8f4ab3ed8cea31e4c3456c433ce52fecb9d3a2afb33c727ab94", "language": "Solidity 0.3.2" }, "spec": { @@ -102,11 +102,11 @@ }, "balance": { "displayName": ["Balance"], - "type": 13 + "type": 14 }, "blockNumber": { "displayName": ["BlockNumber"], - "type": 14 + "type": 15 }, "chainExtension": { "displayName": [], @@ -114,12 +114,12 @@ }, "hash": { "displayName": ["Hash"], - "type": 15 + "type": 16 }, "maxEventTopics": 4, "timestamp": { "displayName": ["Timestamp"], - "type": 14 + "type": 15 } }, "events": [ @@ -275,6 +275,40 @@ "docs": [""], "label": "OwnershipTransferred" }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "sender", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + }, + { + "docs": [], + "indexed": false, + "label": "newProtocolTreasury", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + } + ], + "docs": [ + "emitted when the protocol treasury address is changed" + ], + "label": "ProtocolTreasuryChanged" + }, { "args": [ { @@ -419,7 +453,7 @@ ], "lang_error": { "displayName": ["SolidityError"], - "type": 18 + "type": 19 }, "messages": [ { @@ -857,6 +891,19 @@ }, "selector": "0x0d3a7fd4" }, + { + "args": [], + "default": false, + "docs": [""], + "label": "maxCoverageRatioForSwapIn", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0xb2f3447a" + }, { "args": [], "default": false, @@ -909,19 +956,6 @@ }, "selector": "0xebe26b9e" }, - { - "args": [], - "default": false, - "docs": [""], - "label": "maxCoverageRatioForSwapIn", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["uint256"], - "type": 3 - }, - "selector": "0xb2f3447a" - }, { "args": [ { @@ -1029,6 +1063,31 @@ }, "selector": "0xb9ccf21d" }, + { + "args": [ + { + "label": "_newProtocolTreasury", + "type": { + "displayName": [ + "ink_primitives", + "types", + "AccountId" + ], + "type": 2 + } + } + ], + "default": false, + "docs": ["Set new treasury address"], + "label": "setProtocolTreasury", + "mutates": true, + "payable": false, + "returnType": { + "displayName": ["bool"], + "type": 4 + }, + "selector": "0x0c5a61f8" + }, { "args": [ { @@ -1052,6 +1111,29 @@ }, "selector": "0xb6b55f25" }, + { + "args": [ + { + "label": "_depositAmount", + "type": { + "displayName": ["uint256"], + "type": 3 + } + } + ], + "default": false, + "docs": [ + "Get a quote for the effective amount of tokens for a deposit" + ], + "label": "quoteDeposit", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0xdb431f06" + }, { "args": [ { @@ -1082,6 +1164,29 @@ }, "selector": "0x441a3e70" }, + { + "args": [ + { + "label": "_sharesToBurn", + "type": { + "displayName": ["uint256"], + "type": 3 + } + } + ], + "default": false, + "docs": [ + "Get a quote for the effective amount of tokens for a withdrawal" + ], + "label": "quoteWithdraw", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0xec211840" + }, { "args": [ { @@ -1150,6 +1255,29 @@ }, "selector": "0xc2cb15de" }, + { + "args": [ + { + "label": "_amount", + "type": { + "displayName": ["uint256"], + "type": 3 + } + } + ], + "default": false, + "docs": [ + "Get a quote for the effective amount of tokens for a backstop drain" + ], + "label": "quoteBackstopDrain", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["uint256"], + "type": 3 + }, + "selector": "0xe237fb3d" + }, { "args": [ { @@ -1237,8 +1365,8 @@ "mutates": false, "payable": false, "returnType": { - "displayName": ["uint256"], - "type": 3 + "displayName": ["SwapPool", "quoteSwapOut", "return_type"], + "type": 12 }, "selector": "0x8735c246" }, @@ -1271,7 +1399,7 @@ "payable": false, "returnType": { "displayName": ["SwapPool", "coverage", "return_type"], - "type": 12 + "type": 13 }, "selector": "0xee8f6a0e" }, @@ -1290,33 +1418,6 @@ }, "selector": "0xace0f0d5" }, - { - "args": [ - { - "label": "_liquidityProvider", - "type": { - "displayName": [ - "ink_primitives", - "types", - "AccountId" - ], - "type": 2 - } - } - ], - "default": false, - "docs": [ - "Return the earliest block no that insurance withdrawals are possible." - ], - "label": "insuranceWithdrawalUnlock", - "mutates": false, - "payable": false, - "returnType": { - "displayName": ["uint256"], - "type": 3 - }, - "selector": "0x5c6f4279" - }, { "args": [ { @@ -1575,6 +1676,20 @@ }, "name": "insuranceWithdrawalTimelock" }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0x0000000f", + "ty": 3 + } + }, + "root_key": "0x0000000f" + } + }, + "name": "maxCoverageRatioForSwapIn" + }, { "layout": { "root": { @@ -1584,7 +1699,7 @@ { "layout": { "leaf": { - "key": "0x0000000f", + "key": "0x00000010", "ty": 1 } }, @@ -1594,11 +1709,25 @@ "name": "AccountId" } }, - "root_key": "0x0000000f" + "root_key": "0x00000010" } }, "name": "protocolTreasury" }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0x00000011", + "ty": 3 + } + }, + "root_key": "0x00000011" + } + }, + "name": "latestDepositAtBlockNo" + }, { "layout": { "root": { @@ -1608,20 +1737,38 @@ { "layout": { "leaf": { - "key": "0x00000010", - "ty": 1 + "key": "0x00000012", + "ty": 6 } }, - "name": "" + "name": "lpFee" + }, + { + "layout": { + "leaf": { + "key": "0x00000012", + "ty": 6 + } + }, + "name": "backstopFee" + }, + { + "layout": { + "leaf": { + "key": "0x00000012", + "ty": 6 + } + }, + "name": "protocolFee" } ], - "name": "AccountId" + "name": "SwapFees" } }, - "root_key": "0x00000010" + "root_key": "0x00000012" } }, - "name": "backstop" + "name": "swapFeeConfig" }, { "layout": { @@ -1632,7 +1779,7 @@ { "layout": { "leaf": { - "key": "0x00000011", + "key": "0x00000015", "ty": 1 } }, @@ -1642,10 +1789,10 @@ "name": "AccountId" } }, - "root_key": "0x00000011" + "root_key": "0x00000015" } }, - "name": "router" + "name": "backstop" }, { "layout": { @@ -1656,7 +1803,7 @@ { "layout": { "leaf": { - "key": "0x00000012", + "key": "0x00000016", "ty": 1 } }, @@ -1666,24 +1813,10 @@ "name": "AccountId" } }, - "root_key": "0x00000012" + "root_key": "0x00000016" } }, - "name": "slippageCurve" - }, - { - "layout": { - "root": { - "layout": { - "leaf": { - "key": "0x00000013", - "ty": 3 - } - }, - "root_key": "0x00000013" - } - }, - "name": "latestDepositAtBlockNo" + "name": "router" }, { "layout": { @@ -1694,52 +1827,20 @@ { "layout": { "leaf": { - "key": "0x00000014", - "ty": 6 - } - }, - "name": "lpFee" - }, - { - "layout": { - "leaf": { - "key": "0x00000014", - "ty": 6 - } - }, - "name": "backstopFee" - }, - { - "layout": { - "leaf": { - "key": "0x00000014", - "ty": 6 + "key": "0x00000017", + "ty": 1 } }, - "name": "protocolFee" + "name": "" } ], - "name": "SwapFees" - } - }, - "root_key": "0x00000014" - } - }, - "name": "swapFeeConfig" - }, - { - "layout": { - "root": { - "layout": { - "leaf": { - "key": "0x00000017", - "ty": 3 + "name": "AccountId" } }, "root_key": "0x00000017" } }, - "name": "maxCoverageRatioForSwapIn" + "name": "slippageCurve" } ], "name": "SwapPool" @@ -1879,6 +1980,15 @@ }, { "id": 12, + "type": { + "def": { + "tuple": [3, 3, 3, 3] + }, + "path": ["SwapPool", "quoteSwapOut", "return_type"] + } + }, + { + "id": 13, "type": { "def": { "tuple": [3, 3] @@ -1887,7 +1997,7 @@ } }, { - "id": 13, + "id": 14, "type": { "def": { "primitive": "u128" @@ -1896,7 +2006,7 @@ } }, { - "id": 14, + "id": 15, "type": { "def": { "primitive": "u64" @@ -1905,7 +2015,7 @@ } }, { - "id": 15, + "id": 16, "type": { "def": { "composite": { @@ -1920,7 +2030,7 @@ } }, { - "id": 16, + "id": 17, "type": { "def": { "composite": { @@ -1935,7 +2045,7 @@ } }, { - "id": 17, + "id": 18, "type": { "def": { "composite": { @@ -1950,7 +2060,7 @@ } }, { - "id": 18, + "id": 19, "type": { "def": { "variant": { @@ -1958,7 +2068,7 @@ { "fields": [ { - "type": 16 + "type": 17 } ], "index": 0, @@ -1967,7 +2077,7 @@ { "fields": [ { - "type": 17 + "type": 18 } ], "index": 1, diff --git a/squid-foucoco.yaml b/squid-foucoco.yaml index 188af4df..47455306 100644 --- a/squid-foucoco.yaml +++ b/squid-foucoco.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: foucoco-squid -version: 18 +version: 17 description: 'Foucoco Squid' build: deploy: diff --git a/src/abi/backstop.ts b/src/abi/backstop.ts index 4858086d..a5eba2e7 100644 --- a/src/abi/backstop.ts +++ b/src/abi/backstop.ts @@ -10,7 +10,7 @@ export const metadata = { }, source: { compiler: 'solang 0.3.2', - hash: '0x026ff1b46ca6ae1d60aed9cea110e48ee635da3087675e463bc717a9c23ffbe1', + hash: '0xe07d252b0830943a932a082d3b7a46249af166287420ec4cfbc49b3384e48b6c', language: 'Solidity 0.3.2', }, spec: { @@ -245,6 +245,81 @@ export const metadata = { docs: [''], label: 'OwnershipTransferred', }, + { + args: [ + { + docs: [], + indexed: true, + label: 'sender', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + { + docs: [], + indexed: false, + label: 'swapPool', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + ], + docs: [ + 'emitted when a new swap pool is added to the backstop pool for coverage', + ], + label: 'SwapPoolAdded', + }, + { + args: [ + { + docs: [], + indexed: true, + label: 'sender', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + { + docs: [], + indexed: true, + label: 'swapPool', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + { + docs: [], + indexed: false, + label: 'insuranceFeeBps', + type: { + displayName: ['uint256'], + type: 3, + }, + }, + ], + docs: ['emitted when the insurance fee is set for a swap pool'], + label: 'InsuranceFeeSet', + }, { args: [ { @@ -884,7 +959,10 @@ export const metadata = { label: 'addSwapPool', mutates: true, payable: false, - returnType: null, + returnType: { + displayName: ['bool'], + type: 4, + }, selector: '0xabb26587', }, { @@ -913,7 +991,10 @@ export const metadata = { label: 'setInsuranceFee', mutates: true, payable: false, - returnType: null, + returnType: { + displayName: ['bool'], + type: 4, + }, selector: '0xc6a78196', }, { @@ -2060,9 +2141,11 @@ export type Event = | Event_Approval | Event_Burn | Event_CoverSwapWithdrawal + | Event_InsuranceFeeSet | Event_Mint | Event_OwnershipTransferred | Event_Paused + | Event_SwapPoolAdded | Event_Transfer | Event_Unpaused | Event_WithdrawSwapLiquidity @@ -2090,6 +2173,13 @@ export interface Event_CoverSwapWithdrawal { amountBackstopTokens: uint256 } +export interface Event_InsuranceFeeSet { + __kind: 'InsuranceFeeSet' + sender: AccountId + swapPool: AccountId + insuranceFeeBps: uint256 +} + export interface Event_Mint { __kind: 'Mint' sender: AccountId @@ -2108,6 +2198,12 @@ export interface Event_Paused { account: AccountId } +export interface Event_SwapPoolAdded { + __kind: 'SwapPoolAdded' + sender: AccountId + swapPool: AccountId +} + export interface Event_Transfer { __kind: 'Transfer' from: AccountId diff --git a/src/abi/erc20.ts b/src/abi/erc20.ts index 93fc16d0..2192c0f0 100644 --- a/src/abi/erc20.ts +++ b/src/abi/erc20.ts @@ -8,7 +8,7 @@ export const metadata = { }, source: { compiler: 'solang 0.3.2', - hash: '0xd070e8f0df66f4f13a8ee42d5bf90220b1867883444c8f73f400f8c57ae2c9cd', + hash: '0xfd052826432f969b18f912400fc92fbb97ed4122dd6fa1ee3828bfc81b93e316', language: 'Solidity 0.3.2', }, spec: { diff --git a/src/abi/router.ts b/src/abi/router.ts index 231e9e7d..e6f4af1e 100644 --- a/src/abi/router.ts +++ b/src/abi/router.ts @@ -8,7 +8,7 @@ export const metadata = { }, source: { compiler: 'solang 0.3.2', - hash: '0xe2399cb35f8b6165c02038216d66719e2f91be30096c0324fc759c0826684bcc', + hash: '0x1461e0f01fe866142df918dc0c65f8a185e5079d6a642da2b79436f6839db44e', language: 'Solidity 0.3.2', }, spec: { @@ -31,11 +31,11 @@ export const metadata = { }, balance: { displayName: ['Balance'], - type: 7, + type: 8, }, blockNumber: { displayName: ['BlockNumber'], - type: 8, + type: 9, }, chainExtension: { displayName: [], @@ -43,12 +43,12 @@ export const metadata = { }, hash: { displayName: ['Hash'], - type: 9, + type: 10, }, maxEventTopics: 4, timestamp: { displayName: ['Timestamp'], - type: 8, + type: 9, }, }, events: [ @@ -278,7 +278,7 @@ export const metadata = { ], lang_error: { displayName: ['SolidityError'], - type: 13, + type: 14, }, messages: [ { @@ -585,8 +585,8 @@ export const metadata = { mutates: false, payable: false, returnType: { - displayName: ['uint256'], - type: 3, + displayName: ['Router', 'getAmountOut', 'return_type'], + type: 7, }, selector: '0xb8239ebb', }, @@ -775,6 +775,15 @@ export const metadata = { }, { id: 7, + type: { + def: { + tuple: [3, 3], + }, + path: ['Router', 'getAmountOut', 'return_type'], + }, + }, + { + id: 8, type: { def: { primitive: 'u128', @@ -783,7 +792,7 @@ export const metadata = { }, }, { - id: 8, + id: 9, type: { def: { primitive: 'u64', @@ -792,7 +801,7 @@ export const metadata = { }, }, { - id: 9, + id: 10, type: { def: { composite: { @@ -807,7 +816,7 @@ export const metadata = { }, }, { - id: 10, + id: 11, type: { def: { primitive: 'str', @@ -816,13 +825,13 @@ export const metadata = { }, }, { - id: 11, + id: 12, type: { def: { composite: { fields: [ { - type: 10, + type: 11, }, ], }, @@ -831,7 +840,7 @@ export const metadata = { }, }, { - id: 12, + id: 13, type: { def: { composite: { @@ -846,7 +855,7 @@ export const metadata = { }, }, { - id: 13, + id: 14, type: { def: { variant: { @@ -854,7 +863,7 @@ export const metadata = { { fields: [ { - type: 11, + type: 12, }, ], index: 0, @@ -863,7 +872,7 @@ export const metadata = { { fields: [ { - type: 12, + type: 13, }, ], index: 1, @@ -929,7 +938,7 @@ export class Contract { getAmountOut( _amountIn: uint256, _tokenInOut: AccountId[] - ): Promise { + ): Promise { return this.stateCall('0xb8239ebb', [_amountIn, _tokenInOut]) } @@ -946,6 +955,8 @@ export class Contract { } } +export type return_type = [uint256, uint256] + export type uint256 = bigint export type AccountId = Bytes diff --git a/src/abi/swap.ts b/src/abi/swap.ts index e91b5621..9aa49fa9 100644 --- a/src/abi/swap.ts +++ b/src/abi/swap.ts @@ -10,7 +10,7 @@ export const metadata = { }, source: { compiler: 'solang 0.3.2', - hash: '0xc473b9f6f31f711534a19a44c15935f3e1ffe0f031cf98b3f5701111dc793f49', + hash: '0x42108ada7515f8f4ab3ed8cea31e4c3456c433ce52fecb9d3a2afb33c727ab94', language: 'Solidity 0.3.2', }, spec: { @@ -105,11 +105,11 @@ export const metadata = { }, balance: { displayName: ['Balance'], - type: 13, + type: 14, }, blockNumber: { displayName: ['BlockNumber'], - type: 14, + type: 15, }, chainExtension: { displayName: [], @@ -117,12 +117,12 @@ export const metadata = { }, hash: { displayName: ['Hash'], - type: 15, + type: 16, }, maxEventTopics: 4, timestamp: { displayName: ['Timestamp'], - type: 14, + type: 15, }, }, events: [ @@ -278,6 +278,38 @@ export const metadata = { docs: [''], label: 'OwnershipTransferred', }, + { + args: [ + { + docs: [], + indexed: true, + label: 'sender', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + { + docs: [], + indexed: false, + label: 'newProtocolTreasury', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + ], + docs: ['emitted when the protocol treasury address is changed'], + label: 'ProtocolTreasuryChanged', + }, { args: [ { @@ -422,7 +454,7 @@ export const metadata = { ], lang_error: { displayName: ['SolidityError'], - type: 18, + type: 19, }, messages: [ { @@ -860,6 +892,19 @@ export const metadata = { }, selector: '0x0d3a7fd4', }, + { + args: [], + default: false, + docs: [''], + label: 'maxCoverageRatioForSwapIn', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0xb2f3447a', + }, { args: [], default: false, @@ -912,19 +957,6 @@ export const metadata = { }, selector: '0xebe26b9e', }, - { - args: [], - default: false, - docs: [''], - label: 'maxCoverageRatioForSwapIn', - mutates: false, - payable: false, - returnType: { - displayName: ['uint256'], - type: 3, - }, - selector: '0xb2f3447a', - }, { args: [ { @@ -1032,6 +1064,31 @@ export const metadata = { }, selector: '0xb9ccf21d', }, + { + args: [ + { + label: '_newProtocolTreasury', + type: { + displayName: [ + 'ink_primitives', + 'types', + 'AccountId', + ], + type: 2, + }, + }, + ], + default: false, + docs: ['Set new treasury address'], + label: 'setProtocolTreasury', + mutates: true, + payable: false, + returnType: { + displayName: ['bool'], + type: 4, + }, + selector: '0x0c5a61f8', + }, { args: [ { @@ -1055,6 +1112,29 @@ export const metadata = { }, selector: '0xb6b55f25', }, + { + args: [ + { + label: '_depositAmount', + type: { + displayName: ['uint256'], + type: 3, + }, + }, + ], + default: false, + docs: [ + 'Get a quote for the effective amount of tokens for a deposit', + ], + label: 'quoteDeposit', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0xdb431f06', + }, { args: [ { @@ -1085,6 +1165,29 @@ export const metadata = { }, selector: '0x441a3e70', }, + { + args: [ + { + label: '_sharesToBurn', + type: { + displayName: ['uint256'], + type: 3, + }, + }, + ], + default: false, + docs: [ + 'Get a quote for the effective amount of tokens for a withdrawal', + ], + label: 'quoteWithdraw', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0xec211840', + }, { args: [ { @@ -1153,6 +1256,29 @@ export const metadata = { }, selector: '0xc2cb15de', }, + { + args: [ + { + label: '_amount', + type: { + displayName: ['uint256'], + type: 3, + }, + }, + ], + default: false, + docs: [ + 'Get a quote for the effective amount of tokens for a backstop drain', + ], + label: 'quoteBackstopDrain', + mutates: false, + payable: false, + returnType: { + displayName: ['uint256'], + type: 3, + }, + selector: '0xe237fb3d', + }, { args: [ { @@ -1240,8 +1366,8 @@ export const metadata = { mutates: false, payable: false, returnType: { - displayName: ['uint256'], - type: 3, + displayName: ['SwapPool', 'quoteSwapOut', 'return_type'], + type: 12, }, selector: '0x8735c246', }, @@ -1274,7 +1400,7 @@ export const metadata = { payable: false, returnType: { displayName: ['SwapPool', 'coverage', 'return_type'], - type: 12, + type: 13, }, selector: '0xee8f6a0e', }, @@ -1293,33 +1419,6 @@ export const metadata = { }, selector: '0xace0f0d5', }, - { - args: [ - { - label: '_liquidityProvider', - type: { - displayName: [ - 'ink_primitives', - 'types', - 'AccountId', - ], - type: 2, - }, - }, - ], - default: false, - docs: [ - 'Return the earliest block no that insurance withdrawals are possible.', - ], - label: 'insuranceWithdrawalUnlock', - mutates: false, - payable: false, - returnType: { - displayName: ['uint256'], - type: 3, - }, - selector: '0x5c6f4279', - }, { args: [ { @@ -1578,6 +1677,20 @@ export const metadata = { }, name: 'insuranceWithdrawalTimelock', }, + { + layout: { + root: { + layout: { + leaf: { + key: '0x0000000f', + ty: 3, + }, + }, + root_key: '0x0000000f', + }, + }, + name: 'maxCoverageRatioForSwapIn', + }, { layout: { root: { @@ -1587,7 +1700,7 @@ export const metadata = { { layout: { leaf: { - key: '0x0000000f', + key: '0x00000010', ty: 1, }, }, @@ -1597,11 +1710,25 @@ export const metadata = { name: 'AccountId', }, }, - root_key: '0x0000000f', + root_key: '0x00000010', }, }, name: 'protocolTreasury', }, + { + layout: { + root: { + layout: { + leaf: { + key: '0x00000011', + ty: 3, + }, + }, + root_key: '0x00000011', + }, + }, + name: 'latestDepositAtBlockNo', + }, { layout: { root: { @@ -1611,20 +1738,38 @@ export const metadata = { { layout: { leaf: { - key: '0x00000010', - ty: 1, + key: '0x00000012', + ty: 6, }, }, - name: '', + name: 'lpFee', + }, + { + layout: { + leaf: { + key: '0x00000012', + ty: 6, + }, + }, + name: 'backstopFee', + }, + { + layout: { + leaf: { + key: '0x00000012', + ty: 6, + }, + }, + name: 'protocolFee', }, ], - name: 'AccountId', + name: 'SwapFees', }, }, - root_key: '0x00000010', + root_key: '0x00000012', }, }, - name: 'backstop', + name: 'swapFeeConfig', }, { layout: { @@ -1635,7 +1780,7 @@ export const metadata = { { layout: { leaf: { - key: '0x00000011', + key: '0x00000015', ty: 1, }, }, @@ -1645,10 +1790,10 @@ export const metadata = { name: 'AccountId', }, }, - root_key: '0x00000011', + root_key: '0x00000015', }, }, - name: 'router', + name: 'backstop', }, { layout: { @@ -1659,7 +1804,7 @@ export const metadata = { { layout: { leaf: { - key: '0x00000012', + key: '0x00000016', ty: 1, }, }, @@ -1669,24 +1814,10 @@ export const metadata = { name: 'AccountId', }, }, - root_key: '0x00000012', + root_key: '0x00000016', }, }, - name: 'slippageCurve', - }, - { - layout: { - root: { - layout: { - leaf: { - key: '0x00000013', - ty: 3, - }, - }, - root_key: '0x00000013', - }, - }, - name: 'latestDepositAtBlockNo', + name: 'router', }, { layout: { @@ -1697,52 +1828,20 @@ export const metadata = { { layout: { leaf: { - key: '0x00000014', - ty: 6, - }, - }, - name: 'lpFee', - }, - { - layout: { - leaf: { - key: '0x00000014', - ty: 6, - }, - }, - name: 'backstopFee', - }, - { - layout: { - leaf: { - key: '0x00000014', - ty: 6, + key: '0x00000017', + ty: 1, }, }, - name: 'protocolFee', + name: '', }, ], - name: 'SwapFees', - }, - }, - root_key: '0x00000014', - }, - }, - name: 'swapFeeConfig', - }, - { - layout: { - root: { - layout: { - leaf: { - key: '0x00000017', - ty: 3, + name: 'AccountId', }, }, root_key: '0x00000017', }, }, - name: 'maxCoverageRatioForSwapIn', + name: 'slippageCurve', }, ], name: 'SwapPool', @@ -1882,6 +1981,15 @@ export const metadata = { }, { id: 12, + type: { + def: { + tuple: [3, 3, 3, 3], + }, + path: ['SwapPool', 'quoteSwapOut', 'return_type'], + }, + }, + { + id: 13, type: { def: { tuple: [3, 3], @@ -1890,7 +1998,7 @@ export const metadata = { }, }, { - id: 13, + id: 14, type: { def: { primitive: 'u128', @@ -1899,7 +2007,7 @@ export const metadata = { }, }, { - id: 14, + id: 15, type: { def: { primitive: 'u64', @@ -1908,7 +2016,7 @@ export const metadata = { }, }, { - id: 15, + id: 16, type: { def: { composite: { @@ -1923,7 +2031,7 @@ export const metadata = { }, }, { - id: 16, + id: 17, type: { def: { composite: { @@ -1938,7 +2046,7 @@ export const metadata = { }, }, { - id: 17, + id: 18, type: { def: { composite: { @@ -1953,7 +2061,7 @@ export const metadata = { }, }, { - id: 18, + id: 19, type: { def: { variant: { @@ -1961,7 +2069,7 @@ export const metadata = { { fields: [ { - type: 16, + type: 17, }, ], index: 0, @@ -1970,7 +2078,7 @@ export const metadata = { { fields: [ { - type: 17, + type: 18, }, ], index: 1, @@ -2077,6 +2185,10 @@ export class Contract { return this.stateCall('0x0d3a7fd4', []) } + maxCoverageRatioForSwapIn(): Promise { + return this.stateCall('0xb2f3447a', []) + } + protocolTreasury(): Promise { return this.stateCall('0x803db96d', []) } @@ -2093,19 +2205,29 @@ export class Contract { return this.stateCall('0xebe26b9e', []) } - maxCoverageRatioForSwapIn(): Promise { - return this.stateCall('0xb2f3447a', []) - } - swapFees(): Promise { return this.stateCall('0xb9ccf21d', []) } + quoteDeposit(_depositAmount: uint256): Promise { + return this.stateCall('0xdb431f06', [_depositAmount]) + } + + quoteWithdraw(_sharesToBurn: uint256): Promise { + return this.stateCall('0xec211840', [_sharesToBurn]) + } + + quoteBackstopDrain(_amount: uint256): Promise { + return this.stateCall('0xe237fb3d', [_amount]) + } + quoteSwapInto(_amount: uint256): Promise { return this.stateCall('0x3c945248', [_amount]) } - quoteSwapOut(_amount: uint256): Promise { + quoteSwapOut( + _amount: uint256 + ): Promise<[uint256, uint256, uint256, uint256]> { return this.stateCall('0x8735c246', [_amount]) } @@ -2117,10 +2239,6 @@ export class Contract { return this.stateCall('0xace0f0d5', []) } - insuranceWithdrawalUnlock(_liquidityProvider: AccountId): Promise { - return this.stateCall('0x5c6f4279', [_liquidityProvider]) - } - sharesTargetWorth(_sharesToBurn: uint256): Promise { return this.stateCall('0xcc045745', [_sharesToBurn]) } @@ -2182,7 +2300,6 @@ export type Message = | Message_getExcessLiquidity | Message_increaseAllowance | Message_insuranceWithdrawalTimelock - | Message_insuranceWithdrawalUnlock | Message_maxCoverageRatioForSwapIn | Message_name | Message_owner @@ -2190,8 +2307,11 @@ export type Message = | Message_paused | Message_poolCap | Message_protocolTreasury + | Message_quoteBackstopDrain + | Message_quoteDeposit | Message_quoteSwapInto | Message_quoteSwapOut + | Message_quoteWithdraw | Message_renounceOwnership | Message_reserve | Message_reserveWithSlippage @@ -2199,6 +2319,7 @@ export type Message = | Message_setInsuranceWithdrawalTimelock | Message_setMaxCoverageRatioForSwapIn | Message_setPoolCap + | Message_setProtocolTreasury | Message_setSwapFees | Message_sharesTargetWorth | Message_slippageCurve @@ -2336,14 +2457,6 @@ export interface Message_insuranceWithdrawalTimelock { __kind: 'insuranceWithdrawalTimelock' } -/** - * Return the earliest block no that insurance withdrawals are possible. - */ -export interface Message_insuranceWithdrawalUnlock { - __kind: 'insuranceWithdrawalUnlock' - liquidityProvider: AccountId -} - /** * */ @@ -2393,6 +2506,22 @@ export interface Message_protocolTreasury { __kind: 'protocolTreasury' } +/** + * Get a quote for the effective amount of tokens for a backstop drain + */ +export interface Message_quoteBackstopDrain { + __kind: 'quoteBackstopDrain' + amount: uint256 +} + +/** + * Get a quote for the effective amount of tokens for a deposit + */ +export interface Message_quoteDeposit { + __kind: 'quoteDeposit' + depositAmount: uint256 +} + /** * Get a quote for the effective amount of tokens for a swap into */ @@ -2409,6 +2538,14 @@ export interface Message_quoteSwapOut { amount: uint256 } +/** + * Get a quote for the effective amount of tokens for a withdrawal + */ +export interface Message_quoteWithdraw { + __kind: 'quoteWithdraw' + sharesToBurn: uint256 +} + /** * */ @@ -2461,6 +2598,14 @@ export interface Message_setPoolCap { maxTokens: uint256 } +/** + * Set new treasury address + */ +export interface Message_setProtocolTreasury { + __kind: 'setProtocolTreasury' + newProtocolTreasury: AccountId +} + /** * Set swap fees (applied when swapping funds out of the pool) */ @@ -2581,6 +2726,7 @@ export type Event = | Event_Mint | Event_OwnershipTransferred | Event_Paused + | Event_ProtocolTreasuryChanged | Event_Transfer | Event_Unpaused @@ -2629,6 +2775,12 @@ export interface Event_Paused { account: AccountId } +export interface Event_ProtocolTreasuryChanged { + __kind: 'ProtocolTreasuryChanged' + sender: AccountId + newProtocolTreasury: AccountId +} + export interface Event_Transfer { __kind: 'Transfer' from: AccountId diff --git a/src/types/amplitude/index.ts b/src/types/amplitude/index.ts index c086d212..d50d567d 100644 --- a/src/types/amplitude/index.ts +++ b/src/types/amplitude/index.ts @@ -4,5 +4,6 @@ export * as v8 from './v8' export * as v10 from './v10' export * as v12 from './v12' export * as v7 from './v7' +export * as v15 from './v15' export * as events from './events' export * as storage from './storage' diff --git a/src/types/amplitude/system/storage.ts b/src/types/amplitude/system/storage.ts index 48ce39b8..643bb19c 100644 --- a/src/types/amplitude/system/storage.ts +++ b/src/types/amplitude/system/storage.ts @@ -8,6 +8,7 @@ import { RuntimeCtx, } from '../support' import * as v1 from '../v1' +import * as v15 from '../v15' export const account = { /** @@ -19,6 +20,15 @@ export const account = { [v1.AccountId32], v1.AccountInfo ) as AccountV1, + /** + * The full account information for a particular account ID. + */ + v15: new StorageType( + 'System.Account', + 'Default', + [v15.AccountId32], + v15.AccountInfo + ) as AccountV15, } /** @@ -61,6 +71,49 @@ export interface AccountV1 { ): AsyncIterable<[k: v1.AccountId32, v: v1.AccountInfo | undefined][]> } +/** + * The full account information for a particular account ID. + */ +export interface AccountV15 { + is(block: RuntimeCtx): boolean + getDefault(block: Block): v15.AccountInfo + get( + block: Block, + key: v15.AccountId32 + ): Promise + getMany( + block: Block, + keys: v15.AccountId32[] + ): Promise<(v15.AccountInfo | undefined)[]> + getKeys(block: Block): Promise + getKeys(block: Block, key: v15.AccountId32): Promise + getKeysPaged( + pageSize: number, + block: Block + ): AsyncIterable + getKeysPaged( + pageSize: number, + block: Block, + key: v15.AccountId32 + ): AsyncIterable + getPairs( + block: Block + ): Promise<[k: v15.AccountId32, v: v15.AccountInfo | undefined][]> + getPairs( + block: Block, + key: v15.AccountId32 + ): Promise<[k: v15.AccountId32, v: v15.AccountInfo | undefined][]> + getPairsPaged( + pageSize: number, + block: Block + ): AsyncIterable<[k: v15.AccountId32, v: v15.AccountInfo | undefined][]> + getPairsPaged( + pageSize: number, + block: Block, + key: v15.AccountId32 + ): AsyncIterable<[k: v15.AccountId32, v: v15.AccountInfo | undefined][]> +} + export const blockHash = { /** * Map of block numbers to block hashes. diff --git a/src/types/amplitude/v15.ts b/src/types/amplitude/v15.ts new file mode 100644 index 00000000..7b28ce29 --- /dev/null +++ b/src/types/amplitude/v15.ts @@ -0,0 +1,43 @@ +import { sts, Result, Option, Bytes, BitSequence } from './support' + +export type AccountId32 = Bytes + +export interface AccountInfo { + nonce: number + consumers: number + providers: number + sufficients: number + data: AccountData +} + +export interface AccountData { + free: bigint + reserved: bigint + frozen: bigint + flags: ExtraFlags +} + +export type ExtraFlags = bigint + +export const AccountInfo: sts.Type = sts.struct(() => { + return { + nonce: sts.number(), + consumers: sts.number(), + providers: sts.number(), + sufficients: sts.number(), + data: AccountData, + } +}) + +export const AccountData: sts.Type = sts.struct(() => { + return { + free: sts.bigint(), + reserved: sts.bigint(), + frozen: sts.bigint(), + flags: ExtraFlags, + } +}) + +export const ExtraFlags = sts.bigint() + +export const AccountId32 = sts.bytes() diff --git a/src/types/foucoco/index.ts b/src/types/foucoco/index.ts index f8c88af0..8b12e8b8 100644 --- a/src/types/foucoco/index.ts +++ b/src/types/foucoco/index.ts @@ -1,4 +1,5 @@ export * as v1 from './v1' export * as v4 from './v4' +export * as v13 from './v13' export * as events from './events' export * as storage from './storage' diff --git a/src/types/foucoco/system/storage.ts b/src/types/foucoco/system/storage.ts index 48ce39b8..9b7f7533 100644 --- a/src/types/foucoco/system/storage.ts +++ b/src/types/foucoco/system/storage.ts @@ -8,6 +8,7 @@ import { RuntimeCtx, } from '../support' import * as v1 from '../v1' +import * as v13 from '../v13' export const account = { /** @@ -19,6 +20,15 @@ export const account = { [v1.AccountId32], v1.AccountInfo ) as AccountV1, + /** + * The full account information for a particular account ID. + */ + v13: new StorageType( + 'System.Account', + 'Default', + [v13.AccountId32], + v13.AccountInfo + ) as AccountV13, } /** @@ -61,6 +71,49 @@ export interface AccountV1 { ): AsyncIterable<[k: v1.AccountId32, v: v1.AccountInfo | undefined][]> } +/** + * The full account information for a particular account ID. + */ +export interface AccountV13 { + is(block: RuntimeCtx): boolean + getDefault(block: Block): v13.AccountInfo + get( + block: Block, + key: v13.AccountId32 + ): Promise + getMany( + block: Block, + keys: v13.AccountId32[] + ): Promise<(v13.AccountInfo | undefined)[]> + getKeys(block: Block): Promise + getKeys(block: Block, key: v13.AccountId32): Promise + getKeysPaged( + pageSize: number, + block: Block + ): AsyncIterable + getKeysPaged( + pageSize: number, + block: Block, + key: v13.AccountId32 + ): AsyncIterable + getPairs( + block: Block + ): Promise<[k: v13.AccountId32, v: v13.AccountInfo | undefined][]> + getPairs( + block: Block, + key: v13.AccountId32 + ): Promise<[k: v13.AccountId32, v: v13.AccountInfo | undefined][]> + getPairsPaged( + pageSize: number, + block: Block + ): AsyncIterable<[k: v13.AccountId32, v: v13.AccountInfo | undefined][]> + getPairsPaged( + pageSize: number, + block: Block, + key: v13.AccountId32 + ): AsyncIterable<[k: v13.AccountId32, v: v13.AccountInfo | undefined][]> +} + export const blockHash = { /** * Map of block numbers to block hashes. diff --git a/src/types/foucoco/v13.ts b/src/types/foucoco/v13.ts new file mode 100644 index 00000000..7b28ce29 --- /dev/null +++ b/src/types/foucoco/v13.ts @@ -0,0 +1,43 @@ +import { sts, Result, Option, Bytes, BitSequence } from './support' + +export type AccountId32 = Bytes + +export interface AccountInfo { + nonce: number + consumers: number + providers: number + sufficients: number + data: AccountData +} + +export interface AccountData { + free: bigint + reserved: bigint + frozen: bigint + flags: ExtraFlags +} + +export type ExtraFlags = bigint + +export const AccountInfo: sts.Type = sts.struct(() => { + return { + nonce: sts.number(), + consumers: sts.number(), + providers: sts.number(), + sufficients: sts.number(), + data: AccountData, + } +}) + +export const AccountData: sts.Type = sts.struct(() => { + return { + free: sts.bigint(), + reserved: sts.bigint(), + frozen: sts.bigint(), + flags: ExtraFlags, + } +}) + +export const ExtraFlags = sts.bigint() + +export const AccountId32 = sts.bytes() diff --git a/src/types/pendulum/index.ts b/src/types/pendulum/index.ts index 0740e313..77d549e7 100644 --- a/src/types/pendulum/index.ts +++ b/src/types/pendulum/index.ts @@ -2,5 +2,6 @@ export * as v1 from './v1' export * as v3 from './v3' export * as v9 from './v9' export * as v10 from './v10' +export * as v15 from './v15' export * as events from './events' export * as storage from './storage' diff --git a/src/types/pendulum/system/storage.ts b/src/types/pendulum/system/storage.ts index 48ce39b8..643bb19c 100644 --- a/src/types/pendulum/system/storage.ts +++ b/src/types/pendulum/system/storage.ts @@ -8,6 +8,7 @@ import { RuntimeCtx, } from '../support' import * as v1 from '../v1' +import * as v15 from '../v15' export const account = { /** @@ -19,6 +20,15 @@ export const account = { [v1.AccountId32], v1.AccountInfo ) as AccountV1, + /** + * The full account information for a particular account ID. + */ + v15: new StorageType( + 'System.Account', + 'Default', + [v15.AccountId32], + v15.AccountInfo + ) as AccountV15, } /** @@ -61,6 +71,49 @@ export interface AccountV1 { ): AsyncIterable<[k: v1.AccountId32, v: v1.AccountInfo | undefined][]> } +/** + * The full account information for a particular account ID. + */ +export interface AccountV15 { + is(block: RuntimeCtx): boolean + getDefault(block: Block): v15.AccountInfo + get( + block: Block, + key: v15.AccountId32 + ): Promise + getMany( + block: Block, + keys: v15.AccountId32[] + ): Promise<(v15.AccountInfo | undefined)[]> + getKeys(block: Block): Promise + getKeys(block: Block, key: v15.AccountId32): Promise + getKeysPaged( + pageSize: number, + block: Block + ): AsyncIterable + getKeysPaged( + pageSize: number, + block: Block, + key: v15.AccountId32 + ): AsyncIterable + getPairs( + block: Block + ): Promise<[k: v15.AccountId32, v: v15.AccountInfo | undefined][]> + getPairs( + block: Block, + key: v15.AccountId32 + ): Promise<[k: v15.AccountId32, v: v15.AccountInfo | undefined][]> + getPairsPaged( + pageSize: number, + block: Block + ): AsyncIterable<[k: v15.AccountId32, v: v15.AccountInfo | undefined][]> + getPairsPaged( + pageSize: number, + block: Block, + key: v15.AccountId32 + ): AsyncIterable<[k: v15.AccountId32, v: v15.AccountInfo | undefined][]> +} + export const blockHash = { /** * Map of block numbers to block hashes. diff --git a/src/types/pendulum/v15.ts b/src/types/pendulum/v15.ts new file mode 100644 index 00000000..7b28ce29 --- /dev/null +++ b/src/types/pendulum/v15.ts @@ -0,0 +1,43 @@ +import { sts, Result, Option, Bytes, BitSequence } from './support' + +export type AccountId32 = Bytes + +export interface AccountInfo { + nonce: number + consumers: number + providers: number + sufficients: number + data: AccountData +} + +export interface AccountData { + free: bigint + reserved: bigint + frozen: bigint + flags: ExtraFlags +} + +export type ExtraFlags = bigint + +export const AccountInfo: sts.Type = sts.struct(() => { + return { + nonce: sts.number(), + consumers: sts.number(), + providers: sts.number(), + sufficients: sts.number(), + data: AccountData, + } +}) + +export const AccountData: sts.Type = sts.struct(() => { + return { + free: sts.bigint(), + reserved: sts.bigint(), + frozen: sts.bigint(), + flags: ExtraFlags, + } +}) + +export const ExtraFlags = sts.bigint() + +export const AccountId32 = sts.bytes() From a6cecc8d4a1a4fb8fc630ef6813098d1c97b72ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Thu, 25 Apr 2024 04:07:07 -0300 Subject: [PATCH 11/20] Update generated files --- db/migrations/1714028795707-Data.js | 885 ++++++++++++++++++++++++++++ src/abi/backstop.ts | 8 +- src/abi/erc20.ts | 8 +- src/abi/router.ts | 8 +- src/abi/swap.ts | 8 +- 5 files changed, 901 insertions(+), 16 deletions(-) create mode 100644 db/migrations/1714028795707-Data.js diff --git a/db/migrations/1714028795707-Data.js b/db/migrations/1714028795707-Data.js new file mode 100644 index 00000000..d99dbda6 --- /dev/null +++ b/db/migrations/1714028795707-Data.js @@ -0,0 +1,885 @@ +module.exports = class Data1714028795707 { + name = 'Data1714028795707' + + async up(db) { + await db.query( + `CREATE TABLE "oracle_price" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "blockchain" text NOT NULL, "timestamp" numeric NOT NULL, "price" text NOT NULL, "supply" text NOT NULL, "decimals" integer NOT NULL, CONSTRAINT "PK_606c938b2474588b154eb625f3b" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_6554f47abd46667280a2523381" ON "oracle_price" ("symbol") ` + ) + await db.query( + `CREATE INDEX "IDX_2026224855490e321e5c0b6911" ON "oracle_price" ("blockchain") ` + ) + await db.query( + `CREATE INDEX "IDX_a77ac6d79f0929522f5a1aefcb" ON "oracle_price" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_f7c9bf3bae39fb0a75f12b87dd" ON "oracle_price" ("price") ` + ) + await db.query( + `CREATE TABLE "transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "amount" numeric NOT NULL, "fee" numeric NOT NULL, "remark" text, CONSTRAINT "PK_fd9ddbdd49a17afcbe014401295" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_d6624eacc30144ea97915fe846" ON "transfer" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_70ff8b624c3118ac3a4862d22c" ON "transfer" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_070c555a86b0b41a534a55a659" ON "transfer" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_f4007436c1b546ede08a4fd7ab" ON "transfer" ("amount") ` + ) + await db.query( + `CREATE TABLE "factory" ("id" character varying NOT NULL, "pair_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_volume_eth" text NOT NULL, "untracked_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_1372e5a7d114a3fa80736ba66bb" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "stable_swap_event" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_8b61dbc9b556ed8fcb4030fee7d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_3a147c85b92441217540579be8" ON "stable_swap_event" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_exchange" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_f06e489da865134dcfac3bbcd22" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_1180a78feea28e278229de7db4" ON "stable_swap_exchange" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_819b3b7bf9c8055e14e0bf1c578" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_648b49eb1a4f2a47f24f13bb51" ON "stable_swap_day_data" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "hourly_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_2aedd41b95c37330a4a8429e192" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_94584d2925c30ae0d4b80aadfc" ON "stable_swap_hour_data" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "token_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_token" text NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "total_liquidity_token" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_liquidity_usd" text NOT NULL, "price_usd" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_73fc06337215e86196b36822116" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_b8950a8bc7b60231137573740e" ON "token_day_data" ("token_id") ` + ) + await db.query( + `CREATE TABLE "pair_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "hourly_volume_token0" text NOT NULL, "hourly_volume_token1" text NOT NULL, "hourly_volume_usd" text NOT NULL, "hourly_txns" integer NOT NULL, "pair_id" character varying, CONSTRAINT "PK_ffc544bb3e72cfd3e48a8b01452" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_cf50c55389e428096a68598ee3" ON "pair_hour_data" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "stable_swap_id" character varying, CONSTRAINT "PK_12f435243c8a739330c0881d720" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_f953aebc7c0752f6b8434c9eef" ON "stable_swap_liquidity_position" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_405e0d7aeca80975d88a63bc6e" ON "stable_swap_liquidity_position" ("stable_swap_id") ` + ) + await db.query( + `CREATE TABLE "stake_position" ("id" character varying NOT NULL, "liquidity_staked_balance" numeric NOT NULL, "user_id" character varying, "farm_id" character varying, CONSTRAINT "PK_17615803509bd6065f1ab8b0ced" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_2a2b22d2744b497bbcfb03e6ab" ON "stake_position" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_670629d9904e1f48f4a31abb49" ON "stake_position" ("farm_id") ` + ) + await db.query( + `CREATE TABLE "user" ("id" character varying NOT NULL, "usd_swapped" text NOT NULL, CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_db00d963c96b3914d26abe3c3d2" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_781470585a67fef4e215a59977" ON "liquidity_position" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_5a626c8b8962dc01e0f8801be6" ON "liquidity_position" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "liquidity_position_snapshot" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block" integer NOT NULL, "token0_price_usd" text NOT NULL, "token1_price_usd" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "reserve_usd" text NOT NULL, "liquidity_token_total_supply" text NOT NULL, "liquidity_token_balance" text NOT NULL, "liquidity_position_id" character varying, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_cd4ed3539266b2439349a9fa791" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_eb823fd4d5a47575039e902efa" ON "liquidity_position_snapshot" ("liquidity_position_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ed32a41150bc13f18a01974153" ON "liquidity_position_snapshot" ("user_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ce85a847b2952f7e685f150de1" ON "liquidity_position_snapshot" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "transaction" ("id" character varying NOT NULL, "block_number" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "mints" text array NOT NULL, "burns" text array NOT NULL, "swaps" text array NOT NULL, CONSTRAINT "PK_89eadb93a89810556e1cbcd6ab9" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "mint" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "to" text NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "log_index" integer, "amount_usd" text, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_fcaea791104aa41aa11dac29cb2" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_19f4328320501dfd14e2bae085" ON "mint" ("transaction_id") ` + ) + await db.query( + `CREATE INDEX "IDX_81d470127d4c55d09e9213bc4e" ON "mint" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "burn" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "to" text, "log_index" integer, "amount_usd" text, "needs_complete" boolean NOT NULL, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_dcb4f14ee4534154b31116553f0" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_20ec76c5c56dd6b47dec5f0aaa" ON "burn" ("transaction_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ba144ce938b3266a470d4dd70f" ON "burn" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "swap" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "from" text NOT NULL, "amount0_in" text NOT NULL, "amount1_in" text NOT NULL, "amount0_out" text NOT NULL, "amount1_out" text NOT NULL, "to" text NOT NULL, "log_index" integer, "amount_usd" text NOT NULL, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_4a10d0f359339acef77e7f986d9" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_78506c4050ae7cedd50b08c0dc" ON "swap" ("transaction_id") ` + ) + await db.query( + `CREATE INDEX "IDX_3571ab1dad7640a6b93c705b8f" ON "swap" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "pair" ("id" character varying NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_eth" text NOT NULL, "reserve_usd" text NOT NULL, "tracked_reserve_eth" text NOT NULL, "token0_price" text NOT NULL, "token1_price" text NOT NULL, "volume_token0" text NOT NULL, "volume_token1" text NOT NULL, "volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "created_at_timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "created_at_block_number" numeric NOT NULL, "liquidity_provider_count" integer NOT NULL, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_3eaf216329c5c50aedb94fa797e" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_f74dc53460944a424b56b8f7da" ON "pair" ("token0_id") ` + ) + await db.query( + `CREATE INDEX "IDX_4419691fc411b8af754dfa65ce" ON "pair" ("token1_id") ` + ) + await db.query( + `CREATE TABLE "pair_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "pair_address" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "daily_volume_token0" text NOT NULL, "daily_volume_token1" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "pair_id" character varying, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_ac35ed26ab0c71d491a62e2881a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_d8ba7d7d7ad9f0e1c2933a0b7e" ON "pair_day_data" ("pair_id") ` + ) + await db.query( + `CREATE INDEX "IDX_88f6e19c40b47053e6e197db1c" ON "pair_day_data" ("token0_id") ` + ) + await db.query( + `CREATE INDEX "IDX_ce435d6fc7c373d58e7aab156d" ON "pair_day_data" ("token1_id") ` + ) + await db.query( + `CREATE TABLE "token" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "decimals" integer NOT NULL, "total_supply" text NOT NULL, "trade_volume" text NOT NULL, "trade_volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "total_liquidity" text NOT NULL, "derived_eth" text NOT NULL, CONSTRAINT "PK_82fae97f905930df5d62a702fc9" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "single_token_lock_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_87d03adf6b8624eaff434355e53" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_f3bf64f43101176dbe5f11a36b" ON "single_token_lock_day_data" ("single_token_lock_id") ` + ) + await db.query( + `CREATE TABLE "single_token_lock_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_9173bf5d597c5ce35bbce2e664b" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_b2a84dc625103153d651b701dd" ON "single_token_lock_hour_data" ("single_token_lock_id") ` + ) + await db.query( + `CREATE TABLE "single_token_lock" ("id" character varying NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_eth" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_b3d635331ccfacc4f532569364b" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_8ebffe66457859d6e1c37b81ac" ON "single_token_lock" ("token_id") ` + ) + await db.query( + `CREATE TABLE "incentive" ("id" character varying NOT NULL, "reward_per_day" text NOT NULL, "farm_id" character varying, "reward_token_id" character varying, CONSTRAINT "PK_fc2c4e32d8711392ddf918b9f6c" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_35286137967591eaff8dee7ca2" ON "incentive" ("farm_id") ` + ) + await db.query( + `CREATE INDEX "IDX_041db4166864a3841e5efed53c" ON "incentive" ("reward_token_id") ` + ) + await db.query( + `CREATE TABLE "farm" ("id" character varying NOT NULL, "pid" numeric NOT NULL, "stake_token" text NOT NULL, "liquidity_staked" numeric NOT NULL, "created_at_block" numeric NOT NULL, "created_at_timestamp" numeric NOT NULL, "staked_usd" text NOT NULL, "reward_usd_per_day" text NOT NULL, "stake_apr" text NOT NULL, "single_token_lock_id" character varying, "stable_swap_id" character varying, "pair_id" character varying, CONSTRAINT "PK_3bf246b27a3b6678dfc0b7a3f64" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_679106a1febf251d7fe7fe081a" ON "farm" ("single_token_lock_id") ` + ) + await db.query( + `CREATE INDEX "IDX_00b8f5b860927b1b85e866b20d" ON "farm" ("stable_swap_id") ` + ) + await db.query( + `CREATE INDEX "IDX_11da1bf5c406898262d91b41cb" ON "farm" ("pair_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap" ("id" character varying NOT NULL, "address" text NOT NULL, "base_swap_address" text NOT NULL, "num_tokens" integer NOT NULL, "tokens" text array NOT NULL, "base_tokens" text array NOT NULL, "all_tokens" text array NOT NULL, "balances" text array NOT NULL, "lp_token" text NOT NULL, "lp_total_supply" text NOT NULL, "a" numeric NOT NULL, "swap_fee" numeric NOT NULL, "admin_fee" numeric NOT NULL, "virtual_price" numeric NOT NULL, "tvl_usd" text NOT NULL, "volume_usd" text NOT NULL, "stable_swap_info_id" character varying, CONSTRAINT "PK_37316f6fedc29bf95a6f1804c65" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_88cce14adee6d21f5057551c3e" ON "stable_swap" ("stable_swap_info_id") ` + ) + await db.query( + `CREATE TABLE "stable_swap_info" ("id" character varying NOT NULL, "pool_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_21998b071d5e28639e21e9b2da7" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "zenlink_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, "factory_id" character varying, "stable_swap_info_id" character varying, CONSTRAINT "PK_2526d46468e5c4f7c4156840a90" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_9a6b55d2085464668b622dffe6" ON "zenlink_info" ("factory_id") ` + ) + await db.query( + `CREATE INDEX "IDX_0795adc3723792868094ec76c0" ON "zenlink_info" ("stable_swap_info_id") ` + ) + await db.query( + `CREATE TABLE "token_transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, "remark" text, CONSTRAINT "PK_77384b7f5874553f012eba9da41" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_b47f7192b72dd8436ef4e6d253" ON "token_transfer" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_752d6c330729a7b2e283003374" ON "token_transfer" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_2ef35b71d641ec79b7de3ac237" ON "token_transfer" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_aae50046f62ba400c07477fb6c" ON "token_transfer" ("amount") ` + ) + await db.query( + `CREATE TABLE "token_deposit" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_7c5eea7aeab3f0e71da8d2d9f4f" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_395da815b9927f13e2f87c6b54" ON "token_deposit" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_0f87d313517eaa806c75444749" ON "token_deposit" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_7194acc3ea037189ff3da743ec" ON "token_deposit" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_d23ae7a0ea1f640e8e9875b3c2" ON "token_deposit" ("amount") ` + ) + await db.query( + `CREATE TABLE "token_withdrawn" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_658727649cde2e20f8cf69abeb5" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_e7fd99cae9a1df2e8f69d60892" ON "token_withdrawn" ("block_number") ` + ) + await db.query( + `CREATE INDEX "IDX_70e98131fb737e4dce4455ca43" ON "token_withdrawn" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_867e6d004e7a4994b3b2aeba63" ON "token_withdrawn" ("extrinsic_hash") ` + ) + await db.query( + `CREATE INDEX "IDX_5697bf049746e5102413ebd832" ON "token_withdrawn" ("amount") ` + ) + await db.query( + `CREATE TABLE "bundle" ("id" character varying NOT NULL, "eth_price" text NOT NULL, CONSTRAINT "PK_637e3f87e837d6532109c198dea" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "factory_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_volume_untracked" text NOT NULL, "total_volume_eth" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_4b56c54390ce8e399d8e37e169d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "stable_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, CONSTRAINT "PK_3663f18340bb5fdc0023ecc624a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "zenlink_day_info" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "standard_info_id" character varying, "stable_info_id" character varying, CONSTRAINT "PK_747195cfa3811d6eea0ff6389de" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_9f281ffbf4f668c1671ae24aeb" ON "zenlink_day_info" ("standard_info_id") ` + ) + await db.query( + `CREATE INDEX "IDX_3049b8ac70203e95dfc6b42c02" ON "zenlink_day_info" ("stable_info_id") ` + ) + await db.query( + `CREATE TABLE "zlk_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "burn" numeric NOT NULL, CONSTRAINT "PK_58853b5e24384aba0da2023e91e" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "nabla_token" ("id" character varying NOT NULL, "decimals" integer NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, CONSTRAINT "PK_d036fec883bded17a5c2e09cf0a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "nabla_swap_fee" ("id" character varying NOT NULL, "lp_fees" numeric NOT NULL, "backstop_fees" numeric NOT NULL, "protocol_fees" numeric NOT NULL, "timestamp" numeric NOT NULL, "swap_pool_id" character varying, "backstop_pool_id" character varying, CONSTRAINT "PK_8824e4a63ae77ecf8a55aa5359a" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_208d304702d154e73e4f85c978" ON "nabla_swap_fee" ("swap_pool_id") ` + ) + await db.query( + `CREATE INDEX "IDX_86080eda96a6de9c3c60be41d8" ON "nabla_swap_fee" ("backstop_pool_id") ` + ) + await db.query( + `CREATE TABLE "backstop_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "lp_token_decimals" integer NOT NULL, "reserves" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "router_id" character varying, "token_id" character varying, CONSTRAINT "PK_bf2d01d9ce60ad9ee4b1b087d9d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_13ef09b925620aedf12b3342ca" ON "backstop_pool" ("router_id") ` + ) + await db.query( + `CREATE INDEX "IDX_8a7a25fa2d22ff634bd3041d81" ON "backstop_pool" ("token_id") ` + ) + await db.query( + `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "lp_token_decimals" integer NOT NULL, "reserve" numeric NOT NULL, "reserve_with_slippage" numeric NOT NULL, "total_liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_2f5409f002e18e4a6e2fddd858" ON "swap_pool" ("router_id") ` + ) + await db.query( + `CREATE INDEX "IDX_5c3209a88e41d53bdc450605b3" ON "swap_pool" ("backstop_id") ` + ) + await db.query( + `CREATE INDEX "IDX_b66a5cc8d2ce7bba1b48fd8c1a" ON "swap_pool" ("token_id") ` + ) + await db.query( + `CREATE TABLE "router" ("id" character varying NOT NULL, "paused" boolean NOT NULL, CONSTRAINT "PK_510c864aa88ac8eb3a306789801" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE TABLE "event" ("id" character varying NOT NULL, "index" integer NOT NULL, "phase" text NOT NULL, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "call_id" character varying, CONSTRAINT "PK_30c2f3bbaf6d34a55f8ae6e4614" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_2b0d35d675c4f99751855c4502" ON "event" ("block_id") ` + ) + await db.query( + `CREATE INDEX "IDX_129efedcb305c80256db2d57a5" ON "event" ("extrinsic_id") ` + ) + await db.query( + `CREATE INDEX "IDX_83cf1bd59aa4521ed882fa5145" ON "event" ("call_id") ` + ) + await db.query( + `CREATE INDEX "IDX_7723d04c5a2f56c4373b6a4048" ON "event" ("pallet") ` + ) + await db.query( + `CREATE INDEX "IDX_b535fbe8ec6d832dde22065ebd" ON "event" ("name") ` + ) + await db.query( + `CREATE INDEX "IDX_0a00d817e614a91cda40d734cf" ON "event" ("id", "pallet", "name") ` + ) + await db.query( + `CREATE TABLE "call" ("id" character varying NOT NULL, "address" integer array NOT NULL, "success" boolean NOT NULL, "error" jsonb, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "parent_id" character varying, CONSTRAINT "PK_2098af0169792a34f9cfdd39c47" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_bd3f11fd4110d60ac8b96cd62f" ON "call" ("block_id") ` + ) + await db.query( + `CREATE INDEX "IDX_dde30e4f2c6a80f9236bfdf259" ON "call" ("extrinsic_id") ` + ) + await db.query( + `CREATE INDEX "IDX_11c1e76d5be8f04c472c4a05b9" ON "call" ("parent_id") ` + ) + await db.query( + `CREATE INDEX "IDX_d3a8c3d00494950ad6dc93297d" ON "call" ("success") ` + ) + await db.query( + `CREATE INDEX "IDX_776bccbd3d7b3001c8708cf4e0" ON "call" ("pallet") ` + ) + await db.query( + `CREATE INDEX "IDX_8b212022b7428232091e2f8aa5" ON "call" ("name") ` + ) + await db.query( + `CREATE INDEX "IDX_f1e953379e1b3c453cd896bcd4" ON "call" ("id", "pallet", "name") ` + ) + await db.query( + `CREATE TABLE "extrinsic" ("id" character varying NOT NULL, "index" integer NOT NULL, "version" integer NOT NULL, "signature" jsonb, "tip" numeric, "fee" numeric, "success" boolean, "error" jsonb, "hash" bytea NOT NULL, "block_id" character varying, "call_id" character varying, CONSTRAINT "PK_80d7db0e4b1e83e30336bc76755" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_a3b99daba1259dab0dd040d4f7" ON "extrinsic" ("block_id") ` + ) + await db.query( + `CREATE INDEX "IDX_824d47cc4b2cda726405aa507c" ON "extrinsic" ("call_id") ` + ) + await db.query( + `CREATE INDEX "IDX_21e5db7671dfa1b00dbe6dbbd6" ON "extrinsic" ("success") ` + ) + await db.query( + `CREATE INDEX "IDX_1f45de0713a55049009e8e8127" ON "extrinsic" ("hash") ` + ) + await db.query( + `CREATE TABLE "block" ("id" character varying NOT NULL, "height" integer NOT NULL, "hash" bytea NOT NULL, "parent_hash" bytea NOT NULL, "state_root" bytea NOT NULL, "extrinsicsic_root" bytea NOT NULL, "spec_name" text NOT NULL, "spec_version" integer NOT NULL, "impl_name" text NOT NULL, "impl_version" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "validator" bytea, "extrinsics_count" integer NOT NULL, "calls_count" integer NOT NULL, "events_count" integer NOT NULL, CONSTRAINT "PK_d0925763efb591c2e2ffb267572" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_bce676e2b005104ccb768495db" ON "block" ("height") ` + ) + await db.query( + `CREATE INDEX "IDX_f8fba63d7965bfee9f304c487a" ON "block" ("hash") ` + ) + await db.query( + `CREATE INDEX "IDX_5b79d140fa8e2c64a7ef223598" ON "block" ("spec_version") ` + ) + await db.query( + `CREATE INDEX "IDX_5c67cbcf4960c1a39e5fe25e87" ON "block" ("timestamp") ` + ) + await db.query( + `CREATE INDEX "IDX_b7e2f8fe1384a2910825029dcb" ON "block" ("validator") ` + ) + await db.query( + `CREATE TABLE "items_counter" ("id" character varying NOT NULL, "type" character varying(10) NOT NULL, "level" character varying(6) NOT NULL, "total" integer NOT NULL, CONSTRAINT "PK_161dcf46142538463f5d7174793" PRIMARY KEY ("id"))` + ) + await db.query( + `CREATE INDEX "IDX_68d2eadecb3eeb540d2004acef" ON "items_counter" ("type") ` + ) + await db.query( + `CREATE INDEX "IDX_1d9be1d79f197d42dd163f86c8" ON "items_counter" ("level") ` + ) + await db.query( + `CREATE INDEX "IDX_e03dd1c60ac7622914f72ac2f1" ON "items_counter" ("total") ` + ) + await db.query( + `ALTER TABLE "stable_swap_event" ADD CONSTRAINT "FK_3a147c85b92441217540579be88" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_exchange" ADD CONSTRAINT "FK_1180a78feea28e278229de7db46" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_day_data" ADD CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_hour_data" ADD CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "token_day_data" ADD CONSTRAINT "FK_b8950a8bc7b60231137573740ea" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_hour_data" ADD CONSTRAINT "FK_cf50c55389e428096a68598ee33" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_670629d9904e1f48f4a31abb495" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_781470585a67fef4e215a599773" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_eb823fd4d5a47575039e902efa7" FOREIGN KEY ("liquidity_position_id") REFERENCES "liquidity_position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ed32a41150bc13f18a019741534" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ce85a847b2952f7e685f150de1d" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "mint" ADD CONSTRAINT "FK_19f4328320501dfd14e2bae0855" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "mint" ADD CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "burn" ADD CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "burn" ADD CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap" ADD CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap" ADD CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair" ADD CONSTRAINT "FK_f74dc53460944a424b56b8f7da5" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair" ADD CONSTRAINT "FK_4419691fc411b8af754dfa65ce4" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "single_token_lock_day_data" ADD CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "single_token_lock_hour_data" ADD CONSTRAINT "FK_b2a84dc625103153d651b701dd1" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "single_token_lock" ADD CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "incentive" ADD CONSTRAINT "FK_35286137967591eaff8dee7ca2a" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "incentive" ADD CONSTRAINT "FK_041db4166864a3841e5efed53c4" FOREIGN KEY ("reward_token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "farm" ADD CONSTRAINT "FK_679106a1febf251d7fe7fe081ad" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "farm" ADD CONSTRAINT "FK_00b8f5b860927b1b85e866b20da" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "farm" ADD CONSTRAINT "FK_11da1bf5c406898262d91b41cbb" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "stable_swap" ADD CONSTRAINT "FK_88cce14adee6d21f5057551c3ea" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_9a6b55d2085464668b622dffe64" FOREIGN KEY ("factory_id") REFERENCES "factory"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_0795adc3723792868094ec76c07" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0" FOREIGN KEY ("standard_info_id") REFERENCES "factory_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027" FOREIGN KEY ("stable_info_id") REFERENCES "stable_swap_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_208d304702d154e73e4f85c978b" FOREIGN KEY ("swap_pool_id") REFERENCES "swap_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_86080eda96a6de9c3c60be41d86" FOREIGN KEY ("backstop_pool_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_13ef09b925620aedf12b3342caa" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b" FOREIGN KEY ("backstop_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "event" ADD CONSTRAINT "FK_2b0d35d675c4f99751855c45021" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "event" ADD CONSTRAINT "FK_129efedcb305c80256db2d57a59" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "event" ADD CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "call" ADD CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "call" ADD CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "call" ADD CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95" FOREIGN KEY ("parent_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + await db.query( + `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_824d47cc4b2cda726405aa507ca" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + } + + async down(db) { + await db.query(`DROP TABLE "oracle_price"`) + await db.query(`DROP INDEX "public"."IDX_6554f47abd46667280a2523381"`) + await db.query(`DROP INDEX "public"."IDX_2026224855490e321e5c0b6911"`) + await db.query(`DROP INDEX "public"."IDX_a77ac6d79f0929522f5a1aefcb"`) + await db.query(`DROP INDEX "public"."IDX_f7c9bf3bae39fb0a75f12b87dd"`) + await db.query(`DROP TABLE "transfer"`) + await db.query(`DROP INDEX "public"."IDX_d6624eacc30144ea97915fe846"`) + await db.query(`DROP INDEX "public"."IDX_70ff8b624c3118ac3a4862d22c"`) + await db.query(`DROP INDEX "public"."IDX_070c555a86b0b41a534a55a659"`) + await db.query(`DROP INDEX "public"."IDX_f4007436c1b546ede08a4fd7ab"`) + await db.query(`DROP TABLE "factory"`) + await db.query(`DROP TABLE "stable_swap_event"`) + await db.query(`DROP INDEX "public"."IDX_3a147c85b92441217540579be8"`) + await db.query(`DROP TABLE "stable_swap_exchange"`) + await db.query(`DROP INDEX "public"."IDX_1180a78feea28e278229de7db4"`) + await db.query(`DROP TABLE "stable_swap_day_data"`) + await db.query(`DROP INDEX "public"."IDX_648b49eb1a4f2a47f24f13bb51"`) + await db.query(`DROP TABLE "stable_swap_hour_data"`) + await db.query(`DROP INDEX "public"."IDX_94584d2925c30ae0d4b80aadfc"`) + await db.query(`DROP TABLE "token_day_data"`) + await db.query(`DROP INDEX "public"."IDX_b8950a8bc7b60231137573740e"`) + await db.query(`DROP TABLE "pair_hour_data"`) + await db.query(`DROP INDEX "public"."IDX_cf50c55389e428096a68598ee3"`) + await db.query(`DROP TABLE "stable_swap_liquidity_position"`) + await db.query(`DROP INDEX "public"."IDX_f953aebc7c0752f6b8434c9eef"`) + await db.query(`DROP INDEX "public"."IDX_405e0d7aeca80975d88a63bc6e"`) + await db.query(`DROP TABLE "stake_position"`) + await db.query(`DROP INDEX "public"."IDX_2a2b22d2744b497bbcfb03e6ab"`) + await db.query(`DROP INDEX "public"."IDX_670629d9904e1f48f4a31abb49"`) + await db.query(`DROP TABLE "user"`) + await db.query(`DROP TABLE "liquidity_position"`) + await db.query(`DROP INDEX "public"."IDX_781470585a67fef4e215a59977"`) + await db.query(`DROP INDEX "public"."IDX_5a626c8b8962dc01e0f8801be6"`) + await db.query(`DROP TABLE "liquidity_position_snapshot"`) + await db.query(`DROP INDEX "public"."IDX_eb823fd4d5a47575039e902efa"`) + await db.query(`DROP INDEX "public"."IDX_ed32a41150bc13f18a01974153"`) + await db.query(`DROP INDEX "public"."IDX_ce85a847b2952f7e685f150de1"`) + await db.query(`DROP TABLE "transaction"`) + await db.query(`DROP TABLE "mint"`) + await db.query(`DROP INDEX "public"."IDX_19f4328320501dfd14e2bae085"`) + await db.query(`DROP INDEX "public"."IDX_81d470127d4c55d09e9213bc4e"`) + await db.query(`DROP TABLE "burn"`) + await db.query(`DROP INDEX "public"."IDX_20ec76c5c56dd6b47dec5f0aaa"`) + await db.query(`DROP INDEX "public"."IDX_ba144ce938b3266a470d4dd70f"`) + await db.query(`DROP TABLE "swap"`) + await db.query(`DROP INDEX "public"."IDX_78506c4050ae7cedd50b08c0dc"`) + await db.query(`DROP INDEX "public"."IDX_3571ab1dad7640a6b93c705b8f"`) + await db.query(`DROP TABLE "pair"`) + await db.query(`DROP INDEX "public"."IDX_f74dc53460944a424b56b8f7da"`) + await db.query(`DROP INDEX "public"."IDX_4419691fc411b8af754dfa65ce"`) + await db.query(`DROP TABLE "pair_day_data"`) + await db.query(`DROP INDEX "public"."IDX_d8ba7d7d7ad9f0e1c2933a0b7e"`) + await db.query(`DROP INDEX "public"."IDX_88f6e19c40b47053e6e197db1c"`) + await db.query(`DROP INDEX "public"."IDX_ce435d6fc7c373d58e7aab156d"`) + await db.query(`DROP TABLE "token"`) + await db.query(`DROP TABLE "single_token_lock_day_data"`) + await db.query(`DROP INDEX "public"."IDX_f3bf64f43101176dbe5f11a36b"`) + await db.query(`DROP TABLE "single_token_lock_hour_data"`) + await db.query(`DROP INDEX "public"."IDX_b2a84dc625103153d651b701dd"`) + await db.query(`DROP TABLE "single_token_lock"`) + await db.query(`DROP INDEX "public"."IDX_8ebffe66457859d6e1c37b81ac"`) + await db.query(`DROP TABLE "incentive"`) + await db.query(`DROP INDEX "public"."IDX_35286137967591eaff8dee7ca2"`) + await db.query(`DROP INDEX "public"."IDX_041db4166864a3841e5efed53c"`) + await db.query(`DROP TABLE "farm"`) + await db.query(`DROP INDEX "public"."IDX_679106a1febf251d7fe7fe081a"`) + await db.query(`DROP INDEX "public"."IDX_00b8f5b860927b1b85e866b20d"`) + await db.query(`DROP INDEX "public"."IDX_11da1bf5c406898262d91b41cb"`) + await db.query(`DROP TABLE "stable_swap"`) + await db.query(`DROP INDEX "public"."IDX_88cce14adee6d21f5057551c3e"`) + await db.query(`DROP TABLE "stable_swap_info"`) + await db.query(`DROP TABLE "zenlink_info"`) + await db.query(`DROP INDEX "public"."IDX_9a6b55d2085464668b622dffe6"`) + await db.query(`DROP INDEX "public"."IDX_0795adc3723792868094ec76c0"`) + await db.query(`DROP TABLE "token_transfer"`) + await db.query(`DROP INDEX "public"."IDX_b47f7192b72dd8436ef4e6d253"`) + await db.query(`DROP INDEX "public"."IDX_752d6c330729a7b2e283003374"`) + await db.query(`DROP INDEX "public"."IDX_2ef35b71d641ec79b7de3ac237"`) + await db.query(`DROP INDEX "public"."IDX_aae50046f62ba400c07477fb6c"`) + await db.query(`DROP TABLE "token_deposit"`) + await db.query(`DROP INDEX "public"."IDX_395da815b9927f13e2f87c6b54"`) + await db.query(`DROP INDEX "public"."IDX_0f87d313517eaa806c75444749"`) + await db.query(`DROP INDEX "public"."IDX_7194acc3ea037189ff3da743ec"`) + await db.query(`DROP INDEX "public"."IDX_d23ae7a0ea1f640e8e9875b3c2"`) + await db.query(`DROP TABLE "token_withdrawn"`) + await db.query(`DROP INDEX "public"."IDX_e7fd99cae9a1df2e8f69d60892"`) + await db.query(`DROP INDEX "public"."IDX_70e98131fb737e4dce4455ca43"`) + await db.query(`DROP INDEX "public"."IDX_867e6d004e7a4994b3b2aeba63"`) + await db.query(`DROP INDEX "public"."IDX_5697bf049746e5102413ebd832"`) + await db.query(`DROP TABLE "bundle"`) + await db.query(`DROP TABLE "factory_day_data"`) + await db.query(`DROP TABLE "stable_day_data"`) + await db.query(`DROP TABLE "zenlink_day_info"`) + await db.query(`DROP INDEX "public"."IDX_9f281ffbf4f668c1671ae24aeb"`) + await db.query(`DROP INDEX "public"."IDX_3049b8ac70203e95dfc6b42c02"`) + await db.query(`DROP TABLE "zlk_info"`) + await db.query(`DROP TABLE "nabla_token"`) + await db.query(`DROP TABLE "nabla_swap_fee"`) + await db.query(`DROP INDEX "public"."IDX_208d304702d154e73e4f85c978"`) + await db.query(`DROP INDEX "public"."IDX_86080eda96a6de9c3c60be41d8"`) + await db.query(`DROP TABLE "backstop_pool"`) + await db.query(`DROP INDEX "public"."IDX_13ef09b925620aedf12b3342ca"`) + await db.query(`DROP INDEX "public"."IDX_8a7a25fa2d22ff634bd3041d81"`) + await db.query(`DROP TABLE "swap_pool"`) + await db.query(`DROP INDEX "public"."IDX_2f5409f002e18e4a6e2fddd858"`) + await db.query(`DROP INDEX "public"."IDX_5c3209a88e41d53bdc450605b3"`) + await db.query(`DROP INDEX "public"."IDX_b66a5cc8d2ce7bba1b48fd8c1a"`) + await db.query(`DROP TABLE "router"`) + await db.query(`DROP TABLE "event"`) + await db.query(`DROP INDEX "public"."IDX_2b0d35d675c4f99751855c4502"`) + await db.query(`DROP INDEX "public"."IDX_129efedcb305c80256db2d57a5"`) + await db.query(`DROP INDEX "public"."IDX_83cf1bd59aa4521ed882fa5145"`) + await db.query(`DROP INDEX "public"."IDX_7723d04c5a2f56c4373b6a4048"`) + await db.query(`DROP INDEX "public"."IDX_b535fbe8ec6d832dde22065ebd"`) + await db.query(`DROP INDEX "public"."IDX_0a00d817e614a91cda40d734cf"`) + await db.query(`DROP TABLE "call"`) + await db.query(`DROP INDEX "public"."IDX_bd3f11fd4110d60ac8b96cd62f"`) + await db.query(`DROP INDEX "public"."IDX_dde30e4f2c6a80f9236bfdf259"`) + await db.query(`DROP INDEX "public"."IDX_11c1e76d5be8f04c472c4a05b9"`) + await db.query(`DROP INDEX "public"."IDX_d3a8c3d00494950ad6dc93297d"`) + await db.query(`DROP INDEX "public"."IDX_776bccbd3d7b3001c8708cf4e0"`) + await db.query(`DROP INDEX "public"."IDX_8b212022b7428232091e2f8aa5"`) + await db.query(`DROP INDEX "public"."IDX_f1e953379e1b3c453cd896bcd4"`) + await db.query(`DROP TABLE "extrinsic"`) + await db.query(`DROP INDEX "public"."IDX_a3b99daba1259dab0dd040d4f7"`) + await db.query(`DROP INDEX "public"."IDX_824d47cc4b2cda726405aa507c"`) + await db.query(`DROP INDEX "public"."IDX_21e5db7671dfa1b00dbe6dbbd6"`) + await db.query(`DROP INDEX "public"."IDX_1f45de0713a55049009e8e8127"`) + await db.query(`DROP TABLE "block"`) + await db.query(`DROP INDEX "public"."IDX_bce676e2b005104ccb768495db"`) + await db.query(`DROP INDEX "public"."IDX_f8fba63d7965bfee9f304c487a"`) + await db.query(`DROP INDEX "public"."IDX_5b79d140fa8e2c64a7ef223598"`) + await db.query(`DROP INDEX "public"."IDX_5c67cbcf4960c1a39e5fe25e87"`) + await db.query(`DROP INDEX "public"."IDX_b7e2f8fe1384a2910825029dcb"`) + await db.query(`DROP TABLE "items_counter"`) + await db.query(`DROP INDEX "public"."IDX_68d2eadecb3eeb540d2004acef"`) + await db.query(`DROP INDEX "public"."IDX_1d9be1d79f197d42dd163f86c8"`) + await db.query(`DROP INDEX "public"."IDX_e03dd1c60ac7622914f72ac2f1"`) + await db.query( + `ALTER TABLE "stable_swap_event" DROP CONSTRAINT "FK_3a147c85b92441217540579be88"` + ) + await db.query( + `ALTER TABLE "stable_swap_exchange" DROP CONSTRAINT "FK_1180a78feea28e278229de7db46"` + ) + await db.query( + `ALTER TABLE "stable_swap_day_data" DROP CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510"` + ) + await db.query( + `ALTER TABLE "stable_swap_hour_data" DROP CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8"` + ) + await db.query( + `ALTER TABLE "token_day_data" DROP CONSTRAINT "FK_b8950a8bc7b60231137573740ea"` + ) + await db.query( + `ALTER TABLE "pair_hour_data" DROP CONSTRAINT "FK_cf50c55389e428096a68598ee33"` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8"` + ) + await db.query( + `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee"` + ) + await db.query( + `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0"` + ) + await db.query( + `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_670629d9904e1f48f4a31abb495"` + ) + await db.query( + `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_781470585a67fef4e215a599773"` + ) + await db.query( + `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61"` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_eb823fd4d5a47575039e902efa7"` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ed32a41150bc13f18a019741534"` + ) + await db.query( + `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ce85a847b2952f7e685f150de1d"` + ) + await db.query( + `ALTER TABLE "mint" DROP CONSTRAINT "FK_19f4328320501dfd14e2bae0855"` + ) + await db.query( + `ALTER TABLE "mint" DROP CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1"` + ) + await db.query( + `ALTER TABLE "burn" DROP CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8"` + ) + await db.query( + `ALTER TABLE "burn" DROP CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa"` + ) + await db.query( + `ALTER TABLE "swap" DROP CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5"` + ) + await db.query( + `ALTER TABLE "swap" DROP CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7"` + ) + await db.query( + `ALTER TABLE "pair" DROP CONSTRAINT "FK_f74dc53460944a424b56b8f7da5"` + ) + await db.query( + `ALTER TABLE "pair" DROP CONSTRAINT "FK_4419691fc411b8af754dfa65ce4"` + ) + await db.query( + `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2"` + ) + await db.query( + `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9"` + ) + await db.query( + `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9"` + ) + await db.query( + `ALTER TABLE "single_token_lock_day_data" DROP CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd"` + ) + await db.query( + `ALTER TABLE "single_token_lock_hour_data" DROP CONSTRAINT "FK_b2a84dc625103153d651b701dd1"` + ) + await db.query( + `ALTER TABLE "single_token_lock" DROP CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3"` + ) + await db.query( + `ALTER TABLE "incentive" DROP CONSTRAINT "FK_35286137967591eaff8dee7ca2a"` + ) + await db.query( + `ALTER TABLE "incentive" DROP CONSTRAINT "FK_041db4166864a3841e5efed53c4"` + ) + await db.query( + `ALTER TABLE "farm" DROP CONSTRAINT "FK_679106a1febf251d7fe7fe081ad"` + ) + await db.query( + `ALTER TABLE "farm" DROP CONSTRAINT "FK_00b8f5b860927b1b85e866b20da"` + ) + await db.query( + `ALTER TABLE "farm" DROP CONSTRAINT "FK_11da1bf5c406898262d91b41cbb"` + ) + await db.query( + `ALTER TABLE "stable_swap" DROP CONSTRAINT "FK_88cce14adee6d21f5057551c3ea"` + ) + await db.query( + `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_9a6b55d2085464668b622dffe64"` + ) + await db.query( + `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_0795adc3723792868094ec76c07"` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0"` + ) + await db.query( + `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027"` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_208d304702d154e73e4f85c978b"` + ) + await db.query( + `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_86080eda96a6de9c3c60be41d86"` + ) + await db.query( + `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_13ef09b925620aedf12b3342caa"` + ) + await db.query( + `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b"` + ) + await db.query( + `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab"` + ) + await db.query( + `ALTER TABLE "event" DROP CONSTRAINT "FK_2b0d35d675c4f99751855c45021"` + ) + await db.query( + `ALTER TABLE "event" DROP CONSTRAINT "FK_129efedcb305c80256db2d57a59"` + ) + await db.query( + `ALTER TABLE "event" DROP CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452"` + ) + await db.query( + `ALTER TABLE "call" DROP CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3"` + ) + await db.query( + `ALTER TABLE "call" DROP CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590"` + ) + await db.query( + `ALTER TABLE "call" DROP CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95"` + ) + await db.query( + `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74"` + ) + await db.query( + `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_824d47cc4b2cda726405aa507ca"` + ) + } +} diff --git a/src/abi/backstop.ts b/src/abi/backstop.ts index 09bdf3e7..a5eba2e7 100644 --- a/src/abi/backstop.ts +++ b/src/abi/backstop.ts @@ -1805,14 +1805,14 @@ export class Contract { } private async stateCall(selector: string, args: any[]): Promise { - const input = _abi.encodeMessageInput(selector, args) - const data = encodeCall(this.address, input) - const result = await this.ctx._chain.rpc.call('state_call', [ + let input = _abi.encodeMessageInput(selector, args) + let data = encodeCall(this.address, input) + let result = await this.ctx._chain.rpc.call('state_call', [ 'ContractsApi_call', data, this.blockHash, ]) - const value = decodeResult(result) + let value = decodeResult(result) return _abi.decodeMessageOutput(selector, value) } } diff --git a/src/abi/erc20.ts b/src/abi/erc20.ts index a09c4836..2192c0f0 100644 --- a/src/abi/erc20.ts +++ b/src/abi/erc20.ts @@ -755,14 +755,14 @@ export class Contract { } private async stateCall(selector: string, args: any[]): Promise { - const input = _abi.encodeMessageInput(selector, args) - const data = encodeCall(this.address, input) - const result = await this.ctx._chain.rpc.call('state_call', [ + let input = _abi.encodeMessageInput(selector, args) + let data = encodeCall(this.address, input) + let result = await this.ctx._chain.rpc.call('state_call', [ 'ContractsApi_call', data, this.blockHash, ]) - const value = decodeResult(result) + let value = decodeResult(result) return _abi.decodeMessageOutput(selector, value) } } diff --git a/src/abi/router.ts b/src/abi/router.ts index 78fcca70..e6f4af1e 100644 --- a/src/abi/router.ts +++ b/src/abi/router.ts @@ -943,14 +943,14 @@ export class Contract { } private async stateCall(selector: string, args: any[]): Promise { - const input = _abi.encodeMessageInput(selector, args) - const data = encodeCall(this.address, input) - const result = await this.ctx._chain.rpc.call('state_call', [ + let input = _abi.encodeMessageInput(selector, args) + let data = encodeCall(this.address, input) + let result = await this.ctx._chain.rpc.call('state_call', [ 'ContractsApi_call', data, this.blockHash, ]) - const value = decodeResult(result) + let value = decodeResult(result) return _abi.decodeMessageOutput(selector, value) } } diff --git a/src/abi/swap.ts b/src/abi/swap.ts index 6d736353..9aa49fa9 100644 --- a/src/abi/swap.ts +++ b/src/abi/swap.ts @@ -2244,14 +2244,14 @@ export class Contract { } private async stateCall(selector: string, args: any[]): Promise { - const input = _abi.encodeMessageInput(selector, args) - const data = encodeCall(this.address, input) - const result = await this.ctx._chain.rpc.call('state_call', [ + let input = _abi.encodeMessageInput(selector, args) + let data = encodeCall(this.address, input) + let result = await this.ctx._chain.rpc.call('state_call', [ 'ContractsApi_call', data, this.blockHash, ]) - const value = decodeResult(result) + let value = decodeResult(result) return _abi.decodeMessageOutput(selector, value) } } From 3327b3d7012f17d8ac287112b9239d2c890f79c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Thu, 25 Apr 2024 05:44:50 -0300 Subject: [PATCH 12/20] Handle new Nabla events --- db/migrations/1706733053259-Data.js | 895 ------------------ db/migrations/1708373922157-Data.js | 27 - db/migrations/1708525160246-Data.js | 21 - db/migrations/1714027551702-Data.js | 885 ----------------- ...28795707-Data.js => 1714034652645-Data.js} | 6 +- schema.graphql | 2 + .../nabla/backstopPoolEventHandler.ts | 33 +- src/mappings/nabla/creation.ts | 7 + src/mappings/nabla/swapPoolEventHandler.ts | 33 +- src/model/generated/swapPool.model.ts | 9 + 10 files changed, 82 insertions(+), 1836 deletions(-) delete mode 100644 db/migrations/1706733053259-Data.js delete mode 100644 db/migrations/1708373922157-Data.js delete mode 100644 db/migrations/1708525160246-Data.js delete mode 100644 db/migrations/1714027551702-Data.js rename db/migrations/{1714028795707-Data.js => 1714034652645-Data.js} (99%) diff --git a/db/migrations/1706733053259-Data.js b/db/migrations/1706733053259-Data.js deleted file mode 100644 index b8a5001c..00000000 --- a/db/migrations/1706733053259-Data.js +++ /dev/null @@ -1,895 +0,0 @@ -module.exports = class Data1706733053259 { - name = 'Data1706733053259' - - async up(db) { - await db.query( - `CREATE TABLE "oracle_price" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "blockchain" text NOT NULL, "timestamp" numeric NOT NULL, "price" text NOT NULL, "supply" text NOT NULL, "decimals" integer NOT NULL, CONSTRAINT "PK_606c938b2474588b154eb625f3b" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_6554f47abd46667280a2523381" ON "oracle_price" ("symbol") ` - ) - await db.query( - `CREATE INDEX "IDX_2026224855490e321e5c0b6911" ON "oracle_price" ("blockchain") ` - ) - await db.query( - `CREATE INDEX "IDX_a77ac6d79f0929522f5a1aefcb" ON "oracle_price" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_f7c9bf3bae39fb0a75f12b87dd" ON "oracle_price" ("price") ` - ) - await db.query( - `CREATE TABLE "transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "amount" numeric NOT NULL, "fee" numeric NOT NULL, "remark" text, CONSTRAINT "PK_fd9ddbdd49a17afcbe014401295" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_d6624eacc30144ea97915fe846" ON "transfer" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_70ff8b624c3118ac3a4862d22c" ON "transfer" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_070c555a86b0b41a534a55a659" ON "transfer" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_f4007436c1b546ede08a4fd7ab" ON "transfer" ("amount") ` - ) - await db.query( - `CREATE TABLE "factory" ("id" character varying NOT NULL, "pair_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_volume_eth" text NOT NULL, "untracked_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_1372e5a7d114a3fa80736ba66bb" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "stable_swap_event" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_8b61dbc9b556ed8fcb4030fee7d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_3a147c85b92441217540579be8" ON "stable_swap_event" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_exchange" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_f06e489da865134dcfac3bbcd22" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_1180a78feea28e278229de7db4" ON "stable_swap_exchange" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_819b3b7bf9c8055e14e0bf1c578" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_648b49eb1a4f2a47f24f13bb51" ON "stable_swap_day_data" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "hourly_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_2aedd41b95c37330a4a8429e192" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_94584d2925c30ae0d4b80aadfc" ON "stable_swap_hour_data" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "token_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_token" text NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "total_liquidity_token" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_liquidity_usd" text NOT NULL, "price_usd" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_73fc06337215e86196b36822116" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_b8950a8bc7b60231137573740e" ON "token_day_data" ("token_id") ` - ) - await db.query( - `CREATE TABLE "pair_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "hourly_volume_token0" text NOT NULL, "hourly_volume_token1" text NOT NULL, "hourly_volume_usd" text NOT NULL, "hourly_txns" integer NOT NULL, "pair_id" character varying, CONSTRAINT "PK_ffc544bb3e72cfd3e48a8b01452" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_cf50c55389e428096a68598ee3" ON "pair_hour_data" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "stable_swap_id" character varying, CONSTRAINT "PK_12f435243c8a739330c0881d720" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_f953aebc7c0752f6b8434c9eef" ON "stable_swap_liquidity_position" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_405e0d7aeca80975d88a63bc6e" ON "stable_swap_liquidity_position" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stake_position" ("id" character varying NOT NULL, "liquidity_staked_balance" numeric NOT NULL, "user_id" character varying, "farm_id" character varying, CONSTRAINT "PK_17615803509bd6065f1ab8b0ced" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_2a2b22d2744b497bbcfb03e6ab" ON "stake_position" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_670629d9904e1f48f4a31abb49" ON "stake_position" ("farm_id") ` - ) - await db.query( - `CREATE TABLE "user" ("id" character varying NOT NULL, "usd_swapped" text NOT NULL, CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_db00d963c96b3914d26abe3c3d2" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_781470585a67fef4e215a59977" ON "liquidity_position" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_5a626c8b8962dc01e0f8801be6" ON "liquidity_position" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "liquidity_position_snapshot" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block" integer NOT NULL, "token0_price_usd" text NOT NULL, "token1_price_usd" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "reserve_usd" text NOT NULL, "liquidity_token_total_supply" text NOT NULL, "liquidity_token_balance" text NOT NULL, "liquidity_position_id" character varying, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_cd4ed3539266b2439349a9fa791" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_eb823fd4d5a47575039e902efa" ON "liquidity_position_snapshot" ("liquidity_position_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ed32a41150bc13f18a01974153" ON "liquidity_position_snapshot" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ce85a847b2952f7e685f150de1" ON "liquidity_position_snapshot" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "transaction" ("id" character varying NOT NULL, "block_number" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "mints" text array NOT NULL, "burns" text array NOT NULL, "swaps" text array NOT NULL, CONSTRAINT "PK_89eadb93a89810556e1cbcd6ab9" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "mint" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "to" text NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "log_index" integer, "amount_usd" text, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_fcaea791104aa41aa11dac29cb2" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_19f4328320501dfd14e2bae085" ON "mint" ("transaction_id") ` - ) - await db.query( - `CREATE INDEX "IDX_81d470127d4c55d09e9213bc4e" ON "mint" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "burn" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "to" text, "log_index" integer, "amount_usd" text, "needs_complete" boolean NOT NULL, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_dcb4f14ee4534154b31116553f0" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_20ec76c5c56dd6b47dec5f0aaa" ON "burn" ("transaction_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ba144ce938b3266a470d4dd70f" ON "burn" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "swap" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "from" text NOT NULL, "amount0_in" text NOT NULL, "amount1_in" text NOT NULL, "amount0_out" text NOT NULL, "amount1_out" text NOT NULL, "to" text NOT NULL, "log_index" integer, "amount_usd" text NOT NULL, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_4a10d0f359339acef77e7f986d9" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_78506c4050ae7cedd50b08c0dc" ON "swap" ("transaction_id") ` - ) - await db.query( - `CREATE INDEX "IDX_3571ab1dad7640a6b93c705b8f" ON "swap" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "pair" ("id" character varying NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_eth" text NOT NULL, "reserve_usd" text NOT NULL, "tracked_reserve_eth" text NOT NULL, "token0_price" text NOT NULL, "token1_price" text NOT NULL, "volume_token0" text NOT NULL, "volume_token1" text NOT NULL, "volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "created_at_timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "created_at_block_number" numeric NOT NULL, "liquidity_provider_count" integer NOT NULL, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_3eaf216329c5c50aedb94fa797e" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_f74dc53460944a424b56b8f7da" ON "pair" ("token0_id") ` - ) - await db.query( - `CREATE INDEX "IDX_4419691fc411b8af754dfa65ce" ON "pair" ("token1_id") ` - ) - await db.query( - `CREATE TABLE "pair_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "pair_address" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "daily_volume_token0" text NOT NULL, "daily_volume_token1" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "pair_id" character varying, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_ac35ed26ab0c71d491a62e2881a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_d8ba7d7d7ad9f0e1c2933a0b7e" ON "pair_day_data" ("pair_id") ` - ) - await db.query( - `CREATE INDEX "IDX_88f6e19c40b47053e6e197db1c" ON "pair_day_data" ("token0_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ce435d6fc7c373d58e7aab156d" ON "pair_day_data" ("token1_id") ` - ) - await db.query( - `CREATE TABLE "token" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "decimals" integer NOT NULL, "total_supply" text NOT NULL, "trade_volume" text NOT NULL, "trade_volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "total_liquidity" text NOT NULL, "derived_eth" text NOT NULL, CONSTRAINT "PK_82fae97f905930df5d62a702fc9" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "single_token_lock_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_87d03adf6b8624eaff434355e53" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_f3bf64f43101176dbe5f11a36b" ON "single_token_lock_day_data" ("single_token_lock_id") ` - ) - await db.query( - `CREATE TABLE "single_token_lock_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_9173bf5d597c5ce35bbce2e664b" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_b2a84dc625103153d651b701dd" ON "single_token_lock_hour_data" ("single_token_lock_id") ` - ) - await db.query( - `CREATE TABLE "single_token_lock" ("id" character varying NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_eth" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_b3d635331ccfacc4f532569364b" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_8ebffe66457859d6e1c37b81ac" ON "single_token_lock" ("token_id") ` - ) - await db.query( - `CREATE TABLE "incentive" ("id" character varying NOT NULL, "reward_per_day" text NOT NULL, "farm_id" character varying, "reward_token_id" character varying, CONSTRAINT "PK_fc2c4e32d8711392ddf918b9f6c" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_35286137967591eaff8dee7ca2" ON "incentive" ("farm_id") ` - ) - await db.query( - `CREATE INDEX "IDX_041db4166864a3841e5efed53c" ON "incentive" ("reward_token_id") ` - ) - await db.query( - `CREATE TABLE "farm" ("id" character varying NOT NULL, "pid" numeric NOT NULL, "stake_token" text NOT NULL, "liquidity_staked" numeric NOT NULL, "created_at_block" numeric NOT NULL, "created_at_timestamp" numeric NOT NULL, "staked_usd" text NOT NULL, "reward_usd_per_day" text NOT NULL, "stake_apr" text NOT NULL, "single_token_lock_id" character varying, "stable_swap_id" character varying, "pair_id" character varying, CONSTRAINT "PK_3bf246b27a3b6678dfc0b7a3f64" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_679106a1febf251d7fe7fe081a" ON "farm" ("single_token_lock_id") ` - ) - await db.query( - `CREATE INDEX "IDX_00b8f5b860927b1b85e866b20d" ON "farm" ("stable_swap_id") ` - ) - await db.query( - `CREATE INDEX "IDX_11da1bf5c406898262d91b41cb" ON "farm" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap" ("id" character varying NOT NULL, "address" text NOT NULL, "base_swap_address" text NOT NULL, "num_tokens" integer NOT NULL, "tokens" text array NOT NULL, "base_tokens" text array NOT NULL, "all_tokens" text array NOT NULL, "balances" text array NOT NULL, "lp_token" text NOT NULL, "lp_total_supply" text NOT NULL, "a" numeric NOT NULL, "swap_fee" numeric NOT NULL, "admin_fee" numeric NOT NULL, "virtual_price" numeric NOT NULL, "tvl_usd" text NOT NULL, "volume_usd" text NOT NULL, "stable_swap_info_id" character varying, CONSTRAINT "PK_37316f6fedc29bf95a6f1804c65" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_88cce14adee6d21f5057551c3e" ON "stable_swap" ("stable_swap_info_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_info" ("id" character varying NOT NULL, "pool_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_21998b071d5e28639e21e9b2da7" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "zenlink_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, "factory_id" character varying, "stable_swap_info_id" character varying, CONSTRAINT "PK_2526d46468e5c4f7c4156840a90" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_9a6b55d2085464668b622dffe6" ON "zenlink_info" ("factory_id") ` - ) - await db.query( - `CREATE INDEX "IDX_0795adc3723792868094ec76c0" ON "zenlink_info" ("stable_swap_info_id") ` - ) - await db.query( - `CREATE TABLE "token_transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, "remark" text, CONSTRAINT "PK_77384b7f5874553f012eba9da41" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_b47f7192b72dd8436ef4e6d253" ON "token_transfer" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_752d6c330729a7b2e283003374" ON "token_transfer" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_2ef35b71d641ec79b7de3ac237" ON "token_transfer" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_aae50046f62ba400c07477fb6c" ON "token_transfer" ("amount") ` - ) - await db.query( - `CREATE TABLE "token_deposit" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_7c5eea7aeab3f0e71da8d2d9f4f" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_395da815b9927f13e2f87c6b54" ON "token_deposit" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_0f87d313517eaa806c75444749" ON "token_deposit" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_7194acc3ea037189ff3da743ec" ON "token_deposit" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_d23ae7a0ea1f640e8e9875b3c2" ON "token_deposit" ("amount") ` - ) - await db.query( - `CREATE TABLE "token_withdrawn" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_658727649cde2e20f8cf69abeb5" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_e7fd99cae9a1df2e8f69d60892" ON "token_withdrawn" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_70e98131fb737e4dce4455ca43" ON "token_withdrawn" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_867e6d004e7a4994b3b2aeba63" ON "token_withdrawn" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_5697bf049746e5102413ebd832" ON "token_withdrawn" ("amount") ` - ) - await db.query( - `CREATE TABLE "bundle" ("id" character varying NOT NULL, "eth_price" text NOT NULL, CONSTRAINT "PK_637e3f87e837d6532109c198dea" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "factory_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_volume_untracked" text NOT NULL, "total_volume_eth" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_4b56c54390ce8e399d8e37e169d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "stable_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, CONSTRAINT "PK_3663f18340bb5fdc0023ecc624a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "zenlink_day_info" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "standard_info_id" character varying, "stable_info_id" character varying, CONSTRAINT "PK_747195cfa3811d6eea0ff6389de" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_9f281ffbf4f668c1671ae24aeb" ON "zenlink_day_info" ("standard_info_id") ` - ) - await db.query( - `CREATE INDEX "IDX_3049b8ac70203e95dfc6b42c02" ON "zenlink_day_info" ("stable_info_id") ` - ) - await db.query( - `CREATE TABLE "zlk_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "burn" numeric NOT NULL, CONSTRAINT "PK_58853b5e24384aba0da2023e91e" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "nabla_token" ("id" character varying NOT NULL, "decimals" integer NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "latest_swap_pool_id" character varying, CONSTRAINT "PK_d036fec883bded17a5c2e09cf0a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_03f6f92a4dd0116a68bd46ef66" ON "nabla_token" ("latest_swap_pool_id") ` - ) - await db.query( - `CREATE TABLE "nabla_swap_fee" ("id" character varying NOT NULL, "lp_fees" numeric NOT NULL, "backstop_fees" numeric NOT NULL, "protocol_fees" numeric NOT NULL, "timestamp" numeric NOT NULL, "swap_pool_id" character varying, "backstop_pool_id" character varying, CONSTRAINT "PK_8824e4a63ae77ecf8a55aa5359a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_208d304702d154e73e4f85c978" ON "nabla_swap_fee" ("swap_pool_id") ` - ) - await db.query( - `CREATE INDEX "IDX_86080eda96a6de9c3c60be41d8" ON "nabla_swap_fee" ("backstop_pool_id") ` - ) - await db.query( - `CREATE TABLE "backstop_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "reserves" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "router_id" character varying, "token_id" character varying, CONSTRAINT "PK_bf2d01d9ce60ad9ee4b1b087d9d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_13ef09b925620aedf12b3342ca" ON "backstop_pool" ("router_id") ` - ) - await db.query( - `CREATE INDEX "IDX_8a7a25fa2d22ff634bd3041d81" ON "backstop_pool" ("token_id") ` - ) - await db.query( - `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "reserve" numeric NOT NULL, "reserve_with_slippage" numeric NOT NULL, "total_liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "covered_index" numeric, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_2f5409f002e18e4a6e2fddd858" ON "swap_pool" ("router_id") ` - ) - await db.query( - `CREATE INDEX "IDX_5c3209a88e41d53bdc450605b3" ON "swap_pool" ("backstop_id") ` - ) - await db.query( - `CREATE INDEX "IDX_b66a5cc8d2ce7bba1b48fd8c1a" ON "swap_pool" ("token_id") ` - ) - await db.query( - `CREATE TABLE "router" ("id" character varying NOT NULL, "paused" boolean NOT NULL, CONSTRAINT "PK_510c864aa88ac8eb3a306789801" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "event" ("id" character varying NOT NULL, "index" integer NOT NULL, "phase" text NOT NULL, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "call_id" character varying, CONSTRAINT "PK_30c2f3bbaf6d34a55f8ae6e4614" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_2b0d35d675c4f99751855c4502" ON "event" ("block_id") ` - ) - await db.query( - `CREATE INDEX "IDX_129efedcb305c80256db2d57a5" ON "event" ("extrinsic_id") ` - ) - await db.query( - `CREATE INDEX "IDX_83cf1bd59aa4521ed882fa5145" ON "event" ("call_id") ` - ) - await db.query( - `CREATE INDEX "IDX_7723d04c5a2f56c4373b6a4048" ON "event" ("pallet") ` - ) - await db.query( - `CREATE INDEX "IDX_b535fbe8ec6d832dde22065ebd" ON "event" ("name") ` - ) - await db.query( - `CREATE INDEX "IDX_0a00d817e614a91cda40d734cf" ON "event" ("id", "pallet", "name") ` - ) - await db.query( - `CREATE TABLE "call" ("id" character varying NOT NULL, "address" integer array NOT NULL, "success" boolean NOT NULL, "error" jsonb, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "parent_id" character varying, CONSTRAINT "PK_2098af0169792a34f9cfdd39c47" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_bd3f11fd4110d60ac8b96cd62f" ON "call" ("block_id") ` - ) - await db.query( - `CREATE INDEX "IDX_dde30e4f2c6a80f9236bfdf259" ON "call" ("extrinsic_id") ` - ) - await db.query( - `CREATE INDEX "IDX_11c1e76d5be8f04c472c4a05b9" ON "call" ("parent_id") ` - ) - await db.query( - `CREATE INDEX "IDX_d3a8c3d00494950ad6dc93297d" ON "call" ("success") ` - ) - await db.query( - `CREATE INDEX "IDX_776bccbd3d7b3001c8708cf4e0" ON "call" ("pallet") ` - ) - await db.query( - `CREATE INDEX "IDX_8b212022b7428232091e2f8aa5" ON "call" ("name") ` - ) - await db.query( - `CREATE INDEX "IDX_f1e953379e1b3c453cd896bcd4" ON "call" ("id", "pallet", "name") ` - ) - await db.query( - `CREATE TABLE "extrinsic" ("id" character varying NOT NULL, "index" integer NOT NULL, "version" integer NOT NULL, "signature" jsonb, "tip" numeric, "fee" numeric, "success" boolean, "error" jsonb, "hash" bytea NOT NULL, "block_id" character varying, "call_id" character varying, CONSTRAINT "PK_80d7db0e4b1e83e30336bc76755" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_a3b99daba1259dab0dd040d4f7" ON "extrinsic" ("block_id") ` - ) - await db.query( - `CREATE INDEX "IDX_824d47cc4b2cda726405aa507c" ON "extrinsic" ("call_id") ` - ) - await db.query( - `CREATE INDEX "IDX_21e5db7671dfa1b00dbe6dbbd6" ON "extrinsic" ("success") ` - ) - await db.query( - `CREATE INDEX "IDX_1f45de0713a55049009e8e8127" ON "extrinsic" ("hash") ` - ) - await db.query( - `CREATE TABLE "block" ("id" character varying NOT NULL, "height" integer NOT NULL, "hash" bytea NOT NULL, "parent_hash" bytea NOT NULL, "state_root" bytea NOT NULL, "extrinsicsic_root" bytea NOT NULL, "spec_name" text NOT NULL, "spec_version" integer NOT NULL, "impl_name" text NOT NULL, "impl_version" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "validator" bytea, "extrinsics_count" integer NOT NULL, "calls_count" integer NOT NULL, "events_count" integer NOT NULL, CONSTRAINT "PK_d0925763efb591c2e2ffb267572" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_bce676e2b005104ccb768495db" ON "block" ("height") ` - ) - await db.query( - `CREATE INDEX "IDX_f8fba63d7965bfee9f304c487a" ON "block" ("hash") ` - ) - await db.query( - `CREATE INDEX "IDX_5b79d140fa8e2c64a7ef223598" ON "block" ("spec_version") ` - ) - await db.query( - `CREATE INDEX "IDX_5c67cbcf4960c1a39e5fe25e87" ON "block" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_b7e2f8fe1384a2910825029dcb" ON "block" ("validator") ` - ) - await db.query( - `CREATE TABLE "items_counter" ("id" character varying NOT NULL, "type" character varying(10) NOT NULL, "level" character varying(6) NOT NULL, "total" integer NOT NULL, CONSTRAINT "PK_161dcf46142538463f5d7174793" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_68d2eadecb3eeb540d2004acef" ON "items_counter" ("type") ` - ) - await db.query( - `CREATE INDEX "IDX_1d9be1d79f197d42dd163f86c8" ON "items_counter" ("level") ` - ) - await db.query( - `CREATE INDEX "IDX_e03dd1c60ac7622914f72ac2f1" ON "items_counter" ("total") ` - ) - await db.query( - `ALTER TABLE "stable_swap_event" ADD CONSTRAINT "FK_3a147c85b92441217540579be88" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_exchange" ADD CONSTRAINT "FK_1180a78feea28e278229de7db46" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_day_data" ADD CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_hour_data" ADD CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "token_day_data" ADD CONSTRAINT "FK_b8950a8bc7b60231137573740ea" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_hour_data" ADD CONSTRAINT "FK_cf50c55389e428096a68598ee33" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_670629d9904e1f48f4a31abb495" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_781470585a67fef4e215a599773" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_eb823fd4d5a47575039e902efa7" FOREIGN KEY ("liquidity_position_id") REFERENCES "liquidity_position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ed32a41150bc13f18a019741534" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ce85a847b2952f7e685f150de1d" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "mint" ADD CONSTRAINT "FK_19f4328320501dfd14e2bae0855" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "mint" ADD CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "burn" ADD CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "burn" ADD CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap" ADD CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap" ADD CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair" ADD CONSTRAINT "FK_f74dc53460944a424b56b8f7da5" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair" ADD CONSTRAINT "FK_4419691fc411b8af754dfa65ce4" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "single_token_lock_day_data" ADD CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "single_token_lock_hour_data" ADD CONSTRAINT "FK_b2a84dc625103153d651b701dd1" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "single_token_lock" ADD CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "incentive" ADD CONSTRAINT "FK_35286137967591eaff8dee7ca2a" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "incentive" ADD CONSTRAINT "FK_041db4166864a3841e5efed53c4" FOREIGN KEY ("reward_token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "farm" ADD CONSTRAINT "FK_679106a1febf251d7fe7fe081ad" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "farm" ADD CONSTRAINT "FK_00b8f5b860927b1b85e866b20da" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "farm" ADD CONSTRAINT "FK_11da1bf5c406898262d91b41cbb" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap" ADD CONSTRAINT "FK_88cce14adee6d21f5057551c3ea" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_9a6b55d2085464668b622dffe64" FOREIGN KEY ("factory_id") REFERENCES "factory"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_0795adc3723792868094ec76c07" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0" FOREIGN KEY ("standard_info_id") REFERENCES "factory_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027" FOREIGN KEY ("stable_info_id") REFERENCES "stable_swap_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "nabla_token" ADD CONSTRAINT "FK_03f6f92a4dd0116a68bd46ef66b" FOREIGN KEY ("latest_swap_pool_id") REFERENCES "swap_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_208d304702d154e73e4f85c978b" FOREIGN KEY ("swap_pool_id") REFERENCES "swap_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_86080eda96a6de9c3c60be41d86" FOREIGN KEY ("backstop_pool_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_13ef09b925620aedf12b3342caa" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b" FOREIGN KEY ("backstop_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "event" ADD CONSTRAINT "FK_2b0d35d675c4f99751855c45021" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "event" ADD CONSTRAINT "FK_129efedcb305c80256db2d57a59" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "event" ADD CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "call" ADD CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "call" ADD CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "call" ADD CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95" FOREIGN KEY ("parent_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_824d47cc4b2cda726405aa507ca" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - } - - async down(db) { - await db.query(`DROP TABLE "oracle_price"`) - await db.query(`DROP INDEX "public"."IDX_6554f47abd46667280a2523381"`) - await db.query(`DROP INDEX "public"."IDX_2026224855490e321e5c0b6911"`) - await db.query(`DROP INDEX "public"."IDX_a77ac6d79f0929522f5a1aefcb"`) - await db.query(`DROP INDEX "public"."IDX_f7c9bf3bae39fb0a75f12b87dd"`) - await db.query(`DROP TABLE "transfer"`) - await db.query(`DROP INDEX "public"."IDX_d6624eacc30144ea97915fe846"`) - await db.query(`DROP INDEX "public"."IDX_70ff8b624c3118ac3a4862d22c"`) - await db.query(`DROP INDEX "public"."IDX_070c555a86b0b41a534a55a659"`) - await db.query(`DROP INDEX "public"."IDX_f4007436c1b546ede08a4fd7ab"`) - await db.query(`DROP TABLE "factory"`) - await db.query(`DROP TABLE "stable_swap_event"`) - await db.query(`DROP INDEX "public"."IDX_3a147c85b92441217540579be8"`) - await db.query(`DROP TABLE "stable_swap_exchange"`) - await db.query(`DROP INDEX "public"."IDX_1180a78feea28e278229de7db4"`) - await db.query(`DROP TABLE "stable_swap_day_data"`) - await db.query(`DROP INDEX "public"."IDX_648b49eb1a4f2a47f24f13bb51"`) - await db.query(`DROP TABLE "stable_swap_hour_data"`) - await db.query(`DROP INDEX "public"."IDX_94584d2925c30ae0d4b80aadfc"`) - await db.query(`DROP TABLE "token_day_data"`) - await db.query(`DROP INDEX "public"."IDX_b8950a8bc7b60231137573740e"`) - await db.query(`DROP TABLE "pair_hour_data"`) - await db.query(`DROP INDEX "public"."IDX_cf50c55389e428096a68598ee3"`) - await db.query(`DROP TABLE "stable_swap_liquidity_position"`) - await db.query(`DROP INDEX "public"."IDX_f953aebc7c0752f6b8434c9eef"`) - await db.query(`DROP INDEX "public"."IDX_405e0d7aeca80975d88a63bc6e"`) - await db.query(`DROP TABLE "stake_position"`) - await db.query(`DROP INDEX "public"."IDX_2a2b22d2744b497bbcfb03e6ab"`) - await db.query(`DROP INDEX "public"."IDX_670629d9904e1f48f4a31abb49"`) - await db.query(`DROP TABLE "user"`) - await db.query(`DROP TABLE "liquidity_position"`) - await db.query(`DROP INDEX "public"."IDX_781470585a67fef4e215a59977"`) - await db.query(`DROP INDEX "public"."IDX_5a626c8b8962dc01e0f8801be6"`) - await db.query(`DROP TABLE "liquidity_position_snapshot"`) - await db.query(`DROP INDEX "public"."IDX_eb823fd4d5a47575039e902efa"`) - await db.query(`DROP INDEX "public"."IDX_ed32a41150bc13f18a01974153"`) - await db.query(`DROP INDEX "public"."IDX_ce85a847b2952f7e685f150de1"`) - await db.query(`DROP TABLE "transaction"`) - await db.query(`DROP TABLE "mint"`) - await db.query(`DROP INDEX "public"."IDX_19f4328320501dfd14e2bae085"`) - await db.query(`DROP INDEX "public"."IDX_81d470127d4c55d09e9213bc4e"`) - await db.query(`DROP TABLE "burn"`) - await db.query(`DROP INDEX "public"."IDX_20ec76c5c56dd6b47dec5f0aaa"`) - await db.query(`DROP INDEX "public"."IDX_ba144ce938b3266a470d4dd70f"`) - await db.query(`DROP TABLE "swap"`) - await db.query(`DROP INDEX "public"."IDX_78506c4050ae7cedd50b08c0dc"`) - await db.query(`DROP INDEX "public"."IDX_3571ab1dad7640a6b93c705b8f"`) - await db.query(`DROP TABLE "pair"`) - await db.query(`DROP INDEX "public"."IDX_f74dc53460944a424b56b8f7da"`) - await db.query(`DROP INDEX "public"."IDX_4419691fc411b8af754dfa65ce"`) - await db.query(`DROP TABLE "pair_day_data"`) - await db.query(`DROP INDEX "public"."IDX_d8ba7d7d7ad9f0e1c2933a0b7e"`) - await db.query(`DROP INDEX "public"."IDX_88f6e19c40b47053e6e197db1c"`) - await db.query(`DROP INDEX "public"."IDX_ce435d6fc7c373d58e7aab156d"`) - await db.query(`DROP TABLE "token"`) - await db.query(`DROP TABLE "single_token_lock_day_data"`) - await db.query(`DROP INDEX "public"."IDX_f3bf64f43101176dbe5f11a36b"`) - await db.query(`DROP TABLE "single_token_lock_hour_data"`) - await db.query(`DROP INDEX "public"."IDX_b2a84dc625103153d651b701dd"`) - await db.query(`DROP TABLE "single_token_lock"`) - await db.query(`DROP INDEX "public"."IDX_8ebffe66457859d6e1c37b81ac"`) - await db.query(`DROP TABLE "incentive"`) - await db.query(`DROP INDEX "public"."IDX_35286137967591eaff8dee7ca2"`) - await db.query(`DROP INDEX "public"."IDX_041db4166864a3841e5efed53c"`) - await db.query(`DROP TABLE "farm"`) - await db.query(`DROP INDEX "public"."IDX_679106a1febf251d7fe7fe081a"`) - await db.query(`DROP INDEX "public"."IDX_00b8f5b860927b1b85e866b20d"`) - await db.query(`DROP INDEX "public"."IDX_11da1bf5c406898262d91b41cb"`) - await db.query(`DROP TABLE "stable_swap"`) - await db.query(`DROP INDEX "public"."IDX_88cce14adee6d21f5057551c3e"`) - await db.query(`DROP TABLE "stable_swap_info"`) - await db.query(`DROP TABLE "zenlink_info"`) - await db.query(`DROP INDEX "public"."IDX_9a6b55d2085464668b622dffe6"`) - await db.query(`DROP INDEX "public"."IDX_0795adc3723792868094ec76c0"`) - await db.query(`DROP TABLE "token_transfer"`) - await db.query(`DROP INDEX "public"."IDX_b47f7192b72dd8436ef4e6d253"`) - await db.query(`DROP INDEX "public"."IDX_752d6c330729a7b2e283003374"`) - await db.query(`DROP INDEX "public"."IDX_2ef35b71d641ec79b7de3ac237"`) - await db.query(`DROP INDEX "public"."IDX_aae50046f62ba400c07477fb6c"`) - await db.query(`DROP TABLE "token_deposit"`) - await db.query(`DROP INDEX "public"."IDX_395da815b9927f13e2f87c6b54"`) - await db.query(`DROP INDEX "public"."IDX_0f87d313517eaa806c75444749"`) - await db.query(`DROP INDEX "public"."IDX_7194acc3ea037189ff3da743ec"`) - await db.query(`DROP INDEX "public"."IDX_d23ae7a0ea1f640e8e9875b3c2"`) - await db.query(`DROP TABLE "token_withdrawn"`) - await db.query(`DROP INDEX "public"."IDX_e7fd99cae9a1df2e8f69d60892"`) - await db.query(`DROP INDEX "public"."IDX_70e98131fb737e4dce4455ca43"`) - await db.query(`DROP INDEX "public"."IDX_867e6d004e7a4994b3b2aeba63"`) - await db.query(`DROP INDEX "public"."IDX_5697bf049746e5102413ebd832"`) - await db.query(`DROP TABLE "bundle"`) - await db.query(`DROP TABLE "factory_day_data"`) - await db.query(`DROP TABLE "stable_day_data"`) - await db.query(`DROP TABLE "zenlink_day_info"`) - await db.query(`DROP INDEX "public"."IDX_9f281ffbf4f668c1671ae24aeb"`) - await db.query(`DROP INDEX "public"."IDX_3049b8ac70203e95dfc6b42c02"`) - await db.query(`DROP TABLE "zlk_info"`) - await db.query(`DROP TABLE "nabla_token"`) - await db.query(`DROP INDEX "public"."IDX_03f6f92a4dd0116a68bd46ef66"`) - await db.query(`DROP TABLE "nabla_swap_fee"`) - await db.query(`DROP INDEX "public"."IDX_208d304702d154e73e4f85c978"`) - await db.query(`DROP INDEX "public"."IDX_86080eda96a6de9c3c60be41d8"`) - await db.query(`DROP TABLE "backstop_pool"`) - await db.query(`DROP INDEX "public"."IDX_13ef09b925620aedf12b3342ca"`) - await db.query(`DROP INDEX "public"."IDX_8a7a25fa2d22ff634bd3041d81"`) - await db.query(`DROP TABLE "swap_pool"`) - await db.query(`DROP INDEX "public"."IDX_2f5409f002e18e4a6e2fddd858"`) - await db.query(`DROP INDEX "public"."IDX_5c3209a88e41d53bdc450605b3"`) - await db.query(`DROP INDEX "public"."IDX_b66a5cc8d2ce7bba1b48fd8c1a"`) - await db.query(`DROP TABLE "router"`) - await db.query(`DROP TABLE "event"`) - await db.query(`DROP INDEX "public"."IDX_2b0d35d675c4f99751855c4502"`) - await db.query(`DROP INDEX "public"."IDX_129efedcb305c80256db2d57a5"`) - await db.query(`DROP INDEX "public"."IDX_83cf1bd59aa4521ed882fa5145"`) - await db.query(`DROP INDEX "public"."IDX_7723d04c5a2f56c4373b6a4048"`) - await db.query(`DROP INDEX "public"."IDX_b535fbe8ec6d832dde22065ebd"`) - await db.query(`DROP INDEX "public"."IDX_0a00d817e614a91cda40d734cf"`) - await db.query(`DROP TABLE "call"`) - await db.query(`DROP INDEX "public"."IDX_bd3f11fd4110d60ac8b96cd62f"`) - await db.query(`DROP INDEX "public"."IDX_dde30e4f2c6a80f9236bfdf259"`) - await db.query(`DROP INDEX "public"."IDX_11c1e76d5be8f04c472c4a05b9"`) - await db.query(`DROP INDEX "public"."IDX_d3a8c3d00494950ad6dc93297d"`) - await db.query(`DROP INDEX "public"."IDX_776bccbd3d7b3001c8708cf4e0"`) - await db.query(`DROP INDEX "public"."IDX_8b212022b7428232091e2f8aa5"`) - await db.query(`DROP INDEX "public"."IDX_f1e953379e1b3c453cd896bcd4"`) - await db.query(`DROP TABLE "extrinsic"`) - await db.query(`DROP INDEX "public"."IDX_a3b99daba1259dab0dd040d4f7"`) - await db.query(`DROP INDEX "public"."IDX_824d47cc4b2cda726405aa507c"`) - await db.query(`DROP INDEX "public"."IDX_21e5db7671dfa1b00dbe6dbbd6"`) - await db.query(`DROP INDEX "public"."IDX_1f45de0713a55049009e8e8127"`) - await db.query(`DROP TABLE "block"`) - await db.query(`DROP INDEX "public"."IDX_bce676e2b005104ccb768495db"`) - await db.query(`DROP INDEX "public"."IDX_f8fba63d7965bfee9f304c487a"`) - await db.query(`DROP INDEX "public"."IDX_5b79d140fa8e2c64a7ef223598"`) - await db.query(`DROP INDEX "public"."IDX_5c67cbcf4960c1a39e5fe25e87"`) - await db.query(`DROP INDEX "public"."IDX_b7e2f8fe1384a2910825029dcb"`) - await db.query(`DROP TABLE "items_counter"`) - await db.query(`DROP INDEX "public"."IDX_68d2eadecb3eeb540d2004acef"`) - await db.query(`DROP INDEX "public"."IDX_1d9be1d79f197d42dd163f86c8"`) - await db.query(`DROP INDEX "public"."IDX_e03dd1c60ac7622914f72ac2f1"`) - await db.query( - `ALTER TABLE "stable_swap_event" DROP CONSTRAINT "FK_3a147c85b92441217540579be88"` - ) - await db.query( - `ALTER TABLE "stable_swap_exchange" DROP CONSTRAINT "FK_1180a78feea28e278229de7db46"` - ) - await db.query( - `ALTER TABLE "stable_swap_day_data" DROP CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510"` - ) - await db.query( - `ALTER TABLE "stable_swap_hour_data" DROP CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8"` - ) - await db.query( - `ALTER TABLE "token_day_data" DROP CONSTRAINT "FK_b8950a8bc7b60231137573740ea"` - ) - await db.query( - `ALTER TABLE "pair_hour_data" DROP CONSTRAINT "FK_cf50c55389e428096a68598ee33"` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8"` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee"` - ) - await db.query( - `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0"` - ) - await db.query( - `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_670629d9904e1f48f4a31abb495"` - ) - await db.query( - `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_781470585a67fef4e215a599773"` - ) - await db.query( - `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61"` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_eb823fd4d5a47575039e902efa7"` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ed32a41150bc13f18a019741534"` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ce85a847b2952f7e685f150de1d"` - ) - await db.query( - `ALTER TABLE "mint" DROP CONSTRAINT "FK_19f4328320501dfd14e2bae0855"` - ) - await db.query( - `ALTER TABLE "mint" DROP CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1"` - ) - await db.query( - `ALTER TABLE "burn" DROP CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8"` - ) - await db.query( - `ALTER TABLE "burn" DROP CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa"` - ) - await db.query( - `ALTER TABLE "swap" DROP CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5"` - ) - await db.query( - `ALTER TABLE "swap" DROP CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7"` - ) - await db.query( - `ALTER TABLE "pair" DROP CONSTRAINT "FK_f74dc53460944a424b56b8f7da5"` - ) - await db.query( - `ALTER TABLE "pair" DROP CONSTRAINT "FK_4419691fc411b8af754dfa65ce4"` - ) - await db.query( - `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2"` - ) - await db.query( - `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9"` - ) - await db.query( - `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9"` - ) - await db.query( - `ALTER TABLE "single_token_lock_day_data" DROP CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd"` - ) - await db.query( - `ALTER TABLE "single_token_lock_hour_data" DROP CONSTRAINT "FK_b2a84dc625103153d651b701dd1"` - ) - await db.query( - `ALTER TABLE "single_token_lock" DROP CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3"` - ) - await db.query( - `ALTER TABLE "incentive" DROP CONSTRAINT "FK_35286137967591eaff8dee7ca2a"` - ) - await db.query( - `ALTER TABLE "incentive" DROP CONSTRAINT "FK_041db4166864a3841e5efed53c4"` - ) - await db.query( - `ALTER TABLE "farm" DROP CONSTRAINT "FK_679106a1febf251d7fe7fe081ad"` - ) - await db.query( - `ALTER TABLE "farm" DROP CONSTRAINT "FK_00b8f5b860927b1b85e866b20da"` - ) - await db.query( - `ALTER TABLE "farm" DROP CONSTRAINT "FK_11da1bf5c406898262d91b41cbb"` - ) - await db.query( - `ALTER TABLE "stable_swap" DROP CONSTRAINT "FK_88cce14adee6d21f5057551c3ea"` - ) - await db.query( - `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_9a6b55d2085464668b622dffe64"` - ) - await db.query( - `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_0795adc3723792868094ec76c07"` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0"` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027"` - ) - await db.query( - `ALTER TABLE "nabla_token" DROP CONSTRAINT "FK_03f6f92a4dd0116a68bd46ef66b"` - ) - await db.query( - `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_208d304702d154e73e4f85c978b"` - ) - await db.query( - `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_86080eda96a6de9c3c60be41d86"` - ) - await db.query( - `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_13ef09b925620aedf12b3342caa"` - ) - await db.query( - `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab"` - ) - await db.query( - `ALTER TABLE "event" DROP CONSTRAINT "FK_2b0d35d675c4f99751855c45021"` - ) - await db.query( - `ALTER TABLE "event" DROP CONSTRAINT "FK_129efedcb305c80256db2d57a59"` - ) - await db.query( - `ALTER TABLE "event" DROP CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452"` - ) - await db.query( - `ALTER TABLE "call" DROP CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3"` - ) - await db.query( - `ALTER TABLE "call" DROP CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590"` - ) - await db.query( - `ALTER TABLE "call" DROP CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95"` - ) - await db.query( - `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74"` - ) - await db.query( - `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_824d47cc4b2cda726405aa507ca"` - ) - } -} diff --git a/db/migrations/1708373922157-Data.js b/db/migrations/1708373922157-Data.js deleted file mode 100644 index 7e7fba64..00000000 --- a/db/migrations/1708373922157-Data.js +++ /dev/null @@ -1,27 +0,0 @@ -module.exports = class Data1708373922157 { - name = 'Data1708373922157' - - async up(db) { - await db.query( - `ALTER TABLE "nabla_token" DROP CONSTRAINT "FK_03f6f92a4dd0116a68bd46ef66b"` - ) - await db.query(`DROP INDEX "public"."IDX_03f6f92a4dd0116a68bd46ef66"`) - await db.query( - `ALTER TABLE "nabla_token" DROP COLUMN "latest_swap_pool_id"` - ) - await db.query(`ALTER TABLE "swap_pool" DROP COLUMN "covered_index"`) - } - - async down(db) { - await db.query( - `ALTER TABLE "nabla_token" ADD CONSTRAINT "FK_03f6f92a4dd0116a68bd46ef66b" FOREIGN KEY ("latest_swap_pool_id") REFERENCES "swap_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `CREATE INDEX "IDX_03f6f92a4dd0116a68bd46ef66" ON "nabla_token" ("latest_swap_pool_id") ` - ) - await db.query( - `ALTER TABLE "nabla_token" ADD "latest_swap_pool_id" character varying` - ) - await db.query(`ALTER TABLE "swap_pool" ADD "covered_index" numeric`) - } -} diff --git a/db/migrations/1708525160246-Data.js b/db/migrations/1708525160246-Data.js deleted file mode 100644 index 25f44142..00000000 --- a/db/migrations/1708525160246-Data.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = class Data1708525160246 { - name = 'Data1708525160246' - - async up(db) { - await db.query( - `ALTER TABLE "backstop_pool" ADD "lp_token_decimals" integer NOT NULL` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD "lp_token_decimals" integer NOT NULL` - ) - } - - async down(db) { - await db.query( - `ALTER TABLE "backstop_pool" DROP COLUMN "lp_token_decimals"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP COLUMN "lp_token_decimals"` - ) - } -} diff --git a/db/migrations/1714027551702-Data.js b/db/migrations/1714027551702-Data.js deleted file mode 100644 index 329e8763..00000000 --- a/db/migrations/1714027551702-Data.js +++ /dev/null @@ -1,885 +0,0 @@ -module.exports = class Data1714027551702 { - name = 'Data1714027551702' - - async up(db) { - await db.query( - `CREATE TABLE "oracle_price" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "blockchain" text NOT NULL, "timestamp" numeric NOT NULL, "price" text NOT NULL, "supply" text NOT NULL, "decimals" integer NOT NULL, CONSTRAINT "PK_606c938b2474588b154eb625f3b" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_6554f47abd46667280a2523381" ON "oracle_price" ("symbol") ` - ) - await db.query( - `CREATE INDEX "IDX_2026224855490e321e5c0b6911" ON "oracle_price" ("blockchain") ` - ) - await db.query( - `CREATE INDEX "IDX_a77ac6d79f0929522f5a1aefcb" ON "oracle_price" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_f7c9bf3bae39fb0a75f12b87dd" ON "oracle_price" ("price") ` - ) - await db.query( - `CREATE TABLE "transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "amount" numeric NOT NULL, "fee" numeric NOT NULL, "remark" text, CONSTRAINT "PK_fd9ddbdd49a17afcbe014401295" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_d6624eacc30144ea97915fe846" ON "transfer" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_70ff8b624c3118ac3a4862d22c" ON "transfer" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_070c555a86b0b41a534a55a659" ON "transfer" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_f4007436c1b546ede08a4fd7ab" ON "transfer" ("amount") ` - ) - await db.query( - `CREATE TABLE "factory" ("id" character varying NOT NULL, "pair_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_volume_eth" text NOT NULL, "untracked_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_1372e5a7d114a3fa80736ba66bb" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "stable_swap_event" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_8b61dbc9b556ed8fcb4030fee7d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_3a147c85b92441217540579be8" ON "stable_swap_event" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_exchange" ("id" character varying NOT NULL, "data" jsonb, "block" numeric NOT NULL, "timestamp" numeric NOT NULL, "transaction" bytea NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_f06e489da865134dcfac3bbcd22" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_1180a78feea28e278229de7db4" ON "stable_swap_exchange" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_819b3b7bf9c8055e14e0bf1c578" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_648b49eb1a4f2a47f24f13bb51" ON "stable_swap_day_data" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "hourly_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "stable_swap_id" character varying, CONSTRAINT "PK_2aedd41b95c37330a4a8429e192" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_94584d2925c30ae0d4b80aadfc" ON "stable_swap_hour_data" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "token_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_token" text NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "total_liquidity_token" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_liquidity_usd" text NOT NULL, "price_usd" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_73fc06337215e86196b36822116" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_b8950a8bc7b60231137573740e" ON "token_day_data" ("token_id") ` - ) - await db.query( - `CREATE TABLE "pair_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "hourly_volume_token0" text NOT NULL, "hourly_volume_token1" text NOT NULL, "hourly_volume_usd" text NOT NULL, "hourly_txns" integer NOT NULL, "pair_id" character varying, CONSTRAINT "PK_ffc544bb3e72cfd3e48a8b01452" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_cf50c55389e428096a68598ee3" ON "pair_hour_data" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "stable_swap_id" character varying, CONSTRAINT "PK_12f435243c8a739330c0881d720" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_f953aebc7c0752f6b8434c9eef" ON "stable_swap_liquidity_position" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_405e0d7aeca80975d88a63bc6e" ON "stable_swap_liquidity_position" ("stable_swap_id") ` - ) - await db.query( - `CREATE TABLE "stake_position" ("id" character varying NOT NULL, "liquidity_staked_balance" numeric NOT NULL, "user_id" character varying, "farm_id" character varying, CONSTRAINT "PK_17615803509bd6065f1ab8b0ced" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_2a2b22d2744b497bbcfb03e6ab" ON "stake_position" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_670629d9904e1f48f4a31abb49" ON "stake_position" ("farm_id") ` - ) - await db.query( - `CREATE TABLE "user" ("id" character varying NOT NULL, "usd_swapped" text NOT NULL, CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "liquidity_position" ("id" character varying NOT NULL, "liquidity_token_balance" text NOT NULL, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_db00d963c96b3914d26abe3c3d2" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_781470585a67fef4e215a59977" ON "liquidity_position" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_5a626c8b8962dc01e0f8801be6" ON "liquidity_position" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "liquidity_position_snapshot" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block" integer NOT NULL, "token0_price_usd" text NOT NULL, "token1_price_usd" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "reserve_usd" text NOT NULL, "liquidity_token_total_supply" text NOT NULL, "liquidity_token_balance" text NOT NULL, "liquidity_position_id" character varying, "user_id" character varying, "pair_id" character varying, CONSTRAINT "PK_cd4ed3539266b2439349a9fa791" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_eb823fd4d5a47575039e902efa" ON "liquidity_position_snapshot" ("liquidity_position_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ed32a41150bc13f18a01974153" ON "liquidity_position_snapshot" ("user_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ce85a847b2952f7e685f150de1" ON "liquidity_position_snapshot" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "transaction" ("id" character varying NOT NULL, "block_number" numeric NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "mints" text array NOT NULL, "burns" text array NOT NULL, "swaps" text array NOT NULL, CONSTRAINT "PK_89eadb93a89810556e1cbcd6ab9" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "mint" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "to" text NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "log_index" integer, "amount_usd" text, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_fcaea791104aa41aa11dac29cb2" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_19f4328320501dfd14e2bae085" ON "mint" ("transaction_id") ` - ) - await db.query( - `CREATE INDEX "IDX_81d470127d4c55d09e9213bc4e" ON "mint" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "burn" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "liquidity" text NOT NULL, "sender" text, "amount0" text, "amount1" text, "to" text, "log_index" integer, "amount_usd" text, "needs_complete" boolean NOT NULL, "fee_to" text, "fee_liquidity" text, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_dcb4f14ee4534154b31116553f0" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_20ec76c5c56dd6b47dec5f0aaa" ON "burn" ("transaction_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ba144ce938b3266a470d4dd70f" ON "burn" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "swap" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "from" text NOT NULL, "amount0_in" text NOT NULL, "amount1_in" text NOT NULL, "amount0_out" text NOT NULL, "amount1_out" text NOT NULL, "to" text NOT NULL, "log_index" integer, "amount_usd" text NOT NULL, "transaction_id" character varying, "pair_id" character varying, CONSTRAINT "PK_4a10d0f359339acef77e7f986d9" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_78506c4050ae7cedd50b08c0dc" ON "swap" ("transaction_id") ` - ) - await db.query( - `CREATE INDEX "IDX_3571ab1dad7640a6b93c705b8f" ON "swap" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "pair" ("id" character varying NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_eth" text NOT NULL, "reserve_usd" text NOT NULL, "tracked_reserve_eth" text NOT NULL, "token0_price" text NOT NULL, "token1_price" text NOT NULL, "volume_token0" text NOT NULL, "volume_token1" text NOT NULL, "volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "created_at_timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "created_at_block_number" numeric NOT NULL, "liquidity_provider_count" integer NOT NULL, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_3eaf216329c5c50aedb94fa797e" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_f74dc53460944a424b56b8f7da" ON "pair" ("token0_id") ` - ) - await db.query( - `CREATE INDEX "IDX_4419691fc411b8af754dfa65ce" ON "pair" ("token1_id") ` - ) - await db.query( - `CREATE TABLE "pair_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "pair_address" text NOT NULL, "reserve0" text NOT NULL, "reserve1" text NOT NULL, "total_supply" text NOT NULL, "reserve_usd" text NOT NULL, "daily_volume_token0" text NOT NULL, "daily_volume_token1" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_txns" integer NOT NULL, "pair_id" character varying, "token0_id" character varying, "token1_id" character varying, CONSTRAINT "PK_ac35ed26ab0c71d491a62e2881a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_d8ba7d7d7ad9f0e1c2933a0b7e" ON "pair_day_data" ("pair_id") ` - ) - await db.query( - `CREATE INDEX "IDX_88f6e19c40b47053e6e197db1c" ON "pair_day_data" ("token0_id") ` - ) - await db.query( - `CREATE INDEX "IDX_ce435d6fc7c373d58e7aab156d" ON "pair_day_data" ("token1_id") ` - ) - await db.query( - `CREATE TABLE "token" ("id" character varying NOT NULL, "symbol" text NOT NULL, "name" text NOT NULL, "decimals" integer NOT NULL, "total_supply" text NOT NULL, "trade_volume" text NOT NULL, "trade_volume_usd" text NOT NULL, "untracked_volume_usd" text NOT NULL, "tx_count" integer NOT NULL, "total_liquidity" text NOT NULL, "derived_eth" text NOT NULL, CONSTRAINT "PK_82fae97f905930df5d62a702fc9" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "single_token_lock_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_87d03adf6b8624eaff434355e53" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_f3bf64f43101176dbe5f11a36b" ON "single_token_lock_day_data" ("single_token_lock_id") ` - ) - await db.query( - `CREATE TABLE "single_token_lock_hour_data" ("id" character varying NOT NULL, "hour_start_unix" numeric NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity_eth" text NOT NULL, "single_token_lock_id" character varying, CONSTRAINT "PK_9173bf5d597c5ce35bbce2e664b" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_b2a84dc625103153d651b701dd" ON "single_token_lock_hour_data" ("single_token_lock_id") ` - ) - await db.query( - `CREATE TABLE "single_token_lock" ("id" character varying NOT NULL, "total_liquidity_usd" text NOT NULL, "total_liquidity" text NOT NULL, "total_liquidity_eth" text NOT NULL, "token_id" character varying, CONSTRAINT "PK_b3d635331ccfacc4f532569364b" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_8ebffe66457859d6e1c37b81ac" ON "single_token_lock" ("token_id") ` - ) - await db.query( - `CREATE TABLE "incentive" ("id" character varying NOT NULL, "reward_per_day" text NOT NULL, "farm_id" character varying, "reward_token_id" character varying, CONSTRAINT "PK_fc2c4e32d8711392ddf918b9f6c" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_35286137967591eaff8dee7ca2" ON "incentive" ("farm_id") ` - ) - await db.query( - `CREATE INDEX "IDX_041db4166864a3841e5efed53c" ON "incentive" ("reward_token_id") ` - ) - await db.query( - `CREATE TABLE "farm" ("id" character varying NOT NULL, "pid" numeric NOT NULL, "stake_token" text NOT NULL, "liquidity_staked" numeric NOT NULL, "created_at_block" numeric NOT NULL, "created_at_timestamp" numeric NOT NULL, "staked_usd" text NOT NULL, "reward_usd_per_day" text NOT NULL, "stake_apr" text NOT NULL, "single_token_lock_id" character varying, "stable_swap_id" character varying, "pair_id" character varying, CONSTRAINT "PK_3bf246b27a3b6678dfc0b7a3f64" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_679106a1febf251d7fe7fe081a" ON "farm" ("single_token_lock_id") ` - ) - await db.query( - `CREATE INDEX "IDX_00b8f5b860927b1b85e866b20d" ON "farm" ("stable_swap_id") ` - ) - await db.query( - `CREATE INDEX "IDX_11da1bf5c406898262d91b41cb" ON "farm" ("pair_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap" ("id" character varying NOT NULL, "address" text NOT NULL, "base_swap_address" text NOT NULL, "num_tokens" integer NOT NULL, "tokens" text array NOT NULL, "base_tokens" text array NOT NULL, "all_tokens" text array NOT NULL, "balances" text array NOT NULL, "lp_token" text NOT NULL, "lp_total_supply" text NOT NULL, "a" numeric NOT NULL, "swap_fee" numeric NOT NULL, "admin_fee" numeric NOT NULL, "virtual_price" numeric NOT NULL, "tvl_usd" text NOT NULL, "volume_usd" text NOT NULL, "stable_swap_info_id" character varying, CONSTRAINT "PK_37316f6fedc29bf95a6f1804c65" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_88cce14adee6d21f5057551c3e" ON "stable_swap" ("stable_swap_info_id") ` - ) - await db.query( - `CREATE TABLE "stable_swap_info" ("id" character varying NOT NULL, "pool_count" integer NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_21998b071d5e28639e21e9b2da7" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "zenlink_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "total_volume_usd" text NOT NULL, "total_tvl_usd" text NOT NULL, "tx_count" integer NOT NULL, "factory_id" character varying, "stable_swap_info_id" character varying, CONSTRAINT "PK_2526d46468e5c4f7c4156840a90" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_9a6b55d2085464668b622dffe6" ON "zenlink_info" ("factory_id") ` - ) - await db.query( - `CREATE INDEX "IDX_0795adc3723792868094ec76c0" ON "zenlink_info" ("stable_swap_info_id") ` - ) - await db.query( - `CREATE TABLE "token_transfer" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "from" text NOT NULL, "to" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, "remark" text, CONSTRAINT "PK_77384b7f5874553f012eba9da41" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_b47f7192b72dd8436ef4e6d253" ON "token_transfer" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_752d6c330729a7b2e283003374" ON "token_transfer" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_2ef35b71d641ec79b7de3ac237" ON "token_transfer" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_aae50046f62ba400c07477fb6c" ON "token_transfer" ("amount") ` - ) - await db.query( - `CREATE TABLE "token_deposit" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_7c5eea7aeab3f0e71da8d2d9f4f" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_395da815b9927f13e2f87c6b54" ON "token_deposit" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_0f87d313517eaa806c75444749" ON "token_deposit" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_7194acc3ea037189ff3da743ec" ON "token_deposit" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_d23ae7a0ea1f640e8e9875b3c2" ON "token_deposit" ("amount") ` - ) - await db.query( - `CREATE TABLE "token_withdrawn" ("id" character varying NOT NULL, "block_number" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_hash" text, "who" text NOT NULL, "currency_id" text NOT NULL, "amount" numeric NOT NULL, CONSTRAINT "PK_658727649cde2e20f8cf69abeb5" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_e7fd99cae9a1df2e8f69d60892" ON "token_withdrawn" ("block_number") ` - ) - await db.query( - `CREATE INDEX "IDX_70e98131fb737e4dce4455ca43" ON "token_withdrawn" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_867e6d004e7a4994b3b2aeba63" ON "token_withdrawn" ("extrinsic_hash") ` - ) - await db.query( - `CREATE INDEX "IDX_5697bf049746e5102413ebd832" ON "token_withdrawn" ("amount") ` - ) - await db.query( - `CREATE TABLE "bundle" ("id" character varying NOT NULL, "eth_price" text NOT NULL, CONSTRAINT "PK_637e3f87e837d6532109c198dea" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "factory_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_eth" text NOT NULL, "daily_volume_usd" text NOT NULL, "daily_volume_untracked" text NOT NULL, "total_volume_eth" text NOT NULL, "total_liquidity_eth" text NOT NULL, "total_volume_usd" text NOT NULL, "total_liquidity_usd" text NOT NULL, "tx_count" integer NOT NULL, CONSTRAINT "PK_4b56c54390ce8e399d8e37e169d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "stable_day_data" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, CONSTRAINT "PK_3663f18340bb5fdc0023ecc624a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "zenlink_day_info" ("id" character varying NOT NULL, "date" TIMESTAMP WITH TIME ZONE NOT NULL, "daily_volume_usd" text NOT NULL, "tvl_usd" text NOT NULL, "standard_info_id" character varying, "stable_info_id" character varying, CONSTRAINT "PK_747195cfa3811d6eea0ff6389de" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_9f281ffbf4f668c1671ae24aeb" ON "zenlink_day_info" ("standard_info_id") ` - ) - await db.query( - `CREATE INDEX "IDX_3049b8ac70203e95dfc6b42c02" ON "zenlink_day_info" ("stable_info_id") ` - ) - await db.query( - `CREATE TABLE "zlk_info" ("id" character varying NOT NULL, "updated_date" TIMESTAMP WITH TIME ZONE NOT NULL, "burn" numeric NOT NULL, CONSTRAINT "PK_58853b5e24384aba0da2023e91e" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "nabla_token" ("id" character varying NOT NULL, "decimals" integer NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, CONSTRAINT "PK_d036fec883bded17a5c2e09cf0a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "nabla_swap_fee" ("id" character varying NOT NULL, "lp_fees" numeric NOT NULL, "backstop_fees" numeric NOT NULL, "protocol_fees" numeric NOT NULL, "timestamp" numeric NOT NULL, "swap_pool_id" character varying, "backstop_pool_id" character varying, CONSTRAINT "PK_8824e4a63ae77ecf8a55aa5359a" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_208d304702d154e73e4f85c978" ON "nabla_swap_fee" ("swap_pool_id") ` - ) - await db.query( - `CREATE INDEX "IDX_86080eda96a6de9c3c60be41d8" ON "nabla_swap_fee" ("backstop_pool_id") ` - ) - await db.query( - `CREATE TABLE "backstop_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "lp_token_decimals" integer NOT NULL, "reserves" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "router_id" character varying, "token_id" character varying, CONSTRAINT "PK_bf2d01d9ce60ad9ee4b1b087d9d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_13ef09b925620aedf12b3342ca" ON "backstop_pool" ("router_id") ` - ) - await db.query( - `CREATE INDEX "IDX_8a7a25fa2d22ff634bd3041d81" ON "backstop_pool" ("token_id") ` - ) - await db.query( - `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "lp_token_decimals" integer NOT NULL, "reserve" numeric NOT NULL, "reserve_with_slippage" numeric NOT NULL, "total_liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_2f5409f002e18e4a6e2fddd858" ON "swap_pool" ("router_id") ` - ) - await db.query( - `CREATE INDEX "IDX_5c3209a88e41d53bdc450605b3" ON "swap_pool" ("backstop_id") ` - ) - await db.query( - `CREATE INDEX "IDX_b66a5cc8d2ce7bba1b48fd8c1a" ON "swap_pool" ("token_id") ` - ) - await db.query( - `CREATE TABLE "router" ("id" character varying NOT NULL, "paused" boolean NOT NULL, CONSTRAINT "PK_510c864aa88ac8eb3a306789801" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE TABLE "event" ("id" character varying NOT NULL, "index" integer NOT NULL, "phase" text NOT NULL, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "call_id" character varying, CONSTRAINT "PK_30c2f3bbaf6d34a55f8ae6e4614" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_2b0d35d675c4f99751855c4502" ON "event" ("block_id") ` - ) - await db.query( - `CREATE INDEX "IDX_129efedcb305c80256db2d57a5" ON "event" ("extrinsic_id") ` - ) - await db.query( - `CREATE INDEX "IDX_83cf1bd59aa4521ed882fa5145" ON "event" ("call_id") ` - ) - await db.query( - `CREATE INDEX "IDX_7723d04c5a2f56c4373b6a4048" ON "event" ("pallet") ` - ) - await db.query( - `CREATE INDEX "IDX_b535fbe8ec6d832dde22065ebd" ON "event" ("name") ` - ) - await db.query( - `CREATE INDEX "IDX_0a00d817e614a91cda40d734cf" ON "event" ("id", "pallet", "name") ` - ) - await db.query( - `CREATE TABLE "call" ("id" character varying NOT NULL, "address" integer array NOT NULL, "success" boolean NOT NULL, "error" jsonb, "pallet" text NOT NULL, "name" text NOT NULL, "args" jsonb, "args_str" text array, "block_id" character varying, "extrinsic_id" character varying, "parent_id" character varying, CONSTRAINT "PK_2098af0169792a34f9cfdd39c47" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_bd3f11fd4110d60ac8b96cd62f" ON "call" ("block_id") ` - ) - await db.query( - `CREATE INDEX "IDX_dde30e4f2c6a80f9236bfdf259" ON "call" ("extrinsic_id") ` - ) - await db.query( - `CREATE INDEX "IDX_11c1e76d5be8f04c472c4a05b9" ON "call" ("parent_id") ` - ) - await db.query( - `CREATE INDEX "IDX_d3a8c3d00494950ad6dc93297d" ON "call" ("success") ` - ) - await db.query( - `CREATE INDEX "IDX_776bccbd3d7b3001c8708cf4e0" ON "call" ("pallet") ` - ) - await db.query( - `CREATE INDEX "IDX_8b212022b7428232091e2f8aa5" ON "call" ("name") ` - ) - await db.query( - `CREATE INDEX "IDX_f1e953379e1b3c453cd896bcd4" ON "call" ("id", "pallet", "name") ` - ) - await db.query( - `CREATE TABLE "extrinsic" ("id" character varying NOT NULL, "index" integer NOT NULL, "version" integer NOT NULL, "signature" jsonb, "tip" numeric, "fee" numeric, "success" boolean, "error" jsonb, "hash" bytea NOT NULL, "block_id" character varying, "call_id" character varying, CONSTRAINT "PK_80d7db0e4b1e83e30336bc76755" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_a3b99daba1259dab0dd040d4f7" ON "extrinsic" ("block_id") ` - ) - await db.query( - `CREATE INDEX "IDX_824d47cc4b2cda726405aa507c" ON "extrinsic" ("call_id") ` - ) - await db.query( - `CREATE INDEX "IDX_21e5db7671dfa1b00dbe6dbbd6" ON "extrinsic" ("success") ` - ) - await db.query( - `CREATE INDEX "IDX_1f45de0713a55049009e8e8127" ON "extrinsic" ("hash") ` - ) - await db.query( - `CREATE TABLE "block" ("id" character varying NOT NULL, "height" integer NOT NULL, "hash" bytea NOT NULL, "parent_hash" bytea NOT NULL, "state_root" bytea NOT NULL, "extrinsicsic_root" bytea NOT NULL, "spec_name" text NOT NULL, "spec_version" integer NOT NULL, "impl_name" text NOT NULL, "impl_version" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "validator" bytea, "extrinsics_count" integer NOT NULL, "calls_count" integer NOT NULL, "events_count" integer NOT NULL, CONSTRAINT "PK_d0925763efb591c2e2ffb267572" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_bce676e2b005104ccb768495db" ON "block" ("height") ` - ) - await db.query( - `CREATE INDEX "IDX_f8fba63d7965bfee9f304c487a" ON "block" ("hash") ` - ) - await db.query( - `CREATE INDEX "IDX_5b79d140fa8e2c64a7ef223598" ON "block" ("spec_version") ` - ) - await db.query( - `CREATE INDEX "IDX_5c67cbcf4960c1a39e5fe25e87" ON "block" ("timestamp") ` - ) - await db.query( - `CREATE INDEX "IDX_b7e2f8fe1384a2910825029dcb" ON "block" ("validator") ` - ) - await db.query( - `CREATE TABLE "items_counter" ("id" character varying NOT NULL, "type" character varying(10) NOT NULL, "level" character varying(6) NOT NULL, "total" integer NOT NULL, CONSTRAINT "PK_161dcf46142538463f5d7174793" PRIMARY KEY ("id"))` - ) - await db.query( - `CREATE INDEX "IDX_68d2eadecb3eeb540d2004acef" ON "items_counter" ("type") ` - ) - await db.query( - `CREATE INDEX "IDX_1d9be1d79f197d42dd163f86c8" ON "items_counter" ("level") ` - ) - await db.query( - `CREATE INDEX "IDX_e03dd1c60ac7622914f72ac2f1" ON "items_counter" ("total") ` - ) - await db.query( - `ALTER TABLE "stable_swap_event" ADD CONSTRAINT "FK_3a147c85b92441217540579be88" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_exchange" ADD CONSTRAINT "FK_1180a78feea28e278229de7db46" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_day_data" ADD CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_hour_data" ADD CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "token_day_data" ADD CONSTRAINT "FK_b8950a8bc7b60231137573740ea" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_hour_data" ADD CONSTRAINT "FK_cf50c55389e428096a68598ee33" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" ADD CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stake_position" ADD CONSTRAINT "FK_670629d9904e1f48f4a31abb495" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_781470585a67fef4e215a599773" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position" ADD CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_eb823fd4d5a47575039e902efa7" FOREIGN KEY ("liquidity_position_id") REFERENCES "liquidity_position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ed32a41150bc13f18a019741534" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" ADD CONSTRAINT "FK_ce85a847b2952f7e685f150de1d" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "mint" ADD CONSTRAINT "FK_19f4328320501dfd14e2bae0855" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "mint" ADD CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "burn" ADD CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "burn" ADD CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap" ADD CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5" FOREIGN KEY ("transaction_id") REFERENCES "transaction"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap" ADD CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair" ADD CONSTRAINT "FK_f74dc53460944a424b56b8f7da5" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair" ADD CONSTRAINT "FK_4419691fc411b8af754dfa65ce4" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9" FOREIGN KEY ("token0_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "pair_day_data" ADD CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9" FOREIGN KEY ("token1_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "single_token_lock_day_data" ADD CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "single_token_lock_hour_data" ADD CONSTRAINT "FK_b2a84dc625103153d651b701dd1" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "single_token_lock" ADD CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3" FOREIGN KEY ("token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "incentive" ADD CONSTRAINT "FK_35286137967591eaff8dee7ca2a" FOREIGN KEY ("farm_id") REFERENCES "farm"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "incentive" ADD CONSTRAINT "FK_041db4166864a3841e5efed53c4" FOREIGN KEY ("reward_token_id") REFERENCES "token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "farm" ADD CONSTRAINT "FK_679106a1febf251d7fe7fe081ad" FOREIGN KEY ("single_token_lock_id") REFERENCES "single_token_lock"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "farm" ADD CONSTRAINT "FK_00b8f5b860927b1b85e866b20da" FOREIGN KEY ("stable_swap_id") REFERENCES "stable_swap"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "farm" ADD CONSTRAINT "FK_11da1bf5c406898262d91b41cbb" FOREIGN KEY ("pair_id") REFERENCES "pair"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "stable_swap" ADD CONSTRAINT "FK_88cce14adee6d21f5057551c3ea" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_9a6b55d2085464668b622dffe64" FOREIGN KEY ("factory_id") REFERENCES "factory"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_info" ADD CONSTRAINT "FK_0795adc3723792868094ec76c07" FOREIGN KEY ("stable_swap_info_id") REFERENCES "stable_swap_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0" FOREIGN KEY ("standard_info_id") REFERENCES "factory_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" ADD CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027" FOREIGN KEY ("stable_info_id") REFERENCES "stable_swap_day_data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_208d304702d154e73e4f85c978b" FOREIGN KEY ("swap_pool_id") REFERENCES "swap_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "nabla_swap_fee" ADD CONSTRAINT "FK_86080eda96a6de9c3c60be41d86" FOREIGN KEY ("backstop_pool_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_13ef09b925620aedf12b3342caa" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "backstop_pool" ADD CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582" FOREIGN KEY ("router_id") REFERENCES "router"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b" FOREIGN KEY ("backstop_id") REFERENCES "backstop_pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "swap_pool" ADD CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab" FOREIGN KEY ("token_id") REFERENCES "nabla_token"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "event" ADD CONSTRAINT "FK_2b0d35d675c4f99751855c45021" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "event" ADD CONSTRAINT "FK_129efedcb305c80256db2d57a59" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "event" ADD CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "call" ADD CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "call" ADD CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590" FOREIGN KEY ("extrinsic_id") REFERENCES "extrinsic"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "call" ADD CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95" FOREIGN KEY ("parent_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74" FOREIGN KEY ("block_id") REFERENCES "block"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - await db.query( - `ALTER TABLE "extrinsic" ADD CONSTRAINT "FK_824d47cc4b2cda726405aa507ca" FOREIGN KEY ("call_id") REFERENCES "call"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` - ) - } - - async down(db) { - await db.query(`DROP TABLE "oracle_price"`) - await db.query(`DROP INDEX "public"."IDX_6554f47abd46667280a2523381"`) - await db.query(`DROP INDEX "public"."IDX_2026224855490e321e5c0b6911"`) - await db.query(`DROP INDEX "public"."IDX_a77ac6d79f0929522f5a1aefcb"`) - await db.query(`DROP INDEX "public"."IDX_f7c9bf3bae39fb0a75f12b87dd"`) - await db.query(`DROP TABLE "transfer"`) - await db.query(`DROP INDEX "public"."IDX_d6624eacc30144ea97915fe846"`) - await db.query(`DROP INDEX "public"."IDX_70ff8b624c3118ac3a4862d22c"`) - await db.query(`DROP INDEX "public"."IDX_070c555a86b0b41a534a55a659"`) - await db.query(`DROP INDEX "public"."IDX_f4007436c1b546ede08a4fd7ab"`) - await db.query(`DROP TABLE "factory"`) - await db.query(`DROP TABLE "stable_swap_event"`) - await db.query(`DROP INDEX "public"."IDX_3a147c85b92441217540579be8"`) - await db.query(`DROP TABLE "stable_swap_exchange"`) - await db.query(`DROP INDEX "public"."IDX_1180a78feea28e278229de7db4"`) - await db.query(`DROP TABLE "stable_swap_day_data"`) - await db.query(`DROP INDEX "public"."IDX_648b49eb1a4f2a47f24f13bb51"`) - await db.query(`DROP TABLE "stable_swap_hour_data"`) - await db.query(`DROP INDEX "public"."IDX_94584d2925c30ae0d4b80aadfc"`) - await db.query(`DROP TABLE "token_day_data"`) - await db.query(`DROP INDEX "public"."IDX_b8950a8bc7b60231137573740e"`) - await db.query(`DROP TABLE "pair_hour_data"`) - await db.query(`DROP INDEX "public"."IDX_cf50c55389e428096a68598ee3"`) - await db.query(`DROP TABLE "stable_swap_liquidity_position"`) - await db.query(`DROP INDEX "public"."IDX_f953aebc7c0752f6b8434c9eef"`) - await db.query(`DROP INDEX "public"."IDX_405e0d7aeca80975d88a63bc6e"`) - await db.query(`DROP TABLE "stake_position"`) - await db.query(`DROP INDEX "public"."IDX_2a2b22d2744b497bbcfb03e6ab"`) - await db.query(`DROP INDEX "public"."IDX_670629d9904e1f48f4a31abb49"`) - await db.query(`DROP TABLE "user"`) - await db.query(`DROP TABLE "liquidity_position"`) - await db.query(`DROP INDEX "public"."IDX_781470585a67fef4e215a59977"`) - await db.query(`DROP INDEX "public"."IDX_5a626c8b8962dc01e0f8801be6"`) - await db.query(`DROP TABLE "liquidity_position_snapshot"`) - await db.query(`DROP INDEX "public"."IDX_eb823fd4d5a47575039e902efa"`) - await db.query(`DROP INDEX "public"."IDX_ed32a41150bc13f18a01974153"`) - await db.query(`DROP INDEX "public"."IDX_ce85a847b2952f7e685f150de1"`) - await db.query(`DROP TABLE "transaction"`) - await db.query(`DROP TABLE "mint"`) - await db.query(`DROP INDEX "public"."IDX_19f4328320501dfd14e2bae085"`) - await db.query(`DROP INDEX "public"."IDX_81d470127d4c55d09e9213bc4e"`) - await db.query(`DROP TABLE "burn"`) - await db.query(`DROP INDEX "public"."IDX_20ec76c5c56dd6b47dec5f0aaa"`) - await db.query(`DROP INDEX "public"."IDX_ba144ce938b3266a470d4dd70f"`) - await db.query(`DROP TABLE "swap"`) - await db.query(`DROP INDEX "public"."IDX_78506c4050ae7cedd50b08c0dc"`) - await db.query(`DROP INDEX "public"."IDX_3571ab1dad7640a6b93c705b8f"`) - await db.query(`DROP TABLE "pair"`) - await db.query(`DROP INDEX "public"."IDX_f74dc53460944a424b56b8f7da"`) - await db.query(`DROP INDEX "public"."IDX_4419691fc411b8af754dfa65ce"`) - await db.query(`DROP TABLE "pair_day_data"`) - await db.query(`DROP INDEX "public"."IDX_d8ba7d7d7ad9f0e1c2933a0b7e"`) - await db.query(`DROP INDEX "public"."IDX_88f6e19c40b47053e6e197db1c"`) - await db.query(`DROP INDEX "public"."IDX_ce435d6fc7c373d58e7aab156d"`) - await db.query(`DROP TABLE "token"`) - await db.query(`DROP TABLE "single_token_lock_day_data"`) - await db.query(`DROP INDEX "public"."IDX_f3bf64f43101176dbe5f11a36b"`) - await db.query(`DROP TABLE "single_token_lock_hour_data"`) - await db.query(`DROP INDEX "public"."IDX_b2a84dc625103153d651b701dd"`) - await db.query(`DROP TABLE "single_token_lock"`) - await db.query(`DROP INDEX "public"."IDX_8ebffe66457859d6e1c37b81ac"`) - await db.query(`DROP TABLE "incentive"`) - await db.query(`DROP INDEX "public"."IDX_35286137967591eaff8dee7ca2"`) - await db.query(`DROP INDEX "public"."IDX_041db4166864a3841e5efed53c"`) - await db.query(`DROP TABLE "farm"`) - await db.query(`DROP INDEX "public"."IDX_679106a1febf251d7fe7fe081a"`) - await db.query(`DROP INDEX "public"."IDX_00b8f5b860927b1b85e866b20d"`) - await db.query(`DROP INDEX "public"."IDX_11da1bf5c406898262d91b41cb"`) - await db.query(`DROP TABLE "stable_swap"`) - await db.query(`DROP INDEX "public"."IDX_88cce14adee6d21f5057551c3e"`) - await db.query(`DROP TABLE "stable_swap_info"`) - await db.query(`DROP TABLE "zenlink_info"`) - await db.query(`DROP INDEX "public"."IDX_9a6b55d2085464668b622dffe6"`) - await db.query(`DROP INDEX "public"."IDX_0795adc3723792868094ec76c0"`) - await db.query(`DROP TABLE "token_transfer"`) - await db.query(`DROP INDEX "public"."IDX_b47f7192b72dd8436ef4e6d253"`) - await db.query(`DROP INDEX "public"."IDX_752d6c330729a7b2e283003374"`) - await db.query(`DROP INDEX "public"."IDX_2ef35b71d641ec79b7de3ac237"`) - await db.query(`DROP INDEX "public"."IDX_aae50046f62ba400c07477fb6c"`) - await db.query(`DROP TABLE "token_deposit"`) - await db.query(`DROP INDEX "public"."IDX_395da815b9927f13e2f87c6b54"`) - await db.query(`DROP INDEX "public"."IDX_0f87d313517eaa806c75444749"`) - await db.query(`DROP INDEX "public"."IDX_7194acc3ea037189ff3da743ec"`) - await db.query(`DROP INDEX "public"."IDX_d23ae7a0ea1f640e8e9875b3c2"`) - await db.query(`DROP TABLE "token_withdrawn"`) - await db.query(`DROP INDEX "public"."IDX_e7fd99cae9a1df2e8f69d60892"`) - await db.query(`DROP INDEX "public"."IDX_70e98131fb737e4dce4455ca43"`) - await db.query(`DROP INDEX "public"."IDX_867e6d004e7a4994b3b2aeba63"`) - await db.query(`DROP INDEX "public"."IDX_5697bf049746e5102413ebd832"`) - await db.query(`DROP TABLE "bundle"`) - await db.query(`DROP TABLE "factory_day_data"`) - await db.query(`DROP TABLE "stable_day_data"`) - await db.query(`DROP TABLE "zenlink_day_info"`) - await db.query(`DROP INDEX "public"."IDX_9f281ffbf4f668c1671ae24aeb"`) - await db.query(`DROP INDEX "public"."IDX_3049b8ac70203e95dfc6b42c02"`) - await db.query(`DROP TABLE "zlk_info"`) - await db.query(`DROP TABLE "nabla_token"`) - await db.query(`DROP TABLE "nabla_swap_fee"`) - await db.query(`DROP INDEX "public"."IDX_208d304702d154e73e4f85c978"`) - await db.query(`DROP INDEX "public"."IDX_86080eda96a6de9c3c60be41d8"`) - await db.query(`DROP TABLE "backstop_pool"`) - await db.query(`DROP INDEX "public"."IDX_13ef09b925620aedf12b3342ca"`) - await db.query(`DROP INDEX "public"."IDX_8a7a25fa2d22ff634bd3041d81"`) - await db.query(`DROP TABLE "swap_pool"`) - await db.query(`DROP INDEX "public"."IDX_2f5409f002e18e4a6e2fddd858"`) - await db.query(`DROP INDEX "public"."IDX_5c3209a88e41d53bdc450605b3"`) - await db.query(`DROP INDEX "public"."IDX_b66a5cc8d2ce7bba1b48fd8c1a"`) - await db.query(`DROP TABLE "router"`) - await db.query(`DROP TABLE "event"`) - await db.query(`DROP INDEX "public"."IDX_2b0d35d675c4f99751855c4502"`) - await db.query(`DROP INDEX "public"."IDX_129efedcb305c80256db2d57a5"`) - await db.query(`DROP INDEX "public"."IDX_83cf1bd59aa4521ed882fa5145"`) - await db.query(`DROP INDEX "public"."IDX_7723d04c5a2f56c4373b6a4048"`) - await db.query(`DROP INDEX "public"."IDX_b535fbe8ec6d832dde22065ebd"`) - await db.query(`DROP INDEX "public"."IDX_0a00d817e614a91cda40d734cf"`) - await db.query(`DROP TABLE "call"`) - await db.query(`DROP INDEX "public"."IDX_bd3f11fd4110d60ac8b96cd62f"`) - await db.query(`DROP INDEX "public"."IDX_dde30e4f2c6a80f9236bfdf259"`) - await db.query(`DROP INDEX "public"."IDX_11c1e76d5be8f04c472c4a05b9"`) - await db.query(`DROP INDEX "public"."IDX_d3a8c3d00494950ad6dc93297d"`) - await db.query(`DROP INDEX "public"."IDX_776bccbd3d7b3001c8708cf4e0"`) - await db.query(`DROP INDEX "public"."IDX_8b212022b7428232091e2f8aa5"`) - await db.query(`DROP INDEX "public"."IDX_f1e953379e1b3c453cd896bcd4"`) - await db.query(`DROP TABLE "extrinsic"`) - await db.query(`DROP INDEX "public"."IDX_a3b99daba1259dab0dd040d4f7"`) - await db.query(`DROP INDEX "public"."IDX_824d47cc4b2cda726405aa507c"`) - await db.query(`DROP INDEX "public"."IDX_21e5db7671dfa1b00dbe6dbbd6"`) - await db.query(`DROP INDEX "public"."IDX_1f45de0713a55049009e8e8127"`) - await db.query(`DROP TABLE "block"`) - await db.query(`DROP INDEX "public"."IDX_bce676e2b005104ccb768495db"`) - await db.query(`DROP INDEX "public"."IDX_f8fba63d7965bfee9f304c487a"`) - await db.query(`DROP INDEX "public"."IDX_5b79d140fa8e2c64a7ef223598"`) - await db.query(`DROP INDEX "public"."IDX_5c67cbcf4960c1a39e5fe25e87"`) - await db.query(`DROP INDEX "public"."IDX_b7e2f8fe1384a2910825029dcb"`) - await db.query(`DROP TABLE "items_counter"`) - await db.query(`DROP INDEX "public"."IDX_68d2eadecb3eeb540d2004acef"`) - await db.query(`DROP INDEX "public"."IDX_1d9be1d79f197d42dd163f86c8"`) - await db.query(`DROP INDEX "public"."IDX_e03dd1c60ac7622914f72ac2f1"`) - await db.query( - `ALTER TABLE "stable_swap_event" DROP CONSTRAINT "FK_3a147c85b92441217540579be88"` - ) - await db.query( - `ALTER TABLE "stable_swap_exchange" DROP CONSTRAINT "FK_1180a78feea28e278229de7db46"` - ) - await db.query( - `ALTER TABLE "stable_swap_day_data" DROP CONSTRAINT "FK_648b49eb1a4f2a47f24f13bb510"` - ) - await db.query( - `ALTER TABLE "stable_swap_hour_data" DROP CONSTRAINT "FK_94584d2925c30ae0d4b80aadfc8"` - ) - await db.query( - `ALTER TABLE "token_day_data" DROP CONSTRAINT "FK_b8950a8bc7b60231137573740ea"` - ) - await db.query( - `ALTER TABLE "pair_hour_data" DROP CONSTRAINT "FK_cf50c55389e428096a68598ee33"` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_f953aebc7c0752f6b8434c9eef8"` - ) - await db.query( - `ALTER TABLE "stable_swap_liquidity_position" DROP CONSTRAINT "FK_405e0d7aeca80975d88a63bc6ee"` - ) - await db.query( - `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_2a2b22d2744b497bbcfb03e6ab0"` - ) - await db.query( - `ALTER TABLE "stake_position" DROP CONSTRAINT "FK_670629d9904e1f48f4a31abb495"` - ) - await db.query( - `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_781470585a67fef4e215a599773"` - ) - await db.query( - `ALTER TABLE "liquidity_position" DROP CONSTRAINT "FK_5a626c8b8962dc01e0f8801be61"` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_eb823fd4d5a47575039e902efa7"` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ed32a41150bc13f18a019741534"` - ) - await db.query( - `ALTER TABLE "liquidity_position_snapshot" DROP CONSTRAINT "FK_ce85a847b2952f7e685f150de1d"` - ) - await db.query( - `ALTER TABLE "mint" DROP CONSTRAINT "FK_19f4328320501dfd14e2bae0855"` - ) - await db.query( - `ALTER TABLE "mint" DROP CONSTRAINT "FK_81d470127d4c55d09e9213bc4e1"` - ) - await db.query( - `ALTER TABLE "burn" DROP CONSTRAINT "FK_20ec76c5c56dd6b47dec5f0aaa8"` - ) - await db.query( - `ALTER TABLE "burn" DROP CONSTRAINT "FK_ba144ce938b3266a470d4dd70fa"` - ) - await db.query( - `ALTER TABLE "swap" DROP CONSTRAINT "FK_78506c4050ae7cedd50b08c0dc5"` - ) - await db.query( - `ALTER TABLE "swap" DROP CONSTRAINT "FK_3571ab1dad7640a6b93c705b8f7"` - ) - await db.query( - `ALTER TABLE "pair" DROP CONSTRAINT "FK_f74dc53460944a424b56b8f7da5"` - ) - await db.query( - `ALTER TABLE "pair" DROP CONSTRAINT "FK_4419691fc411b8af754dfa65ce4"` - ) - await db.query( - `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_d8ba7d7d7ad9f0e1c2933a0b7e2"` - ) - await db.query( - `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_88f6e19c40b47053e6e197db1c9"` - ) - await db.query( - `ALTER TABLE "pair_day_data" DROP CONSTRAINT "FK_ce435d6fc7c373d58e7aab156d9"` - ) - await db.query( - `ALTER TABLE "single_token_lock_day_data" DROP CONSTRAINT "FK_f3bf64f43101176dbe5f11a36bd"` - ) - await db.query( - `ALTER TABLE "single_token_lock_hour_data" DROP CONSTRAINT "FK_b2a84dc625103153d651b701dd1"` - ) - await db.query( - `ALTER TABLE "single_token_lock" DROP CONSTRAINT "FK_8ebffe66457859d6e1c37b81ac3"` - ) - await db.query( - `ALTER TABLE "incentive" DROP CONSTRAINT "FK_35286137967591eaff8dee7ca2a"` - ) - await db.query( - `ALTER TABLE "incentive" DROP CONSTRAINT "FK_041db4166864a3841e5efed53c4"` - ) - await db.query( - `ALTER TABLE "farm" DROP CONSTRAINT "FK_679106a1febf251d7fe7fe081ad"` - ) - await db.query( - `ALTER TABLE "farm" DROP CONSTRAINT "FK_00b8f5b860927b1b85e866b20da"` - ) - await db.query( - `ALTER TABLE "farm" DROP CONSTRAINT "FK_11da1bf5c406898262d91b41cbb"` - ) - await db.query( - `ALTER TABLE "stable_swap" DROP CONSTRAINT "FK_88cce14adee6d21f5057551c3ea"` - ) - await db.query( - `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_9a6b55d2085464668b622dffe64"` - ) - await db.query( - `ALTER TABLE "zenlink_info" DROP CONSTRAINT "FK_0795adc3723792868094ec76c07"` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_9f281ffbf4f668c1671ae24aeb0"` - ) - await db.query( - `ALTER TABLE "zenlink_day_info" DROP CONSTRAINT "FK_3049b8ac70203e95dfc6b42c027"` - ) - await db.query( - `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_208d304702d154e73e4f85c978b"` - ) - await db.query( - `ALTER TABLE "nabla_swap_fee" DROP CONSTRAINT "FK_86080eda96a6de9c3c60be41d86"` - ) - await db.query( - `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_13ef09b925620aedf12b3342caa"` - ) - await db.query( - `ALTER TABLE "backstop_pool" DROP CONSTRAINT "FK_8a7a25fa2d22ff634bd3041d818"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_2f5409f002e18e4a6e2fddd8582"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_5c3209a88e41d53bdc450605b3b"` - ) - await db.query( - `ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab"` - ) - await db.query( - `ALTER TABLE "event" DROP CONSTRAINT "FK_2b0d35d675c4f99751855c45021"` - ) - await db.query( - `ALTER TABLE "event" DROP CONSTRAINT "FK_129efedcb305c80256db2d57a59"` - ) - await db.query( - `ALTER TABLE "event" DROP CONSTRAINT "FK_83cf1bd59aa4521ed882fa51452"` - ) - await db.query( - `ALTER TABLE "call" DROP CONSTRAINT "FK_bd3f11fd4110d60ac8b96cd62f3"` - ) - await db.query( - `ALTER TABLE "call" DROP CONSTRAINT "FK_dde30e4f2c6a80f9236bfdf2590"` - ) - await db.query( - `ALTER TABLE "call" DROP CONSTRAINT "FK_11c1e76d5be8f04c472c4a05b95"` - ) - await db.query( - `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_a3b99daba1259dab0dd040d4f74"` - ) - await db.query( - `ALTER TABLE "extrinsic" DROP CONSTRAINT "FK_824d47cc4b2cda726405aa507ca"` - ) - } -} diff --git a/db/migrations/1714028795707-Data.js b/db/migrations/1714034652645-Data.js similarity index 99% rename from db/migrations/1714028795707-Data.js rename to db/migrations/1714034652645-Data.js index d99dbda6..232eacfc 100644 --- a/db/migrations/1714028795707-Data.js +++ b/db/migrations/1714034652645-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1714028795707 { - name = 'Data1714028795707' +module.exports = class Data1714034652645 { + name = 'Data1714034652645' async up(db) { await db.query( @@ -312,7 +312,7 @@ module.exports = class Data1714028795707 { `CREATE INDEX "IDX_8a7a25fa2d22ff634bd3041d81" ON "backstop_pool" ("token_id") ` ) await db.query( - `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "lp_token_decimals" integer NOT NULL, "reserve" numeric NOT NULL, "reserve_with_slippage" numeric NOT NULL, "total_liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` + `CREATE TABLE "swap_pool" ("id" character varying NOT NULL, "name" text NOT NULL, "symbol" text NOT NULL, "lp_token_decimals" integer NOT NULL, "reserve" numeric NOT NULL, "reserve_with_slippage" numeric NOT NULL, "total_liabilities" numeric NOT NULL, "total_supply" numeric NOT NULL, "paused" boolean NOT NULL, "apr" numeric NOT NULL, "insurance_fee_bps" numeric NOT NULL, "protocol_treasury_address" text, "router_id" character varying, "backstop_id" character varying, "token_id" character varying, CONSTRAINT "PK_e78e7b899d2e3327494e5fe975d" PRIMARY KEY ("id"))` ) await db.query( `CREATE INDEX "IDX_2f5409f002e18e4a6e2fddd858" ON "swap_pool" ("router_id") ` diff --git a/schema.graphql b/schema.graphql index 34c63455..faf13b30 100644 --- a/schema.graphql +++ b/schema.graphql @@ -771,6 +771,8 @@ type SwapPool @entity { paused: Boolean! # whether the swap pool is paused feesHistory: [NablaSwapFee!]! @derivedFrom(field: "swapPool") # history of swap fees apr: BigInt! # annual percentage rate of the swap pool + insuranceFeeBps: BigInt! # insurance fee in basis points + protocolTreasuryAddress: String # address of the treasury } type BackstopPool @entity { diff --git a/src/mappings/nabla/backstopPoolEventHandler.ts b/src/mappings/nabla/backstopPoolEventHandler.ts index aedd319e..e4c7a7f1 100644 --- a/src/mappings/nabla/backstopPoolEventHandler.ts +++ b/src/mappings/nabla/backstopPoolEventHandler.ts @@ -6,6 +6,7 @@ import { Event_CoverSwapWithdrawal, Event_WithdrawSwapLiquidity, Contract as BackstopPoolContract, + Event_InsuranceFeeSet, } from '../../abi/backstop' import { Contract as Erc20Contract } from '../../abi/erc20' import { hexToSs58, ss58ToHex } from './addresses' @@ -19,6 +20,10 @@ export async function handleBackstopPoolEvent( const event = decodeEvent(ctx.event.args.data) switch (event.__kind) { + case 'Approval': + // No action required + break + case 'Burn': await handleBurn(ctx, backstopPool) break @@ -27,6 +32,10 @@ export async function handleBackstopPoolEvent( await handleCoverSwapWithdrawal(ctx, event, backstopPool) break + case 'InsuranceFeeSet': + await handleInsuranceFeeSet(ctx, event, backstopPool) + break + case 'Mint': await handleMint(ctx, backstopPool) break @@ -40,6 +49,10 @@ export async function handleBackstopPoolEvent( await handlePaused(ctx, backstopPool) break + case 'SwapPoolAdded': + // No action required + break + case 'Transfer': // No action required break @@ -69,7 +82,7 @@ export async function handleCoverSwapWithdrawal( ) { const swapPoolSs58Address = hexToSs58(event.swapPool) const pool = await getSwapPool(ctx, swapPoolSs58Address) - if (pool === undefined) { + if (pool === undefined || pool.backstop.id !== backstopPool.id) { // this is a non-standard or malicious swap pool, ignore return } @@ -81,6 +94,22 @@ export async function handleCoverSwapWithdrawal( await ctx.store.save(pool) } +export async function handleInsuranceFeeSet( + ctx: EventHandlerContext, + event: Event_InsuranceFeeSet, + backstopPool: BackstopPool +) { + const swapPoolSs58Address = hexToSs58(event.swapPool) + const swapPool = await getSwapPool(ctx, swapPoolSs58Address) + if (swapPool === undefined || swapPool.backstop.id !== backstopPool.id) { + // this is a non-standard or malicious swap pool, ignore + return + } + + swapPool.insuranceFeeBps = event.insuranceFeeBps + await ctx.store.save(swapPool) +} + export async function handleMint( ctx: EventHandlerContext, backstopPool: BackstopPool @@ -112,7 +141,7 @@ export async function handleWithdrawSwapLiquidity( ) { const swapPoolSs58Address = hexToSs58(event.swapPool) const pool = await getSwapPool(ctx, swapPoolSs58Address) - if (pool === undefined) { + if (pool === undefined || pool.backstop.id !== backstopPool.id) { // this is a non-standard or malicious swap pool, ignore return } diff --git a/src/mappings/nabla/creation.ts b/src/mappings/nabla/creation.ts index 301c8d2a..9add20e7 100644 --- a/src/mappings/nabla/creation.ts +++ b/src/mappings/nabla/creation.ts @@ -147,6 +147,7 @@ export async function createSwapPool( const backstopPoolAddress = await contract.backstop() const routerAddress = await contract.router() const tokenAddress = await contract.asset() + const protocolTreasuryAddress = await contract.protocolTreasury() if ( backstopPoolAddress === ZERO_ADDRESS || @@ -156,6 +157,10 @@ export async function createSwapPool( return undefined } + const protocolTreasurySs58Address = + protocolTreasuryAddress === ZERO_ADDRESS + ? null + : hexToSs58(protocolTreasuryAddress) const backstopPoolSs58Address = hexToSs58(backstopPoolAddress) const routerSs58Address = hexToSs58(routerAddress) const backstop = await getBackstopPool(ctx, backstopPoolSs58Address) @@ -182,6 +187,8 @@ export async function createSwapPool( totalSupply: await contract.totalSupply(), paused: false, apr: 0n, + insuranceFeeBps: 0n, + protocolTreasuryAddress: protocolTreasurySs58Address, }) await ctx.store.save(swapPool) } diff --git a/src/mappings/nabla/swapPoolEventHandler.ts b/src/mappings/nabla/swapPoolEventHandler.ts index ce420732..f9fd355d 100644 --- a/src/mappings/nabla/swapPoolEventHandler.ts +++ b/src/mappings/nabla/swapPoolEventHandler.ts @@ -1,14 +1,19 @@ import { EventHandlerContext } from '../../processor' -import { createSwapFee, getBackstopPool, getSwapPool } from './creation' +import { + ZERO_ADDRESS, + createSwapFee, + getBackstopPool, + getSwapPool, +} from './creation' import { NablaSwapFee, SwapPool } from '../../model' import { decodeEvent, Contract as SwapPoolContract, Event_ChargedSwapFees, + Event_ProtocolTreasuryChanged, } from '../../abi/swap' -import { Contract as Erc20Contract } from '../../abi/erc20' import { Contract as BackstopPoolContract } from '../../abi/backstop' -import { ss58ToHex } from './addresses' +import { hexToSs58, ss58ToHex } from './addresses' import { updateBackstopCoverageAndSupply } from './backstopPoolEventHandler' const SWAP_FEE_PRUNE_INTERVAL_MILLI_SECONDS = 7 * 24 * 60 * 60 * 1000 @@ -20,6 +25,10 @@ export async function handleSwapPoolEvent( const event = decodeEvent(ctx.event.args.data) switch (event.__kind) { + case 'Approval': + // No action required + break + case 'BackstopDrain': await handleBackstopDrain(ctx, swapPool) break @@ -45,6 +54,10 @@ export async function handleSwapPoolEvent( await handlePaused(ctx, swapPool) break + case 'ProtocolTreasuryChanged': + await handleProtocolTreasuryChanged(ctx, event, swapPool) + break + case 'Transfer': // No action required break @@ -111,6 +124,20 @@ export async function handlePaused( await ctx.store.save(swapPool) } +export async function handleProtocolTreasuryChanged( + ctx: EventHandlerContext, + event: Event_ProtocolTreasuryChanged, + swapPool: SwapPool +) { + const protocolTreasurySs58Address = + event.newProtocolTreasury === ZERO_ADDRESS + ? null + : hexToSs58(event.newProtocolTreasury) + + swapPool.protocolTreasuryAddress = protocolTreasurySs58Address + await ctx.store.save(swapPool) +} + export async function handleUnpaused( ctx: EventHandlerContext, swapPool: SwapPool diff --git a/src/model/generated/swapPool.model.ts b/src/model/generated/swapPool.model.ts index ebd947e1..522531f7 100644 --- a/src/model/generated/swapPool.model.ts +++ b/src/model/generated/swapPool.model.ts @@ -77,4 +77,13 @@ export class SwapPool { nullable: false, }) apr!: bigint + + @Column_('numeric', { + transformer: marshal.bigintTransformer, + nullable: false, + }) + insuranceFeeBps!: bigint + + @Column_('text', { nullable: true }) + protocolTreasuryAddress!: string | undefined | null } From ae15c896bc54b5fc1c62bda4a422bc25c7813dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Thu, 25 Apr 2024 05:46:20 -0300 Subject: [PATCH 13/20] Bump squid version --- squid-amplitude.yaml | 2 +- squid-foucoco.yaml | 2 +- squid-pendulum.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/squid-amplitude.yaml b/squid-amplitude.yaml index 84a1e728..596f7bb3 100644 --- a/squid-amplitude.yaml +++ b/squid-amplitude.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: amplitude-squid -version: 20 +version: 21 description: 'Amplitude Kusama Squid' build: deploy: diff --git a/squid-foucoco.yaml b/squid-foucoco.yaml index 7b7a63ab..4c47c8ce 100644 --- a/squid-foucoco.yaml +++ b/squid-foucoco.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: foucoco-squid -version: 20 +version: 21 description: 'Foucoco Squid' build: deploy: diff --git a/squid-pendulum.yaml b/squid-pendulum.yaml index 7e1ddbae..70f23760 100644 --- a/squid-pendulum.yaml +++ b/squid-pendulum.yaml @@ -1,6 +1,6 @@ manifestVersion: subsquid.io/v0.1 name: pendulum-squid -version: 20 +version: 21 description: 'Pendulum Squid' build: deploy: From 4ad7c45197b65b58ec9c9bcd59fdad0b65215464 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Mon, 6 May 2024 11:48:41 +0200 Subject: [PATCH 14/20] Use Nabla ABIs compiled with solang 0.3.3 --- nabla-abi/backstop.json | 6 +++--- nabla-abi/erc20.json | 6 +++--- nabla-abi/router.json | 6 +++--- nabla-abi/swap.json | 6 +++--- src/abi/backstop.ts | 6 +++--- src/abi/erc20.ts | 6 +++--- src/abi/router.ts | 6 +++--- src/abi/swap.ts | 6 +++--- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/nabla-abi/backstop.json b/nabla-abi/backstop.json index 09c6efbc..f331fbdc 100644 --- a/nabla-abi/backstop.json +++ b/nabla-abi/backstop.json @@ -6,9 +6,9 @@ "version": "0.0.1" }, "source": { - "compiler": "solang 0.3.2", - "hash": "0xe07d252b0830943a932a082d3b7a46249af166287420ec4cfbc49b3384e48b6c", - "language": "Solidity 0.3.2" + "compiler": "solang 0.3.3", + "hash": "0xe56d59aa7b37b21d9e1950de9866c64e8174a577c014259045fdf8a80df89f81", + "language": "Solidity 0.3.3" }, "spec": { "constructors": [ diff --git a/nabla-abi/erc20.json b/nabla-abi/erc20.json index 6a4da62c..712a9a77 100644 --- a/nabla-abi/erc20.json +++ b/nabla-abi/erc20.json @@ -5,9 +5,9 @@ "version": "0.0.1" }, "source": { - "compiler": "solang 0.3.2", - "hash": "0xfd052826432f969b18f912400fc92fbb97ed4122dd6fa1ee3828bfc81b93e316", - "language": "Solidity 0.3.2" + "compiler": "solang 0.3.3", + "hash": "0xc2ab6f62a37392bf78cd94965557e3609d035b91a9c7b3c55d6584f63bead278", + "language": "Solidity 0.3.3" }, "spec": { "constructors": [ diff --git a/nabla-abi/router.json b/nabla-abi/router.json index 8e06ae68..442c6859 100644 --- a/nabla-abi/router.json +++ b/nabla-abi/router.json @@ -5,9 +5,9 @@ "version": "0.0.1" }, "source": { - "compiler": "solang 0.3.2", - "hash": "0x1461e0f01fe866142df918dc0c65f8a185e5079d6a642da2b79436f6839db44e", - "language": "Solidity 0.3.2" + "compiler": "solang 0.3.3", + "hash": "0xadaf9467356a3cf9e5bb5436974f7bf48063f342ae435e855b734458e1bad21d", + "language": "Solidity 0.3.3" }, "spec": { "constructors": [ diff --git a/nabla-abi/swap.json b/nabla-abi/swap.json index 7366d328..055c54f7 100644 --- a/nabla-abi/swap.json +++ b/nabla-abi/swap.json @@ -6,9 +6,9 @@ "version": "0.0.1" }, "source": { - "compiler": "solang 0.3.2", - "hash": "0x42108ada7515f8f4ab3ed8cea31e4c3456c433ce52fecb9d3a2afb33c727ab94", - "language": "Solidity 0.3.2" + "compiler": "solang 0.3.3", + "hash": "0x25ef3d2e4bf9ddc56ac00c3e1a81acfbcf61028c1db20558c4c12f0a6fb34507", + "language": "Solidity 0.3.3" }, "spec": { "constructors": [ diff --git a/src/abi/backstop.ts b/src/abi/backstop.ts index a5eba2e7..178c021b 100644 --- a/src/abi/backstop.ts +++ b/src/abi/backstop.ts @@ -9,9 +9,9 @@ export const metadata = { version: '0.0.1', }, source: { - compiler: 'solang 0.3.2', - hash: '0xe07d252b0830943a932a082d3b7a46249af166287420ec4cfbc49b3384e48b6c', - language: 'Solidity 0.3.2', + compiler: 'solang 0.3.3', + hash: '0xe56d59aa7b37b21d9e1950de9866c64e8174a577c014259045fdf8a80df89f81', + language: 'Solidity 0.3.3', }, spec: { constructors: [ diff --git a/src/abi/erc20.ts b/src/abi/erc20.ts index 2192c0f0..4b077b46 100644 --- a/src/abi/erc20.ts +++ b/src/abi/erc20.ts @@ -7,9 +7,9 @@ export const metadata = { version: '0.0.1', }, source: { - compiler: 'solang 0.3.2', - hash: '0xfd052826432f969b18f912400fc92fbb97ed4122dd6fa1ee3828bfc81b93e316', - language: 'Solidity 0.3.2', + compiler: 'solang 0.3.3', + hash: '0xc2ab6f62a37392bf78cd94965557e3609d035b91a9c7b3c55d6584f63bead278', + language: 'Solidity 0.3.3', }, spec: { constructors: [ diff --git a/src/abi/router.ts b/src/abi/router.ts index e6f4af1e..e499835e 100644 --- a/src/abi/router.ts +++ b/src/abi/router.ts @@ -7,9 +7,9 @@ export const metadata = { version: '0.0.1', }, source: { - compiler: 'solang 0.3.2', - hash: '0x1461e0f01fe866142df918dc0c65f8a185e5079d6a642da2b79436f6839db44e', - language: 'Solidity 0.3.2', + compiler: 'solang 0.3.3', + hash: '0xadaf9467356a3cf9e5bb5436974f7bf48063f342ae435e855b734458e1bad21d', + language: 'Solidity 0.3.3', }, spec: { constructors: [ diff --git a/src/abi/swap.ts b/src/abi/swap.ts index 9aa49fa9..105d3d62 100644 --- a/src/abi/swap.ts +++ b/src/abi/swap.ts @@ -9,9 +9,9 @@ export const metadata = { version: '0.0.1', }, source: { - compiler: 'solang 0.3.2', - hash: '0x42108ada7515f8f4ab3ed8cea31e4c3456c433ce52fecb9d3a2afb33c727ab94', - language: 'Solidity 0.3.2', + compiler: 'solang 0.3.3', + hash: '0x25ef3d2e4bf9ddc56ac00c3e1a81acfbcf61028c1db20558c4c12f0a6fb34507', + language: 'Solidity 0.3.3', }, spec: { constructors: [ From f436f0388b973f754f29107c6c45e3fca2e016c3 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Mon, 6 May 2024 11:48:51 +0200 Subject: [PATCH 15/20] Amend README --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bfbf2697..4c9d7c67 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,12 @@ npx squid-ink-typegen --abi nabla-abi/{contract}.json --output src/abi/{contract ``` We must ensure that the contract's ABI is generated properly and added to the `nabla-abi` -directory. It is possible to obtain the ABI upon compilation of the ink! contract. +directory. +It is possible to obtain the ABI upon compilation of the ink! contract. +The ABI is contained in the `.contract` file. +You can copy the contents of that file as is to a new `.json` file but make sure to remove +the `"source": { "wasm": <0x...> }` field from the JSON object as it's not needed and too large to be included in the +ABI. To generate the types for all the ABI's contained in `nabla-abi`, run: From 20fe8aa891434c9b8664956be942e24eaa76f006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Wed, 8 May 2024 21:04:40 -0300 Subject: [PATCH 16/20] Clean up APR related code --- src/mappings/nabla/swapPoolEventHandler.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mappings/nabla/swapPoolEventHandler.ts b/src/mappings/nabla/swapPoolEventHandler.ts index f9fd355d..8e2e9e01 100644 --- a/src/mappings/nabla/swapPoolEventHandler.ts +++ b/src/mappings/nabla/swapPoolEventHandler.ts @@ -159,7 +159,7 @@ export async function updateSwapPoolCoverageAndSupply( swapPool.reserveWithSlippage = await contract.reserveWithSlippage() } -async function updateAndPruneSwapFeeHistory( +async function pruneSwapFeeHistory( ctx: EventHandlerContext, swapPoolWithFeeHistory: SwapPool, newSwapFee: NablaSwapFee @@ -167,11 +167,6 @@ async function updateAndPruneSwapFeeHistory( // Prune fee events older than 7 days const sevenDaysAgo = newSwapFee.timestamp - BigInt(SWAP_FEE_PRUNE_INTERVAL_MILLI_SECONDS) - - /* - * Swap Pool fees history - */ - // Add the swapFee to the pool's fee history const poolFeesHistory = swapPoolWithFeeHistory.feesHistory await filterSwapFeeHistory(ctx, poolFeesHistory, sevenDaysAgo) } @@ -181,8 +176,6 @@ async function filterSwapFeeHistory( feesHistory: NablaSwapFee[], pastPeriodInSeconds: bigint ) { - const filteredFeeHistory: string[] = [] - for (const swapFee of feesHistory) { if (swapFee.timestamp < pastPeriodInSeconds) { await ctx.store.remove(swapFee) @@ -196,7 +189,7 @@ export async function updateAprAfterSwap( newSwapFee: NablaSwapFee ): Promise { // Update the fee history (swapFee, backstopFee) - await updateAndPruneSwapFeeHistory(ctx, swapPoolWithFeeHistory, newSwapFee) + await pruneSwapFeeHistory(ctx, swapPoolWithFeeHistory, newSwapFee) const updatedSwapPool = (await getSwapPool( ctx, swapPoolWithFeeHistory.id, @@ -255,6 +248,11 @@ export async function updateAprAfterSwap( } } +/// This function takes +/// - some total fee generated within 7 days and +/// - some amount of token (totalSupply) +/// It then extrapolates the total fee generated in a year +/// (assuming the same rate) per token of the total supply function calculateApr( totalFees: bigint, totalSupply: bigint, From cb9ab7ecb077d4df6a74499d7eb0ad541918730b Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Thu, 16 May 2024 13:59:42 +0200 Subject: [PATCH 17/20] Revert "Use Nabla ABIs compiled with solang 0.3.3" This reverts commit 4ad7c45197b65b58ec9c9bcd59fdad0b65215464. --- nabla-abi/backstop.json | 6 +++--- nabla-abi/erc20.json | 6 +++--- nabla-abi/router.json | 6 +++--- nabla-abi/swap.json | 6 +++--- src/abi/backstop.ts | 6 +++--- src/abi/erc20.ts | 6 +++--- src/abi/router.ts | 6 +++--- src/abi/swap.ts | 6 +++--- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/nabla-abi/backstop.json b/nabla-abi/backstop.json index f331fbdc..09c6efbc 100644 --- a/nabla-abi/backstop.json +++ b/nabla-abi/backstop.json @@ -6,9 +6,9 @@ "version": "0.0.1" }, "source": { - "compiler": "solang 0.3.3", - "hash": "0xe56d59aa7b37b21d9e1950de9866c64e8174a577c014259045fdf8a80df89f81", - "language": "Solidity 0.3.3" + "compiler": "solang 0.3.2", + "hash": "0xe07d252b0830943a932a082d3b7a46249af166287420ec4cfbc49b3384e48b6c", + "language": "Solidity 0.3.2" }, "spec": { "constructors": [ diff --git a/nabla-abi/erc20.json b/nabla-abi/erc20.json index 712a9a77..6a4da62c 100644 --- a/nabla-abi/erc20.json +++ b/nabla-abi/erc20.json @@ -5,9 +5,9 @@ "version": "0.0.1" }, "source": { - "compiler": "solang 0.3.3", - "hash": "0xc2ab6f62a37392bf78cd94965557e3609d035b91a9c7b3c55d6584f63bead278", - "language": "Solidity 0.3.3" + "compiler": "solang 0.3.2", + "hash": "0xfd052826432f969b18f912400fc92fbb97ed4122dd6fa1ee3828bfc81b93e316", + "language": "Solidity 0.3.2" }, "spec": { "constructors": [ diff --git a/nabla-abi/router.json b/nabla-abi/router.json index 442c6859..8e06ae68 100644 --- a/nabla-abi/router.json +++ b/nabla-abi/router.json @@ -5,9 +5,9 @@ "version": "0.0.1" }, "source": { - "compiler": "solang 0.3.3", - "hash": "0xadaf9467356a3cf9e5bb5436974f7bf48063f342ae435e855b734458e1bad21d", - "language": "Solidity 0.3.3" + "compiler": "solang 0.3.2", + "hash": "0x1461e0f01fe866142df918dc0c65f8a185e5079d6a642da2b79436f6839db44e", + "language": "Solidity 0.3.2" }, "spec": { "constructors": [ diff --git a/nabla-abi/swap.json b/nabla-abi/swap.json index 055c54f7..7366d328 100644 --- a/nabla-abi/swap.json +++ b/nabla-abi/swap.json @@ -6,9 +6,9 @@ "version": "0.0.1" }, "source": { - "compiler": "solang 0.3.3", - "hash": "0x25ef3d2e4bf9ddc56ac00c3e1a81acfbcf61028c1db20558c4c12f0a6fb34507", - "language": "Solidity 0.3.3" + "compiler": "solang 0.3.2", + "hash": "0x42108ada7515f8f4ab3ed8cea31e4c3456c433ce52fecb9d3a2afb33c727ab94", + "language": "Solidity 0.3.2" }, "spec": { "constructors": [ diff --git a/src/abi/backstop.ts b/src/abi/backstop.ts index 178c021b..a5eba2e7 100644 --- a/src/abi/backstop.ts +++ b/src/abi/backstop.ts @@ -9,9 +9,9 @@ export const metadata = { version: '0.0.1', }, source: { - compiler: 'solang 0.3.3', - hash: '0xe56d59aa7b37b21d9e1950de9866c64e8174a577c014259045fdf8a80df89f81', - language: 'Solidity 0.3.3', + compiler: 'solang 0.3.2', + hash: '0xe07d252b0830943a932a082d3b7a46249af166287420ec4cfbc49b3384e48b6c', + language: 'Solidity 0.3.2', }, spec: { constructors: [ diff --git a/src/abi/erc20.ts b/src/abi/erc20.ts index 4b077b46..2192c0f0 100644 --- a/src/abi/erc20.ts +++ b/src/abi/erc20.ts @@ -7,9 +7,9 @@ export const metadata = { version: '0.0.1', }, source: { - compiler: 'solang 0.3.3', - hash: '0xc2ab6f62a37392bf78cd94965557e3609d035b91a9c7b3c55d6584f63bead278', - language: 'Solidity 0.3.3', + compiler: 'solang 0.3.2', + hash: '0xfd052826432f969b18f912400fc92fbb97ed4122dd6fa1ee3828bfc81b93e316', + language: 'Solidity 0.3.2', }, spec: { constructors: [ diff --git a/src/abi/router.ts b/src/abi/router.ts index e499835e..e6f4af1e 100644 --- a/src/abi/router.ts +++ b/src/abi/router.ts @@ -7,9 +7,9 @@ export const metadata = { version: '0.0.1', }, source: { - compiler: 'solang 0.3.3', - hash: '0xadaf9467356a3cf9e5bb5436974f7bf48063f342ae435e855b734458e1bad21d', - language: 'Solidity 0.3.3', + compiler: 'solang 0.3.2', + hash: '0x1461e0f01fe866142df918dc0c65f8a185e5079d6a642da2b79436f6839db44e', + language: 'Solidity 0.3.2', }, spec: { constructors: [ diff --git a/src/abi/swap.ts b/src/abi/swap.ts index 105d3d62..9aa49fa9 100644 --- a/src/abi/swap.ts +++ b/src/abi/swap.ts @@ -9,9 +9,9 @@ export const metadata = { version: '0.0.1', }, source: { - compiler: 'solang 0.3.3', - hash: '0x25ef3d2e4bf9ddc56ac00c3e1a81acfbcf61028c1db20558c4c12f0a6fb34507', - language: 'Solidity 0.3.3', + compiler: 'solang 0.3.2', + hash: '0x42108ada7515f8f4ab3ed8cea31e4c3456c433ce52fecb9d3a2afb33c727ab94', + language: 'Solidity 0.3.2', }, spec: { constructors: [ From 84d220c8ce2d0fa32da16822f50446ba8db77843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Thu, 23 May 2024 19:57:16 -0300 Subject: [PATCH 18/20] Simplify logic for local network configuration --- src/config.ts | 60 +++++++++++++++++---------- src/types/events.ts | 2 +- src/types/eventsAndStorageSelector.ts | 4 +- src/types/storage.ts | 2 +- src/types/support.ts | 2 +- 5 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/config.ts b/src/config.ts index dd1a969a..ce80be75 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,8 +1,23 @@ import { ProcessorConfig } from './types' import { lookupArchive } from '@subsquid/archive-registry' import axios from 'axios' -export type Network = 'foucoco' | 'amplitude' | 'pendulum' | 'local' -export const network = (process.env.NETWORK as Network) || 'amplitude' + +export type Network = 'foucoco' | 'amplitude' | 'pendulum' +function determineNetwork(): Network { + switch (process.env.NETWORK) { + case 'foucoco': + case 'local': + return 'foucoco' + case 'pendulum': + return 'pendulum' + case 'amplitude': + default: + return 'amplitude' + } +} + +export const network = determineNetwork() +export const isLocalExecution = process.env.NETWORK === 'local' export const blockRetentionNumber = process.env.BLOCK_RETENTION_NUMBER ? parseInt(process.env.BLOCK_RETENTION_NUMBER, 10) @@ -48,10 +63,10 @@ const localConfig: ProcessorConfig = { } export const config: ProcessorConfig = - network === 'local' - ? localConfig - : network === 'foucoco' - ? foucocoConfig + network === 'foucoco' + ? isLocalExecution + ? localConfig + : foucocoConfig : network === 'amplitude' ? amplitudeConfig : pendulumConfig @@ -60,20 +75,19 @@ console.log('Using ProcessorConfig: ', config) // Fetch max height from the archive and export it as a promise -export const maxHeightPromise = - network === 'local' - ? Promise.resolve(0) - : axios - .get(config.dataSource.archive + '/height') - .then((response) => { - const data = response.data - console.log('Max height:', data) - return data - }) - .catch((error) => { - console.error( - 'Error getting block height from archive, using default value instead:', - error - ) - return Number.MAX_SAFE_INTEGER - }) +export const maxHeightPromise = isLocalExecution + ? Promise.resolve(0) + : axios + .get(config.dataSource.archive + '/height') + .then((response) => { + const data = response.data + console.log('Max height:', data) + return data + }) + .catch((error) => { + console.error( + 'Error getting block height from archive, using default value instead:', + error + ) + return Number.MAX_SAFE_INTEGER + }) diff --git a/src/types/events.ts b/src/types/events.ts index 9c800318..f8800085 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -5,7 +5,7 @@ import * as pendulumEvents from './pendulum/events' import { network } from '../config' const events = - network === 'foucoco' || network === 'local' + network === 'foucoco' ? foucocoEvents : network === 'amplitude' ? amplitudeEvents diff --git a/src/types/eventsAndStorageSelector.ts b/src/types/eventsAndStorageSelector.ts index 60cddadb..c0ea9886 100644 --- a/src/types/eventsAndStorageSelector.ts +++ b/src/types/eventsAndStorageSelector.ts @@ -33,7 +33,7 @@ export function decodeEvent( let networkEventsAny let eventVersions: string[] - if (network === 'foucoco' || network === 'local') { + if (network === 'foucoco') { networkEventsAny = foucocoEvents as { [key: string]: any } eventVersions = foucocoVersions } else if (network === 'pendulum') { @@ -68,7 +68,7 @@ export async function getVersionedStorage( ): Promise { let networkStorageAny let storageVersions: string[] - if (network === 'foucoco' || network === 'local') { + if (network === 'foucoco') { networkStorageAny = foucocoStorage as { [key: string]: any } storageVersions = foucocoVersions } else if (network === 'pendulum') { diff --git a/src/types/storage.ts b/src/types/storage.ts index a983195d..39e25fb1 100644 --- a/src/types/storage.ts +++ b/src/types/storage.ts @@ -4,7 +4,7 @@ import * as pendulumStorage from './pendulum/storage' import { network } from '../config' const storage = - network === 'foucoco' || network === 'local' + network === 'foucoco' ? foucocoStorage : network === 'amplitude' ? amplitudeStorage diff --git a/src/types/support.ts b/src/types/support.ts index 1632014f..37da54d1 100644 --- a/src/types/support.ts +++ b/src/types/support.ts @@ -5,7 +5,7 @@ import * as pendulumSupport from './pendulum/support' import { network } from '../config' const support = - network === 'foucoco' || network === 'local' + network === 'foucoco' ? foucocoSupport : network === 'amplitude' ? amplitudeSupport From 9dab1b0e52d318a9e755568ed803ffefb9565567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Thu, 23 May 2024 20:30:19 -0300 Subject: [PATCH 19/20] Removed unused variable --- src/mappings/nabla/routerEventHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mappings/nabla/routerEventHandler.ts b/src/mappings/nabla/routerEventHandler.ts index 4fa49f66..4b229c85 100644 --- a/src/mappings/nabla/routerEventHandler.ts +++ b/src/mappings/nabla/routerEventHandler.ts @@ -104,7 +104,7 @@ export async function handleSwapPoolRegistered( return } - const token = await getOrCreateNablaToken(ctx, ss58ToHex(swapPool.token.id)) + await getOrCreateNablaToken(ctx, ss58ToHex(swapPool.token.id)) const registeredSwapPool = await getSwapPoolsOfRouterForToken( ctx, From 8a543ff3b98523cb9c628724020f5f7568d9f57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Mon, 27 May 2024 05:05:30 -0300 Subject: [PATCH 20/20] Add console.logs to some early returns --- src/mappings/nabla/creation.ts | 7 +++++++ src/mappings/nabla/routerEventHandler.ts | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/mappings/nabla/creation.ts b/src/mappings/nabla/creation.ts index 9add20e7..e09ed19b 100644 --- a/src/mappings/nabla/creation.ts +++ b/src/mappings/nabla/creation.ts @@ -61,6 +61,9 @@ export async function createBackstopPool( const ss58Address = hexToSs58(hexAddress) if (await getBackstopPool(ctx, ss58Address)) { // Unexpected error: backstop pool already exists at that address + console.log( + `createBackstopPool: backstop pool already exists at ${ss58Address}` + ) return } @@ -103,6 +106,7 @@ export async function createRouter( const ss58Address = hexToSs58(hexAddress) if (await getRouter(ctx, ss58Address)) { // Unexpected error: router already exists at that address + console.log(`createRouter: router already exists at ${ss58Address}`) return } @@ -139,6 +143,9 @@ export async function createSwapPool( const ss58Address = hexToSs58(hexAddress) if (await getSwapPool(ctx, ss58Address)) { // Unexpected error: swap pool already exists at that address + console.log( + `createSwapPool: swap pool already exists at ${ss58Address}` + ) return } diff --git a/src/mappings/nabla/routerEventHandler.ts b/src/mappings/nabla/routerEventHandler.ts index 4b229c85..c5f8c606 100644 --- a/src/mappings/nabla/routerEventHandler.ts +++ b/src/mappings/nabla/routerEventHandler.ts @@ -115,6 +115,9 @@ export async function handleSwapPoolRegistered( if (registeredSwapPool) { if (registeredSwapPool.id === swapPool.id) { // this swap pool is already registered, no action required + console.log( + `handleSwapPoolRegistered: swap pool already registered at ${swapPool.id}` + ) return }