Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

58 setup queries for nabla backend for campaign and mainnet reward program #62

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6aa5b86
Apply codegen, typegen and migrations
TorstenStueber Jan 26, 2024
2519556
Change schema.graphql and nabla-abi to new Nabla version
TorstenStueber Jan 26, 2024
2106321
Adopt types from official Nabla indexer
TorstenStueber Jan 27, 2024
42cfd0d
Migrate squid logic to new Nabla
TorstenStueber Jan 31, 2024
46cd3e2
Implement properly working Nabla indexer
TorstenStueber Feb 19, 2024
a4ae1cb
Clean up debugging instructions
TorstenStueber Feb 19, 2024
6f127b5
Clean up output
TorstenStueber Feb 19, 2024
4709f4c
Resolve merge conflicts
TorstenStueber Feb 19, 2024
09de98c
Bump squid version
TorstenStueber Feb 19, 2024
9187105
Merge latest changes from main
TorstenStueber Feb 20, 2024
5b4b527
Additionally track lp token decimals
TorstenStueber Feb 21, 2024
3aa56fb
Incorporate new Nabla metadata
TorstenStueber Apr 25, 2024
704c224
Merge latest changes from main
TorstenStueber Apr 25, 2024
a6cecc8
Update generated files
TorstenStueber Apr 25, 2024
3327b3d
Handle new Nabla events
TorstenStueber Apr 25, 2024
ae15c89
Bump squid version
TorstenStueber Apr 25, 2024
fe71b51
Add new types to schema
bogdanS98 May 2, 2024
61fd22a
Regenerate models
bogdanS98 May 2, 2024
5602754
Create migration
bogdanS98 May 2, 2024
3e2debd
Update mappings
bogdanS98 May 2, 2024
d4152c6
Update mappings
bogdanS98 May 2, 2024
4ad7c45
Use Nabla ABIs compiled with solang 0.3.3
ebma May 6, 2024
f436f03
Amend README
ebma May 6, 2024
5a7da94
Merge branch '44-migrate-to-new-nabla-contracts' of https://github.co…
bogdanS98 May 6, 2024
20fe8aa
Clean up APR related code
TorstenStueber May 9, 2024
cb9ab7e
Revert "Use Nabla ABIs compiled with solang 0.3.3"
ebma May 16, 2024
c21623f
Merge branch '44-migrate-to-new-nabla-contracts' into 58-setup-querie…
ebma May 23, 2024
84d220c
Simplify logic for local network configuration
TorstenStueber May 23, 2024
672978d
git pushMerge branch '44-migrate-to-new-nabla-contracts' of github.co…
TorstenStueber May 23, 2024
9dab1b0
Removed unused variable
TorstenStueber May 23, 2024
8a543ff
Add console.logs to some early returns
TorstenStueber May 27, 2024
75b2cc2
Address comments
bogdanS98 May 28, 2024
03f2dd6
Regenerate models
bogdanS98 May 28, 2024
84460a6
Merge branch '44-migrate-to-new-nabla-contracts' of https://github.co…
bogdanS98 May 28, 2024
ee25e61
Regenerate models
bogdanS98 May 28, 2024
b684fd5
Address change requests
bogdanS98 May 30, 2024
37d714a
Regenerate models
bogdanS98 May 30, 2024
2bd07e7
Merge branch 'main' of https://github.com/pendulum-chain/pendulum-squ…
bogdanS98 May 30, 2024
5aaf990
Fix failed merge
bogdanS98 May 30, 2024
5957b14
Regenerate models
bogdanS98 May 30, 2024
99e48ef
Remove unnecessary comments
bogdanS98 May 30, 2024
4280449
Bump squid versions
bogdanS98 May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
8 changes: 8 additions & 0 deletions commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = class Data1701282385470 {
name = 'Data1701282385470'
module.exports = class Data1714664455673 {
name = 'Data1714664455673'

async up(db) {
await db.query(
Expand Down Expand Up @@ -294,7 +294,16 @@ module.exports = class Data1701282385470 {
`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"))`
`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") `
Expand All @@ -303,7 +312,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, "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") `
Expand All @@ -317,6 +326,24 @@ module.exports = class Data1701282385470 {
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 "nabla_swap" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "amount_in" numeric NOT NULL, "amount_out" numeric NOT NULL, "token_in" text NOT NULL, "token_out" text NOT NULL, "to" text NOT NULL, "swap_fee_id" character varying, CONSTRAINT "PK_6274610b518e1a9e61b1c6f03bb" PRIMARY KEY ("id"))`
)
await db.query(
`CREATE INDEX "IDX_dd24afed240ad46290bfcf0603" ON "nabla_swap" ("swap_fee_id") `
)
await db.query(
`CREATE TABLE "nabla_backstop_liquidity_deposit" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "pool_shares_minted" numeric NOT NULL, "amount_principle_deposited" numeric NOT NULL, CONSTRAINT "PK_6a7b952f6ac801d591360e47743" PRIMARY KEY ("id"))`
)
await db.query(
`CREATE TABLE "nabla_swap_liquidity_deposit" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "pool_shares_minted" numeric NOT NULL, "amount_principle_deposited" numeric NOT NULL, CONSTRAINT "PK_4788b03472eec9547df44a82c48" PRIMARY KEY ("id"))`
)
await db.query(
`CREATE TABLE "nabla_backstop_liquidity_withdrawal" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "pool_shares_burned" numeric NOT NULL, "amount_principle_withdrawn" numeric NOT NULL, CONSTRAINT "PK_9fca1665db21118d0b318e1f828" PRIMARY KEY ("id"))`
)
await db.query(
`CREATE TABLE "nabla_swap_liquidity_withdrawal" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "sender" text NOT NULL, "pool_shares_burned" numeric NOT NULL, "amount_principle_withdrawn" numeric NOT NULL, CONSTRAINT "PK_38c9ff7047fcf36ccbd4b7cb521" 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"))`
)
Expand Down Expand Up @@ -524,6 +551,12 @@ 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_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`
)
Expand All @@ -539,6 +572,9 @@ module.exports = class Data1701282385470 {
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 "nabla_swap" ADD CONSTRAINT "FK_dd24afed240ad46290bfcf0603b" FOREIGN KEY ("swap_fee_id") REFERENCES "nabla_swap_fee"("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`
)
Expand Down Expand Up @@ -663,6 +699,9 @@ 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 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"`)
Expand All @@ -671,6 +710,12 @@ module.exports = class Data1701282385470 {
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 "nabla_swap"`)
await db.query(`DROP INDEX "public"."IDX_dd24afed240ad46290bfcf0603"`)
await db.query(`DROP TABLE "nabla_backstop_liquidity_deposit"`)
await db.query(`DROP TABLE "nabla_swap_liquidity_deposit"`)
await db.query(`DROP TABLE "nabla_backstop_liquidity_withdrawal"`)
await db.query(`DROP TABLE "nabla_swap_liquidity_withdrawal"`)
await db.query(`DROP TABLE "event"`)
await db.query(`DROP INDEX "public"."IDX_2b0d35d675c4f99751855c4502"`)
await db.query(`DROP INDEX "public"."IDX_129efedcb305c80256db2d57a5"`)
Expand Down Expand Up @@ -818,6 +863,12 @@ module.exports = class Data1701282385470 {
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"`
)
Expand All @@ -833,6 +884,9 @@ module.exports = class Data1701282385470 {
await db.query(
`ALTER TABLE "swap_pool" DROP CONSTRAINT "FK_b66a5cc8d2ce7bba1b48fd8c1ab"`
)
await db.query(
`ALTER TABLE "nabla_swap" DROP CONSTRAINT "FK_dd24afed240ad46290bfcf0603b"`
)
await db.query(
`ALTER TABLE "event" DROP CONSTRAINT "FK_2b0d35d675c4f99751855c45021"`
)
Expand Down
Loading