From 2edf9f3796a9408b61464db04d6ba09f4615cacb Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:29:28 -0700 Subject: [PATCH 01/88] Add cache builder js scripts for peg cross --- .../subgraph-bean/cache-builder/beanstalk3.js | 1 + .../cache-builder/peg-crosses.js | 62 +++++++++ .../results/PegCrossBlocks2.ts} | 18 ++- projects/subgraph-bean/package.json | 1 + projects/subgraph-bean/src/BlockHandler.ts | 2 +- projects/subgraph-bean/tests/Cross.test.ts | 2 +- projects/subgraph-beanstalk/package.json | 1 + yarn.lock | 131 +++++++++++++++++- 8 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 projects/subgraph-bean/cache-builder/beanstalk3.js create mode 100644 projects/subgraph-bean/cache-builder/peg-crosses.js rename projects/subgraph-bean/{src/result_cache/PegCrossBlocks.ts => cache-builder/results/PegCrossBlocks2.ts} (97%) diff --git a/projects/subgraph-bean/cache-builder/beanstalk3.js b/projects/subgraph-bean/cache-builder/beanstalk3.js new file mode 100644 index 0000000000..790a809399 --- /dev/null +++ b/projects/subgraph-bean/cache-builder/beanstalk3.js @@ -0,0 +1 @@ +const url = "graph.bean.money/bean"; diff --git a/projects/subgraph-bean/cache-builder/peg-crosses.js b/projects/subgraph-bean/cache-builder/peg-crosses.js new file mode 100644 index 0000000000..d8973dacfc --- /dev/null +++ b/projects/subgraph-bean/cache-builder/peg-crosses.js @@ -0,0 +1,62 @@ +const { GraphQLClient, gql } = require("graphql-request"); +const fs = require("fs"); + +const subgraph = new GraphQLClient("https://graph.bean.money/bean"); + +// Gets all unique blocks in which there was either a pool or peg cross. +async function getAllPegCrossBlocks() { + const allCrossBlocks = []; + + let nextBlock = 1; + while (nextBlock) { + let queryResult = await _getCrossesSince(nextBlock); + + for (const poolCross of queryResult.poolCrosses) { + if (!allCrossBlocks.includes(poolCross.blockNumber)) { + allCrossBlocks.push(poolCross.blockNumber); + } + } + for (const beanCross of queryResult.beanCrosses) { + if (!allCrossBlocks.includes(beanCross.blockNumber)) { + allCrossBlocks.push(beanCross.blockNumber); + } + } + + const maxPoolBlock = queryResult.poolCrosses[999]?.blockNumber; + const maxBeanBlock = queryResult.beanCrosses[999]?.blockNumber; + if (!maxPoolBlock && !maxBeanBlock) { + nextBlock = undefined; + } else if (maxPoolBlock && !maxBeanBlock) { + nextBlock = maxPoolBlock; + } else if (!maxPoolBlock && maxBeanBlock) { + nextBlock = maxBeanBlock; + } else { + nextBlock = Math.min(maxPoolBlock, maxBeanBlock); + } + } + allCrossBlocks.sort(); + + await fs.promises.appendFile( + `${__dirname}/results/PegCrossBlocks2.ts`, + `export const PEG_CROSS_BLOCKS: u32[] = [${allCrossBlocks.join(",")}]; + export const PEG_CROSS_BLOCKS_LAST: u32 = ${allCrossBlocks[allCrossBlocks.length - 1]}; + ` + ); + + return allCrossBlocks; +} + +async function _getCrossesSince(block) { + return await subgraph.request(gql` + { + poolCrosses(where: { blockNumber_gt: ${block}}, first: 1000, orderBy: blockNumber, orderDirection: asc) { + blockNumber + } + beanCrosses(where: { blockNumber_gt: ${block}}, first: 1000, orderBy: blockNumber, orderDirection: asc) { + blockNumber + } + } + `); +} + +getAllPegCrossBlocks(); diff --git a/projects/subgraph-bean/src/result_cache/PegCrossBlocks.ts b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks2.ts similarity index 97% rename from projects/subgraph-bean/src/result_cache/PegCrossBlocks.ts rename to projects/subgraph-bean/cache-builder/results/PegCrossBlocks2.ts index e47390b948..4a5663d38a 100644 --- a/projects/subgraph-bean/src/result_cache/PegCrossBlocks.ts +++ b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks2.ts @@ -605,6 +605,20 @@ export const PEG_CROSS_BLOCKS: u32[] = [ 19410497, 19410510, 19410916, 19411000, 19411002, 19411204, 19411937, 19411939, 19411997, 19512944, 19513029, 19513189, 19513202, 19513396, 19513538, 19513695, 19513945, 19513992, 19516059, 19516062, 19516075, 19516084, 19516968, 19517224, 19554953, 19558472, 19609701, 19609719, 19609892, 19609947, 19610025, 19610494, 19610647, 19610652, 19610959, 19611209, 19611291, 19612269, 19612444, - 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285 + 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285, 19613989, 19614239, 19614595, 19614600, + 19614607, 19615112, 19615114, 19615248, 19726042, 19726057, 19748242, 19748244, 19748269, 19748278, 19748377, 19750672, 19750695, + 19750702, 19750822, 19750833, 19751058, 19751064, 19751102, 19751108, 19751169, 19751172, 19751269, 19751854, 19751865, 19751878, + 19751936, 19752030, 19752349, 19755044, 19755063, 19755440, 19755881, 19756813, 19761538, 19761592, 19761593, 19761680, 19761685, + 19761995, 19762162, 19762167, 19763218, 19763430, 19763945, 19764280, 19764311, 19764333, 19764676, 19764744, 19765216, 19765374, + 19765479, 19767631, 19792072, 19792136, 19792139, 19793277, 19793318, 19793322, 19793528, 19793536, 19796241, 19796405, 19796407, + 19802815, 19802816, 19802881, 19804775, 19805218, 19805360, 19805515, 19807739, 19807796, 19808997, 19809396, 19809725, 19809990, + 19913194, 19913195, 19914726, 19914727, 19914735, 19914741, 19914769, 19914811, 19914876, 19914877, 19916067, 19917537, 19917540, + 19917991, 19918159, 19918171, 19918197, 19918202, 19918295, 19918302, 19918429, 19918432, 19918524, 19918639, 19918716, 19918797, + 19918799, 19918991, 19918992, 19919153, 19919287, 19919383, 19919514, 19919971, 19919995, 19920374, 19920778, 19920779, 19921528, + 19921531, 19921674, 19921675, 19921724, 19923306, 19923308, 19923480, 19923532, 19923534, 19923692, 19923702, 19923790, 19923814, + 19923818, 19923880, 19923884, 19924275, 19924279, 19924358, 19924367, 19924384, 19925554, 19925869, 19926582, 19926586, 19926619, + 19926620, 19926687, 19926859, 19926884, 19926887, 19926891, 19926959, 19927302, 19927422, 19928859, 19929054, 19932992, 19933015, + 19933313, 19933316, 19933328, 19933410, 19933760, 19933818, 19933876, 19934184, 19934490, 19934606, 19934621, 19934741, 19959354, + 19959578, 19960026, 19960122, 19962154, 19962536 ]; -export const PEG_CROSS_BLOCKS_LAST: u32 = 19613285; +export const PEG_CROSS_BLOCKS_LAST: u32 = 19962536; diff --git a/projects/subgraph-bean/package.json b/projects/subgraph-bean/package.json index ced13f3a95..208f145674 100644 --- a/projects/subgraph-bean/package.json +++ b/projects/subgraph-bean/package.json @@ -22,6 +22,7 @@ "@graphprotocol/graph-ts": "0.34.0" }, "devDependencies": { + "graphql-request": "^6.1.0", "matchstick-as": "^0.6.0" }, "private": true diff --git a/projects/subgraph-bean/src/BlockHandler.ts b/projects/subgraph-bean/src/BlockHandler.ts index 84c64471e2..2690b902be 100644 --- a/projects/subgraph-bean/src/BlockHandler.ts +++ b/projects/subgraph-bean/src/BlockHandler.ts @@ -6,7 +6,7 @@ import { toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals" import { checkBeanCross, checkPoolCross } from "./utils/Cross"; import { loadOrCreatePool, updatePoolPrice, updatePoolValues } from "./utils/Pool"; import { BeanstalkPrice_try_price } from "./utils/price/BeanstalkPrice"; -import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "./result_cache/PegCrossBlocks"; +import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "./cache/PegCrossBlocks"; import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; // Processing as each new ethereum block is created diff --git a/projects/subgraph-bean/tests/Cross.test.ts b/projects/subgraph-bean/tests/Cross.test.ts index d919409153..401c43c2c9 100644 --- a/projects/subgraph-bean/tests/Cross.test.ts +++ b/projects/subgraph-bean/tests/Cross.test.ts @@ -15,7 +15,7 @@ import { getPreReplantPriceETH, constantProductPrice, uniswapV2Reserves } from " import { mockPoolPriceAndLiquidity, mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves } from "./entity-mocking/MockPool"; import { updatePricesAndCheckCrosses as crv_updatePricesAndCheckCrosses } from "../src/Bean3CRVHandler_V1"; import { setWhitelistedPools } from "./entity-mocking/MockBean"; -import { PEG_CROSS_BLOCKS } from "../src/result_cache/PegCrossBlocks"; +import { PEG_CROSS_BLOCKS } from "../src/cache/PegCrossBlocks"; import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; const wellCrossId = (n: u32): string => { diff --git a/projects/subgraph-beanstalk/package.json b/projects/subgraph-beanstalk/package.json index 288b489ac7..b21639c4dc 100644 --- a/projects/subgraph-beanstalk/package.json +++ b/projects/subgraph-beanstalk/package.json @@ -22,6 +22,7 @@ "@graphprotocol/graph-ts": "0.34.0" }, "devDependencies": { + "graphql-request": "^6.1.0", "matchstick-as": "^0.6.0" }, "private": true diff --git a/yarn.lock b/yarn.lock index 7dff752053..5b9b9ee343 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8205,6 +8205,34 @@ __metadata: languageName: node linkType: hard +"@molt/command@npm:^0.9.0": + version: 0.9.0 + resolution: "@molt/command@npm:0.9.0" + dependencies: + "@molt/types": "npm:0.2.0" + alge: "npm:0.8.1" + chalk: "npm:^5.3.0" + lodash.camelcase: "npm:^4.3.0" + lodash.snakecase: "npm:^4.1.1" + readline-sync: "npm:^1.4.10" + string-length: "npm:^6.0.0" + strip-ansi: "npm:^7.1.0" + ts-toolbelt: "npm:^9.6.0" + type-fest: "npm:^4.3.1" + zod: "npm:^3.22.2" + checksum: 10/e6ec7c6c2c6a64a1b28e09074196e5aa891bdcbff4129e54c59b902e1b6f4151033fd92c8535666be32267163d04ce3ce454ca0df0a4d5669a8506817131984e + languageName: node + linkType: hard + +"@molt/types@npm:0.2.0": + version: 0.2.0 + resolution: "@molt/types@npm:0.2.0" + dependencies: + ts-toolbelt: "npm:^9.6.0" + checksum: 10/0c7eab1dda0d689fda7025b4e4b37ffc290a7e2f7bfb0463a8bffc5834c30af66ab92d63bc2f71dc515cdd0121fc3587596690353a7e1c40d530395135540063 + languageName: node + linkType: hard + "@motionone/animation@npm:^10.12.0": version: 10.17.0 resolution: "@motionone/animation@npm:10.17.0" @@ -17489,6 +17517,18 @@ __metadata: languageName: node linkType: hard +"alge@npm:0.8.1": + version: 0.8.1 + resolution: "alge@npm:0.8.1" + dependencies: + lodash.ismatch: "npm:^4.4.0" + remeda: "npm:^1.0.0" + ts-toolbelt: "npm:^9.6.0" + zod: "npm:^3.17.3" + checksum: 10/11483523289bc7750b6462698a2b61c816bf3c7eada2ade206bc02b964679b6bf4b298cc561ae267f382573668b68ff311a0aec60c5ae011aecde491932240e8 + languageName: node + linkType: hard + "all-node-versions@npm:^11.3.0": version: 11.3.0 resolution: "all-node-versions@npm:11.3.0" @@ -20106,7 +20146,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:5.3.0": +"chalk@npm:5.3.0, chalk@npm:^5.3.0": version: 5.3.0 resolution: "chalk@npm:5.3.0" checksum: 10/6373caaab21bd64c405bfc4bd9672b145647fc9482657b5ea1d549b3b2765054e9d3d928870cdf764fb4aad67555f5061538ff247b8310f110c5c888d92397ea @@ -27579,6 +27619,31 @@ __metadata: languageName: node linkType: hard +"graphql-request@npm:7.1.0": + version: 7.1.0 + resolution: "graphql-request@npm:7.1.0" + dependencies: + "@graphql-typed-document-node/core": "npm:^3.2.0" + "@molt/command": "npm:^0.9.0" + zod: "npm:^3.23.8" + peerDependencies: + "@dprint/formatter": ^0.3.0 + "@dprint/typescript": ^0.91.1 + dprint: ^0.46.2 + graphql: 14 - 16 + peerDependenciesMeta: + "@dprint/formatter": + optional: true + "@dprint/typescript": + optional: true + dprint: + optional: true + bin: + graffle: build/cli/generate.js + checksum: 10/6e61cd8200f9842569a657b0fdc0cb45a8433d8afa730ace911fa9a09318fb3cae3ccd9396a9ab2e1795bf9ccbce976fc90fb0bfac9dfe2fc821e74845be57d9 + languageName: node + linkType: hard + "graphql-request@npm:^4": version: 4.3.0 resolution: "graphql-request@npm:4.3.0" @@ -27606,7 +27671,7 @@ __metadata: languageName: node linkType: hard -"graphql-request@npm:^6.0.0": +"graphql-request@npm:^6.0.0, graphql-request@npm:^6.1.0": version: 6.1.0 resolution: "graphql-request@npm:6.1.0" dependencies: @@ -32993,6 +33058,13 @@ __metadata: languageName: node linkType: hard +"lodash.ismatch@npm:^4.4.0": + version: 4.4.0 + resolution: "lodash.ismatch@npm:4.4.0" + checksum: 10/946a7176cdf4048f7b624378defda00dc0d01a2dad9933c54dad11fbecc253716df4210fbbfcd7d042e6fdb7603463cfe48e0ef576e20bf60d43f7deb1a2fe04 + languageName: node + linkType: hard + "lodash.isnumber@npm:^3.0.3": version: 3.0.3 resolution: "lodash.isnumber@npm:3.0.3" @@ -38634,6 +38706,13 @@ __metadata: languageName: node linkType: hard +"readline-sync@npm:^1.4.10": + version: 1.4.10 + resolution: "readline-sync@npm:1.4.10" + checksum: 10/5eb6465f5c5391e32cb525022a307a910a565828cd53da87ac05fca291607df54099dd65bc9c7a513ac53a5eb4e11454d48f0dcf4ad54126d36dec5fcec4a8f0 + languageName: node + linkType: hard + "real-require@npm:^0.1.0": version: 0.1.0 resolution: "real-require@npm:0.1.0" @@ -39054,6 +39133,13 @@ __metadata: languageName: node linkType: hard +"remeda@npm:^1.0.0": + version: 1.61.0 + resolution: "remeda@npm:1.61.0" + checksum: 10/0b0ec8688e340c7525a8788e99701b174ddca2eaf230d47f9e087d9aaccd54c7181a1f58bf4f95cb9c12bc1d26f03b17e3d3d9046a59225074a7ac3fa1356da3 + languageName: node + linkType: hard + "remedial@npm:^1.0.7": version: 1.0.8 resolution: "remedial@npm:1.0.8" @@ -41321,6 +41407,15 @@ __metadata: languageName: node linkType: hard +"string-length@npm:^6.0.0": + version: 6.0.0 + resolution: "string-length@npm:6.0.0" + dependencies: + strip-ansi: "npm:^7.1.0" + checksum: 10/b171e9e193ec292ad71f8b2a36e20478bf1bac8cd5beec062fb126942d627dfd9311959e271e9ab7b0a383d16b85b9e25a183d15786e30f22104d152e7627f99 + languageName: node + linkType: hard + "string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.0.0, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.2, string-width@npm:^4.2.3": version: 4.2.3 resolution: "string-width@npm:4.2.3" @@ -41571,6 +41666,15 @@ __metadata: languageName: node linkType: hard +"strip-ansi@npm:^7.1.0": + version: 7.1.0 + resolution: "strip-ansi@npm:7.1.0" + dependencies: + ansi-regex: "npm:^6.0.1" + checksum: 10/475f53e9c44375d6e72807284024ac5d668ee1d06010740dec0b9744f2ddf47de8d7151f80e5f6190fc8f384e802fdf9504b76a7e9020c9faee7103623338be2 + languageName: node + linkType: hard + "strip-bom@npm:^2.0.0": version: 2.0.0 resolution: "strip-bom@npm:2.0.0" @@ -41768,6 +41872,7 @@ __metadata: dependencies: "@graphprotocol/graph-cli": "npm:0.79.2" "@graphprotocol/graph-ts": "npm:0.34.0" + graphql-request: "npm:^6.1.0" matchstick-as: "npm:^0.6.0" languageName: unknown linkType: soft @@ -41778,6 +41883,7 @@ __metadata: dependencies: "@graphprotocol/graph-cli": "npm:0.79.2" "@graphprotocol/graph-ts": "npm:0.34.0" + graphql-request: "npm:7.1.0" matchstick-as: "npm:^0.6.0" languageName: unknown linkType: soft @@ -42823,6 +42929,13 @@ __metadata: languageName: node linkType: hard +"ts-toolbelt@npm:^9.6.0": + version: 9.6.0 + resolution: "ts-toolbelt@npm:9.6.0" + checksum: 10/2c2dea2631dbd7372a79cccc6d09a377a6ca2f319f767fd239d2e312cd1d9165a90f8c1777a047227bfdcda6aeba3addbadce88fdfc7f43caf4534d385a43c82 + languageName: node + linkType: hard + "tsc-alias@npm:1.8.8": version: 1.8.8 resolution: "tsc-alias@npm:1.8.8" @@ -43029,6 +43142,13 @@ __metadata: languageName: node linkType: hard +"type-fest@npm:^4.3.1": + version: 4.26.0 + resolution: "type-fest@npm:4.26.0" + checksum: 10/f5fe86d2c3db693f7154c8ab0d228a89394e4c446f2ed30ea3b61afaea9757c87c4e79475ef8d6f5fafbd7a4efd302e3b0237d9657dd425228f20a27feee3aef + languageName: node + linkType: hard + "type-is@npm:~1.6.18": version: 1.6.18 resolution: "type-is@npm:1.6.18" @@ -45829,6 +45949,13 @@ __metadata: languageName: node linkType: hard +"zod@npm:^3.17.3, zod@npm:^3.22.2, zod@npm:^3.23.8": + version: 3.23.8 + resolution: "zod@npm:3.23.8" + checksum: 10/846fd73e1af0def79c19d510ea9e4a795544a67d5b34b7e1c4d0425bf6bfd1c719446d94cdfa1721c1987d891321d61f779e8236fde517dc0e524aa851a6eff1 + languageName: node + linkType: hard + "zustand@npm:4.4.1": version: 4.4.1 resolution: "zustand@npm:4.4.1" From 3c9361a322c1fc2c05292e077f2e9b26ec0501f7 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:37:01 -0700 Subject: [PATCH 02/88] add package script for build-cache --- .../cache-builder/peg-crosses.js | 9 +- .../cache-builder/results/PegCrossBlocks.ts | 1872 +++++++++++++++++ .../cache-builder/results/PegCrossBlocks2.ts | 624 ------ projects/subgraph-bean/package.json | 1 + projects/subgraph-bean/src/BlockHandler.ts | 2 +- projects/subgraph-bean/tests/Cross.test.ts | 2 +- 6 files changed, 1882 insertions(+), 628 deletions(-) create mode 100644 projects/subgraph-bean/cache-builder/results/PegCrossBlocks.ts delete mode 100644 projects/subgraph-bean/cache-builder/results/PegCrossBlocks2.ts diff --git a/projects/subgraph-bean/cache-builder/peg-crosses.js b/projects/subgraph-bean/cache-builder/peg-crosses.js index d8973dacfc..6ee85915b3 100644 --- a/projects/subgraph-bean/cache-builder/peg-crosses.js +++ b/projects/subgraph-bean/cache-builder/peg-crosses.js @@ -1,10 +1,13 @@ const { GraphQLClient, gql } = require("graphql-request"); const fs = require("fs"); -const subgraph = new GraphQLClient("https://graph.bean.money/bean"); +const url = "https://graph.bean.money/bean"; +const subgraph = new GraphQLClient(url); // Gets all unique blocks in which there was either a pool or peg cross. async function getAllPegCrossBlocks() { + console.log(`Pulling historical peg cross blocks from ${url}...`); + const allCrossBlocks = []; let nextBlock = 1; @@ -36,12 +39,14 @@ async function getAllPegCrossBlocks() { } allCrossBlocks.sort(); + const outFile = `${__dirname}/results/PegCrossBlocks.ts`; await fs.promises.appendFile( - `${__dirname}/results/PegCrossBlocks2.ts`, + outFile, `export const PEG_CROSS_BLOCKS: u32[] = [${allCrossBlocks.join(",")}]; export const PEG_CROSS_BLOCKS_LAST: u32 = ${allCrossBlocks[allCrossBlocks.length - 1]}; ` ); + console.log(`Wrote historical peg cross blocks to ${outFile}`); return allCrossBlocks; } diff --git a/projects/subgraph-bean/cache-builder/results/PegCrossBlocks.ts b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks.ts new file mode 100644 index 0000000000..eafddd4971 --- /dev/null +++ b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks.ts @@ -0,0 +1,1872 @@ +export const PEG_CROSS_BLOCKS: u32[] = [ + 12974091, 12975421, 12978538, 12978615, 12978680, 12978911, 12979148, 12979149, 12979167, 12979171, 12979228, 12979230, 12979607, + 12983847, 12983871, 12983895, 12983897, 12983926, 12984038, 12984104, 12984170, 12984257, 12984310, 12984929, 12986590, 12986603, + 12986901, 12987603, 12990064, 12991358, 12991399, 12992193, 12992519, 12993217, 12993281, 12998537, 12998539, 12998546, 12998550, + 12998551, 12998553, 12999530, 12999585, 12999767, 12999776, 12999777, 12999779, 12999817, 12999840, 13000158, 13000196, 13000305, + 13000309, 13000334, 13000347, 13000356, 13000377, 13000577, 13000587, 13001082, 13001089, 13001396, 13001414, 13001894, 13001913, + 13001956, 13002009, 13002735, 13002738, 13003196, 13003198, 13004037, 13004045, 13004360, 13004364, 13004638, 13004646, 13004655, + 13004657, 13004817, 13004839, 13004843, 13004883, 13005075, 13005103, 13005107, 13005109, 13005372, 13005380, 13005673, 13005715, + 13005730, 13005733, 13005944, 13005946, 13006200, 13006202, 13006203, 13006321, 13006487, 13006488, 13006499, 13006546, 13006708, + 13006709, 13006980, 13007010, 13007245, 13007246, 13007274, 13007275, 13007509, 13007525, 13007574, 13007607, 13007780, 13007798, + 13007859, 13007898, 13008063, 13008065, 13008117, 13008191, 13008375, 13008387, 13008617, 13008671, 13008712, 13008736, 13008895, + 13008901, 13008906, 13008912, 13009163, 13009169, 13009190, 13009193, 13009199, 13009203, 13009381, 13009423, 13009669, 13009671, + 13009676, 13009679, 13009681, 13009687, 13009958, 13009972, 13009973, 13010009, 13010222, 13010231, 13010492, 13010556, 13010779, + 13014211, 13016266, 13018933, 13019023, 13019754, 13020690, 13020782, 13022699, 13022701, 13022825, 13023185, 13023247, 13023922, + 13025396, 13025666, 13026184, 13026256, 13026638, 13026640, 13027512, 13029384, 13030010, 13030107, 13030123, 13030393, 13030528, + 13031004, 13031259, 13032695, 13032731, 13032942, 13033010, 13033033, 13033210, 13034517, 13034543, 13035839, 13035922, 13035929, + 13036165, 13036689, 13036884, 13036897, 13036926, 13037135, 13037615, 13037642, 13038069, 13038108, 13038138, 13038145, 13038184, + 13039743, 13043682, 13043699, 13044756, 13044762, 13044770, 13044955, 13045801, 13046502, 13051141, 13051348, 13056233, 13056234, + 13057499, 13057501, 13057527, 13057595, 13058927, 13059717, 13059983, 13060079, 13060086, 13060118, 13060119, 13060121, 13060123, + 13060132, 13060160, 13060198, 13060449, 13060450, 13060479, 13060489, 13060492, 13060680, 13060716, 13060796, 13060802, 13060842, + 13060960, 13062059, 13062295, 13062299, 13062306, 13062319, 13062333, 13062352, 13062366, 13063788, 13063838, 13063861, 13063878, + 13075770, 13075888, 13076058, 13076195, 13076316, 13076435, 13076636, 13076662, 13076679, 13076703, 13076890, 13076891, 13076899, + 13076947, 13076964, 13076972, 13077164, 13077246, 13077426, 13077429, 13077495, 13077503, 13077730, 13077736, 13078272, 13078287, + 13078449, 13078457, 13078466, 13078470, 13078482, 13078487, 13078488, 13078519, 13078541, 13078561, 13078796, 13078810, 13078813, + 13078834, 13079299, 13079303, 13079572, 13079587, 13079588, 13079596, 13079620, 13079642, 13079648, 13079683, 13079724, 13079755, + 13079814, 13079885, 13079887, 13079895, 13079899, 13079919, 13079920, 13079941, 13080074, 13080179, 13080198, 13080229, 13080352, + 13080375, 13080400, 13080408, 13080634, 13080637, 13080648, 13080660, 13080672, 13080677, 13080678, 13080680, 13080768, 13080770, + 13080887, 13080888, 13080932, 13080934, 13080937, 13080958, 13080977, 13080990, 13080996, 13080999, 13081011, 13081057, 13081145, + 13081209, 13081632, 13081635, 13081700, 13081721, 13081750, 13081754, 13081766, 13081895, 13081963, 13081977, 13081992, 13081994, + 13082000, 13082006, 13082094, 13082163, 13082230, 13082282, 13082300, 13082301, 13082504, 13082507, 13082510, 13082555, 13082863, + 13082876, 13082878, 13082888, 13082969, 13083844, 13084930, 13084956, 13084984, 13085212, 13085233, 13085236, 13085311, 13085508, + 13085645, 13085877, 13086288, 13086337, 13086338, 13086356, 13086362, 13086369, 13086376, 13086400, 13086422, 13086440, 13086459, + 13086461, 13087211, 13087217, 13087221, 13087225, 13087231, 13087377, 13087393, 13087405, 13087410, 13087411, 13087527, 13088104, + 13088272, 13093705, 13093899, 13093903, 13093921, 13093932, 13093971, 13093975, 13099188, 13099189, 13099353, 13099362, 13099414, + 13099461, 13099465, 13099710, 13099714, 13099747, 13100289, 13100319, 13100358, 13100371, 13100898, 13100923, 13102868, 13102939, + 13107071, 13107096, 13110581, 13110588, 13110634, 13110706, 13110819, 13110844, 13111074, 13113042, 13113109, 13113110, 13113423, + 13113442, 13113448, 13113452, 13113453, 13113553, 13114481, 13114574, 13115940, 13115946, 13115955, 13115972, 13115989, 13115990, + 13117862, 13118077, 13118145, 13118291, 13118320, 13118321, 13118355, 13118356, 13118402, 13118413, 13118423, 13118428, 13118436, + 13118467, 13121070, 13121089, 13121099, 13121128, 13121178, 13121244, 13121307, 13121310, 13122225, 13122395, 13122407, 13122455, + 13122874, 13122951, 13122985, 13124397, 13124895, 13129783, 13129786, 13129854, 13129981, 13129991, 13130001, 13130094, 13130178, + 13131625, 13131662, 13131722, 13131929, 13137125, 13137568, 13138520, 13138647, 13138700, 13138778, 13138782, 13138813, 13138856, + 13138858, 13139212, 13139273, 13139367, 13139407, 13139408, 13139410, 13139609, 13140003, 13140015, 13140024, 13140027, 13140327, + 13140447, 13140687, 13141148, 13141156, 13141160, 13141165, 13141195, 13141863, 13141869, 13141870, 13141940, 13142135, 13143729, + 13143754, 13143760, 13143762, 13143763, 13143816, 13144293, 13144300, 13144362, 13144364, 13144774, 13144823, 13145005, 13145190, + 13145194, 13145195, 13145198, 13145206, 13145220, 13145747, 13146082, 13146089, 13147016, 13147028, 13147044, 13147045, 13148291, + 13148316, 13149112, 13150275, 13150279, 13150280, 13151314, 13151333, 13151356, 13151443, 13151450, 13151451, 13151460, 13151462, + 13151595, 13151598, 13151696, 13151700, 13151863, 13151867, 13152103, 13152260, 13152269, 13153306, 13153325, 13155620, 13156284, + 13156748, 13156781, 13157326, 13158957, 13159234, 13159235, 13159247, 13159248, 13159486, 13159495, 13161064, 13161086, 13161299, + 13161376, 13161392, 13161406, 13161416, 13161423, 13161487, 13161550, 13161611, 13161634, 13161636, 13162200, 13162208, 13162329, + 13162331, 13163395, 13163536, 13163565, 13163567, 13163596, 13163597, 13163604, 13163670, 13163995, 13164187, 13164189, 13164192, + 13164658, 13164746, 13165237, 13165391, 13165408, 13165727, 13165897, 13165996, 13166015, 13166072, 13166219, 13166222, 13166242, + 13166250, 13166251, 13166258, 13166259, 13166283, 13166287, 13166319, 13166381, 13166437, 13167205, 13167549, 13167575, 13167591, + 13167742, 13167972, 13168519, 13168524, 13169110, 13171988, 13175038, 13175053, 13175058, 13175064, 13175069, 13175146, 13175397, + 13175452, 13175497, 13175514, 13175520, 13175609, 13177587, 13177589, 13177597, 13177615, 13177647, 13177659, 13177660, 13177714, + 13177758, 13178360, 13178584, 13178652, 13179149, 13179177, 13179251, 13179252, 13179253, 13179274, 13179308, 13179337, 13179353, + 13179400, 13180079, 13180083, 13180101, 13180102, 13180117, 13180145, 13180189, 13180216, 13180664, 13180692, 13180713, 13180715, + 13180730, 13180758, 13180833, 13180888, 13180897, 13180909, 13181023, 13181155, 13181755, 13181777, 13181802, 13181820, 13182646, + 13182655, 13183890, 13183894, 13183955, 13183956, 13183957, 13184012, 13184973, 13184974, 13185191, 13185260, 13185321, 13185384, + 13185495, 13185703, 13185732, 13185850, 13187086, 13187116, 13187178, 13187233, 13188042, 13189001, 13189010, 13189082, 13191072, + 13191091, 13191099, 13191106, 13191522, 13191635, 13191637, 13191644, 13192232, 13192596, 13192599, 13192604, 13193031, 13193802, + 13194379, 13194410, 13194615, 13194717, 13194719, 13194824, 13196049, 13196067, 13196141, 13196190, 13196445, 13196459, 13196460, + 13198164, 13198273, 13198316, 13198557, 13198899, 13198902, 13198907, 13198909, 13198925, 13199052, 13199074, 13199086, 13199099, + 13199116, 13199129, 13199131, 13199260, 13199361, 13199363, 13200193, 13200194, 13200216, 13200219, 13200224, 13201208, 13201289, + 13201290, 13201321, 13201322, 13206138, 13206229, 13206338, 13206947, 13207266, 13207395, 13207435, 13207444, 13207445, 13207578, + 13207663, 13208184, 13211822, 13211897, 13211967, 13213641, 13214042, 13214163, 13214206, 13215008, 13215982, 13217044, 13217061, + 13217222, 13217341, 13217478, 13217783, 13217784, 13217810, 13217953, 13217970, 13217973, 13218020, 13218050, 13218279, 13218810, + 13218815, 13218816, 13218909, 13218949, 13218953, 13218954, 13225077, 13225299, 13226246, 13226559, 13226732, 13226957, 13227000, + 13229110, 13229499, 13229747, 13232674, 13232699, 13232717, 13233025, 13234172, 13234178, 13234264, 13234554, 13236246, 13236247, + 13236250, 13236319, 13237109, 13237552, 13244459, 13244462, 13245028, 13245032, 13245040, 13245162, 13245172, 13245175, 13245180, + 13245275, 13245545, 13245546, 13246387, 13246388, 13246647, 13246651, 13246920, 13246926, 13246980, 13246983, 13247415, 13247416, + 13247678, 13247695, 13247947, 13247952, 13248208, 13248209, 13248470, 13248473, 13249273, 13249276, 13249292, 13249294, 13249543, + 13249561, 13249800, 13249818, 13249822, 13250039, 13250057, 13250059, 13256813, 13256815, 13257386, 13257389, 13258210, 13258214, + 13259590, 13259594, 13259863, 13259865, 13260039, 13260056, 13260062, 13260063, 13260114, 13260126, 13260381, 13260386, 13260388, + 13260389, 13260884, 13260886, 13261140, 13261142, 13261145, 13261155, 13261156, 13261186, 13261206, 13261363, 13261373, 13261399, + 13262381, 13262382, 13262425, 13262428, 13262440, 13262442, 13262455, 13262462, 13262465, 13262469, 13262553, 13262554, 13262569, + 13262592, 13262593, 13262713, 13262719, 13262729, 13262748, 13262896, 13262899, 13262913, 13263080, 13263772, 13263871, 13264127, + 13264135, 13264139, 13264149, 13272546, 13272560, 13272905, 13272934, 13273058, 13273061, 13273064, 13273373, 13273436, 13273458, + 13273503, 13273513, 13273717, 13273719, 13274023, 13274030, 13274057, 13274064, 13274105, 13274148, 13274189, 13274198, 13274217, + 13274220, 13274242, 13274248, 13335750, 13335755, 13335869, 13336244, 13336323, 13336461, 13336505, 13336560, 13336618, 13336695, + 13336714, 13336777, 13336959, 13337532, 13337559, 13337935, 13337937, 13337959, 13340698, 13340781, 13340820, 13340947, 13341028, + 13341076, 13341108, 13341147, 13341156, 13341366, 13341373, 13342047, 13342121, 13342224, 13342548, 13376585, 13376710, 13376778, + 13378143, 13378793, 13378816, 13378829, 13379464, 13434006, 13434877, 13435565, 13435971, 13436006, 13436018, 13436025, 13436035, + 13436049, 13436107, 13437998, 13438644, 13438667, 13440517, 13442086, 13442913, 13443210, 13443231, 13443232, 13443239, 13443256, + 13443258, 13443270, 13443271, 13444653, 13444660, 13444712, 13446459, 13448008, 13449065, 13449128, 13449167, 13449303, 13449313, + 13449493, 13449495, 13449505, 13449506, 13449551, 13449634, 13449650, 13449705, 13449790, 13449821, 13449841, 13449855, 13449875, + 13449913, 13450052, 13450154, 13450187, 13450472, 13450507, 13450522, 13451061, 13451131, 13451155, 13451468, 13451543, 13451544, + 13451550, 13451555, 13451564, 13451596, 13451598, 13451649, 13451671, 13451675, 13455280, 13455282, 13455557, 13455600, 13455618, + 13455860, 13455891, 13455896, 13455911, 13461738, 13462027, 13462049, 13462066, 13462165, 13463379, 13463381, 13464408, 13466451, + 13467419, 13467691, 13468508, 13468675, 13468784, 13469000, 13469007, 13469012, 13469034, 13470634, 13470770, 13471747, 13474744, + 13474934, 13475341, 13475377, 13475394, 13475519, 13475523, 13475746, 13476174, 13476209, 13476325, 13476418, 13476419, 13479133, + 13479136, 13479138, 13479152, 13479196, 13479242, 13479941, 13480370, 13480372, 13480449, 13480647, 13480648, 13480717, 13481304, + 13481717, 13481988, 13482011, 13482102, 13483897, 13483977, 13483982, 13483998, 13484811, 13484846, 13484847, 13486887, 13486969, + 13488473, 13488482, 13489574, 13489977, 13490465, 13490505, 13490507, 13490517, 13490518, 13491374, 13494424, 13494752, 13494754, + 13495520, 13495854, 13497794, 13497797, 13497803, 13497820, 13497844, 13497868, 13498035, 13503686, 13503690, 13503704, 13503709, + 13503751, 13503763, 13503770, 13503813, 13503910, 13508461, 13508666, 13508680, 13508728, 13508759, 13508780, 13510297, 13510507, + 13510508, 13510514, 13510516, 13510518, 13510520, 13510556, 13510590, 13510603, 13510605, 13510610, 13510727, 13511700, 13511890, + 13511907, 13512045, 13512048, 13512304, 13512305, 13512359, 13512365, 13514281, 13514282, 13514705, 13514719, 13514721, 13514734, + 13515060, 13516318, 13516526, 13516569, 13517036, 13517567, 13518970, 13519495, 13519497, 13519756, 13521882, 13522133, 13523828, + 13523847, 13523862, 13523885, 13523912, 13523967, 13523969, 13524379, 13524397, 13525787, 13525872, 13525873, 13528534, 13528544, + 13528546, 13528558, 13528574, 13528579, 13528967, 13529028, 13531631, 13531875, 13531910, 13531954, 13531961, 13531990, 13532016, + 13532023, 13532081, 13532126, 13532137, 13532138, 13532143, 13532151, 13532161, 13532176, 13532179, 13532198, 13532239, 13532920, + 13532929, 13532946, 13533454, 13533933, 13535490, 13535493, 13535494, 13535499, 13538211, 13538232, 13538866, 13538895, 13539218, + 13539249, 13539673, 13539923, 13539946, 13539951, 13540826, 13540841, 13541140, 13541325, 13541849, 13541933, 13541958, 13541980, + 13541997, 13542002, 13542077, 13542086, 13542175, 13542179, 13542232, 13542254, 13543917, 13544624, 13545832, 13545837, 13545858, + 13546411, 13547018, 13547059, 13547095, 13547595, 13547630, 13548233, 13548387, 13550252, 13550987, 13551029, 13551119, 13551280, + 13551291, 13552190, 13552241, 13552260, 13552307, 13552675, 13552678, 13552681, 13552684, 13552688, 13552701, 13552704, 13552750, + 13552752, 13552754, 13552943, 13553661, 13553662, 13553676, 13553677, 13553853, 13554976, 13555095, 13555457, 13557196, 13557954, + 13558105, 13558112, 13558113, 13558114, 13558116, 13558121, 13558735, 13558752, 13558776, 13559078, 13559084, 13559255, 13559291, + 13559303, 13559410, 13559415, 13559416, 13559425, 13559561, 13559568, 13559602, 13559647, 13559656, 13559658, 13559791, 13559882, + 13560317, 13560318, 13560937, 13564634, 13564681, 13564697, 13564713, 13564837, 13564852, 13564859, 13564871, 13564879, 13564889, + 13564891, 13566648, 13568113, 13568302, 13568342, 13568345, 13568357, 13568484, 13568492, 13568495, 13568667, 13570256, 13570277, + 13570284, 13570300, 13570316, 13570318, 13570944, 13570952, 13571175, 13572652, 13572673, 13572674, 13572854, 13572856, 13572884, + 13572895, 13572918, 13572923, 13572958, 13572969, 13573024, 13573028, 13573096, 13573097, 13573405, 13573522, 13573523, 13573686, + 13573687, 13573693, 13573695, 13574201, 13574213, 13574289, 13574294, 13575376, 13575377, 13576614, 13576620, 13576635, 13576661, + 13576663, 13577153, 13577969, 13578897, 13578901, 13578940, 13578947, 13579158, 13579160, 13579235, 13579351, 13579385, 13579447, + 13579490, 13579530, 13579565, 13579572, 13579588, 13579894, 13579900, 13579911, 13579912, 13579914, 13579918, 13579942, 13580072, + 13580087, 13580260, 13580280, 13581920, 13582005, 13582060, 13582068, 13582069, 13582090, 13582096, 13582336, 13582467, 13582468, + 13582749, 13583449, 13583933, 13584045, 13584069, 13584076, 13584080, 13584082, 13584102, 13584104, 13584107, 13584126, 13584153, + 13584183, 13584184, 13584192, 13584195, 13584208, 13584209, 13584211, 13584243, 13584286, 13584294, 13584296, 13584485, 13584486, + 13585001, 13585594, 13585602, 13585607, 13585610, 13585641, 13585748, 13585775, 13585976, 13585992, 13586067, 13587038, 13587054, + 13587160, 13589367, 13589405, 13589454, 13589471, 13589485, 13589486, 13589512, 13589515, 13589527, 13589532, 13589574, 13589656, + 13589661, 13589867, 13590103, 13592391, 13594358, 13595502, 13595599, 13595883, 13596659, 13596666, 13596668, 13596671, 13598662, + 13599510, 13599974, 13600003, 13600116, 13600221, 13600229, 13600230, 13600343, 13600344, 13600519, 13602309, 13602377, 13602479, + 13602483, 13602486, 13602488, 13602489, 13602490, 13602493, 13602978, 13603574, 13603586, 13603652, 13603887, 13604255, 13605773, + 13605779, 13606896, 13607198, 13607202, 13607203, 13608420, 13608519, 13608665, 13608681, 13608968, 13610066, 13611161, 13614876, + 13614927, 13614991, 13614998, 13615404, 13617630, 13618342, 13621035, 13622147, 13623486, 13623495, 13623499, 13623577, 13623590, + 13623764, 13624270, 13624355, 13624363, 13624366, 13624383, 13624517, 13625958, 13625960, 13625982, 13626112, 13626125, 13626166, + 13626170, 13626212, 13628785, 13628854, 13628864, 13628865, 13629661, 13629662, 13629784, 13629785, 13629852, 13630011, 13630129, + 13630230, 13630429, 13630583, 13630683, 13630775, 13630780, 13630796, 13631292, 13631331, 13640082, 13640087, 13640104, 13640132, + 13640218, 13640556, 13640587, 13640615, 13641928, 13641929, 13642057, 13642071, 13642137, 13642155, 13642160, 13642167, 13642168, + 13642207, 13642212, 13642215, 13642216, 13642265, 13642911, 13644410, 13646116, 13646163, 13647476, 13647732, 13647733, 13647905, + 13657931, 13657936, 13658078, 13658083, 13658088, 13658106, 13666892, 13666908, 13667064, 13667842, 13671879, 13672266, 13685409, + 13685501, 13687313, 13687327, 13688700, 13688718, 13688728, 13688770, 13688773, 13689077, 13693941, 13693995, 13694143, 13694177, + 13703288, 13703407, 13704796, 13704804, 13704850, 13704871, 13710244, 13710333, 13710534, 13710568, 13717643, 13717686, 13720847, + 13720981, 13721138, 13721150, 13721209, 13721255, 13721263, 13721265, 13721279, 13721280, 13722372, 13722456, 13722731, 13722854, + 13722860, 13722861, 13722883, 13722884, 13722898, 13722924, 13723078, 13723597, 13723611, 13723617, 13724121, 13724580, 13724940, + 13724949, 13724958, 13725168, 13725481, 13725714, 13725715, 13725761, 13726532, 13728022, 13728049, 13729075, 13729079, 13729488, + 13729572, 13729622, 13729660, 13729666, 13729719, 13729765, 13729836, 13731361, 13731396, 13731754, 13731765, 13731769, 13731770, + 13731798, 13731966, 13732954, 13732957, 13732964, 13734204, 13734565, 13734582, 13734613, 13734671, 13735055, 13735059, 13735060, + 13735378, 13740278, 13740773, 13740781, 13740808, 13740821, 13740879, 13741264, 13742045, 13742386, 13742413, 13742433, 13742461, + 13742522, 13743142, 13743432, 13743636, 13743643, 13743676, 13744107, 13744604, 13800996, 13800999, 13801241, 13801243, 13804633, + 13804667, 13804672, 13804727, 13812443, 13812884, 13812892, 13812903, 13813249, 13813688, 13829732, 13829784, 13844956, 13844964, + 13845655, 13845657, 13845739, 13845745, 13845757, 13845780, 13848953, 13851591, 13851617, 13852217, 13852286, 13852519, 13853027, + 13854735, 13854789, 13854927, 13854932, 13854936, 13854950, 13854954, 13856012, 13856028, 13856077, 13856953, 13856955, 13857267, + 13857323, 13857365, 13857466, 13857469, 13857483, 13857490, 13857624, 13857918, 13858695, 13858898, 13858902, 13858904, 13858923, + 13858924, 13859670, 13859826, 13859936, 13860025, 13860899, 13861827, 13861932, 13861937, 13862044, 13862064, 13862197, 13862355, + 13862374, 13863113, 13864512, 13864522, 13864530, 13864926, 13864941, 13864946, 13864969, 13865001, 13865043, 13865070, 13865081, + 13865342, 13865516, 13865553, 13865581, 13865604, 13865623, 13865647, 13865678, 13866062, 13869401, 13869405, 13869422, 13869451, + 13869457, 13869834, 13870311, 13870632, 13871204, 13871210, 13871302, 13871334, 13871339, 13871363, 13871424, 13871435, 13871497, + 13871551, 13871568, 13871570, 13871583, 13871761, 13872175, 13872207, 13872240, 13872304, 13872378, 13872402, 13872443, 13872834, + 13872889, 13872979, 13873525, 13873669, 13874108, 13874137, 13874154, 13874198, 13874244, 13874484, 13875063, 13875708, 13875709, + 13876095, 13876631, 13876822, 13876828, 13876980, 13877074, 13877075, 13877496, 13877517, 13877520, 13877638, 13877848, 13878148, + 13882302, 13882360, 13882365, 13882591, 13882592, 13882597, 13882599, 13882806, 13882807, 13883051, 13883360, 13883433, 13884709, + 13885349, 13885866, 13885918, 13886883, 13887001, 13887338, 13887344, 13887380, 13887548, 13887611, 13888142, 13888577, 13888593, + 13888668, 13888746, 13889461, 13889503, 13889510, 13889524, 13889539, 13889649, 13890458, 13891050, 13891076, 13891081, 13891130, + 13891135, 13891138, 13902888, 13902992, 13906563, 13906944, 13908405, 13908630, 13912128, 13912739, 13913099, 13913121, 13913454, + 13913585, 13913596, 13914008, 13926989, 13926996, 13927003, 13927014, 13927024, 13927479, 13927483, 13927492, 13938606, 13938669, + 13939585, 13939590, 13939599, 13939708, 13939849, 13939850, 13942560, 13942563, 13942611, 13954079, 13954146, 13954148, 13954178, + 13985645, 13985651, 13992100, 14005135, 14005139, 14005140, 14005142, 14005185, 14009388, 14009390, 14038443, 14043167, 14043168, + 14098158, 14098190, 14098343, 14098347, 14098363, 14098372, 14098448, 14098510, 14099411, 14099421, 14111704, 14111988, 14112175, + 14112178, 14112222, 14112272, 14112281, 14112322, 14112332, 14112523, 14112534, 14112721, 14112870, 14113018, 14113027, 14113380, + 14113524, 14113544, 14113990, 14114153, 14114184, 14114266, 14114286, 14114342, 14114380, 14114399, 14114404, 14114436, 14114512, + 14114628, 14114673, 14114833, 14114886, 14114898, 14115278, 14115362, 14115372, 14115446, 14115500, 14115574, 14116384, 14116406, + 14116506, 14116797, 14116986, 14117002, 14117059, 14117070, 14117097, 14117135, 14117265, 14117322, 14117503, 14117521, 14117550, + 14118001, 14118142, 14118146, 14118158, 14118197, 14118368, 14118496, 14118533, 14118647, 14118701, 14118714, 14118937, 14119187, + 14119295, 14119413, 14119877, 14119901, 14119970, 14120278, 14120281, 14120282, 14120389, 14120437, 14120542, 14120552, 14120595, + 14121317, 14121366, 14121432, 14121455, 14121577, 14121580, 14121596, 14121601, 14121630, 14121638, 14121679, 14121684, 14121722, + 14121856, 14122382, 14122403, 14122483, 14122757, 14122763, 14122767, 14122824, 14122827, 14122833, 14122844, 14122853, 14122877, + 14123193, 14123200, 14123302, 14123407, 14124143, 14124163, 14124204, 14124296, 14124337, 14124352, 14124366, 14124368, 14124374, + 14124391, 14124991, 14125047, 14126549, 14126762, 14126770, 14126771, 14126782, 14126791, 14126823, 14126841, 14128740, 14128817, + 14128883, 14128944, 14129293, 14129452, 14129553, 14129573, 14129597, 14129617, 14129837, 14129898, 14129913, 14129915, 14129939, + 14130007, 14130296, 14130298, 14130316, 14130334, 14130355, 14130372, 14130378, 14130387, 14130388, 14130423, 14130440, 14130465, + 14130641, 14131066, 14131081, 14131115, 14131324, 14131407, 14131588, 14132136, 14132310, 14133768, 14133783, 14133786, 14133815, + 14133830, 14133981, 14134041, 14135528, 14135807, 14135812, 14135828, 14137560, 14137824, 14137853, 14138293, 14138307, 14138600, + 14138669, 14138825, 14138845, 14138888, 14139112, 14139816, 14140071, 14140079, 14140134, 14140318, 14140343, 14140597, 14140903, + 14140910, 14141386, 14141418, 14141461, 14141473, 14141478, 14141480, 14141489, 14141517, 14141541, 14141549, 14141628, 14141732, + 14141733, 14141780, 14141786, 14141800, 14142398, 14142742, 14142749, 14143111, 14143196, 14143745, 14143763, 14143828, 14143864, + 14144282, 14144473, 14145076, 14145285, 14145784, 14145908, 14145935, 14145988, 14146061, 14146091, 14146109, 14146166, 14146173, + 14146182, 14146184, 14146190, 14146207, 14146234, 14146754, 14146771, 14146832, 14147019, 14147204, 14147423, 14147483, 14147519, + 14147526, 14147554, 14147587, 14147607, 14147732, 14148521, 14148714, 14149592, 14149619, 14149789, 14149804, 14149812, 14149940, + 14149961, 14149966, 14149992, 14151350, 14151353, 14153570, 14154639, 14154760, 14154939, 14155463, 14155476, 14155742, 14155762, + 14155771, 14155906, 14155935, 14156644, 14156695, 14156824, 14157718, 14158023, 14158178, 14158179, 14158192, 14158225, 14158234, + 14160434, 14160448, 14160484, 14160591, 14160631, 14160678, 14161007, 14161029, 14161053, 14161067, 14161227, 14161241, 14161396, + 14161541, 14161546, 14161548, 14161549, 14161604, 14161618, 14161833, 14161976, 14161996, 14162133, 14162387, 14162615, 14162897, + 14163117, 14163286, 14163301, 14163309, 14163900, 14163967, 14164571, 14165063, 14165098, 14165182, 14165193, 14165728, 14165832, + 14166064, 14166499, 14166555, 14166559, 14166586, 14167320, 14167457, 14167507, 14167584, 14167707, 14167751, 14167792, 14167806, + 14167809, 14167830, 14167859, 14167868, 14167877, 14167979, 14167980, 14171368, 14171777, 14171890, 14171953, 14172042, 14172047, + 14172089, 14172170, 14172332, 14172456, 14172572, 14172639, 14173001, 14174547, 14174910, 14175087, 14175109, 14175111, 14175869, + 14175907, 14176246, 14176253, 14176343, 14176607, 14177124, 14177447, 14177503, 14177734, 14178614, 14178630, 14178820, 14178821, + 14178839, 14179074, 14179192, 14179237, 14179326, 14180592, 14180796, 14180851, 14181128, 14181137, 14181693, 14181698, 14181762, + 14181792, 14182209, 14182468, 14182581, 14183420, 14183543, 14183809, 14183872, 14184752, 14184842, 14185023, 14185412, 14185453, + 14185501, 14185653, 14185710, 14185798, 14186682, 14186733, 14187745, 14187752, 14187757, 14187821, 14188264, 14188460, 14188465, + 14188729, 14188778, 14189095, 14189171, 14191103, 14191217, 14191927, 14192000, 14192052, 14192242, 14192398, 14192827, 14192854, + 14193065, 14193073, 14193103, 14193143, 14193158, 14193482, 14193580, 14194305, 14194319, 14194412, 14194419, 14194484, 14194546, + 14194595, 14199795, 14199935, 14199983, 14199986, 14200044, 14200084, 14200111, 14200139, 14200182, 14200190, 14204347, 14204418, + 14204510, 14204511, 14204779, 14204797, 14204839, 14205356, 14205469, 14205477, 14205495, 14206818, 14206853, 14207065, 14207638, + 14207651, 14207666, 14207674, 14207769, 14208925, 14208929, 14208933, 14209218, 14209304, 14209336, 14209575, 14209637, 14209654, + 14209658, 14209756, 14209776, 14209798, 14209927, 14210583, 14210845, 14211495, 14211541, 14211907, 14211929, 14212341, 14212472, + 14212477, 14212690, 14213033, 14213418, 14213497, 14213514, 14213530, 14213652, 14213946, 14213953, 14213972, 14214116, 14214142, + 14214143, 14214366, 14214977, 14214987, 14215167, 14215207, 14215399, 14215416, 14215450, 14215516, 14217199, 14217219, 14217260, + 14217509, 14218325, 14218896, 14218935, 14219106, 14219113, 14219114, 14219119, 14219130, 14219957, 14219958, 14220038, 14220087, + 14220173, 14220219, 14220804, 14221341, 14222488, 14222500, 14222878, 14222894, 14222935, 14223004, 14223669, 14223764, 14227432, + 14227444, 14227445, 14227450, 14227692, 14227697, 14228042, 14228163, 14228181, 14228408, 14228421, 14228485, 14228486, 14228491, + 14228508, 14228587, 14228717, 14228762, 14228769, 14228773, 14228791, 14228792, 14228804, 14228903, 14229010, 14229018, 14229159, + 14231125, 14231300, 14231443, 14231448, 14232109, 14232208, 14232209, 14232381, 14232406, 14232802, 14232810, 14232864, 14232909, + 14233312, 14233318, 14233470, 14233715, 14233727, 14233759, 14235991, 14236061, 14236156, 14236267, 14236301, 14236377, 14236429, + 14236512, 14236650, 14236713, 14236756, 14236769, 14236824, 14236825, 14237021, 14237138, 14237249, 14237357, 14237367, 14237368, + 14237405, 14237422, 14237465, 14237979, 14238006, 14238047, 14238053, 14238054, 14238064, 14238210, 14241229, 14242371, 14242374, + 14242376, 14242495, 14242761, 14242796, 14242807, 14242848, 14242857, 14242860, 14242895, 14242902, 14242903, 14243742, 14243745, + 14243747, 14243828, 14243830, 14243898, 14243995, 14244554, 14244572, 14244661, 14244663, 14245554, 14245560, 14245614, 14245629, + 14245794, 14246045, 14246318, 14246687, 14246846, 14247108, 14247338, 14247826, 14247928, 14247954, 14247963, 14247985, 14248202, + 14248403, 14248732, 14249055, 14249278, 14249875, 14250216, 14250927, 14250928, 14251116, 14251143, 14251320, 14251343, 14251406, + 14251457, 14251569, 14251635, 14251874, 14251884, 14251898, 14252039, 14252092, 14252144, 14252246, 14252318, 14252972, 14253022, + 14255299, 14255310, 14255475, 14255516, 14255543, 14255556, 14255822, 14255995, 14256057, 14256504, 14256561, 14256571, 14256620, + 14258923, 14258985, 14259150, 14259607, 14259661, 14260250, 14260264, 14261054, 14261145, 14261150, 14261244, 14261398, 14261838, + 14261932, 14261969, 14262054, 14262427, 14262460, 14262621, 14263627, 14263682, 14267276, 14267288, 14267519, 14267528, 14267529, + 14267548, 14267622, 14267663, 14268607, 14268629, 14268630, 14268672, 14268685, 14268744, 14268750, 14268751, 14268755, 14269086, + 14269140, 14269168, 14269178, 14269347, 14269356, 14269543, 14269547, 14269776, 14269820, 14270276, 14270280, 14270283, 14270286, + 14270294, 14270310, 14270354, 14270419, 14270466, 14270486, 14270530, 14270550, 14270654, 14270738, 14270744, 14270751, 14270757, + 14270778, 14270784, 14270811, 14270841, 14270889, 14270897, 14270940, 14270943, 14270967, 14270972, 14271360, 14271401, 14271992, + 14271999, 14272079, 14272130, 14272289, 14272325, 14272717, 14272750, 14274773, 14274777, 14274997, 14275001, 14275127, 14275130, + 14275146, 14275323, 14275353, 14275424, 14275668, 14276086, 14276123, 14276168, 14276309, 14276370, 14276458, 14276520, 14277427, + 14277434, 14277438, 14277439, 14277514, 14277581, 14277637, 14278054, 14278075, 14278093, 14278096, 14278100, 14278142, 14278209, + 14278267, 14278302, 14278331, 14278429, 14278440, 14278687, 14278756, 14278811, 14279537, 14279693, 14279798, 14280053, 14280185, + 14280204, 14280267, 14280452, 14280583, 14280616, 14280703, 14281278, 14281362, 14281532, 14281603, 14281860, 14281911, 14282559, + 14283530, 14283550, 14283560, 14283564, 14283579, 14283595, 14283598, 14283613, 14283697, 14283746, 14284070, 14284218, 14284578, + 14284847, 14286487, 14286490, 14286613, 14286765, 14287334, 14287353, 14287608, 14287664, 14287752, 14287787, 14287796, 14287799, + 14287800, 14287802, 14287945, 14288161, 14288307, 14288451, 14288502, 14288846, 14288983, 14289001, 14289005, 14289016, 14289060, + 14289723, 14290173, 14290424, 14290457, 14290459, 14290506, 14290571, 14290766, 14290801, 14290962, 14291669, 14291708, 14291718, + 14291815, 14292939, 14292956, 14293247, 14293268, 14293297, 14293393, 14293441, 14293602, 14293740, 14293803, 14294518, 14294563, + 14294601, 14294625, 14295118, 14295131, 14295183, 14295205, 14295233, 14295243, 14295256, 14295279, 14295325, 14295328, 14295332, + 14295394, 14295420, 14295683, 14295688, 14295809, 14296174, 14296471, 14296495, 14296520, 14296596, 14296598, 14296727, 14296803, + 14296887, 14296913, 14296925, 14297069, 14297070, 14297260, 14297371, 14297452, 14297529, 14297538, 14297676, 14297759, 14297807, + 14297822, 14298409, 14298639, 14298896, 14298903, 14298932, 14299363, 14299554, 14300286, 14300298, 14300301, 14300495, 14300640, + 14300659, 14301074, 14301263, 14301438, 14301472, 14301639, 14301663, 14301665, 14301705, 14301827, 14302166, 14302216, 14302438, + 14302631, 14302782, 14302982, 14303337, 14303485, 14303928, 14304191, 14304195, 14304374, 14304577, 14304591, 14304640, 14305416, + 14305568, 14305668, 14305702, 14305917, 14305920, 14306074, 14306134, 14306454, 14307152, 14307386, 14307402, 14307413, 14307462, + 14307466, 14307547, 14307632, 14307804, 14307929, 14308045, 14308232, 14308345, 14308437, 14308448, 14309558, 14309627, 14309634, + 14309679, 14309714, 14309805, 14309832, 14309939, 14310154, 14310541, 14310658, 14310887, 14310987, 14311341, 14312039, 14312218, + 14312227, 14312251, 14312317, 14312327, 14312447, 14312532, 14313179, 14313565, 14313860, 14313880, 14313896, 14313985, 14314069, + 14314262, 14314503, 14314504, 14315064, 14315149, 14315158, 14315195, 14315406, 14315429, 14315534, 14315796, 14316030, 14316190, + 14316259, 14316600, 14316647, 14316861, 14317147, 14317635, 14317647, 14317657, 14317734, 14317812, 14317833, 14317844, 14317921, + 14317930, 14317937, 14317942, 14317945, 14317982, 14317988, 14318921, 14318922, 14319270, 14319315, 14319942, 14320162, 14320227, + 14320284, 14320753, 14320763, 14322722, 14322745, 14322786, 14322880, 14322990, 14323725, 14323744, 14324520, 14324584, 14324706, + 14324707, 14328007, 14328024, 14331549, 14331550, 14331679, 14332651, 14332653, 14332760, 14332764, 14332800, 14332809, 14333294, + 14333328, 14333336, 14333346, 14333551, 14333562, 14334351, 14334509, 14334540, 14334564, 14337693, 14340622, 14342084, 14342092, + 14342313, 14342321, 14342457, 14342462, 14343083, 14343087, 14343141, 14343154, 14343161, 14343551, 14343566, 14343577, 14343609, + 14343647, 14343803, 14343938, 14343962, 14344087, 14344928, 14344933, 14345088, 14345153, 14345161, 14345601, 14345744, 14345777, + 14346561, 14346614, 14346765, 14346782, 14346783, 14347126, 14347150, 14347420, 14347452, 14347570, 14347598, 14347626, 14347635, + 14347637, 14347725, 14347781, 14348725, 14348905, 14349352, 14349447, 14351917, 14352564, 14352616, 14352773, 14352923, 14353039, + 14354130, 14354236, 14354276, 14354277, 14354290, 14354327, 14354329, 14354337, 14354362, 14354420, 14354429, 14354456, 14354679, + 14354688, 14354691, 14354801, 14354829, 14354874, 14354902, 14354918, 14355487, 14355501, 14355611, 14355907, 14356212, 14356334, + 14356358, 14356391, 14356876, 14357035, 14357313, 14357658, 14357681, 14357718, 14357730, 14357799, 14357850, 14357987, 14358091, + 14358190, 14358267, 14358722, 14359057, 14359213, 14359358, 14359371, 14359465, 14359589, 14359597, 14359648, 14359654, 14360676, + 14360709, 14360796, 14361052, 14361484, 14361538, 14361631, 14361731, 14362244, 14362395, 14362428, 14362460, 14362496, 14362567, + 14362798, 14362805, 14362808, 14363004, 14363041, 14363050, 14363058, 14363068, 14363172, 14363510, 14363570, 14363734, 14364469, + 14364510, 14364518, 14365738, 14365742, 14365752, 14365867, 14365890, 14366055, 14366116, 14366211, 14366224, 14366233, 14366246, + 14366288, 14366309, 14366329, 14366429, 14366430, 14366443, 14366448, 14366472, 14366539, 14366589, 14366750, 14366765, 14366794, + 14366934, 14367112, 14367251, 14367272, 14367282, 14367466, 14367467, 14367468, 14367469, 14367477, 14367496, 14367530, 14367687, + 14367800, 14367833, 14367960, 14368004, 14368015, 14368024, 14368061, 14368069, 14368160, 14368167, 14368170, 14368194, 14368302, + 14368786, 14368797, 14368798, 14368810, 14368823, 14370205, 14370209, 14370844, 14370852, 14371635, 14371854, 14372502, 14372811, + 14375059, 14375196, 14375337, 14375353, 14376850, 14377162, 14377188, 14378134, 14378139, 14378142, 14378262, 14378276, 14378281, + 14378284, 14378300, 14378310, 14378366, 14378380, 14378433, 14380203, 14380358, 14380376, 14380432, 14380454, 14380479, 14380500, + 14380502, 14380511, 14380523, 14380526, 14380576, 14381101, 14381108, 14381116, 14381149, 14381187, 14381336, 14381643, 14381650, + 14384971, 14385017, 14385299, 14385327, 14385345, 14385346, 14385398, 14385409, 14386643, 14386717, 14387783, 14387792, 14387814, + 14387938, 14388060, 14388082, 14388164, 14388173, 14388184, 14388185, 14388190, 14388205, 14388211, 14388234, 14388244, 14388337, + 14388466, 14389756, 14389760, 14391505, 14391529, 14392389, 14392425, 14392444, 14392452, 14392466, 14392654, 14393420, 14393502, + 14393594, 14393595, 14393599, 14393671, 14394385, 14395110, 14395112, 14395122, 14395139, 14395232, 14395237, 14395341, 14395364, + 14395414, 14395416, 14397686, 14397758, 14397792, 14397865, 14398937, 14398955, 14398982, 14399110, 14399114, 14399131, 14399141, + 14399198, 14399200, 14399218, 14399248, 14399251, 14399276, 14399914, 14399919, 14399960, 14399989, 14399992, 14400040, 14400043, + 14400048, 14400097, 14400128, 14400131, 14402470, 14402526, 14402741, 14402794, 14402800, 14402805, 14402891, 14402926, 14404738, + 14404762, 14404988, 14405199, 14405204, 14405237, 14405348, 14406107, 14406164, 14406177, 14406665, 14406666, 14406887, 14406900, + 14406901, 14406982, 14406984, 14407108, 14407204, 14407309, 14407326, 14408372, 14408387, 14408522, 14408523, 14408534, 14408798, + 14408824, 14408858, 14410649, 14410860, 14410915, 14410986, 14411113, 14411190, 14411745, 14411764, 14412210, 14412275, 14412297, + 14412428, 14412434, 14412741, 14412857, 14412866, 14412869, 14413198, 14413199, 14413906, 14413934, 14414045, 14414168, 14414430, + 14414443, 14414710, 14415221, 14415252, 14415388, 14415429, 14415469, 14415513, 14415554, 14415608, 14415656, 14415660, 14415666, + 14415927, 14415975, 14416165, 14417518, 14418203, 14418277, 14418301, 14418317, 14418392, 14418533, 14418543, 14418546, 14419038, + 14419373, 14419466, 14419469, 14419481, 14419488, 14419499, 14419512, 14419521, 14419616, 14419697, 14419698, 14419805, 14419900, + 14419928, 14419929, 14419941, 14419942, 14419962, 14420023, 14420069, 14420082, 14420084, 14420086, 14420091, 14420094, 14420112, + 14420116, 14420129, 14420131, 14420180, 14420183, 14420193, 14420247, 14420253, 14420256, 14420275, 14420293, 14420303, 14420341, + 14420348, 14420480, 14420699, 14420814, 14420849, 14420851, 14420971, 14421014, 14421036, 14421045, 14421046, 14421169, 14421176, + 14421440, 14421858, 14421886, 14421920, 14422148, 14422321, 14422453, 14422593, 14422767, 14422856, 14423018, 14423133, 14423196, + 14423206, 14423268, 14423271, 14423515, 14423532, 14423583, 14423860, 14423881, 14423932, 14424014, 14424043, 14424067, 14424296, + 14424429, 14424452, 14424558, 14424562, 14424571, 14424585, 14424586, 14424589, 14424636, 14424685, 14424736, 14424750, 14424769, + 14425463, 14425546, 14425574, 14425575, 14425633, 14425767, 14425781, 14425849, 14425993, 14426028, 14426072, 14426221, 14426583, + 14427051, 14427197, 14427202, 14427208, 14427399, 14427441, 14427452, 14427473, 14427870, 14428817, 14428898, 14428920, 14429168, + 14429174, 14429180, 14429324, 14430071, 14430108, 14430138, 14430143, 14430231, 14430255, 14430816, 14430855, 14430886, 14430899, + 14430901, 14430902, 14430905, 14430924, 14430965, 14431006, 14431063, 14431282, 14431502, 14431545, 14431559, 14431720, 14431721, + 14432038, 14432172, 14432192, 14432201, 14432626, 14432636, 14432638, 14433023, 14433345, 14433362, 14433891, 14433944, 14434390, + 14434409, 14434414, 14434471, 14434649, 14436439, 14436511, 14436521, 14436616, 14436975, 14437026, 14437134, 14437167, 14437191, + 14437201, 14437204, 14437205, 14437268, 14437527, 14437534, 14437547, 14437565, 14437613, 14437807, 14437820, 14438118, 14438156, + 14438160, 14438162, 14438168, 14438215, 14438333, 14438365, 14438531, 14438538, 14438956, 14439014, 14439085, 14439105, 14439107, + 14439173, 14439501, 14439515, 14439776, 14439868, 14440295, 14440312, 14440363, 14440392, 14440418, 14440420, 14440431, 14440986, + 14440993, 14441010, 14441090, 14441114, 14441175, 14441182, 14441421, 14441424, 14441436, 14441455, 14442331, 14442410, 14442412, + 14442499, 14442590, 14443032, 14443124, 14443702, 14443783, 14443785, 14443880, 14443986, 14443987, 14443996, 14444016, 14444291, + 14444335, 14444348, 14444958, 14445106, 14445730, 14445744, 14445796, 14445857, 14445956, 14445960, 14449012, 14449107, 14449279, + 14449287, 14450086, 14450107, 14450169, 14450196, 14451369, 14451491, 14451664, 14451679, 14452080, 14452088, 14452158, 14452281, + 14452377, 14452464, 14454060, 14454100, 14454259, 14454284, 14455932, 14455937, 14456161, 14456169, 14456173, 14456215, 14456220, + 14456251, 14456262, 14456272, 14456374, 14456386, 14456389, 14456408, 14456422, 14456596, 14456654, 14456697, 14456714, 14457226, + 14457236, 14457251, 14457272, 14457294, 14457295, 14457323, 14457332, 14457341, 14457872, 14457925, 14458268, 14458361, 14462180, + 14462204, 14462241, 14462308, 14464172, 14464255, 14466306, 14466331, 14466411, 14466425, 14466470, 14466488, 14466497, 14466523, + 14466972, 14466984, 14467004, 14467023, 14468341, 14468496, 14469581, 14469604, 14469619, 14469675, 14470339, 14470341, 14470456, + 14470514, 14470520, 14470622, 14470887, 14470888, 14471412, 14471417, 14471591, 14471594, 14473086, 14473092, 14473096, 14473097, + 14473637, 14473642, 14475479, 14475496, 14475695, 14475733, 14476630, 14476676, 14476712, 14476812, 14477122, 14477145, 14477588, + 14477589, 14477594, 14477605, 14477607, 14477633, 14477742, 14477772, 14477777, 14478030, 14478043, 14478624, 14478666, 14479141, + 14479784, 14479865, 14479943, 14479950, 14479961, 14481636, 14481637, 14481722, 14481726, 14481758, 14481986, 14481997, 14482096, + 14482102, 14482118, 14482138, 14482420, 14482427, 14482457, 14482487, 14482508, 14482687, 14482693, 14482834, 14482845, 14483435, + 14483438, 14483442, 14483453, 14483471, 14483605, 14483834, 14483839, 14484322, 14484339, 14484341, 14484392, 14484412, 14484498, + 14484698, 14484752, 14484755, 14488867, 14488878, 14488894, 14488896, 14489287, 14489291, 14489510, 14489549, 14490029, 14490073, + 14490084, 14490085, 14490086, 14490088, 14490123, 14490128, 14490190, 14490213, 14490644, 14490652, 14490708, 14490728, 14490903, + 14490908, 14491415, 14491754, 14491757, 14491758, 14491805, 14492838, 14493628, 14494367, 14494372, 14494373, 14494376, 14494379, + 14494381, 14494646, 14494656, 14494661, 14494752, 14494868, 14494907, 14494921, 14494941, 14494953, 14494954, 14495034, 14495065, + 14495075, 14495076, 14495135, 14495154, 14495165, 14495173, 14495188, 14495192, 14495488, 14495493, 14495495, 14495501, 14495644, + 14495687, 14495688, 14495840, 14495967, 14495968, 14496394, 14496406, 14496408, 14496432, 14496500, 14496551, 14496604, 14496966, + 14497034, 14497038, 14497550, 14497568, 14497570, 14497668, 14497702, 14497706, 14497708, 14497820, 14497848, 14497895, 14497913, + 14497935, 14497937, 14498323, 14498354, 14498355, 14501002, 14501005, 14501526, 14502186, 14502208, 14502215, 14502229, 14502284, + 14502295, 14502315, 14502353, 14502605, 14502627, 14502635, 14502663, 14502758, 14502769, 14503020, 14503058, 14503061, 14503068, + 14503086, 14503134, 14503288, 14503395, 14503429, 14503435, 14503522, 14503525, 14504153, 14504162, 14504169, 14504173, 14504371, + 14504422, 14504432, 14504442, 14507145, 14507147, 14507476, 14507486, 14507489, 14507515, 14507520, 14507570, 14507702, 14507732, + 14508208, 14508212, 14509089, 14509103, 14509612, 14509623, 14511370, 14511373, 14511378, 14511379, 14511768, 14511773, 14512246, + 14512248, 14514087, 14514094, 14514100, 14514117, 14514130, 14514133, 14514156, 14514162, 14514508, 14514588, 14514908, 14514918, + 14514964, 14514971, 14514989, 14515007, 14515063, 14515165, 14515419, 14515421, 14515591, 14515593, 14515714, 14515716, 14515719, + 14515720, 14515748, 14515749, 14515854, 14515860, 14515903, 14515904, 14515951, 14515955, 14515993, 14515997, 14516253, 14516270, + 14516372, 14516412, 14516497, 14516503, 14517397, 14517439, 14519618, 14519619, 14519694, 14519701, 14519702, 14519714, 14519776, + 14519782, 14519803, 14519804, 14519955, 14519996, 14520020, 14520024, 14520043, 14520060, 14520061, 14520062, 14520115, 14520126, + 14520159, 14520172, 14520186, 14520190, 14520198, 14520212, 14520222, 14520227, 14520235, 14520497, 14520498, 14520746, 14520774, + 14520977, 14520982, 14520986, 14521011, 14521066, 14521069, 14522110, 14522112, 14522118, 14522165, 14522218, 14522219, 14522733, + 14522797, 14523118, 14523126, 14523830, 14523835, 14524242, 14524243, 14524259, 14524266, 14526070, 14526077, 14526083, 14526086, + 14526087, 14526099, 14526120, 14526126, 14526141, 14526211, 14526215, 14526221, 14526244, 14526255, 14526300, 14526321, 14526332, + 14526340, 14526344, 14526346, 14526356, 14526363, 14526380, 14526442, 14526463, 14527065, 14527080, 14527084, 14527176, 14527178, + 14527369, 14527370, 14527424, 14527431, 14527447, 14527451, 14527599, 14527626, 14527627, 14527633, 14527696, 14527715, 14527723, + 14527735, 14527839, 14528084, 14528085, 14528093, 14528124, 14528171, 14528614, 14528712, 14528723, 14528757, 14528758, 14528864, + 14528925, 14528961, 14528969, 14528986, 14528993, 14528997, 14529009, 14529012, 14529017, 14529021, 14529024, 14529026, 14529029, + 14529033, 14529037, 14529046, 14529100, 14529124, 14529557, 14530096, 14530149, 14531104, 14531141, 14531213, 14531235, 14531744, + 14531775, 14531956, 14531968, 14531999, 14532026, 14532066, 14532097, 14532696, 14532706, 14532729, 14532730, 14532739, 14532749, + 14532758, 14532838, 14532843, 14533032, 14533035, 14533049, 14533066, 14533070, 14533079, 14533136, 14533141, 14533267, 14533299, + 14533319, 14533321, 14533346, 14533372, 14533410, 14533430, 14533442, 14533526, 14533548, 14533722, 14533805, 14533836, 14533847, + 14533860, 14533861, 14533873, 14533878, 14533920, 14534184, 14534185, 14534191, 14534193, 14534233, 14534256, 14534343, 14534366, + 14534397, 14534426, 14535016, 14535017, 14535020, 14535028, 14535045, 14535083, 14535119, 14535180, 14535199, 14535394, 14535426, + 14535428, 14535456, 14535475, 14535634, 14535662, 14535688, 14535691, 14535692, 14535702, 14536479, 14536480, 14536489, 14536490, + 14536492, 14536493, 14538931, 14538950, 14539037, 14539038, 14539216, 14539309, 14539334, 14539344, 14539390, 14539420, 14539473, + 14539534, 14539537, 14539564, 14540149, 14540166, 14540656, 14540667, 14540769, 14540796, 14541039, 14541063, 14541069, 14541071, + 14541159, 14541165, 14541181, 14541201, 14541315, 14541323, 14541325, 14541328, 14541535, 14542840, 14542888, 14542906, 14542907, + 14543190, 14543248, 14543853, 14543908, 14544590, 14544596, 14544603, 14544616, 14544670, 14544671, 14544700, 14544710, 14544746, + 14544754, 14544827, 14544828, 14544837, 14544856, 14544877, 14544962, 14545025, 14545172, 14545204, 14545224, 14545226, 14545234, + 14545464, 14545483, 14545723, 14545743, 14545958, 14545994, 14546116, 14546131, 14546151, 14546163, 14546371, 14546380, 14546408, + 14546419, 14546448, 14546450, 14546509, 14546553, 14546560, 14546608, 14546630, 14546636, 14546678, 14546684, 14546867, 14546869, + 14547247, 14547249, 14547565, 14547577, 14547724, 14547850, 14547854, 14547861, 14547962, 14548000, 14550132, 14550221, 14552498, + 14552506, 14552667, 14552671, 14552813, 14552828, 14553470, 14553472, 14553476, 14554183, 14554188, 14554192, 14554225, 14554740, + 14554785, 14555988, 14556013, 14556021, 14556022, 14556083, 14556084, 14556089, 14556092, 14556100, 14556103, 14556108, 14556140, + 14556651, 14558534, 14559061, 14559072, 14559085, 14559733, 14559791, 14560016, 14560026, 14560028, 14560038, 14560040, 14560076, + 14560273, 14560275, 14560303, 14560306, 14560310, 14560322, 14560576, 14560577, 14560582, 14560595, 14560608, 14560622, 14560728, + 14560734, 14561795, 14561825, 14561840, 14562587, 14562623, 14562630, 14562645, 14563527, 14563541, 14563542, 14563549, 14563729, + 14563739, 14563740, 14563748, 14563749, 14563755, 14563766, 14563768, 14563774, 14563775, 14563894, 14563959, 14563963, 14563967, + 14564050, 14564054, 14564058, 14564075, 14564164, 14564730, 14564733, 14565457, 14565462, 14565943, 14566817, 14566822, 14588081, + 15278993, 15298860, 15299275, 15299420, 15299520, 15299715, 15299731, 15299757, 15301708, 15301850, 15301875, 15302455, 15302967, + 15304019, 15305121, 15305561, 15307407, 15307490, 15307868, 15308032, 15311107, 15311210, 15311599, 15316343, 15316528, 15316535, + 15317411, 15318069, 15318235, 15318288, 15318437, 15318758, 15319019, 15319366, 15319403, 15320313, 15321005, 15321511, 15321634, + 15321707, 15321890, 15322055, 15322136, 15323088, 15323182, 15323543, 15324636, 15327600, 15328789, 15328903, 15328961, 15329151, + 15330358, 15330441, 15330468, 15331215, 15331280, 15333764, 15333830, 15335397, 15336059, 15337247, 15337395, 15337630, 15339099, + 15340038, 15340971, 15341319, 15341479, 15341544, 15342783, 15343155, 15343302, 15343551, 15343809, 15344150, 15344169, 15344370, + 15344584, 15346218, 15346421, 15346604, 15346684, 15346714, 15346716, 15350123, 15350143, 15350966, 15351041, 15351346, 15351348, + 15352316, 15352341, 15353576, 15353802, 15354436, 15354503, 15354708, 15354744, 15355751, 15355938, 15356263, 15356464, 15357773, + 15357806, 15357836, 15357870, 15359242, 15359261, 15359409, 15359557, 15359701, 15359731, 15359846, 15359932, 15360348, 15360351, + 15360966, 15360968, 15360998, 15361018, 15363267, 15363312, 15363413, 15363420, 15363920, 15364070, 15364136, 15364150, 15364663, + 15364715, 15367310, 15367326, 15368095, 15368104, 15368537, 15368541, 15368874, 15368881, 15369797, 15369898, 15370883, 15370885, + 15371463, 15371516, 15372941, 15373029, 15373035, 15373039, 15373489, 15373548, 15374297, 15374326, 15374448, 15374596, 15375231, + 15375318, 15375776, 15375803, 15376049, 15376057, 15377278, 15377371, 15378036, 15378043, 15378052, 15378059, 15378164, 15378166, + 15379378, 15379430, 15379848, 15379863, 15379880, 15379890, 15381333, 15381472, 15381587, 15381594, 15382319, 15382335, 15382622, + 15382689, 15384884, 15384889, 15386453, 15386482, 15386506, 15386762, 15386943, 15387036, 15387461, 15387465, 15387752, 15387804, + 15388394, 15388486, 15388606, 15388617, 15389904, 15390109, 15390434, 15390437, 15390816, 15390866, 15393023, 15393050, 15393079, + 15393299, 15393785, 15393789, 15394171, 15394184, 15394223, 15394363, 15397304, 15397311, 15397367, 15397572, 15398540, 15398542, + 15398966, 15398984, 15400273, 15400276, 15400610, 15400638, 15401565, 15401650, 15404521, 15404620, 15406007, 15406017, 15406624, + 15406687, 15407958, 15407964, 15408278, 15408287, 15410615, 15410769, 15411104, 15411119, 15411326, 15411591, 15411833, 15411836, + 15413038, 15413046, 15413111, 15413148, 15413371, 15413374, 15413483, 15413499, 15415282, 15415416, 15417725, 15417802, 15417896, + 15417906, 15419558, 15419604, 15419797, 15419800, 15419980, 15420000, 15420016, 15420019, 15421514, 15421544, 15423424, 15423558, + 15423661, 15423673, 15424869, 15424873, 15425240, 15425382, 15425895, 15425897, 15426289, 15426372, 15427195, 15427225, 15427230, + 15427233, 15427289, 15427298, 15427993, 15427999, 15428176, 15428217, 15428227, 15428516, 15428529, 15428567, 15428784, 15429008, + 15429020, 15429026, 15429032, 15429281, 15430344, 15430346, 15430706, 15430735, 15430879, 15430885, 15431260, 15431365, 15432397, + 15432422, 15432649, 15432654, 15432804, 15432819, 15433923, 15433932, 15435272, 15435298, 15437041, 15437050, 15438105, 15438114, + 15440121, 15440253, 15441104, 15441282, 15442199, 15442584, 15443871, 15444142, 15444188, 15444408, 15444685, 15444690, 15445733, + 15445736, 15445863, 15445878, 15447031, 15447065, 15448796, 15448816, 15449403, 15449413, 15449587, 15449609, 15449711, 15449878, + 15449962, 15449964, 15450263, 15450405, 15450446, 15450450, 15451400, 15451408, 15451819, 15451857, 15452179, 15452192, 15452979, + 15453020, 15453357, 15453514, 15455431, 15455434, 15455761, 15455880, 15456762, 15456784, 15457983, 15459043, 15459439, 15459567, + 15459814, 15459822, 15460508, 15460591, 15461069, 15461082, 15462424, 15462426, 15462594, 15462656, 15462690, 15462696, 15463436, + 15463936, 15464266, 15465784, 15465839, 15465937, 15466610, 15466631, 15467021, 15467085, 15467103, 15467109, 15467756, 15467851, + 15468430, 15468503, 15468511, 15468652, 15469184, 15469200, 15469285, 15469458, 15469754, 15469759, 15470276, 15470283, 15470370, + 15470392, 15471545, 15471785, 15473261, 15473269, 15473454, 15473460, 15474422, 15474425, 15474922, 15475151, 15475640, 15475643, + 15476163, 15476405, 15476427, 15476439, 15477009, 15477179, 15477640, 15477649, 15479093, 15479107, 15480142, 15480151, 15480580, + 15480814, 15481022, 15481026, 15481035, 15481037, 15481562, 15481565, 15481590, 15481591, 15481741, 15481744, 15482067, 15482078, + 15482616, 15482683, 15486561, 15486564, 15486616, 15486617, 15486666, 15486668, 15486678, 15486680, 15487459, 15487500, 15488119, + 15488127, 15488401, 15488409, 15488440, 15488442, 15488965, 15488970, 15489694, 15489700, 15490595, 15490615, 15491720, 15491760, + 15492016, 15492020, 15492072, 15492087, 15492855, 15492857, 15493002, 15493004, 15493071, 15493074, 15493106, 15493108, 15493360, + 15493365, 15494319, 15494332, 15496258, 15496263, 15497235, 15497254, 15497321, 15497338, 15498352, 15498354, 15499365, 15499369, + 15501348, 15501354, 15502470, 15502478, 15503665, 15503673, 15504523, 15504537, 15504621, 15504628, 15504938, 15505080, 15506069, + 15506072, 15506112, 15506113, 15506426, 15506436, 15507433, 15507435, 15508130, 15508192, 15508250, 15508358, 15510418, 15510430, + 15510706, 15510712, 15511523, 15511526, 15511628, 15511629, 15512065, 15512071, 15512120, 15512121, 15513126, 15513199, 15513214, + 15513441, 15514260, 15514460, 15515518, 15515520, 15515699, 15515701, 15516480, 15516482, 15517627, 15517654, 15518075, 15518102, + 15519576, 15519578, 15520859, 15520864, 15521342, 15521351, 15521537, 15521553, 15521701, 15521707, 15522808, 15523015, 15523483, + 15523488, 15524388, 15524397, 15524703, 15524713, 15525341, 15525343, 15525349, 15525353, 15526412, 15526559, 15527127, 15527133, + 15527672, 15527675, 15528231, 15528248, 15528274, 15528307, 15529512, 15529522, 15529961, 15530071, 15530915, 15530926, 15531367, + 15531370, 15533472, 15533487, 15534560, 15534786, 15535306, 15535318, 15535392, 15535522, 15538116, 15539371, 15540337, 15540602, + 15541064, 15541071, 15541659, 15541666, 15541681, 15541719, 15541771, 15541777, 15542276, 15542282, 15542576, 15542585, 15542589, + 15542594, 15542886, 15542896, 15543880, 15543976, 15544196, 15546926, 15547006, 15547018, 15547117, 15547119, 15547436, 15547520, + 15547554, 15547587, 15547642, 15547644, 15549036, 15549039, 15549429, 15549448, 15550823, 15550828, 15551147, 15551381, 15551716, + 15551720, 15552150, 15552267, 15554087, 15554090, 15554449, 15554456, 15555207, 15555210, 15556032, 15556037, 15556177, 15556184, + 15557755, 15557761, 15558433, 15558443, 15559082, 15559107, 15560806, 15560890, 15561941, 15562075, 15562258, 15562260, 15563500, + 15563507, 15563620, 15563624, 15565974, 15565985, 15566159, 15566161, 15566675, 15567720, 15567772, 15697646, 15698252, 15699048, + 15699049, 15699308, 15699355, 15701033, 15701037, 15701139, 15701868, 15722361, 15723839, 15725644, 15726602, 15726621, 15726727, + 15726730, 15728420, 15728425, 15729973, 15729986, 15731110, 15731125, 15732349, 15732819, 15733345, 15733382, 15736966, 15741478, + 15742747, 15743712, 15744541, 15746902, 15748357, 15751438, 15751801, 15754322, 15755697, 15768595, 15768635, 15768636, 15771170, + 15771235, 15771418, 15771566, 15772511, 15772514, 15773217, 15773287, 15773693, 15775062, 15775162, 15775170, 15775628, 15775748, + 15777966, 15778518, 15780571, 15780590, 15781334, 15781414, 15783805, 15784103, 15784218, 15784222, 15784336, 15786288, 15786350, + 15786412, 15786880, 15787424, 15791418, 15791577, 15791945, 15792759, 15792904, 15792905, 15793375, 15799982, 15800147, 15800148, + 15800738, 15800739, 15801497, 15801498, 15803568, 15803571, 15805641, 15808771, 15809000, 15815539, 15815540, 15815571, 15816365, + 15816366, 15820482, 15820483, 15820930, 15820933, 15822783, 15822784, 15823306, 15823308, 15823485, 15823486, 15827101, 15827102, + 15830019, 15830020, 15830105, 15830106, 15835137, 15835138, 15838243, 15839723, 15840576, 15841503, 15841688, 15841690, 15847048, + 15847050, 15847745, 15848829, 15850375, 15855827, 15859288, 15859289, 15860023, 15860373, 15860606, 15860607, 15860828, 15860829, + 15861647, 15861648, 15861982, 15861983, 15863539, 15865475, 15865811, 15865812, 15865814, 15865819, 15865939, 15865940, 15866722, + 15866723, 15867794, 15869548, 15870297, 15870823, 15870956, 15870957, 15871190, 15871197, 15871254, 15871766, 15872132, 15873270, + 15875334, 15875634, 15875797, 15876025, 15876802, 15876803, 15876808, 15876810, 15876831, 15876833, 15876844, 15876845, 15876858, + 15876859, 15876865, 15876866, 15876996, 15877054, 15877147, 15878253, 15878396, 15878397, 15878409, 15878410, 15880251, 15880252, + 15880976, 15883223, 15883257, 15883258, 15883267, 15883268, 15883338, 15883366, 15883572, 15883573, 15883704, 15883705, 15883815, + 15883866, 15884708, 15885134, 15886585, 15886948, 15889015, 15889135, 15889263, 15889264, 15889297, 15890107, 15890836, 15890856, + 15891258, 15891259, 15891595, 15891596, 15898995, 15899413, 15900484, 15900485, 15900856, 15900857, 15900999, 15901784, 15902052, + 15902074, 15903287, 15904479, 15904560, 15904561, 15904756, 15904948, 15905428, 15905429, 15908728, 15908729, 15908732, 15908733, + 15908737, 15908739, 15911168, 15911169, 15911465, 15911466, 15912295, 15912378, 15912429, 15912435, 15912645, 15913367, 15915228, + 15915229, 15915232, 15915233, 15915473, 15915474, 15915509, 15915510, 15915885, 15915886, 15916207, 15916208, 15916906, 15916907, + 15917200, 15917202, 15917206, 15917207, 15921490, 15921491, 15921519, 15922789, 15923115, 15923117, 15924339, 15924525, 15924533, + 15926434, 15927196, 15928263, 15929673, 15929674, 15929698, 15929766, 15930272, 15941143, 15941944, 15941945, 15941949, 15941950, + 15941954, 15941955, 15941966, 15941967, 15942041, 15942242, 15943918, 15944225, 15944958, 15948423, 15948742, 15948893, 15948934, + 15948935, 15948952, 15948953, 15948974, 15948975, 15948980, 15948981, 15948984, 15948985, 15948995, 15948996, 15949061, 15949062, + 15950050, 15950051, 15950637, 15950638, 15950642, 15950643, 15950646, 15950647, 15950650, 15950651, 15950666, 15950667, 15950686, + 15950687, 15951694, 15951695, 15951941, 15951942, 15951970, 15951971, 15951974, 15951975, 15951978, 15951979, 15952040, 15954672, + 15956700, 15956815, 15957170, 15957963, 15965549, 15968309, 15969082, 15969120, 15970110, 15970111, 15970828, 15970854, 15971891, + 15971916, 15971980, 15972006, 15973526, 15973527, 15973835, 15974371, 15976265, 15977379, 15978362, 15978948, 15979197, 15980087, + 15980290, 15980299, 15981105, 15981106, 15981914, 15981915, 15982995, 15985005, 15985847, 15986020, 15986468, 15990277, 15990962, + 15991688, 15992374, 15992627, 15992966, 15994933, 15995140, 15995217, 15998964, 16006307, 16010481, 16011214, 16012893, 16013844, + 16015906, 17636688, 17637873, 17638275, 17638348, 17638487, 17638892, 17664726, 17667175, 17673330, 17673544, 17673816, 17681905, + 17685084, 17685085, 17687705, 17691885, 17692405, 17693311, 17694199, 17698519, 17699421, 17699575, 17699776, 17704976, 17705868, + 17707335, 17707490, 17710949, 17711356, 17711906, 17712444, 17720306, 17720567, 17723439, 17723538, 17729149, 17729172, 17730669, + 17735353, 17738506, 17739593, 17742978, 17746144, 17752865, 17759547, 17770240, 17774229, 17774250, 17778606, 17779105, 17782179, + 17783310, 17783420, 17784087, 17791119, 17792330, 17793195, 17795208, 17796208, 17798702, 17803925, 17806758, 17808553, 17811929, + 17815836, 17818217, 17853647, 17855162, 17855180, 17874661, 17881967, 17886031, 17886472, 17886499, 17892400, 17892586, 17893593, + 17918105, 17920208, 17923983, 17932312, 17940478, 17949572, 17950256, 17978577, 17978638, 17979243, 17981913, 17981914, 17986345, + 17995612, 17998455, 18001936, 18018601, 18019359, 18020832, 18020852, 18020857, 18021161, 18024791, 18028665, 18028982, 18029024, + 18029065, 18029402, 18029410, 18029412, 18029430, 18029461, 18029535, 18029709, 18029941, 18030109, 18030158, 18030174, 18030618, + 18030897, 18031010, 18031050, 18031102, 18031119, 18033407, 18033471, 18033519, 18034800, 18035522, 18035524, 18035558, 18035587, + 18035592, 18035611, 18035718, 18036283, 18037159, 18037177, 18037518, 18037756, 18037831, 18038107, 18038314, 18040137, 18040830, + 18042044, 18042107, 18042113, 18042989, 18044136, 18044214, 18045284, 18046457, 18046504, 18046619, 18046757, 18047186, 18047597, + 18047661, 18047776, 18047878, 18047880, 18048688, 18049264, 18050153, 18050586, 18050926, 18051022, 18052532, 18052575, 18052827, + 18053165, 18053676, 18053753, 18054135, 18055170, 18056994, 18057401, 18057693, 18057697, 18058403, 18058457, 18058779, 18058896, + 18059950, 18059951, 18061046, 18061130, 18061163, 18061330, 18062045, 18062047, 18062332, 18063045, 18063475, 18063531, 18063738, + 18064294, 18065075, 18065242, 18065980, 18066212, 18066443, 18066962, 18067060, 18067533, 18067720, 18067880, 18067908, 18067926, + 18069030, 18069287, 18069478, 18069486, 18070682, 18070696, 18070945, 18070960, 18071100, 18071247, 18071778, 18071877, 18071965, + 18072000, 18072080, 18072170, 18072197, 18072238, 18072391, 18072987, 18073243, 18074765, 18075302, 18075625, 18075780, 18075781, + 18075911, 18075915, 18075944, 18075961, 18078850, 18079649, 18082360, 18084867, 18084911, 18085324, 18085709, 18087962, 18087963, + 18088191, 18088242, 18088250, 18088280, 18088356, 18088559, 18088585, 18088685, 18088801, 18089141, 18089688, 18089823, 18090573, + 18092942, 18093321, 18093525, 18093792, 18094278, 18094280, 18094353, 18094818, 18095086, 18096830, 18096870, 18096945, 18099264, + 18099563, 18103567, 18105534, 18105712, 18105730, 18106676, 18106758, 18107898, 18108072, 18108109, 18108251, 18108364, 18108366, + 18108385, 18108608, 18109192, 18109630, 18109736, 18109886, 18110216, 18111914, 18117472, 18120015, 18121451, 18121461, 18123475, + 18126178, 18127068, 18127313, 18128050, 18128330, 18128335, 18128741, 18129173, 18129186, 18129274, 18129299, 18129598, 18129647, + 18130999, 18131052, 18132357, 18132384, 18132993, 18133129, 18133459, 18134121, 18134494, 18134563, 18134668, 18134725, 18135378, + 18135538, 18135637, 18136098, 18136421, 18136723, 18136850, 18138655, 18138798, 18139149, 18139266, 18139885, 18144618, 18145061, + 18145076, 18145167, 18145171, 18145489, 18145498, 18151530, 18154233, 18157193, 18157230, 18157352, 18157653, 18158227, 18159887, + 18160433, 18160599, 18163130, 18167158, 18167584, 18167696, 18168147, 18168194, 18169252, 18169257, 18169269, 18171907, 18171970, + 18173270, 18173746, 18173941, 18173950, 18174259, 18174963, 18176304, 18176339, 18176342, 18177237, 18177283, 18177395, 18177473, + 18177557, 18177648, 18178048, 18178068, 18179144, 18179923, 18180023, 18180031, 18182471, 18182554, 18183350, 18185302, 18186630, + 18189759, 18191550, 18191572, 18191690, 18191760, 18209428, 18209658, 18210069, 18210134, 18211447, 18211680, 18213658, 18214305, + 18226915, 18227231, 18233695, 18234036, 18234679, 18237160, 18237345, 18237354, 18237447, 18238159, 18238169, 18238305, 18238306, + 18238341, 18239452, 18239552, 18239591, 18242107, 18243775, 18247187, 18248062, 18248090, 18248152, 18248702, 18248948, 18251287, + 18253159, 18253172, 18253256, 18253494, 18253674, 18253702, 18253731, 18253737, 18254465, 18254579, 18254961, 18255157, 18255423, + 18255953, 18255964, 18255975, 18256059, 18256119, 18256175, 18256361, 18258481, 18258531, 18258617, 18258894, 18258898, 18258975, + 18259049, 18259278, 18259287, 18259310, 18260016, 18261458, 18261488, 18261623, 18262488, 18262528, 18262642, 18262749, 18262798, + 18262808, 18262813, 18262819, 18262827, 18262860, 18263274, 18265073, 18265373, 18274127, 18274713, 18274727, 18275088, 18275112, + 18275130, 18278505, 18278955, 18279067, 18279081, 18282620, 18282661, 18283406, 18283563, 18283848, 18284148, 18284248, 18284447, + 18284548, 18285101, 18285102, 18285296, 18285465, 18285587, 18286538, 18286732, 18286922, 18287028, 18287423, 18287435, 18288316, + 18288614, 18288684, 18289315, 18289388, 18289811, 18290157, 18291493, 18291622, 18291700, 18291765, 18292103, 18292104, 18292192, + 18292266, 18293383, 18293550, 18293680, 18293751, 18293811, 18294213, 18294759, 18299826, 18299990, 18300398, 18301246, 18301327, + 18303702, 18303813, 18304121, 18306402, 18306490, 18306738, 18307134, 18307258, 18307380, 18307382, 18307680, 18308694, 18308707, + 18308744, 18308789, 18308936, 18309470, 18309756, 18310124, 18310324, 18310679, 18313272, 18313276, 18313936, 18313942, 18314463, + 18314471, 18314489, 18314786, 18314944, 18314957, 18315430, 18315905, 18315975, 18316319, 18316622, 18316913, 18317424, 18317507, + 18317562, 18317614, 18318101, 18318833, 18319890, 18320642, 18320688, 18322258, 18322526, 18322711, 18323528, 18323546, 18324258, + 18326071, 18328517, 18329261, 18333428, 18334440, 18334468, 18340005, 18340701, 18341515, 18342104, 18343985, 18344306, 18344387, + 18344445, 18349782, 18354524, 18354532, 18354567, 18354647, 18355784, 18355800, 18355890, 18356093, 18356174, 18357105, 18358907, + 18359179, 18360540, 18360761, 18361109, 18362474, 18362701, 18363071, 18363333, 18363353, 18363359, 18363669, 18363849, 18364852, + 18365537, 18365642, 18370037, 18374101, 18374518, 18374703, 18378858, 18378979, 18379121, 18388650, 18392831, 18392906, 18393035, + 18393498, 18395705, 18396655, 18396696, 18399717, 18399721, 18399791, 18399885, 18400237, 18400318, 18401555, 18403896, 18403898, + 18403948, 18403950, 18404071, 18404074, 18404115, 18404117, 18404169, 18404170, 18404177, 18404214, 18408893, 18409021, 18409026, + 18409046, 18409296, 18409304, 18409332, 18409338, 18409342, 18409356, 18409383, 18409396, 18409511, 18409551, 18409567, 18409579, + 18409581, 18409638, 18409642, 18409660, 18409669, 18409705, 18409710, 18409737, 18410309, 18410336, 18410366, 18410382, 18410392, + 18410418, 18410426, 18410429, 18410929, 18410976, 18411158, 18414923, 18414966, 18414967, 18414971, 18414973, 18414996, 18415012, + 18415335, 18415343, 18415344, 18415372, 18415383, 18415401, 18415404, 18415409, 18415410, 18415439, 18415463, 18415730, 18415734, + 18415751, 18415752, 18415755, 18415762, 18415770, 18415789, 18415907, 18415911, 18415914, 18415915, 18415918, 18415919, 18415924, + 18415934, 18415935, 18415948, 18415951, 18415960, 18415962, 18415969, 18415974, 18415988, 18415996, 18416003, 18416007, 18416096, + 18416097, 18416098, 18416099, 18416110, 18416111, 18416121, 18417000, 18417004, 18417110, 18417111, 18417153, 18417223, 18417250, + 18417254, 18417255, 18417271, 18417276, 18417298, 18417306, 18418074, 18418081, 18419778, 18419803, 18419847, 18419867, 18419982, + 18420104, 18420138, 18420139, 18420149, 18420289, 18420295, 18421340, 18421341, 18421351, 18421354, 18421396, 18422027, 18422036, + 18422039, 18422146, 18422232, 18422238, 18422335, 18422473, 18422479, 18422569, 18422577, 18422932, 18423232, 18423233, 18423380, + 18423386, 18423801, 18423803, 18424005, 18424006, 18424106, 18424119, 18427918, 18428063, 18428188, 18428190, 18428341, 18428344, + 18428376, 18428378, 18428415, 18429089, 18429190, 18429191, 18429295, 18429301, 18429401, 18429408, 18429419, 18429425, 18429515, + 18429526, 18429763, 18430201, 18430203, 18430403, 18431180, 18431188, 18431554, 18431563, 18431586, 18431622, 18431858, 18431859, + 18432040, 18432050, 18432832, 18433010, 18433079, 18433119, 18459655, 18461356, 18461857, 18462173, 18463453, 18463531, 18479349, + 18479433, 18479437, 18479545, 18479547, 18479583, 18479584, 18479595, 18479615, 18479616, 18479622, 18481099, 18481103, 18481144, + 18481145, 18481150, 18481262, 18481457, 18481554, 18481769, 18485920, 18501825, 18501901, 18501914, 18503176, 18503321, 18503324, + 18503327, 18503748, 18503861, 18505085, 18505121, 18505795, 18505826, 18505827, 18505942, 18507352, 18507393, 18507395, 18507485, + 18507493, 18513155, 18513195, 18513450, 18513477, 18513488, 18513513, 18513532, 18513740, 18535188, 18535211, 18535223, 18535504, + 18535506, 18535511, 18535523, 18535526, 18535693, 18535863, 18535867, 18535950, 18535960, 18536171, 18536855, 18536862, 18536866, + 18536868, 18536869, 18537563, 18537686, 18537828, 18537830, 18539322, 18539428, 18539449, 18539565, 18539569, 18542957, 18549853, + 18549867, 18614667, 18614674, 18614685, 18614689, 18629129, 18629130, 18629263, 18629369, 18629370, 18629490, 18629492, 18630041, + 18630174, 18630284, 18640752, 18640754, 18640811, 18640900, 18640907, 18640943, 18640945, 18641080, 18641081, 18641157, 18641158, + 18641209, 18641401, 18642300, 18642313, 18642314, 18642405, 18642455, 18642533, 18642534, 18642593, 18642798, 18642799, 18644754, + 18690658, 18690699, 18692929, 18692939, 18698953, 18698954, 18699153, 18699427, 18699430, 18700378, 18700541, 18700543, 18700746, + 18700748, 18700766, 18700833, 18700834, 18700841, 18700842, 18701022, 18701473, 18701507, 18701522, 18701524, 18701573, 18701579, + 18701583, 18701911, 18702014, 18702025, 18702055, 18702094, 18702904, 18703319, 18703328, 18703920, 18704157, 18704427, 18704428, + 18705700, 18706080, 18707114, 18707117, 18707253, 18707486, 18707577, 18707592, 18707596, 18707946, 18707947, 18707956, 18707959, + 18707960, 18708017, 18708020, 18708754, 18708755, 18708938, 18709230, 18709237, 18709605, 18709606, 18709614, 18709621, 18709666, + 18709675, 18709742, 18709754, 18709760, 18709875, 18709881, 18709972, 18709987, 18710107, 18710153, 18710156, 18710159, 18710194, + 18710203, 18710456, 18710530, 18710672, 18722404, 18722407, 18722441, 18722444, 18722474, 18722476, 18722661, 18722684, 18722853, + 18722855, 18722857, 18722860, 18722964, 18722965, 18722991, 18723370, 18723413, 18723704, 18723707, 18723764, 18723766, 18723857, + 18723860, 18723916, 18723941, 18723981, 18735304, 18735677, 18737090, 18737199, 18737256, 18737264, 18737394, 18737400, 18738534, + 18738537, 18738632, 18738633, 18738690, 18738691, 18738755, 18739002, 18739014, 18739017, 18739026, 18739095, 18739204, 18739715, + 18739719, 18739774, 18739780, 18741326, 18741377, 18742319, 18742321, 18742401, 18743044, 18743049, 18743102, 18743109, 18743127, + 18743150, 18743153, 18744034, 18744038, 18744047, 18744053, 18744099, 18744100, 18744161, 18744178, 18744272, 18744440, 18744448, + 18744503, 18744507, 18744957, 18744963, 18745309, 18746182, 18746720, 18746766, 18746769, 18747055, 18747115, 18747509, 18748208, + 18748215, 18748216, 18748616, 18748632, 18748881, 18748930, 18749143, 18749153, 18749347, 18749597, 18749859, 18749862, 18749865, + 18750557, 18750566, 18750749, 18751180, 18751334, 18751358, 18751444, 18751733, 18751772, 18751777, 18751784, 18751800, 18751962, + 18751964, 18751967, 18751970, 18751974, 18751975, 18751977, 18752073, 18752085, 18752241, 18752245, 18752369, 18752782, 18752796, + 18753020, 18753025, 18753230, 18753299, 18753321, 18753444, 18754157, 18754468, 18754629, 18754632, 18755348, 18755580, 18755647, + 18756137, 18756196, 18757143, 18757175, 18757227, 18757294, 18757300, 18757544, 18757547, 18757917, 18757930, 18758219, 18758228, + 18758428, 18783923, 18784255, 18784257, 18784278, 18784506, 18784512, 18785925, 18785928, 18786059, 18787397, 18787805, 18787842, + 18840505, 18840540, 18842111, 18842255, 18842546, 18842613, 18843081, 18843086, 18843202, 18877846, 18877886, 18877938, 18877995, + 18878286, 18878288, 18878602, 18878604, 18878910, 18879022, 18879087, 18879201, 18879299, 18879376, 18879694, 18879819, 18879825, + 18879959, 18879963, 18880086, 18880208, 18880209, 18880253, 18880256, 18880438, 18880477, 18880478, 18880579, 18880588, 18880589, + 18880590, 18880674, 18880675, 18880688, 18880690, 18880698, 18880703, 18880710, 18880723, 18880777, 18880778, 18880818, 18880829, + 18880956, 18880957, 18880961, 18880971, 18881047, 18881049, 18881057, 18881059, 18881244, 18881250, 18881271, 18881309, 18881313, + 18881413, 18881417, 18881470, 18881473, 18881573, 18881588, 18881603, 18881665, 18881667, 18881833, 18881834, 18881875, 18881876, + 18881945, 18881946, 18882110, 18882201, 18882333, 18882334, 18882600, 18882620, 18882747, 18882795, 18882797, 18882825, 18882827, + 18882864, 18882874, 18883468, 18883469, 18883511, 18883515, 18883910, 18884107, 18884303, 18884455, 18884839, 18884840, 18884853, + 18885134, 18885240, 18885713, 18885715, 18885719, 18885720, 18890921, 18890923, 18890924, 18891002, 18891007, 18891013, 18891073, + 18891226, 18891230, 18891902, 18892071, 18916117, 18916500, 18917173, 18917229, 18917481, 18917487, 18917714, 18918454, 18918700, + 18919243, 18919244, 18919304, 18919307, 18919365, 18919372, 18919534, 18919859, 18919932, 18920320, 18934396, 18934399, 18934421, + 18934700, 18935088, 18935417, 18935420, 18935494, 18935501, 18936000, 18936103, 18936391, 18936459, 18936570, 18936578, 18936587, + 18936614, 18936649, 18936673, 18962602, 18962613, 18962625, 18962645, 18962662, 18962676, 18963370, 18963420, 18963833, 18963836, + 18963887, 18963911, 18964240, 18964303, 18964451, 18964454, 18964458, 18964500, 18964761, 18965395, 18965426, 18965875, 18965880, + 18965881, 18965931, 18965958, 18965959, 18965984, 18965985, 18967428, 18967463, 18967632, 18968583, 18968607, 18972151, 18972181, + 18972195, 18972196, 18972221, 18972231, 18972471, 18972549, 18972554, 18972611, 18972613, 18972651, 18972928, 18972929, 18972973, + 18972974, 18972992, 18972993, 18973042, 18973044, 18973048, 18973096, 18973098, 18973116, 18973218, 18973912, 18973952, 18973955, + 18974076, 18974093, 18974104, 18974117, 18974129, 18974206, 18974209, 18974419, 18974465, 18974797, 18974894, 18975162, 18975166, + 18975316, 18975374, 18975576, 18975578, 18976376, 18976386, 18976399, 18976405, 18977338, 18977345, 18977358, 18977728, 18977730, + 18977734, 18977736, 18978127, 18978129, 18978246, 18978494, 18978496, 18978826, 18978859, 18978866, 18978868, 18978873, 18978921, + 18978923, 18978933, 18978935, 18979157, 18979213, 18979247, 18979362, 18979627, 18979629, 18979659, 18979665, 18979666, 18979668, + 18979670, 18979746, 18979760, 18979767, 18979772, 18979782, 18979798, 18979820, 18979833, 18979855, 18979857, 18979955, 18979956, + 18980169, 18980439, 18980547, 18980548, 18980554, 18980591, 18980595, 18980691, 18980698, 18980831, 18980853, 18981626, 18981703, + 18981830, 18981937, 18981943, 18982171, 18982176, 18982186, 18982188, 18982196, 18982429, 18982431, 18982437, 18982740, 18982825, + 18982829, 18982867, 18982883, 18982926, 18983055, 18983244, 18983397, 18983401, 18983612, 18983619, 18983620, 18983932, 18983935, + 18983996, 18984329, 18984386, 18984405, 18984407, 18984413, 18984431, 18984501, 18984511, 18984763, 18984769, 18984913, 18984991, + 18985047, 18985161, 18985246, 18985248, 18985301, 18985304, 18985312, 18985520, 18985521, 18985726, 18985822, 18985850, 18986106, + 18986173, 18986174, 18986252, 18986266, 18986267, 18987017, 18987031, 18987048, 18987053, 18987081, 18987680, 18988159, 18988166, + 18988194, 18988205, 18988573, 18988712, 18988715, 18988857, 18988982, 18988984, 18988985, 18989012, 18989013, 18989018, 18989086, + 18989099, 18989125, 18989132, 18989165, 18989462, 18989464, 18989759, 18989899, 18989954, 18989955, 18990839, 18990846, 18990863, + 18990866, 18991105, 18991433, 18991452, 18991456, 18991462, 18991467, 18991469, 18991662, 18992464, 18992650, 18992774, 18992801, + 18992856, 18992860, 18992906, 18999657, 18999676, 18999686, 18999697, 18999881, 18999886, 19000091, 19000224, 19000241, 19000489, + 19000503, 19001195, 19001201, 19001347, 19001359, 19007968, 19007971, 19008121, 19011401, 19011569, 19011588, 19011656, 19011677, + 19011754, 19011759, 19012403, 19012416, 19012603, 19012613, 19012746, 19012747, 19014099, 19014206, 19020339, 19020428, 19020735, + 19020954, 19020959, 19021745, 19021748, 19021802, 19021803, 19022518, 19022523, 19157469, 19157470, 19157562, 19157597, 19157681, + 19157693, 19157727, 19157735, 19177628, 19177631, 19179127, 19180014, 19180478, 19180496, 19180576, 19180594, 19180601, 19180609, + 19182388, 19182390, 19182566, 19182598, 19183939, 19184062, 19184172, 19184613, 19187655, 19187674, 19187949, 19187959, 19189135, + 19190233, 19190353, 19190502, 19190504, 19190594, 19191003, 19191043, 19191046, 19191091, 19191098, 19191118, 19191122, 19191234, + 19191237, 19191305, 19191307, 19191407, 19191408, 19191453, 19191858, 19192015, 19192485, 19192487, 19192606, 19192607, 19192611, + 19192615, 19192896, 19192903, 19193680, 19193768, 19193789, 19193876, 19193879, 19194492, 19195385, 19200168, 19200172, 19200274, + 19200290, 19200578, 19200583, 19202205, 19202286, 19202388, 19202392, 19202403, 19202424, 19202450, 19202506, 19202509, 19203134, + 19203366, 19203572, 19203746, 19203752, 19204197, 19206989, 19207000, 19207077, 19207171, 19207271, 19207272, 19208337, 19208345, + 19208730, 19212689, 19212690, 19212744, 19212946, 19212947, 19213039, 19213045, 19213048, 19213301, 19213303, 19213574, 19213575, + 19213942, 19214581, 19214583, 19214681, 19214684, 19214905, 19215052, 19215418, 19216089, 19216095, 19218331, 19218601, 19218604, + 19218875, 19219205, 19220095, 19220100, 19221680, 19221683, 19221894, 19222484, 19222586, 19222590, 19224624, 19224626, 19225180, + 19226142, 19226145, 19226595, 19226609, 19226890, 19226896, 19226910, 19226911, 19226927, 19227005, 19227837, 19227907, 19227909, + 19228054, 19228056, 19228106, 19228107, 19228121, 19228123, 19228259, 19228261, 19228302, 19228304, 19229883, 19229890, 19230123, + 19233910, 19234320, 19234345, 19234424, 19234537, 19234956, 19235288, 19235308, 19237190, 19237199, 19237208, 19237233, 19239254, + 19239258, 19239376, 19239377, 19239389, 19239407, 19240001, 19240024, 19240499, 19240901, 19250124, 19250127, 19250230, 19250239, + 19252820, 19252824, 19252856, 19252859, 19253253, 19253258, 19253341, 19253648, 19253658, 19254248, 19254257, 19254261, 19254273, + 19255415, 19255483, 19255486, 19256056, 19256595, 19256596, 19257023, 19257421, 19257656, 19257794, 19257795, 19257825, 19257827, + 19257973, 19258287, 19258305, 19259424, 19259426, 19260016, 19260028, 19260034, 19260047, 19260053, 19260136, 19260185, 19260252, + 19260535, 19260539, 19263045, 19263046, 19263072, 19263297, 19263547, 19264542, 19264897, 19268898, 19268900, 19268986, 19268990, + 19269163, 19269421, 19269423, 19271598, 19271984, 19272062, 19272201, 19272203, 19272401, 19272409, 19272445, 19272449, 19281870, + 19281883, 19282504, 19285192, 19285575, 19285576, 19285624, 19301651, 19301652, 19301719, 19301721, 19302758, 19302769, 19302830, + 19302832, 19302846, 19304733, 19304737, 19304857, 19304863, 19304956, 19304961, 19305572, 19306684, 19306759, 19306763, 19306795, + 19306821, 19306844, 19306849, 19307117, 19307412, 19307778, 19307893, 19308083, 19308148, 19308304, 19314020, 19314021, 19314052, + 19314238, 19314253, 19315712, 19316333, 19317997, 19317999, 19318269, 19318271, 19318527, 19318529, 19318536, 19318578, 19318582, + 19318880, 19318881, 19319054, 19319328, 19319330, 19319376, 19324587, 19324593, 19324769, 19324771, 19324874, 19324883, 19324952, + 19324954, 19325006, 19325007, 19325008, 19325103, 19325184, 19325185, 19325391, 19325392, 19325399, 19325401, 19325570, 19325804, + 19326308, 19326329, 19326348, 19326618, 19326756, 19326757, 19326935, 19326944, 19326947, 19327176, 19327529, 19329583, 19329702, + 19329703, 19329745, 19329746, 19329754, 19329758, 19330909, 19330912, 19331006, 19331009, 19331094, 19331095, 19331200, 19331224, + 19331676, 19331678, 19331729, 19331732, 19332246, 19332827, 19332934, 19332935, 19333061, 19358286, 19358287, 19358310, 19360688, + 19360690, 19360794, 19360932, 19361096, 19362472, 19362473, 19362976, 19362979, 19363289, 19363291, 19363391, 19363719, 19364350, + 19364366, 19364392, 19364402, 19364936, 19364944, 19365015, 19365017, 19365059, 19365710, 19365714, 19365844, 19366349, 19366686, + 19366920, 19366924, 19367057, 19367062, 19367152, 19367158, 19367216, 19367219, 19367501, 19367504, 19368429, 19368434, 19368444, + 19368449, 19368461, 19368484, 19368500, 19368501, 19368676, 19368680, 19368783, 19368797, 19368801, 19368942, 19368948, 19368949, + 19368955, 19368966, 19369066, 19369075, 19369217, 19369229, 19369302, 19369310, 19369314, 19369341, 19369343, 19369598, 19369600, + 19369688, 19369690, 19369879, 19369904, 19369907, 19369914, 19369919, 19369924, 19370031, 19373906, 19373910, 19373914, 19373996, + 19374015, 19374165, 19374181, 19374182, 19374198, 19374266, 19374299, 19374800, 19375006, 19375010, 19375171, 19375174, 19375178, + 19375183, 19375189, 19375203, 19375209, 19375252, 19375259, 19375260, 19375719, 19375788, 19375789, 19376019, 19376020, 19376061, + 19385710, 19385787, 19389326, 19389328, 19389440, 19389442, 19389987, 19390185, 19390188, 19390245, 19390250, 19390286, 19390313, + 19390322, 19390345, 19390352, 19390586, 19390710, 19392042, 19392044, 19410405, 19410437, 19410449, 19410488, 19410489, 19410496, + 19410497, 19410510, 19410916, 19411000, 19411002, 19411204, 19411937, 19411939, 19411997, 19512944, 19513029, 19513189, 19513202, + 19513396, 19513538, 19513695, 19513945, 19513992, 19516059, 19516062, 19516075, 19516084, 19516968, 19517224, 19554953, 19558472, + 19609701, 19609719, 19609892, 19609947, 19610025, 19610494, 19610647, 19610652, 19610959, 19611209, 19611291, 19612269, 19612444, + 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285, 19613989, 19614239, 19614595, 19614600, + 19614607, 19615112, 19615114, 19615248, 19726042, 19726057, 19748242, 19748244, 19748269, 19748278, 19748377, 19750672, 19750695, + 19750702, 19750822, 19750833, 19751058, 19751064, 19751102, 19751108, 19751169, 19751172, 19751269, 19751854, 19751865, 19751878, + 19751936, 19752030, 19752349, 19755044, 19755063, 19755440, 19755881, 19756813, 19761538, 19761592, 19761593, 19761680, 19761685, + 19761995, 19762162, 19762167, 19763218, 19763430, 19763945, 19764280, 19764311, 19764333, 19764676, 19764744, 19765216, 19765374, + 19765479, 19767631, 19792072, 19792136, 19792139, 19793277, 19793318, 19793322, 19793528, 19793536, 19796241, 19796405, 19796407, + 19802815, 19802816, 19802881, 19804775, 19805218, 19805360, 19805515, 19807739, 19807796, 19808997, 19809396, 19809725, 19809990, + 19913194, 19913195, 19914726, 19914727, 19914735, 19914741, 19914769, 19914811, 19914876, 19914877, 19916067, 19917537, 19917540, + 19917991, 19918159, 19918171, 19918197, 19918202, 19918295, 19918302, 19918429, 19918432, 19918524, 19918639, 19918716, 19918797, + 19918799, 19918991, 19918992, 19919153, 19919287, 19919383, 19919514, 19919971, 19919995, 19920374, 19920778, 19920779, 19921528, + 19921531, 19921674, 19921675, 19921724, 19923306, 19923308, 19923480, 19923532, 19923534, 19923692, 19923702, 19923790, 19923814, + 19923818, 19923880, 19923884, 19924275, 19924279, 19924358, 19924367, 19924384, 19925554, 19925869, 19926582, 19926586, 19926619, + 19926620, 19926687, 19926859, 19926884, 19926887, 19926891, 19926959, 19927302, 19927422, 19928859, 19929054, 19932992, 19933015, + 19933313, 19933316, 19933328, 19933410, 19933760, 19933818, 19933876, 19934184, 19934490, 19934606, 19934621, 19934741, 19959354, + 19959578, 19960026, 19960122, 19962154, 19962536 +]; +export const PEG_CROSS_BLOCKS_LAST: u32 = 19962536; +export const PEG_CROSS_BLOCKS: u32[] = [ + 12974091, 12975421, 12978538, 12978615, 12978680, 12978911, 12979148, 12979149, 12979167, 12979171, 12979228, 12979230, 12979607, + 12983847, 12983871, 12983895, 12983897, 12983926, 12984038, 12984104, 12984170, 12984257, 12984310, 12984929, 12986590, 12986603, + 12986901, 12987603, 12990064, 12991358, 12991399, 12992193, 12992519, 12993217, 12993281, 12998537, 12998539, 12998546, 12998550, + 12998551, 12998553, 12999530, 12999585, 12999767, 12999776, 12999777, 12999779, 12999817, 12999840, 13000158, 13000196, 13000305, + 13000309, 13000334, 13000347, 13000356, 13000377, 13000577, 13000587, 13001082, 13001089, 13001396, 13001414, 13001894, 13001913, + 13001956, 13002009, 13002735, 13002738, 13003196, 13003198, 13004037, 13004045, 13004360, 13004364, 13004638, 13004646, 13004655, + 13004657, 13004817, 13004839, 13004843, 13004883, 13005075, 13005103, 13005107, 13005109, 13005372, 13005380, 13005673, 13005715, + 13005730, 13005733, 13005944, 13005946, 13006200, 13006202, 13006203, 13006321, 13006487, 13006488, 13006499, 13006546, 13006708, + 13006709, 13006980, 13007010, 13007245, 13007246, 13007274, 13007275, 13007509, 13007525, 13007574, 13007607, 13007780, 13007798, + 13007859, 13007898, 13008063, 13008065, 13008117, 13008191, 13008375, 13008387, 13008617, 13008671, 13008712, 13008736, 13008895, + 13008901, 13008906, 13008912, 13009163, 13009169, 13009190, 13009193, 13009199, 13009203, 13009381, 13009423, 13009669, 13009671, + 13009676, 13009679, 13009681, 13009687, 13009958, 13009972, 13009973, 13010009, 13010222, 13010231, 13010492, 13010556, 13010779, + 13014211, 13016266, 13018933, 13019023, 13019754, 13020690, 13020782, 13022699, 13022701, 13022825, 13023185, 13023247, 13023922, + 13025396, 13025666, 13026184, 13026256, 13026638, 13026640, 13027512, 13029384, 13030010, 13030107, 13030123, 13030393, 13030528, + 13031004, 13031259, 13032695, 13032731, 13032942, 13033010, 13033033, 13033210, 13034517, 13034543, 13035839, 13035922, 13035929, + 13036165, 13036689, 13036884, 13036897, 13036926, 13037135, 13037615, 13037642, 13038069, 13038108, 13038138, 13038145, 13038184, + 13039743, 13043682, 13043699, 13044756, 13044762, 13044770, 13044955, 13045801, 13046502, 13051141, 13051348, 13056233, 13056234, + 13057499, 13057501, 13057527, 13057595, 13058927, 13059717, 13059983, 13060079, 13060086, 13060118, 13060119, 13060121, 13060123, + 13060132, 13060160, 13060198, 13060449, 13060450, 13060479, 13060489, 13060492, 13060680, 13060716, 13060796, 13060802, 13060842, + 13060960, 13062059, 13062295, 13062299, 13062306, 13062319, 13062333, 13062352, 13062366, 13063788, 13063838, 13063861, 13063878, + 13075770, 13075888, 13076058, 13076195, 13076316, 13076435, 13076636, 13076662, 13076679, 13076703, 13076890, 13076891, 13076899, + 13076947, 13076964, 13076972, 13077164, 13077246, 13077426, 13077429, 13077495, 13077503, 13077730, 13077736, 13078272, 13078287, + 13078449, 13078457, 13078466, 13078470, 13078482, 13078487, 13078488, 13078519, 13078541, 13078561, 13078796, 13078810, 13078813, + 13078834, 13079299, 13079303, 13079572, 13079587, 13079588, 13079596, 13079620, 13079642, 13079648, 13079683, 13079724, 13079755, + 13079814, 13079885, 13079887, 13079895, 13079899, 13079919, 13079920, 13079941, 13080074, 13080179, 13080198, 13080229, 13080352, + 13080375, 13080400, 13080408, 13080634, 13080637, 13080648, 13080660, 13080672, 13080677, 13080678, 13080680, 13080768, 13080770, + 13080887, 13080888, 13080932, 13080934, 13080937, 13080958, 13080977, 13080990, 13080996, 13080999, 13081011, 13081057, 13081145, + 13081209, 13081632, 13081635, 13081700, 13081721, 13081750, 13081754, 13081766, 13081895, 13081963, 13081977, 13081992, 13081994, + 13082000, 13082006, 13082094, 13082163, 13082230, 13082282, 13082300, 13082301, 13082504, 13082507, 13082510, 13082555, 13082863, + 13082876, 13082878, 13082888, 13082969, 13083844, 13084930, 13084956, 13084984, 13085212, 13085233, 13085236, 13085311, 13085508, + 13085645, 13085877, 13086288, 13086337, 13086338, 13086356, 13086362, 13086369, 13086376, 13086400, 13086422, 13086440, 13086459, + 13086461, 13087211, 13087217, 13087221, 13087225, 13087231, 13087377, 13087393, 13087405, 13087410, 13087411, 13087527, 13088104, + 13088272, 13093705, 13093899, 13093903, 13093921, 13093932, 13093971, 13093975, 13099188, 13099189, 13099353, 13099362, 13099414, + 13099461, 13099465, 13099710, 13099714, 13099747, 13100289, 13100319, 13100358, 13100371, 13100898, 13100923, 13102868, 13102939, + 13107071, 13107096, 13110581, 13110588, 13110634, 13110706, 13110819, 13110844, 13111074, 13113042, 13113109, 13113110, 13113423, + 13113442, 13113448, 13113452, 13113453, 13113553, 13114481, 13114574, 13115940, 13115946, 13115955, 13115972, 13115989, 13115990, + 13117862, 13118077, 13118145, 13118291, 13118320, 13118321, 13118355, 13118356, 13118402, 13118413, 13118423, 13118428, 13118436, + 13118467, 13121070, 13121089, 13121099, 13121128, 13121178, 13121244, 13121307, 13121310, 13122225, 13122395, 13122407, 13122455, + 13122874, 13122951, 13122985, 13124397, 13124895, 13129783, 13129786, 13129854, 13129981, 13129991, 13130001, 13130094, 13130178, + 13131625, 13131662, 13131722, 13131929, 13137125, 13137568, 13138520, 13138647, 13138700, 13138778, 13138782, 13138813, 13138856, + 13138858, 13139212, 13139273, 13139367, 13139407, 13139408, 13139410, 13139609, 13140003, 13140015, 13140024, 13140027, 13140327, + 13140447, 13140687, 13141148, 13141156, 13141160, 13141165, 13141195, 13141863, 13141869, 13141870, 13141940, 13142135, 13143729, + 13143754, 13143760, 13143762, 13143763, 13143816, 13144293, 13144300, 13144362, 13144364, 13144774, 13144823, 13145005, 13145190, + 13145194, 13145195, 13145198, 13145206, 13145220, 13145747, 13146082, 13146089, 13147016, 13147028, 13147044, 13147045, 13148291, + 13148316, 13149112, 13150275, 13150279, 13150280, 13151314, 13151333, 13151356, 13151443, 13151450, 13151451, 13151460, 13151462, + 13151595, 13151598, 13151696, 13151700, 13151863, 13151867, 13152103, 13152260, 13152269, 13153306, 13153325, 13155620, 13156284, + 13156748, 13156781, 13157326, 13158957, 13159234, 13159235, 13159247, 13159248, 13159486, 13159495, 13161064, 13161086, 13161299, + 13161376, 13161392, 13161406, 13161416, 13161423, 13161487, 13161550, 13161611, 13161634, 13161636, 13162200, 13162208, 13162329, + 13162331, 13163395, 13163536, 13163565, 13163567, 13163596, 13163597, 13163604, 13163670, 13163995, 13164187, 13164189, 13164192, + 13164658, 13164746, 13165237, 13165391, 13165408, 13165727, 13165897, 13165996, 13166015, 13166072, 13166219, 13166222, 13166242, + 13166250, 13166251, 13166258, 13166259, 13166283, 13166287, 13166319, 13166381, 13166437, 13167205, 13167549, 13167575, 13167591, + 13167742, 13167972, 13168519, 13168524, 13169110, 13171988, 13175038, 13175053, 13175058, 13175064, 13175069, 13175146, 13175397, + 13175452, 13175497, 13175514, 13175520, 13175609, 13177587, 13177589, 13177597, 13177615, 13177647, 13177659, 13177660, 13177714, + 13177758, 13178360, 13178584, 13178652, 13179149, 13179177, 13179251, 13179252, 13179253, 13179274, 13179308, 13179337, 13179353, + 13179400, 13180079, 13180083, 13180101, 13180102, 13180117, 13180145, 13180189, 13180216, 13180664, 13180692, 13180713, 13180715, + 13180730, 13180758, 13180833, 13180888, 13180897, 13180909, 13181023, 13181155, 13181755, 13181777, 13181802, 13181820, 13182646, + 13182655, 13183890, 13183894, 13183955, 13183956, 13183957, 13184012, 13184973, 13184974, 13185191, 13185260, 13185321, 13185384, + 13185495, 13185703, 13185732, 13185850, 13187086, 13187116, 13187178, 13187233, 13188042, 13189001, 13189010, 13189082, 13191072, + 13191091, 13191099, 13191106, 13191522, 13191635, 13191637, 13191644, 13192232, 13192596, 13192599, 13192604, 13193031, 13193802, + 13194379, 13194410, 13194615, 13194717, 13194719, 13194824, 13196049, 13196067, 13196141, 13196190, 13196445, 13196459, 13196460, + 13198164, 13198273, 13198316, 13198557, 13198899, 13198902, 13198907, 13198909, 13198925, 13199052, 13199074, 13199086, 13199099, + 13199116, 13199129, 13199131, 13199260, 13199361, 13199363, 13200193, 13200194, 13200216, 13200219, 13200224, 13201208, 13201289, + 13201290, 13201321, 13201322, 13206138, 13206229, 13206338, 13206947, 13207266, 13207395, 13207435, 13207444, 13207445, 13207578, + 13207663, 13208184, 13211822, 13211897, 13211967, 13213641, 13214042, 13214163, 13214206, 13215008, 13215982, 13217044, 13217061, + 13217222, 13217341, 13217478, 13217783, 13217784, 13217810, 13217953, 13217970, 13217973, 13218020, 13218050, 13218279, 13218810, + 13218815, 13218816, 13218909, 13218949, 13218953, 13218954, 13225077, 13225299, 13226246, 13226559, 13226732, 13226957, 13227000, + 13229110, 13229499, 13229747, 13232674, 13232699, 13232717, 13233025, 13234172, 13234178, 13234264, 13234554, 13236246, 13236247, + 13236250, 13236319, 13237109, 13237552, 13244459, 13244462, 13245028, 13245032, 13245040, 13245162, 13245172, 13245175, 13245180, + 13245275, 13245545, 13245546, 13246387, 13246388, 13246647, 13246651, 13246920, 13246926, 13246980, 13246983, 13247415, 13247416, + 13247678, 13247695, 13247947, 13247952, 13248208, 13248209, 13248470, 13248473, 13249273, 13249276, 13249292, 13249294, 13249543, + 13249561, 13249800, 13249818, 13249822, 13250039, 13250057, 13250059, 13256813, 13256815, 13257386, 13257389, 13258210, 13258214, + 13259590, 13259594, 13259863, 13259865, 13260039, 13260056, 13260062, 13260063, 13260114, 13260126, 13260381, 13260386, 13260388, + 13260389, 13260884, 13260886, 13261140, 13261142, 13261145, 13261155, 13261156, 13261186, 13261206, 13261363, 13261373, 13261399, + 13262381, 13262382, 13262425, 13262428, 13262440, 13262442, 13262455, 13262462, 13262465, 13262469, 13262553, 13262554, 13262569, + 13262592, 13262593, 13262713, 13262719, 13262729, 13262748, 13262896, 13262899, 13262913, 13263080, 13263772, 13263871, 13264127, + 13264135, 13264139, 13264149, 13272546, 13272560, 13272905, 13272934, 13273058, 13273061, 13273064, 13273373, 13273436, 13273458, + 13273503, 13273513, 13273717, 13273719, 13274023, 13274030, 13274057, 13274064, 13274105, 13274148, 13274189, 13274198, 13274217, + 13274220, 13274242, 13274248, 13335750, 13335755, 13335869, 13336244, 13336323, 13336461, 13336505, 13336560, 13336618, 13336695, + 13336714, 13336777, 13336959, 13337532, 13337559, 13337935, 13337937, 13337959, 13340698, 13340781, 13340820, 13340947, 13341028, + 13341076, 13341108, 13341147, 13341156, 13341366, 13341373, 13342047, 13342121, 13342224, 13342548, 13376585, 13376710, 13376778, + 13378143, 13378793, 13378816, 13378829, 13379464, 13434006, 13434877, 13435565, 13435971, 13436006, 13436018, 13436025, 13436035, + 13436049, 13436107, 13437998, 13438644, 13438667, 13440517, 13442086, 13442913, 13443210, 13443231, 13443232, 13443239, 13443256, + 13443258, 13443270, 13443271, 13444653, 13444660, 13444712, 13446459, 13448008, 13449065, 13449128, 13449167, 13449303, 13449313, + 13449493, 13449495, 13449505, 13449506, 13449551, 13449634, 13449650, 13449705, 13449790, 13449821, 13449841, 13449855, 13449875, + 13449913, 13450052, 13450154, 13450187, 13450472, 13450507, 13450522, 13451061, 13451131, 13451155, 13451468, 13451543, 13451544, + 13451550, 13451555, 13451564, 13451596, 13451598, 13451649, 13451671, 13451675, 13455280, 13455282, 13455557, 13455600, 13455618, + 13455860, 13455891, 13455896, 13455911, 13461738, 13462027, 13462049, 13462066, 13462165, 13463379, 13463381, 13464408, 13466451, + 13467419, 13467691, 13468508, 13468675, 13468784, 13469000, 13469007, 13469012, 13469034, 13470634, 13470770, 13471747, 13474744, + 13474934, 13475341, 13475377, 13475394, 13475519, 13475523, 13475746, 13476174, 13476209, 13476325, 13476418, 13476419, 13479133, + 13479136, 13479138, 13479152, 13479196, 13479242, 13479941, 13480370, 13480372, 13480449, 13480647, 13480648, 13480717, 13481304, + 13481717, 13481988, 13482011, 13482102, 13483897, 13483977, 13483982, 13483998, 13484811, 13484846, 13484847, 13486887, 13486969, + 13488473, 13488482, 13489574, 13489977, 13490465, 13490505, 13490507, 13490517, 13490518, 13491374, 13494424, 13494752, 13494754, + 13495520, 13495854, 13497794, 13497797, 13497803, 13497820, 13497844, 13497868, 13498035, 13503686, 13503690, 13503704, 13503709, + 13503751, 13503763, 13503770, 13503813, 13503910, 13508461, 13508666, 13508680, 13508728, 13508759, 13508780, 13510297, 13510507, + 13510508, 13510514, 13510516, 13510518, 13510520, 13510556, 13510590, 13510603, 13510605, 13510610, 13510727, 13511700, 13511890, + 13511907, 13512045, 13512048, 13512304, 13512305, 13512359, 13512365, 13514281, 13514282, 13514705, 13514719, 13514721, 13514734, + 13515060, 13516318, 13516526, 13516569, 13517036, 13517567, 13518970, 13519495, 13519497, 13519756, 13521882, 13522133, 13523828, + 13523847, 13523862, 13523885, 13523912, 13523967, 13523969, 13524379, 13524397, 13525787, 13525872, 13525873, 13528534, 13528544, + 13528546, 13528558, 13528574, 13528579, 13528967, 13529028, 13531631, 13531875, 13531910, 13531954, 13531961, 13531990, 13532016, + 13532023, 13532081, 13532126, 13532137, 13532138, 13532143, 13532151, 13532161, 13532176, 13532179, 13532198, 13532239, 13532920, + 13532929, 13532946, 13533454, 13533933, 13535490, 13535493, 13535494, 13535499, 13538211, 13538232, 13538866, 13538895, 13539218, + 13539249, 13539673, 13539923, 13539946, 13539951, 13540826, 13540841, 13541140, 13541325, 13541849, 13541933, 13541958, 13541980, + 13541997, 13542002, 13542077, 13542086, 13542175, 13542179, 13542232, 13542254, 13543917, 13544624, 13545832, 13545837, 13545858, + 13546411, 13547018, 13547059, 13547095, 13547595, 13547630, 13548233, 13548387, 13550252, 13550987, 13551029, 13551119, 13551280, + 13551291, 13552190, 13552241, 13552260, 13552307, 13552675, 13552678, 13552681, 13552684, 13552688, 13552701, 13552704, 13552750, + 13552752, 13552754, 13552943, 13553661, 13553662, 13553676, 13553677, 13553853, 13554976, 13555095, 13555457, 13557196, 13557954, + 13558105, 13558112, 13558113, 13558114, 13558116, 13558121, 13558735, 13558752, 13558776, 13559078, 13559084, 13559255, 13559291, + 13559303, 13559410, 13559415, 13559416, 13559425, 13559561, 13559568, 13559602, 13559647, 13559656, 13559658, 13559791, 13559882, + 13560317, 13560318, 13560937, 13564634, 13564681, 13564697, 13564713, 13564837, 13564852, 13564859, 13564871, 13564879, 13564889, + 13564891, 13566648, 13568113, 13568302, 13568342, 13568345, 13568357, 13568484, 13568492, 13568495, 13568667, 13570256, 13570277, + 13570284, 13570300, 13570316, 13570318, 13570944, 13570952, 13571175, 13572652, 13572673, 13572674, 13572854, 13572856, 13572884, + 13572895, 13572918, 13572923, 13572958, 13572969, 13573024, 13573028, 13573096, 13573097, 13573405, 13573522, 13573523, 13573686, + 13573687, 13573693, 13573695, 13574201, 13574213, 13574289, 13574294, 13575376, 13575377, 13576614, 13576620, 13576635, 13576661, + 13576663, 13577153, 13577969, 13578897, 13578901, 13578940, 13578947, 13579158, 13579160, 13579235, 13579351, 13579385, 13579447, + 13579490, 13579530, 13579565, 13579572, 13579588, 13579894, 13579900, 13579911, 13579912, 13579914, 13579918, 13579942, 13580072, + 13580087, 13580260, 13580280, 13581920, 13582005, 13582060, 13582068, 13582069, 13582090, 13582096, 13582336, 13582467, 13582468, + 13582749, 13583449, 13583933, 13584045, 13584069, 13584076, 13584080, 13584082, 13584102, 13584104, 13584107, 13584126, 13584153, + 13584183, 13584184, 13584192, 13584195, 13584208, 13584209, 13584211, 13584243, 13584286, 13584294, 13584296, 13584485, 13584486, + 13585001, 13585594, 13585602, 13585607, 13585610, 13585641, 13585748, 13585775, 13585976, 13585992, 13586067, 13587038, 13587054, + 13587160, 13589367, 13589405, 13589454, 13589471, 13589485, 13589486, 13589512, 13589515, 13589527, 13589532, 13589574, 13589656, + 13589661, 13589867, 13590103, 13592391, 13594358, 13595502, 13595599, 13595883, 13596659, 13596666, 13596668, 13596671, 13598662, + 13599510, 13599974, 13600003, 13600116, 13600221, 13600229, 13600230, 13600343, 13600344, 13600519, 13602309, 13602377, 13602479, + 13602483, 13602486, 13602488, 13602489, 13602490, 13602493, 13602978, 13603574, 13603586, 13603652, 13603887, 13604255, 13605773, + 13605779, 13606896, 13607198, 13607202, 13607203, 13608420, 13608519, 13608665, 13608681, 13608968, 13610066, 13611161, 13614876, + 13614927, 13614991, 13614998, 13615404, 13617630, 13618342, 13621035, 13622147, 13623486, 13623495, 13623499, 13623577, 13623590, + 13623764, 13624270, 13624355, 13624363, 13624366, 13624383, 13624517, 13625958, 13625960, 13625982, 13626112, 13626125, 13626166, + 13626170, 13626212, 13628785, 13628854, 13628864, 13628865, 13629661, 13629662, 13629784, 13629785, 13629852, 13630011, 13630129, + 13630230, 13630429, 13630583, 13630683, 13630775, 13630780, 13630796, 13631292, 13631331, 13640082, 13640087, 13640104, 13640132, + 13640218, 13640556, 13640587, 13640615, 13641928, 13641929, 13642057, 13642071, 13642137, 13642155, 13642160, 13642167, 13642168, + 13642207, 13642212, 13642215, 13642216, 13642265, 13642911, 13644410, 13646116, 13646163, 13647476, 13647732, 13647733, 13647905, + 13657931, 13657936, 13658078, 13658083, 13658088, 13658106, 13666892, 13666908, 13667064, 13667842, 13671879, 13672266, 13685409, + 13685501, 13687313, 13687327, 13688700, 13688718, 13688728, 13688770, 13688773, 13689077, 13693941, 13693995, 13694143, 13694177, + 13703288, 13703407, 13704796, 13704804, 13704850, 13704871, 13710244, 13710333, 13710534, 13710568, 13717643, 13717686, 13720847, + 13720981, 13721138, 13721150, 13721209, 13721255, 13721263, 13721265, 13721279, 13721280, 13722372, 13722456, 13722731, 13722854, + 13722860, 13722861, 13722883, 13722884, 13722898, 13722924, 13723078, 13723597, 13723611, 13723617, 13724121, 13724580, 13724940, + 13724949, 13724958, 13725168, 13725481, 13725714, 13725715, 13725761, 13726532, 13728022, 13728049, 13729075, 13729079, 13729488, + 13729572, 13729622, 13729660, 13729666, 13729719, 13729765, 13729836, 13731361, 13731396, 13731754, 13731765, 13731769, 13731770, + 13731798, 13731966, 13732954, 13732957, 13732964, 13734204, 13734565, 13734582, 13734613, 13734671, 13735055, 13735059, 13735060, + 13735378, 13740278, 13740773, 13740781, 13740808, 13740821, 13740879, 13741264, 13742045, 13742386, 13742413, 13742433, 13742461, + 13742522, 13743142, 13743432, 13743636, 13743643, 13743676, 13744107, 13744604, 13800996, 13800999, 13801241, 13801243, 13804633, + 13804667, 13804672, 13804727, 13812443, 13812884, 13812892, 13812903, 13813249, 13813688, 13829732, 13829784, 13844956, 13844964, + 13845655, 13845657, 13845739, 13845745, 13845757, 13845780, 13848953, 13851591, 13851617, 13852217, 13852286, 13852519, 13853027, + 13854735, 13854789, 13854927, 13854932, 13854936, 13854950, 13854954, 13856012, 13856028, 13856077, 13856953, 13856955, 13857267, + 13857323, 13857365, 13857466, 13857469, 13857483, 13857490, 13857624, 13857918, 13858695, 13858898, 13858902, 13858904, 13858923, + 13858924, 13859670, 13859826, 13859936, 13860025, 13860899, 13861827, 13861932, 13861937, 13862044, 13862064, 13862197, 13862355, + 13862374, 13863113, 13864512, 13864522, 13864530, 13864926, 13864941, 13864946, 13864969, 13865001, 13865043, 13865070, 13865081, + 13865342, 13865516, 13865553, 13865581, 13865604, 13865623, 13865647, 13865678, 13866062, 13869401, 13869405, 13869422, 13869451, + 13869457, 13869834, 13870311, 13870632, 13871204, 13871210, 13871302, 13871334, 13871339, 13871363, 13871424, 13871435, 13871497, + 13871551, 13871568, 13871570, 13871583, 13871761, 13872175, 13872207, 13872240, 13872304, 13872378, 13872402, 13872443, 13872834, + 13872889, 13872979, 13873525, 13873669, 13874108, 13874137, 13874154, 13874198, 13874244, 13874484, 13875063, 13875708, 13875709, + 13876095, 13876631, 13876822, 13876828, 13876980, 13877074, 13877075, 13877496, 13877517, 13877520, 13877638, 13877848, 13878148, + 13882302, 13882360, 13882365, 13882591, 13882592, 13882597, 13882599, 13882806, 13882807, 13883051, 13883360, 13883433, 13884709, + 13885349, 13885866, 13885918, 13886883, 13887001, 13887338, 13887344, 13887380, 13887548, 13887611, 13888142, 13888577, 13888593, + 13888668, 13888746, 13889461, 13889503, 13889510, 13889524, 13889539, 13889649, 13890458, 13891050, 13891076, 13891081, 13891130, + 13891135, 13891138, 13902888, 13902992, 13906563, 13906944, 13908405, 13908630, 13912128, 13912739, 13913099, 13913121, 13913454, + 13913585, 13913596, 13914008, 13926989, 13926996, 13927003, 13927014, 13927024, 13927479, 13927483, 13927492, 13938606, 13938669, + 13939585, 13939590, 13939599, 13939708, 13939849, 13939850, 13942560, 13942563, 13942611, 13954079, 13954146, 13954148, 13954178, + 13985645, 13985651, 13992100, 14005135, 14005139, 14005140, 14005142, 14005185, 14009388, 14009390, 14038443, 14043167, 14043168, + 14098158, 14098190, 14098343, 14098347, 14098363, 14098372, 14098448, 14098510, 14099411, 14099421, 14111704, 14111988, 14112175, + 14112178, 14112222, 14112272, 14112281, 14112322, 14112332, 14112523, 14112534, 14112721, 14112870, 14113018, 14113027, 14113380, + 14113524, 14113544, 14113990, 14114153, 14114184, 14114266, 14114286, 14114342, 14114380, 14114399, 14114404, 14114436, 14114512, + 14114628, 14114673, 14114833, 14114886, 14114898, 14115278, 14115362, 14115372, 14115446, 14115500, 14115574, 14116384, 14116406, + 14116506, 14116797, 14116986, 14117002, 14117059, 14117070, 14117097, 14117135, 14117265, 14117322, 14117503, 14117521, 14117550, + 14118001, 14118142, 14118146, 14118158, 14118197, 14118368, 14118496, 14118533, 14118647, 14118701, 14118714, 14118937, 14119187, + 14119295, 14119413, 14119877, 14119901, 14119970, 14120278, 14120281, 14120282, 14120389, 14120437, 14120542, 14120552, 14120595, + 14121317, 14121366, 14121432, 14121455, 14121577, 14121580, 14121596, 14121601, 14121630, 14121638, 14121679, 14121684, 14121722, + 14121856, 14122382, 14122403, 14122483, 14122757, 14122763, 14122767, 14122824, 14122827, 14122833, 14122844, 14122853, 14122877, + 14123193, 14123200, 14123302, 14123407, 14124143, 14124163, 14124204, 14124296, 14124337, 14124352, 14124366, 14124368, 14124374, + 14124391, 14124991, 14125047, 14126549, 14126762, 14126770, 14126771, 14126782, 14126791, 14126823, 14126841, 14128740, 14128817, + 14128883, 14128944, 14129293, 14129452, 14129553, 14129573, 14129597, 14129617, 14129837, 14129898, 14129913, 14129915, 14129939, + 14130007, 14130296, 14130298, 14130316, 14130334, 14130355, 14130372, 14130378, 14130387, 14130388, 14130423, 14130440, 14130465, + 14130641, 14131066, 14131081, 14131115, 14131324, 14131407, 14131588, 14132136, 14132310, 14133768, 14133783, 14133786, 14133815, + 14133830, 14133981, 14134041, 14135528, 14135807, 14135812, 14135828, 14137560, 14137824, 14137853, 14138293, 14138307, 14138600, + 14138669, 14138825, 14138845, 14138888, 14139112, 14139816, 14140071, 14140079, 14140134, 14140318, 14140343, 14140597, 14140903, + 14140910, 14141386, 14141418, 14141461, 14141473, 14141478, 14141480, 14141489, 14141517, 14141541, 14141549, 14141628, 14141732, + 14141733, 14141780, 14141786, 14141800, 14142398, 14142742, 14142749, 14143111, 14143196, 14143745, 14143763, 14143828, 14143864, + 14144282, 14144473, 14145076, 14145285, 14145784, 14145908, 14145935, 14145988, 14146061, 14146091, 14146109, 14146166, 14146173, + 14146182, 14146184, 14146190, 14146207, 14146234, 14146754, 14146771, 14146832, 14147019, 14147204, 14147423, 14147483, 14147519, + 14147526, 14147554, 14147587, 14147607, 14147732, 14148521, 14148714, 14149592, 14149619, 14149789, 14149804, 14149812, 14149940, + 14149961, 14149966, 14149992, 14151350, 14151353, 14153570, 14154639, 14154760, 14154939, 14155463, 14155476, 14155742, 14155762, + 14155771, 14155906, 14155935, 14156644, 14156695, 14156824, 14157718, 14158023, 14158178, 14158179, 14158192, 14158225, 14158234, + 14160434, 14160448, 14160484, 14160591, 14160631, 14160678, 14161007, 14161029, 14161053, 14161067, 14161227, 14161241, 14161396, + 14161541, 14161546, 14161548, 14161549, 14161604, 14161618, 14161833, 14161976, 14161996, 14162133, 14162387, 14162615, 14162897, + 14163117, 14163286, 14163301, 14163309, 14163900, 14163967, 14164571, 14165063, 14165098, 14165182, 14165193, 14165728, 14165832, + 14166064, 14166499, 14166555, 14166559, 14166586, 14167320, 14167457, 14167507, 14167584, 14167707, 14167751, 14167792, 14167806, + 14167809, 14167830, 14167859, 14167868, 14167877, 14167979, 14167980, 14171368, 14171777, 14171890, 14171953, 14172042, 14172047, + 14172089, 14172170, 14172332, 14172456, 14172572, 14172639, 14173001, 14174547, 14174910, 14175087, 14175109, 14175111, 14175869, + 14175907, 14176246, 14176253, 14176343, 14176607, 14177124, 14177447, 14177503, 14177734, 14178614, 14178630, 14178820, 14178821, + 14178839, 14179074, 14179192, 14179237, 14179326, 14180592, 14180796, 14180851, 14181128, 14181137, 14181693, 14181698, 14181762, + 14181792, 14182209, 14182468, 14182581, 14183420, 14183543, 14183809, 14183872, 14184752, 14184842, 14185023, 14185412, 14185453, + 14185501, 14185653, 14185710, 14185798, 14186682, 14186733, 14187745, 14187752, 14187757, 14187821, 14188264, 14188460, 14188465, + 14188729, 14188778, 14189095, 14189171, 14191103, 14191217, 14191927, 14192000, 14192052, 14192242, 14192398, 14192827, 14192854, + 14193065, 14193073, 14193103, 14193143, 14193158, 14193482, 14193580, 14194305, 14194319, 14194412, 14194419, 14194484, 14194546, + 14194595, 14199795, 14199935, 14199983, 14199986, 14200044, 14200084, 14200111, 14200139, 14200182, 14200190, 14204347, 14204418, + 14204510, 14204511, 14204779, 14204797, 14204839, 14205356, 14205469, 14205477, 14205495, 14206818, 14206853, 14207065, 14207638, + 14207651, 14207666, 14207674, 14207769, 14208925, 14208929, 14208933, 14209218, 14209304, 14209336, 14209575, 14209637, 14209654, + 14209658, 14209756, 14209776, 14209798, 14209927, 14210583, 14210845, 14211495, 14211541, 14211907, 14211929, 14212341, 14212472, + 14212477, 14212690, 14213033, 14213418, 14213497, 14213514, 14213530, 14213652, 14213946, 14213953, 14213972, 14214116, 14214142, + 14214143, 14214366, 14214977, 14214987, 14215167, 14215207, 14215399, 14215416, 14215450, 14215516, 14217199, 14217219, 14217260, + 14217509, 14218325, 14218896, 14218935, 14219106, 14219113, 14219114, 14219119, 14219130, 14219957, 14219958, 14220038, 14220087, + 14220173, 14220219, 14220804, 14221341, 14222488, 14222500, 14222878, 14222894, 14222935, 14223004, 14223669, 14223764, 14227432, + 14227444, 14227445, 14227450, 14227692, 14227697, 14228042, 14228163, 14228181, 14228408, 14228421, 14228485, 14228486, 14228491, + 14228508, 14228587, 14228717, 14228762, 14228769, 14228773, 14228791, 14228792, 14228804, 14228903, 14229010, 14229018, 14229159, + 14231125, 14231300, 14231443, 14231448, 14232109, 14232208, 14232209, 14232381, 14232406, 14232802, 14232810, 14232864, 14232909, + 14233312, 14233318, 14233470, 14233715, 14233727, 14233759, 14235991, 14236061, 14236156, 14236267, 14236301, 14236377, 14236429, + 14236512, 14236650, 14236713, 14236756, 14236769, 14236824, 14236825, 14237021, 14237138, 14237249, 14237357, 14237367, 14237368, + 14237405, 14237422, 14237465, 14237979, 14238006, 14238047, 14238053, 14238054, 14238064, 14238210, 14241229, 14242371, 14242374, + 14242376, 14242495, 14242761, 14242796, 14242807, 14242848, 14242857, 14242860, 14242895, 14242902, 14242903, 14243742, 14243745, + 14243747, 14243828, 14243830, 14243898, 14243995, 14244554, 14244572, 14244661, 14244663, 14245554, 14245560, 14245614, 14245629, + 14245794, 14246045, 14246318, 14246687, 14246846, 14247108, 14247338, 14247826, 14247928, 14247954, 14247963, 14247985, 14248202, + 14248403, 14248732, 14249055, 14249278, 14249875, 14250216, 14250927, 14250928, 14251116, 14251143, 14251320, 14251343, 14251406, + 14251457, 14251569, 14251635, 14251874, 14251884, 14251898, 14252039, 14252092, 14252144, 14252246, 14252318, 14252972, 14253022, + 14255299, 14255310, 14255475, 14255516, 14255543, 14255556, 14255822, 14255995, 14256057, 14256504, 14256561, 14256571, 14256620, + 14258923, 14258985, 14259150, 14259607, 14259661, 14260250, 14260264, 14261054, 14261145, 14261150, 14261244, 14261398, 14261838, + 14261932, 14261969, 14262054, 14262427, 14262460, 14262621, 14263627, 14263682, 14267276, 14267288, 14267519, 14267528, 14267529, + 14267548, 14267622, 14267663, 14268607, 14268629, 14268630, 14268672, 14268685, 14268744, 14268750, 14268751, 14268755, 14269086, + 14269140, 14269168, 14269178, 14269347, 14269356, 14269543, 14269547, 14269776, 14269820, 14270276, 14270280, 14270283, 14270286, + 14270294, 14270310, 14270354, 14270419, 14270466, 14270486, 14270530, 14270550, 14270654, 14270738, 14270744, 14270751, 14270757, + 14270778, 14270784, 14270811, 14270841, 14270889, 14270897, 14270940, 14270943, 14270967, 14270972, 14271360, 14271401, 14271992, + 14271999, 14272079, 14272130, 14272289, 14272325, 14272717, 14272750, 14274773, 14274777, 14274997, 14275001, 14275127, 14275130, + 14275146, 14275323, 14275353, 14275424, 14275668, 14276086, 14276123, 14276168, 14276309, 14276370, 14276458, 14276520, 14277427, + 14277434, 14277438, 14277439, 14277514, 14277581, 14277637, 14278054, 14278075, 14278093, 14278096, 14278100, 14278142, 14278209, + 14278267, 14278302, 14278331, 14278429, 14278440, 14278687, 14278756, 14278811, 14279537, 14279693, 14279798, 14280053, 14280185, + 14280204, 14280267, 14280452, 14280583, 14280616, 14280703, 14281278, 14281362, 14281532, 14281603, 14281860, 14281911, 14282559, + 14283530, 14283550, 14283560, 14283564, 14283579, 14283595, 14283598, 14283613, 14283697, 14283746, 14284070, 14284218, 14284578, + 14284847, 14286487, 14286490, 14286613, 14286765, 14287334, 14287353, 14287608, 14287664, 14287752, 14287787, 14287796, 14287799, + 14287800, 14287802, 14287945, 14288161, 14288307, 14288451, 14288502, 14288846, 14288983, 14289001, 14289005, 14289016, 14289060, + 14289723, 14290173, 14290424, 14290457, 14290459, 14290506, 14290571, 14290766, 14290801, 14290962, 14291669, 14291708, 14291718, + 14291815, 14292939, 14292956, 14293247, 14293268, 14293297, 14293393, 14293441, 14293602, 14293740, 14293803, 14294518, 14294563, + 14294601, 14294625, 14295118, 14295131, 14295183, 14295205, 14295233, 14295243, 14295256, 14295279, 14295325, 14295328, 14295332, + 14295394, 14295420, 14295683, 14295688, 14295809, 14296174, 14296471, 14296495, 14296520, 14296596, 14296598, 14296727, 14296803, + 14296887, 14296913, 14296925, 14297069, 14297070, 14297260, 14297371, 14297452, 14297529, 14297538, 14297676, 14297759, 14297807, + 14297822, 14298409, 14298639, 14298896, 14298903, 14298932, 14299363, 14299554, 14300286, 14300298, 14300301, 14300495, 14300640, + 14300659, 14301074, 14301263, 14301438, 14301472, 14301639, 14301663, 14301665, 14301705, 14301827, 14302166, 14302216, 14302438, + 14302631, 14302782, 14302982, 14303337, 14303485, 14303928, 14304191, 14304195, 14304374, 14304577, 14304591, 14304640, 14305416, + 14305568, 14305668, 14305702, 14305917, 14305920, 14306074, 14306134, 14306454, 14307152, 14307386, 14307402, 14307413, 14307462, + 14307466, 14307547, 14307632, 14307804, 14307929, 14308045, 14308232, 14308345, 14308437, 14308448, 14309558, 14309627, 14309634, + 14309679, 14309714, 14309805, 14309832, 14309939, 14310154, 14310541, 14310658, 14310887, 14310987, 14311341, 14312039, 14312218, + 14312227, 14312251, 14312317, 14312327, 14312447, 14312532, 14313179, 14313565, 14313860, 14313880, 14313896, 14313985, 14314069, + 14314262, 14314503, 14314504, 14315064, 14315149, 14315158, 14315195, 14315406, 14315429, 14315534, 14315796, 14316030, 14316190, + 14316259, 14316600, 14316647, 14316861, 14317147, 14317635, 14317647, 14317657, 14317734, 14317812, 14317833, 14317844, 14317921, + 14317930, 14317937, 14317942, 14317945, 14317982, 14317988, 14318921, 14318922, 14319270, 14319315, 14319942, 14320162, 14320227, + 14320284, 14320753, 14320763, 14322722, 14322745, 14322786, 14322880, 14322990, 14323725, 14323744, 14324520, 14324584, 14324706, + 14324707, 14328007, 14328024, 14331549, 14331550, 14331679, 14332651, 14332653, 14332760, 14332764, 14332800, 14332809, 14333294, + 14333328, 14333336, 14333346, 14333551, 14333562, 14334351, 14334509, 14334540, 14334564, 14337693, 14340622, 14342084, 14342092, + 14342313, 14342321, 14342457, 14342462, 14343083, 14343087, 14343141, 14343154, 14343161, 14343551, 14343566, 14343577, 14343609, + 14343647, 14343803, 14343938, 14343962, 14344087, 14344928, 14344933, 14345088, 14345153, 14345161, 14345601, 14345744, 14345777, + 14346561, 14346614, 14346765, 14346782, 14346783, 14347126, 14347150, 14347420, 14347452, 14347570, 14347598, 14347626, 14347635, + 14347637, 14347725, 14347781, 14348725, 14348905, 14349352, 14349447, 14351917, 14352564, 14352616, 14352773, 14352923, 14353039, + 14354130, 14354236, 14354276, 14354277, 14354290, 14354327, 14354329, 14354337, 14354362, 14354420, 14354429, 14354456, 14354679, + 14354688, 14354691, 14354801, 14354829, 14354874, 14354902, 14354918, 14355487, 14355501, 14355611, 14355907, 14356212, 14356334, + 14356358, 14356391, 14356876, 14357035, 14357313, 14357658, 14357681, 14357718, 14357730, 14357799, 14357850, 14357987, 14358091, + 14358190, 14358267, 14358722, 14359057, 14359213, 14359358, 14359371, 14359465, 14359589, 14359597, 14359648, 14359654, 14360676, + 14360709, 14360796, 14361052, 14361484, 14361538, 14361631, 14361731, 14362244, 14362395, 14362428, 14362460, 14362496, 14362567, + 14362798, 14362805, 14362808, 14363004, 14363041, 14363050, 14363058, 14363068, 14363172, 14363510, 14363570, 14363734, 14364469, + 14364510, 14364518, 14365738, 14365742, 14365752, 14365867, 14365890, 14366055, 14366116, 14366211, 14366224, 14366233, 14366246, + 14366288, 14366309, 14366329, 14366429, 14366430, 14366443, 14366448, 14366472, 14366539, 14366589, 14366750, 14366765, 14366794, + 14366934, 14367112, 14367251, 14367272, 14367282, 14367466, 14367467, 14367468, 14367469, 14367477, 14367496, 14367530, 14367687, + 14367800, 14367833, 14367960, 14368004, 14368015, 14368024, 14368061, 14368069, 14368160, 14368167, 14368170, 14368194, 14368302, + 14368786, 14368797, 14368798, 14368810, 14368823, 14370205, 14370209, 14370844, 14370852, 14371635, 14371854, 14372502, 14372811, + 14375059, 14375196, 14375337, 14375353, 14376850, 14377162, 14377188, 14378134, 14378139, 14378142, 14378262, 14378276, 14378281, + 14378284, 14378300, 14378310, 14378366, 14378380, 14378433, 14380203, 14380358, 14380376, 14380432, 14380454, 14380479, 14380500, + 14380502, 14380511, 14380523, 14380526, 14380576, 14381101, 14381108, 14381116, 14381149, 14381187, 14381336, 14381643, 14381650, + 14384971, 14385017, 14385299, 14385327, 14385345, 14385346, 14385398, 14385409, 14386643, 14386717, 14387783, 14387792, 14387814, + 14387938, 14388060, 14388082, 14388164, 14388173, 14388184, 14388185, 14388190, 14388205, 14388211, 14388234, 14388244, 14388337, + 14388466, 14389756, 14389760, 14391505, 14391529, 14392389, 14392425, 14392444, 14392452, 14392466, 14392654, 14393420, 14393502, + 14393594, 14393595, 14393599, 14393671, 14394385, 14395110, 14395112, 14395122, 14395139, 14395232, 14395237, 14395341, 14395364, + 14395414, 14395416, 14397686, 14397758, 14397792, 14397865, 14398937, 14398955, 14398982, 14399110, 14399114, 14399131, 14399141, + 14399198, 14399200, 14399218, 14399248, 14399251, 14399276, 14399914, 14399919, 14399960, 14399989, 14399992, 14400040, 14400043, + 14400048, 14400097, 14400128, 14400131, 14402470, 14402526, 14402741, 14402794, 14402800, 14402805, 14402891, 14402926, 14404738, + 14404762, 14404988, 14405199, 14405204, 14405237, 14405348, 14406107, 14406164, 14406177, 14406665, 14406666, 14406887, 14406900, + 14406901, 14406982, 14406984, 14407108, 14407204, 14407309, 14407326, 14408372, 14408387, 14408522, 14408523, 14408534, 14408798, + 14408824, 14408858, 14410649, 14410860, 14410915, 14410986, 14411113, 14411190, 14411745, 14411764, 14412210, 14412275, 14412297, + 14412428, 14412434, 14412741, 14412857, 14412866, 14412869, 14413198, 14413199, 14413906, 14413934, 14414045, 14414168, 14414430, + 14414443, 14414710, 14415221, 14415252, 14415388, 14415429, 14415469, 14415513, 14415554, 14415608, 14415656, 14415660, 14415666, + 14415927, 14415975, 14416165, 14417518, 14418203, 14418277, 14418301, 14418317, 14418392, 14418533, 14418543, 14418546, 14419038, + 14419373, 14419466, 14419469, 14419481, 14419488, 14419499, 14419512, 14419521, 14419616, 14419697, 14419698, 14419805, 14419900, + 14419928, 14419929, 14419941, 14419942, 14419962, 14420023, 14420069, 14420082, 14420084, 14420086, 14420091, 14420094, 14420112, + 14420116, 14420129, 14420131, 14420180, 14420183, 14420193, 14420247, 14420253, 14420256, 14420275, 14420293, 14420303, 14420341, + 14420348, 14420480, 14420699, 14420814, 14420849, 14420851, 14420971, 14421014, 14421036, 14421045, 14421046, 14421169, 14421176, + 14421440, 14421858, 14421886, 14421920, 14422148, 14422321, 14422453, 14422593, 14422767, 14422856, 14423018, 14423133, 14423196, + 14423206, 14423268, 14423271, 14423515, 14423532, 14423583, 14423860, 14423881, 14423932, 14424014, 14424043, 14424067, 14424296, + 14424429, 14424452, 14424558, 14424562, 14424571, 14424585, 14424586, 14424589, 14424636, 14424685, 14424736, 14424750, 14424769, + 14425463, 14425546, 14425574, 14425575, 14425633, 14425767, 14425781, 14425849, 14425993, 14426028, 14426072, 14426221, 14426583, + 14427051, 14427197, 14427202, 14427208, 14427399, 14427441, 14427452, 14427473, 14427870, 14428817, 14428898, 14428920, 14429168, + 14429174, 14429180, 14429324, 14430071, 14430108, 14430138, 14430143, 14430231, 14430255, 14430816, 14430855, 14430886, 14430899, + 14430901, 14430902, 14430905, 14430924, 14430965, 14431006, 14431063, 14431282, 14431502, 14431545, 14431559, 14431720, 14431721, + 14432038, 14432172, 14432192, 14432201, 14432626, 14432636, 14432638, 14433023, 14433345, 14433362, 14433891, 14433944, 14434390, + 14434409, 14434414, 14434471, 14434649, 14436439, 14436511, 14436521, 14436616, 14436975, 14437026, 14437134, 14437167, 14437191, + 14437201, 14437204, 14437205, 14437268, 14437527, 14437534, 14437547, 14437565, 14437613, 14437807, 14437820, 14438118, 14438156, + 14438160, 14438162, 14438168, 14438215, 14438333, 14438365, 14438531, 14438538, 14438956, 14439014, 14439085, 14439105, 14439107, + 14439173, 14439501, 14439515, 14439776, 14439868, 14440295, 14440312, 14440363, 14440392, 14440418, 14440420, 14440431, 14440986, + 14440993, 14441010, 14441090, 14441114, 14441175, 14441182, 14441421, 14441424, 14441436, 14441455, 14442331, 14442410, 14442412, + 14442499, 14442590, 14443032, 14443124, 14443702, 14443783, 14443785, 14443880, 14443986, 14443987, 14443996, 14444016, 14444291, + 14444335, 14444348, 14444958, 14445106, 14445730, 14445744, 14445796, 14445857, 14445956, 14445960, 14449012, 14449107, 14449279, + 14449287, 14450086, 14450107, 14450169, 14450196, 14451369, 14451491, 14451664, 14451679, 14452080, 14452088, 14452158, 14452281, + 14452377, 14452464, 14454060, 14454100, 14454259, 14454284, 14455932, 14455937, 14456161, 14456169, 14456173, 14456215, 14456220, + 14456251, 14456262, 14456272, 14456374, 14456386, 14456389, 14456408, 14456422, 14456596, 14456654, 14456697, 14456714, 14457226, + 14457236, 14457251, 14457272, 14457294, 14457295, 14457323, 14457332, 14457341, 14457872, 14457925, 14458268, 14458361, 14462180, + 14462204, 14462241, 14462308, 14464172, 14464255, 14466306, 14466331, 14466411, 14466425, 14466470, 14466488, 14466497, 14466523, + 14466972, 14466984, 14467004, 14467023, 14468341, 14468496, 14469581, 14469604, 14469619, 14469675, 14470339, 14470341, 14470456, + 14470514, 14470520, 14470622, 14470887, 14470888, 14471412, 14471417, 14471591, 14471594, 14473086, 14473092, 14473096, 14473097, + 14473637, 14473642, 14475479, 14475496, 14475695, 14475733, 14476630, 14476676, 14476712, 14476812, 14477122, 14477145, 14477588, + 14477589, 14477594, 14477605, 14477607, 14477633, 14477742, 14477772, 14477777, 14478030, 14478043, 14478624, 14478666, 14479141, + 14479784, 14479865, 14479943, 14479950, 14479961, 14481636, 14481637, 14481722, 14481726, 14481758, 14481986, 14481997, 14482096, + 14482102, 14482118, 14482138, 14482420, 14482427, 14482457, 14482487, 14482508, 14482687, 14482693, 14482834, 14482845, 14483435, + 14483438, 14483442, 14483453, 14483471, 14483605, 14483834, 14483839, 14484322, 14484339, 14484341, 14484392, 14484412, 14484498, + 14484698, 14484752, 14484755, 14488867, 14488878, 14488894, 14488896, 14489287, 14489291, 14489510, 14489549, 14490029, 14490073, + 14490084, 14490085, 14490086, 14490088, 14490123, 14490128, 14490190, 14490213, 14490644, 14490652, 14490708, 14490728, 14490903, + 14490908, 14491415, 14491754, 14491757, 14491758, 14491805, 14492838, 14493628, 14494367, 14494372, 14494373, 14494376, 14494379, + 14494381, 14494646, 14494656, 14494661, 14494752, 14494868, 14494907, 14494921, 14494941, 14494953, 14494954, 14495034, 14495065, + 14495075, 14495076, 14495135, 14495154, 14495165, 14495173, 14495188, 14495192, 14495488, 14495493, 14495495, 14495501, 14495644, + 14495687, 14495688, 14495840, 14495967, 14495968, 14496394, 14496406, 14496408, 14496432, 14496500, 14496551, 14496604, 14496966, + 14497034, 14497038, 14497550, 14497568, 14497570, 14497668, 14497702, 14497706, 14497708, 14497820, 14497848, 14497895, 14497913, + 14497935, 14497937, 14498323, 14498354, 14498355, 14501002, 14501005, 14501526, 14502186, 14502208, 14502215, 14502229, 14502284, + 14502295, 14502315, 14502353, 14502605, 14502627, 14502635, 14502663, 14502758, 14502769, 14503020, 14503058, 14503061, 14503068, + 14503086, 14503134, 14503288, 14503395, 14503429, 14503435, 14503522, 14503525, 14504153, 14504162, 14504169, 14504173, 14504371, + 14504422, 14504432, 14504442, 14507145, 14507147, 14507476, 14507486, 14507489, 14507515, 14507520, 14507570, 14507702, 14507732, + 14508208, 14508212, 14509089, 14509103, 14509612, 14509623, 14511370, 14511373, 14511378, 14511379, 14511768, 14511773, 14512246, + 14512248, 14514087, 14514094, 14514100, 14514117, 14514130, 14514133, 14514156, 14514162, 14514508, 14514588, 14514908, 14514918, + 14514964, 14514971, 14514989, 14515007, 14515063, 14515165, 14515419, 14515421, 14515591, 14515593, 14515714, 14515716, 14515719, + 14515720, 14515748, 14515749, 14515854, 14515860, 14515903, 14515904, 14515951, 14515955, 14515993, 14515997, 14516253, 14516270, + 14516372, 14516412, 14516497, 14516503, 14517397, 14517439, 14519618, 14519619, 14519694, 14519701, 14519702, 14519714, 14519776, + 14519782, 14519803, 14519804, 14519955, 14519996, 14520020, 14520024, 14520043, 14520060, 14520061, 14520062, 14520115, 14520126, + 14520159, 14520172, 14520186, 14520190, 14520198, 14520212, 14520222, 14520227, 14520235, 14520497, 14520498, 14520746, 14520774, + 14520977, 14520982, 14520986, 14521011, 14521066, 14521069, 14522110, 14522112, 14522118, 14522165, 14522218, 14522219, 14522733, + 14522797, 14523118, 14523126, 14523830, 14523835, 14524242, 14524243, 14524259, 14524266, 14526070, 14526077, 14526083, 14526086, + 14526087, 14526099, 14526120, 14526126, 14526141, 14526211, 14526215, 14526221, 14526244, 14526255, 14526300, 14526321, 14526332, + 14526340, 14526344, 14526346, 14526356, 14526363, 14526380, 14526442, 14526463, 14527065, 14527080, 14527084, 14527176, 14527178, + 14527369, 14527370, 14527424, 14527431, 14527447, 14527451, 14527599, 14527626, 14527627, 14527633, 14527696, 14527715, 14527723, + 14527735, 14527839, 14528084, 14528085, 14528093, 14528124, 14528171, 14528614, 14528712, 14528723, 14528757, 14528758, 14528864, + 14528925, 14528961, 14528969, 14528986, 14528993, 14528997, 14529009, 14529012, 14529017, 14529021, 14529024, 14529026, 14529029, + 14529033, 14529037, 14529046, 14529100, 14529124, 14529557, 14530096, 14530149, 14531104, 14531141, 14531213, 14531235, 14531744, + 14531775, 14531956, 14531968, 14531999, 14532026, 14532066, 14532097, 14532696, 14532706, 14532729, 14532730, 14532739, 14532749, + 14532758, 14532838, 14532843, 14533032, 14533035, 14533049, 14533066, 14533070, 14533079, 14533136, 14533141, 14533267, 14533299, + 14533319, 14533321, 14533346, 14533372, 14533410, 14533430, 14533442, 14533526, 14533548, 14533722, 14533805, 14533836, 14533847, + 14533860, 14533861, 14533873, 14533878, 14533920, 14534184, 14534185, 14534191, 14534193, 14534233, 14534256, 14534343, 14534366, + 14534397, 14534426, 14535016, 14535017, 14535020, 14535028, 14535045, 14535083, 14535119, 14535180, 14535199, 14535394, 14535426, + 14535428, 14535456, 14535475, 14535634, 14535662, 14535688, 14535691, 14535692, 14535702, 14536479, 14536480, 14536489, 14536490, + 14536492, 14536493, 14538931, 14538950, 14539037, 14539038, 14539216, 14539309, 14539334, 14539344, 14539390, 14539420, 14539473, + 14539534, 14539537, 14539564, 14540149, 14540166, 14540656, 14540667, 14540769, 14540796, 14541039, 14541063, 14541069, 14541071, + 14541159, 14541165, 14541181, 14541201, 14541315, 14541323, 14541325, 14541328, 14541535, 14542840, 14542888, 14542906, 14542907, + 14543190, 14543248, 14543853, 14543908, 14544590, 14544596, 14544603, 14544616, 14544670, 14544671, 14544700, 14544710, 14544746, + 14544754, 14544827, 14544828, 14544837, 14544856, 14544877, 14544962, 14545025, 14545172, 14545204, 14545224, 14545226, 14545234, + 14545464, 14545483, 14545723, 14545743, 14545958, 14545994, 14546116, 14546131, 14546151, 14546163, 14546371, 14546380, 14546408, + 14546419, 14546448, 14546450, 14546509, 14546553, 14546560, 14546608, 14546630, 14546636, 14546678, 14546684, 14546867, 14546869, + 14547247, 14547249, 14547565, 14547577, 14547724, 14547850, 14547854, 14547861, 14547962, 14548000, 14550132, 14550221, 14552498, + 14552506, 14552667, 14552671, 14552813, 14552828, 14553470, 14553472, 14553476, 14554183, 14554188, 14554192, 14554225, 14554740, + 14554785, 14555988, 14556013, 14556021, 14556022, 14556083, 14556084, 14556089, 14556092, 14556100, 14556103, 14556108, 14556140, + 14556651, 14558534, 14559061, 14559072, 14559085, 14559733, 14559791, 14560016, 14560026, 14560028, 14560038, 14560040, 14560076, + 14560273, 14560275, 14560303, 14560306, 14560310, 14560322, 14560576, 14560577, 14560582, 14560595, 14560608, 14560622, 14560728, + 14560734, 14561795, 14561825, 14561840, 14562587, 14562623, 14562630, 14562645, 14563527, 14563541, 14563542, 14563549, 14563729, + 14563739, 14563740, 14563748, 14563749, 14563755, 14563766, 14563768, 14563774, 14563775, 14563894, 14563959, 14563963, 14563967, + 14564050, 14564054, 14564058, 14564075, 14564164, 14564730, 14564733, 14565457, 14565462, 14565943, 14566817, 14566822, 14588081, + 15278993, 15298860, 15299275, 15299420, 15299520, 15299715, 15299731, 15299757, 15301708, 15301850, 15301875, 15302455, 15302967, + 15304019, 15305121, 15305561, 15307407, 15307490, 15307868, 15308032, 15311107, 15311210, 15311599, 15316343, 15316528, 15316535, + 15317411, 15318069, 15318235, 15318288, 15318437, 15318758, 15319019, 15319366, 15319403, 15320313, 15321005, 15321511, 15321634, + 15321707, 15321890, 15322055, 15322136, 15323088, 15323182, 15323543, 15324636, 15327600, 15328789, 15328903, 15328961, 15329151, + 15330358, 15330441, 15330468, 15331215, 15331280, 15333764, 15333830, 15335397, 15336059, 15337247, 15337395, 15337630, 15339099, + 15340038, 15340971, 15341319, 15341479, 15341544, 15342783, 15343155, 15343302, 15343551, 15343809, 15344150, 15344169, 15344370, + 15344584, 15346218, 15346421, 15346604, 15346684, 15346714, 15346716, 15350123, 15350143, 15350966, 15351041, 15351346, 15351348, + 15352316, 15352341, 15353576, 15353802, 15354436, 15354503, 15354708, 15354744, 15355751, 15355938, 15356263, 15356464, 15357773, + 15357806, 15357836, 15357870, 15359242, 15359261, 15359409, 15359557, 15359701, 15359731, 15359846, 15359932, 15360348, 15360351, + 15360966, 15360968, 15360998, 15361018, 15363267, 15363312, 15363413, 15363420, 15363920, 15364070, 15364136, 15364150, 15364663, + 15364715, 15367310, 15367326, 15368095, 15368104, 15368537, 15368541, 15368874, 15368881, 15369797, 15369898, 15370883, 15370885, + 15371463, 15371516, 15372941, 15373029, 15373035, 15373039, 15373489, 15373548, 15374297, 15374326, 15374448, 15374596, 15375231, + 15375318, 15375776, 15375803, 15376049, 15376057, 15377278, 15377371, 15378036, 15378043, 15378052, 15378059, 15378164, 15378166, + 15379378, 15379430, 15379848, 15379863, 15379880, 15379890, 15381333, 15381472, 15381587, 15381594, 15382319, 15382335, 15382622, + 15382689, 15384884, 15384889, 15386453, 15386482, 15386506, 15386762, 15386943, 15387036, 15387461, 15387465, 15387752, 15387804, + 15388394, 15388486, 15388606, 15388617, 15389904, 15390109, 15390434, 15390437, 15390816, 15390866, 15393023, 15393050, 15393079, + 15393299, 15393785, 15393789, 15394171, 15394184, 15394223, 15394363, 15397304, 15397311, 15397367, 15397572, 15398540, 15398542, + 15398966, 15398984, 15400273, 15400276, 15400610, 15400638, 15401565, 15401650, 15404521, 15404620, 15406007, 15406017, 15406624, + 15406687, 15407958, 15407964, 15408278, 15408287, 15410615, 15410769, 15411104, 15411119, 15411326, 15411591, 15411833, 15411836, + 15413038, 15413046, 15413111, 15413148, 15413371, 15413374, 15413483, 15413499, 15415282, 15415416, 15417725, 15417802, 15417896, + 15417906, 15419558, 15419604, 15419797, 15419800, 15419980, 15420000, 15420016, 15420019, 15421514, 15421544, 15423424, 15423558, + 15423661, 15423673, 15424869, 15424873, 15425240, 15425382, 15425895, 15425897, 15426289, 15426372, 15427195, 15427225, 15427230, + 15427233, 15427289, 15427298, 15427993, 15427999, 15428176, 15428217, 15428227, 15428516, 15428529, 15428567, 15428784, 15429008, + 15429020, 15429026, 15429032, 15429281, 15430344, 15430346, 15430706, 15430735, 15430879, 15430885, 15431260, 15431365, 15432397, + 15432422, 15432649, 15432654, 15432804, 15432819, 15433923, 15433932, 15435272, 15435298, 15437041, 15437050, 15438105, 15438114, + 15440121, 15440253, 15441104, 15441282, 15442199, 15442584, 15443871, 15444142, 15444188, 15444408, 15444685, 15444690, 15445733, + 15445736, 15445863, 15445878, 15447031, 15447065, 15448796, 15448816, 15449403, 15449413, 15449587, 15449609, 15449711, 15449878, + 15449962, 15449964, 15450263, 15450405, 15450446, 15450450, 15451400, 15451408, 15451819, 15451857, 15452179, 15452192, 15452979, + 15453020, 15453357, 15453514, 15455431, 15455434, 15455761, 15455880, 15456762, 15456784, 15457983, 15459043, 15459439, 15459567, + 15459814, 15459822, 15460508, 15460591, 15461069, 15461082, 15462424, 15462426, 15462594, 15462656, 15462690, 15462696, 15463436, + 15463936, 15464266, 15465784, 15465839, 15465937, 15466610, 15466631, 15467021, 15467085, 15467103, 15467109, 15467756, 15467851, + 15468430, 15468503, 15468511, 15468652, 15469184, 15469200, 15469285, 15469458, 15469754, 15469759, 15470276, 15470283, 15470370, + 15470392, 15471545, 15471785, 15473261, 15473269, 15473454, 15473460, 15474422, 15474425, 15474922, 15475151, 15475640, 15475643, + 15476163, 15476405, 15476427, 15476439, 15477009, 15477179, 15477640, 15477649, 15479093, 15479107, 15480142, 15480151, 15480580, + 15480814, 15481022, 15481026, 15481035, 15481037, 15481562, 15481565, 15481590, 15481591, 15481741, 15481744, 15482067, 15482078, + 15482616, 15482683, 15486561, 15486564, 15486616, 15486617, 15486666, 15486668, 15486678, 15486680, 15487459, 15487500, 15488119, + 15488127, 15488401, 15488409, 15488440, 15488442, 15488965, 15488970, 15489694, 15489700, 15490595, 15490615, 15491720, 15491760, + 15492016, 15492020, 15492072, 15492087, 15492855, 15492857, 15493002, 15493004, 15493071, 15493074, 15493106, 15493108, 15493360, + 15493365, 15494319, 15494332, 15496258, 15496263, 15497235, 15497254, 15497321, 15497338, 15498352, 15498354, 15499365, 15499369, + 15501348, 15501354, 15502470, 15502478, 15503665, 15503673, 15504523, 15504537, 15504621, 15504628, 15504938, 15505080, 15506069, + 15506072, 15506112, 15506113, 15506426, 15506436, 15507433, 15507435, 15508130, 15508192, 15508250, 15508358, 15510418, 15510430, + 15510706, 15510712, 15511523, 15511526, 15511628, 15511629, 15512065, 15512071, 15512120, 15512121, 15513126, 15513199, 15513214, + 15513441, 15514260, 15514460, 15515518, 15515520, 15515699, 15515701, 15516480, 15516482, 15517627, 15517654, 15518075, 15518102, + 15519576, 15519578, 15520859, 15520864, 15521342, 15521351, 15521537, 15521553, 15521701, 15521707, 15522808, 15523015, 15523483, + 15523488, 15524388, 15524397, 15524703, 15524713, 15525341, 15525343, 15525349, 15525353, 15526412, 15526559, 15527127, 15527133, + 15527672, 15527675, 15528231, 15528248, 15528274, 15528307, 15529512, 15529522, 15529961, 15530071, 15530915, 15530926, 15531367, + 15531370, 15533472, 15533487, 15534560, 15534786, 15535306, 15535318, 15535392, 15535522, 15538116, 15539371, 15540337, 15540602, + 15541064, 15541071, 15541659, 15541666, 15541681, 15541719, 15541771, 15541777, 15542276, 15542282, 15542576, 15542585, 15542589, + 15542594, 15542886, 15542896, 15543880, 15543976, 15544196, 15546926, 15547006, 15547018, 15547117, 15547119, 15547436, 15547520, + 15547554, 15547587, 15547642, 15547644, 15549036, 15549039, 15549429, 15549448, 15550823, 15550828, 15551147, 15551381, 15551716, + 15551720, 15552150, 15552267, 15554087, 15554090, 15554449, 15554456, 15555207, 15555210, 15556032, 15556037, 15556177, 15556184, + 15557755, 15557761, 15558433, 15558443, 15559082, 15559107, 15560806, 15560890, 15561941, 15562075, 15562258, 15562260, 15563500, + 15563507, 15563620, 15563624, 15565974, 15565985, 15566159, 15566161, 15566675, 15567720, 15567772, 15697646, 15698252, 15699048, + 15699049, 15699308, 15699355, 15701033, 15701037, 15701139, 15701868, 15722361, 15723839, 15725644, 15726602, 15726621, 15726727, + 15726730, 15728420, 15728425, 15729973, 15729986, 15731110, 15731125, 15732349, 15732819, 15733345, 15733382, 15736966, 15741478, + 15742747, 15743712, 15744541, 15746902, 15748357, 15751438, 15751801, 15754322, 15755697, 15768595, 15768635, 15768636, 15771170, + 15771235, 15771418, 15771566, 15772511, 15772514, 15773217, 15773287, 15773693, 15775062, 15775162, 15775170, 15775628, 15775748, + 15777966, 15778518, 15780571, 15780590, 15781334, 15781414, 15783805, 15784103, 15784218, 15784222, 15784336, 15786288, 15786350, + 15786412, 15786880, 15787424, 15791418, 15791577, 15791945, 15792759, 15792904, 15792905, 15793375, 15799982, 15800147, 15800148, + 15800738, 15800739, 15801497, 15801498, 15803568, 15803571, 15805641, 15808771, 15809000, 15815539, 15815540, 15815571, 15816365, + 15816366, 15820482, 15820483, 15820930, 15820933, 15822783, 15822784, 15823306, 15823308, 15823485, 15823486, 15827101, 15827102, + 15830019, 15830020, 15830105, 15830106, 15835137, 15835138, 15838243, 15839723, 15840576, 15841503, 15841688, 15841690, 15847048, + 15847050, 15847745, 15848829, 15850375, 15855827, 15859288, 15859289, 15860023, 15860373, 15860606, 15860607, 15860828, 15860829, + 15861647, 15861648, 15861982, 15861983, 15863539, 15865475, 15865811, 15865812, 15865814, 15865819, 15865939, 15865940, 15866722, + 15866723, 15867794, 15869548, 15870297, 15870823, 15870956, 15870957, 15871190, 15871197, 15871254, 15871766, 15872132, 15873270, + 15875334, 15875634, 15875797, 15876025, 15876802, 15876803, 15876808, 15876810, 15876831, 15876833, 15876844, 15876845, 15876858, + 15876859, 15876865, 15876866, 15876996, 15877054, 15877147, 15878253, 15878396, 15878397, 15878409, 15878410, 15880251, 15880252, + 15880976, 15883223, 15883257, 15883258, 15883267, 15883268, 15883338, 15883366, 15883572, 15883573, 15883704, 15883705, 15883815, + 15883866, 15884708, 15885134, 15886585, 15886948, 15889015, 15889135, 15889263, 15889264, 15889297, 15890107, 15890836, 15890856, + 15891258, 15891259, 15891595, 15891596, 15898995, 15899413, 15900484, 15900485, 15900856, 15900857, 15900999, 15901784, 15902052, + 15902074, 15903287, 15904479, 15904560, 15904561, 15904756, 15904948, 15905428, 15905429, 15908728, 15908729, 15908732, 15908733, + 15908737, 15908739, 15911168, 15911169, 15911465, 15911466, 15912295, 15912378, 15912429, 15912435, 15912645, 15913367, 15915228, + 15915229, 15915232, 15915233, 15915473, 15915474, 15915509, 15915510, 15915885, 15915886, 15916207, 15916208, 15916906, 15916907, + 15917200, 15917202, 15917206, 15917207, 15921490, 15921491, 15921519, 15922789, 15923115, 15923117, 15924339, 15924525, 15924533, + 15926434, 15927196, 15928263, 15929673, 15929674, 15929698, 15929766, 15930272, 15941143, 15941944, 15941945, 15941949, 15941950, + 15941954, 15941955, 15941966, 15941967, 15942041, 15942242, 15943918, 15944225, 15944958, 15948423, 15948742, 15948893, 15948934, + 15948935, 15948952, 15948953, 15948974, 15948975, 15948980, 15948981, 15948984, 15948985, 15948995, 15948996, 15949061, 15949062, + 15950050, 15950051, 15950637, 15950638, 15950642, 15950643, 15950646, 15950647, 15950650, 15950651, 15950666, 15950667, 15950686, + 15950687, 15951694, 15951695, 15951941, 15951942, 15951970, 15951971, 15951974, 15951975, 15951978, 15951979, 15952040, 15954672, + 15956700, 15956815, 15957170, 15957963, 15965549, 15968309, 15969082, 15969120, 15970110, 15970111, 15970828, 15970854, 15971891, + 15971916, 15971980, 15972006, 15973526, 15973527, 15973835, 15974371, 15976265, 15977379, 15978362, 15978948, 15979197, 15980087, + 15980290, 15980299, 15981105, 15981106, 15981914, 15981915, 15982995, 15985005, 15985847, 15986020, 15986468, 15990277, 15990962, + 15991688, 15992374, 15992627, 15992966, 15994933, 15995140, 15995217, 15998964, 16006307, 16010481, 16011214, 16012893, 16013844, + 16015906, 17636688, 17637873, 17638275, 17638348, 17638487, 17638892, 17664726, 17667175, 17673330, 17673544, 17673816, 17681905, + 17685084, 17685085, 17687705, 17691885, 17692405, 17693311, 17694199, 17698519, 17699421, 17699575, 17699776, 17704976, 17705868, + 17707335, 17707490, 17710949, 17711356, 17711906, 17712444, 17720306, 17720567, 17723439, 17723538, 17729149, 17729172, 17730669, + 17735353, 17738506, 17739593, 17742978, 17746144, 17752865, 17759547, 17770240, 17774229, 17774250, 17778606, 17779105, 17782179, + 17783310, 17783420, 17784087, 17791119, 17792330, 17793195, 17795208, 17796208, 17798702, 17803925, 17806758, 17808553, 17811929, + 17815836, 17818217, 17853647, 17855162, 17855180, 17874661, 17881967, 17886031, 17886472, 17886499, 17892400, 17892586, 17893593, + 17918105, 17920208, 17923983, 17932312, 17940478, 17949572, 17950256, 17978577, 17978638, 17979243, 17981913, 17981914, 17986345, + 17995612, 17998455, 18001936, 18018601, 18019359, 18020832, 18020852, 18020857, 18021161, 18024791, 18028665, 18028982, 18029024, + 18029065, 18029402, 18029410, 18029412, 18029430, 18029461, 18029535, 18029709, 18029941, 18030109, 18030158, 18030174, 18030618, + 18030897, 18031010, 18031050, 18031102, 18031119, 18033407, 18033471, 18033519, 18034800, 18035522, 18035524, 18035558, 18035587, + 18035592, 18035611, 18035718, 18036283, 18037159, 18037177, 18037518, 18037756, 18037831, 18038107, 18038314, 18040137, 18040830, + 18042044, 18042107, 18042113, 18042989, 18044136, 18044214, 18045284, 18046457, 18046504, 18046619, 18046757, 18047186, 18047597, + 18047661, 18047776, 18047878, 18047880, 18048688, 18049264, 18050153, 18050586, 18050926, 18051022, 18052532, 18052575, 18052827, + 18053165, 18053676, 18053753, 18054135, 18055170, 18056994, 18057401, 18057693, 18057697, 18058403, 18058457, 18058779, 18058896, + 18059950, 18059951, 18061046, 18061130, 18061163, 18061330, 18062045, 18062047, 18062332, 18063045, 18063475, 18063531, 18063738, + 18064294, 18065075, 18065242, 18065980, 18066212, 18066443, 18066962, 18067060, 18067533, 18067720, 18067880, 18067908, 18067926, + 18069030, 18069287, 18069478, 18069486, 18070682, 18070696, 18070945, 18070960, 18071100, 18071247, 18071778, 18071877, 18071965, + 18072000, 18072080, 18072170, 18072197, 18072238, 18072391, 18072987, 18073243, 18074765, 18075302, 18075625, 18075780, 18075781, + 18075911, 18075915, 18075944, 18075961, 18078850, 18079649, 18082360, 18084867, 18084911, 18085324, 18085709, 18087962, 18087963, + 18088191, 18088242, 18088250, 18088280, 18088356, 18088559, 18088585, 18088685, 18088801, 18089141, 18089688, 18089823, 18090573, + 18092942, 18093321, 18093525, 18093792, 18094278, 18094280, 18094353, 18094818, 18095086, 18096830, 18096870, 18096945, 18099264, + 18099563, 18103567, 18105534, 18105712, 18105730, 18106676, 18106758, 18107898, 18108072, 18108109, 18108251, 18108364, 18108366, + 18108385, 18108608, 18109192, 18109630, 18109736, 18109886, 18110216, 18111914, 18117472, 18120015, 18121451, 18121461, 18123475, + 18126178, 18127068, 18127313, 18128050, 18128330, 18128335, 18128741, 18129173, 18129186, 18129274, 18129299, 18129598, 18129647, + 18130999, 18131052, 18132357, 18132384, 18132993, 18133129, 18133459, 18134121, 18134494, 18134563, 18134668, 18134725, 18135378, + 18135538, 18135637, 18136098, 18136421, 18136723, 18136850, 18138655, 18138798, 18139149, 18139266, 18139885, 18144618, 18145061, + 18145076, 18145167, 18145171, 18145489, 18145498, 18151530, 18154233, 18157193, 18157230, 18157352, 18157653, 18158227, 18159887, + 18160433, 18160599, 18163130, 18167158, 18167584, 18167696, 18168147, 18168194, 18169252, 18169257, 18169269, 18171907, 18171970, + 18173270, 18173746, 18173941, 18173950, 18174259, 18174963, 18176304, 18176339, 18176342, 18177237, 18177283, 18177395, 18177473, + 18177557, 18177648, 18178048, 18178068, 18179144, 18179923, 18180023, 18180031, 18182471, 18182554, 18183350, 18185302, 18186630, + 18189759, 18191550, 18191572, 18191690, 18191760, 18209428, 18209658, 18210069, 18210134, 18211447, 18211680, 18213658, 18214305, + 18226915, 18227231, 18233695, 18234036, 18234679, 18237160, 18237345, 18237354, 18237447, 18238159, 18238169, 18238305, 18238306, + 18238341, 18239452, 18239552, 18239591, 18242107, 18243775, 18247187, 18248062, 18248090, 18248152, 18248702, 18248948, 18251287, + 18253159, 18253172, 18253256, 18253494, 18253674, 18253702, 18253731, 18253737, 18254465, 18254579, 18254961, 18255157, 18255423, + 18255953, 18255964, 18255975, 18256059, 18256119, 18256175, 18256361, 18258481, 18258531, 18258617, 18258894, 18258898, 18258975, + 18259049, 18259278, 18259287, 18259310, 18260016, 18261458, 18261488, 18261623, 18262488, 18262528, 18262642, 18262749, 18262798, + 18262808, 18262813, 18262819, 18262827, 18262860, 18263274, 18265073, 18265373, 18274127, 18274713, 18274727, 18275088, 18275112, + 18275130, 18278505, 18278955, 18279067, 18279081, 18282620, 18282661, 18283406, 18283563, 18283848, 18284148, 18284248, 18284447, + 18284548, 18285101, 18285102, 18285296, 18285465, 18285587, 18286538, 18286732, 18286922, 18287028, 18287423, 18287435, 18288316, + 18288614, 18288684, 18289315, 18289388, 18289811, 18290157, 18291493, 18291622, 18291700, 18291765, 18292103, 18292104, 18292192, + 18292266, 18293383, 18293550, 18293680, 18293751, 18293811, 18294213, 18294759, 18299826, 18299990, 18300398, 18301246, 18301327, + 18303702, 18303813, 18304121, 18306402, 18306490, 18306738, 18307134, 18307258, 18307380, 18307382, 18307680, 18308694, 18308707, + 18308744, 18308789, 18308936, 18309470, 18309756, 18310124, 18310324, 18310679, 18313272, 18313276, 18313936, 18313942, 18314463, + 18314471, 18314489, 18314786, 18314944, 18314957, 18315430, 18315905, 18315975, 18316319, 18316622, 18316913, 18317424, 18317507, + 18317562, 18317614, 18318101, 18318833, 18319890, 18320642, 18320688, 18322258, 18322526, 18322711, 18323528, 18323546, 18324258, + 18326071, 18328517, 18329261, 18333428, 18334440, 18334468, 18340005, 18340701, 18341515, 18342104, 18343985, 18344306, 18344387, + 18344445, 18349782, 18354524, 18354532, 18354567, 18354647, 18355784, 18355800, 18355890, 18356093, 18356174, 18357105, 18358907, + 18359179, 18360540, 18360761, 18361109, 18362474, 18362701, 18363071, 18363333, 18363353, 18363359, 18363669, 18363849, 18364852, + 18365537, 18365642, 18370037, 18374101, 18374518, 18374703, 18378858, 18378979, 18379121, 18388650, 18392831, 18392906, 18393035, + 18393498, 18395705, 18396655, 18396696, 18399717, 18399721, 18399791, 18399885, 18400237, 18400318, 18401555, 18403896, 18403898, + 18403948, 18403950, 18404071, 18404074, 18404115, 18404117, 18404169, 18404170, 18404177, 18404214, 18408893, 18409021, 18409026, + 18409046, 18409296, 18409304, 18409332, 18409338, 18409342, 18409356, 18409383, 18409396, 18409511, 18409551, 18409567, 18409579, + 18409581, 18409638, 18409642, 18409660, 18409669, 18409705, 18409710, 18409737, 18410309, 18410336, 18410366, 18410382, 18410392, + 18410418, 18410426, 18410429, 18410929, 18410976, 18411158, 18414923, 18414966, 18414967, 18414971, 18414973, 18414996, 18415012, + 18415335, 18415343, 18415344, 18415372, 18415383, 18415401, 18415404, 18415409, 18415410, 18415439, 18415463, 18415730, 18415734, + 18415751, 18415752, 18415755, 18415762, 18415770, 18415789, 18415907, 18415911, 18415914, 18415915, 18415918, 18415919, 18415924, + 18415934, 18415935, 18415948, 18415951, 18415960, 18415962, 18415969, 18415974, 18415988, 18415996, 18416003, 18416007, 18416096, + 18416097, 18416098, 18416099, 18416110, 18416111, 18416121, 18417000, 18417004, 18417110, 18417111, 18417153, 18417223, 18417250, + 18417254, 18417255, 18417271, 18417276, 18417298, 18417306, 18418074, 18418081, 18419778, 18419803, 18419847, 18419867, 18419982, + 18420104, 18420138, 18420139, 18420149, 18420289, 18420295, 18421340, 18421341, 18421351, 18421354, 18421396, 18422027, 18422036, + 18422039, 18422146, 18422232, 18422238, 18422335, 18422473, 18422479, 18422569, 18422577, 18422932, 18423232, 18423233, 18423380, + 18423386, 18423801, 18423803, 18424005, 18424006, 18424106, 18424119, 18427918, 18428063, 18428188, 18428190, 18428341, 18428344, + 18428376, 18428378, 18428415, 18429089, 18429190, 18429191, 18429295, 18429301, 18429401, 18429408, 18429419, 18429425, 18429515, + 18429526, 18429763, 18430201, 18430203, 18430403, 18431180, 18431188, 18431554, 18431563, 18431586, 18431622, 18431858, 18431859, + 18432040, 18432050, 18432832, 18433010, 18433079, 18433119, 18459655, 18461356, 18461857, 18462173, 18463453, 18463531, 18479349, + 18479433, 18479437, 18479545, 18479547, 18479583, 18479584, 18479595, 18479615, 18479616, 18479622, 18481099, 18481103, 18481144, + 18481145, 18481150, 18481262, 18481457, 18481554, 18481769, 18485920, 18501825, 18501901, 18501914, 18503176, 18503321, 18503324, + 18503327, 18503748, 18503861, 18505085, 18505121, 18505795, 18505826, 18505827, 18505942, 18507352, 18507393, 18507395, 18507485, + 18507493, 18513155, 18513195, 18513450, 18513477, 18513488, 18513513, 18513532, 18513740, 18535188, 18535211, 18535223, 18535504, + 18535506, 18535511, 18535523, 18535526, 18535693, 18535863, 18535867, 18535950, 18535960, 18536171, 18536855, 18536862, 18536866, + 18536868, 18536869, 18537563, 18537686, 18537828, 18537830, 18539322, 18539428, 18539449, 18539565, 18539569, 18542957, 18549853, + 18549867, 18614667, 18614674, 18614685, 18614689, 18629129, 18629130, 18629263, 18629369, 18629370, 18629490, 18629492, 18630041, + 18630174, 18630284, 18640752, 18640754, 18640811, 18640900, 18640907, 18640943, 18640945, 18641080, 18641081, 18641157, 18641158, + 18641209, 18641401, 18642300, 18642313, 18642314, 18642405, 18642455, 18642533, 18642534, 18642593, 18642798, 18642799, 18644754, + 18690658, 18690699, 18692929, 18692939, 18698953, 18698954, 18699153, 18699427, 18699430, 18700378, 18700541, 18700543, 18700746, + 18700748, 18700766, 18700833, 18700834, 18700841, 18700842, 18701022, 18701473, 18701507, 18701522, 18701524, 18701573, 18701579, + 18701583, 18701911, 18702014, 18702025, 18702055, 18702094, 18702904, 18703319, 18703328, 18703920, 18704157, 18704427, 18704428, + 18705700, 18706080, 18707114, 18707117, 18707253, 18707486, 18707577, 18707592, 18707596, 18707946, 18707947, 18707956, 18707959, + 18707960, 18708017, 18708020, 18708754, 18708755, 18708938, 18709230, 18709237, 18709605, 18709606, 18709614, 18709621, 18709666, + 18709675, 18709742, 18709754, 18709760, 18709875, 18709881, 18709972, 18709987, 18710107, 18710153, 18710156, 18710159, 18710194, + 18710203, 18710456, 18710530, 18710672, 18722404, 18722407, 18722441, 18722444, 18722474, 18722476, 18722661, 18722684, 18722853, + 18722855, 18722857, 18722860, 18722964, 18722965, 18722991, 18723370, 18723413, 18723704, 18723707, 18723764, 18723766, 18723857, + 18723860, 18723916, 18723941, 18723981, 18735304, 18735677, 18737090, 18737199, 18737256, 18737264, 18737394, 18737400, 18738534, + 18738537, 18738632, 18738633, 18738690, 18738691, 18738755, 18739002, 18739014, 18739017, 18739026, 18739095, 18739204, 18739715, + 18739719, 18739774, 18739780, 18741326, 18741377, 18742319, 18742321, 18742401, 18743044, 18743049, 18743102, 18743109, 18743127, + 18743150, 18743153, 18744034, 18744038, 18744047, 18744053, 18744099, 18744100, 18744161, 18744178, 18744272, 18744440, 18744448, + 18744503, 18744507, 18744957, 18744963, 18745309, 18746182, 18746720, 18746766, 18746769, 18747055, 18747115, 18747509, 18748208, + 18748215, 18748216, 18748616, 18748632, 18748881, 18748930, 18749143, 18749153, 18749347, 18749597, 18749859, 18749862, 18749865, + 18750557, 18750566, 18750749, 18751180, 18751334, 18751358, 18751444, 18751733, 18751772, 18751777, 18751784, 18751800, 18751962, + 18751964, 18751967, 18751970, 18751974, 18751975, 18751977, 18752073, 18752085, 18752241, 18752245, 18752369, 18752782, 18752796, + 18753020, 18753025, 18753230, 18753299, 18753321, 18753444, 18754157, 18754468, 18754629, 18754632, 18755348, 18755580, 18755647, + 18756137, 18756196, 18757143, 18757175, 18757227, 18757294, 18757300, 18757544, 18757547, 18757917, 18757930, 18758219, 18758228, + 18758428, 18783923, 18784255, 18784257, 18784278, 18784506, 18784512, 18785925, 18785928, 18786059, 18787397, 18787805, 18787842, + 18840505, 18840540, 18842111, 18842255, 18842546, 18842613, 18843081, 18843086, 18843202, 18877846, 18877886, 18877938, 18877995, + 18878286, 18878288, 18878602, 18878604, 18878910, 18879022, 18879087, 18879201, 18879299, 18879376, 18879694, 18879819, 18879825, + 18879959, 18879963, 18880086, 18880208, 18880209, 18880253, 18880256, 18880438, 18880477, 18880478, 18880579, 18880588, 18880589, + 18880590, 18880674, 18880675, 18880688, 18880690, 18880698, 18880703, 18880710, 18880723, 18880777, 18880778, 18880818, 18880829, + 18880956, 18880957, 18880961, 18880971, 18881047, 18881049, 18881057, 18881059, 18881244, 18881250, 18881271, 18881309, 18881313, + 18881413, 18881417, 18881470, 18881473, 18881573, 18881588, 18881603, 18881665, 18881667, 18881833, 18881834, 18881875, 18881876, + 18881945, 18881946, 18882110, 18882201, 18882333, 18882334, 18882600, 18882620, 18882747, 18882795, 18882797, 18882825, 18882827, + 18882864, 18882874, 18883468, 18883469, 18883511, 18883515, 18883910, 18884107, 18884303, 18884455, 18884839, 18884840, 18884853, + 18885134, 18885240, 18885713, 18885715, 18885719, 18885720, 18890921, 18890923, 18890924, 18891002, 18891007, 18891013, 18891073, + 18891226, 18891230, 18891902, 18892071, 18916117, 18916500, 18917173, 18917229, 18917481, 18917487, 18917714, 18918454, 18918700, + 18919243, 18919244, 18919304, 18919307, 18919365, 18919372, 18919534, 18919859, 18919932, 18920320, 18934396, 18934399, 18934421, + 18934700, 18935088, 18935417, 18935420, 18935494, 18935501, 18936000, 18936103, 18936391, 18936459, 18936570, 18936578, 18936587, + 18936614, 18936649, 18936673, 18962602, 18962613, 18962625, 18962645, 18962662, 18962676, 18963370, 18963420, 18963833, 18963836, + 18963887, 18963911, 18964240, 18964303, 18964451, 18964454, 18964458, 18964500, 18964761, 18965395, 18965426, 18965875, 18965880, + 18965881, 18965931, 18965958, 18965959, 18965984, 18965985, 18967428, 18967463, 18967632, 18968583, 18968607, 18972151, 18972181, + 18972195, 18972196, 18972221, 18972231, 18972471, 18972549, 18972554, 18972611, 18972613, 18972651, 18972928, 18972929, 18972973, + 18972974, 18972992, 18972993, 18973042, 18973044, 18973048, 18973096, 18973098, 18973116, 18973218, 18973912, 18973952, 18973955, + 18974076, 18974093, 18974104, 18974117, 18974129, 18974206, 18974209, 18974419, 18974465, 18974797, 18974894, 18975162, 18975166, + 18975316, 18975374, 18975576, 18975578, 18976376, 18976386, 18976399, 18976405, 18977338, 18977345, 18977358, 18977728, 18977730, + 18977734, 18977736, 18978127, 18978129, 18978246, 18978494, 18978496, 18978826, 18978859, 18978866, 18978868, 18978873, 18978921, + 18978923, 18978933, 18978935, 18979157, 18979213, 18979247, 18979362, 18979627, 18979629, 18979659, 18979665, 18979666, 18979668, + 18979670, 18979746, 18979760, 18979767, 18979772, 18979782, 18979798, 18979820, 18979833, 18979855, 18979857, 18979955, 18979956, + 18980169, 18980439, 18980547, 18980548, 18980554, 18980591, 18980595, 18980691, 18980698, 18980831, 18980853, 18981626, 18981703, + 18981830, 18981937, 18981943, 18982171, 18982176, 18982186, 18982188, 18982196, 18982429, 18982431, 18982437, 18982740, 18982825, + 18982829, 18982867, 18982883, 18982926, 18983055, 18983244, 18983397, 18983401, 18983612, 18983619, 18983620, 18983932, 18983935, + 18983996, 18984329, 18984386, 18984405, 18984407, 18984413, 18984431, 18984501, 18984511, 18984763, 18984769, 18984913, 18984991, + 18985047, 18985161, 18985246, 18985248, 18985301, 18985304, 18985312, 18985520, 18985521, 18985726, 18985822, 18985850, 18986106, + 18986173, 18986174, 18986252, 18986266, 18986267, 18987017, 18987031, 18987048, 18987053, 18987081, 18987680, 18988159, 18988166, + 18988194, 18988205, 18988573, 18988712, 18988715, 18988857, 18988982, 18988984, 18988985, 18989012, 18989013, 18989018, 18989086, + 18989099, 18989125, 18989132, 18989165, 18989462, 18989464, 18989759, 18989899, 18989954, 18989955, 18990839, 18990846, 18990863, + 18990866, 18991105, 18991433, 18991452, 18991456, 18991462, 18991467, 18991469, 18991662, 18992464, 18992650, 18992774, 18992801, + 18992856, 18992860, 18992906, 18999657, 18999676, 18999686, 18999697, 18999881, 18999886, 19000091, 19000224, 19000241, 19000489, + 19000503, 19001195, 19001201, 19001347, 19001359, 19007968, 19007971, 19008121, 19011401, 19011569, 19011588, 19011656, 19011677, + 19011754, 19011759, 19012403, 19012416, 19012603, 19012613, 19012746, 19012747, 19014099, 19014206, 19020339, 19020428, 19020735, + 19020954, 19020959, 19021745, 19021748, 19021802, 19021803, 19022518, 19022523, 19157469, 19157470, 19157562, 19157597, 19157681, + 19157693, 19157727, 19157735, 19177628, 19177631, 19179127, 19180014, 19180478, 19180496, 19180576, 19180594, 19180601, 19180609, + 19182388, 19182390, 19182566, 19182598, 19183939, 19184062, 19184172, 19184613, 19187655, 19187674, 19187949, 19187959, 19189135, + 19190233, 19190353, 19190502, 19190504, 19190594, 19191003, 19191043, 19191046, 19191091, 19191098, 19191118, 19191122, 19191234, + 19191237, 19191305, 19191307, 19191407, 19191408, 19191453, 19191858, 19192015, 19192485, 19192487, 19192606, 19192607, 19192611, + 19192615, 19192896, 19192903, 19193680, 19193768, 19193789, 19193876, 19193879, 19194492, 19195385, 19200168, 19200172, 19200274, + 19200290, 19200578, 19200583, 19202205, 19202286, 19202388, 19202392, 19202403, 19202424, 19202450, 19202506, 19202509, 19203134, + 19203366, 19203572, 19203746, 19203752, 19204197, 19206989, 19207000, 19207077, 19207171, 19207271, 19207272, 19208337, 19208345, + 19208730, 19212689, 19212690, 19212744, 19212946, 19212947, 19213039, 19213045, 19213048, 19213301, 19213303, 19213574, 19213575, + 19213942, 19214581, 19214583, 19214681, 19214684, 19214905, 19215052, 19215418, 19216089, 19216095, 19218331, 19218601, 19218604, + 19218875, 19219205, 19220095, 19220100, 19221680, 19221683, 19221894, 19222484, 19222586, 19222590, 19224624, 19224626, 19225180, + 19226142, 19226145, 19226595, 19226609, 19226890, 19226896, 19226910, 19226911, 19226927, 19227005, 19227837, 19227907, 19227909, + 19228054, 19228056, 19228106, 19228107, 19228121, 19228123, 19228259, 19228261, 19228302, 19228304, 19229883, 19229890, 19230123, + 19233910, 19234320, 19234345, 19234424, 19234537, 19234956, 19235288, 19235308, 19237190, 19237199, 19237208, 19237233, 19239254, + 19239258, 19239376, 19239377, 19239389, 19239407, 19240001, 19240024, 19240499, 19240901, 19250124, 19250127, 19250230, 19250239, + 19252820, 19252824, 19252856, 19252859, 19253253, 19253258, 19253341, 19253648, 19253658, 19254248, 19254257, 19254261, 19254273, + 19255415, 19255483, 19255486, 19256056, 19256595, 19256596, 19257023, 19257421, 19257656, 19257794, 19257795, 19257825, 19257827, + 19257973, 19258287, 19258305, 19259424, 19259426, 19260016, 19260028, 19260034, 19260047, 19260053, 19260136, 19260185, 19260252, + 19260535, 19260539, 19263045, 19263046, 19263072, 19263297, 19263547, 19264542, 19264897, 19268898, 19268900, 19268986, 19268990, + 19269163, 19269421, 19269423, 19271598, 19271984, 19272062, 19272201, 19272203, 19272401, 19272409, 19272445, 19272449, 19281870, + 19281883, 19282504, 19285192, 19285575, 19285576, 19285624, 19301651, 19301652, 19301719, 19301721, 19302758, 19302769, 19302830, + 19302832, 19302846, 19304733, 19304737, 19304857, 19304863, 19304956, 19304961, 19305572, 19306684, 19306759, 19306763, 19306795, + 19306821, 19306844, 19306849, 19307117, 19307412, 19307778, 19307893, 19308083, 19308148, 19308304, 19314020, 19314021, 19314052, + 19314238, 19314253, 19315712, 19316333, 19317997, 19317999, 19318269, 19318271, 19318527, 19318529, 19318536, 19318578, 19318582, + 19318880, 19318881, 19319054, 19319328, 19319330, 19319376, 19324587, 19324593, 19324769, 19324771, 19324874, 19324883, 19324952, + 19324954, 19325006, 19325007, 19325008, 19325103, 19325184, 19325185, 19325391, 19325392, 19325399, 19325401, 19325570, 19325804, + 19326308, 19326329, 19326348, 19326618, 19326756, 19326757, 19326935, 19326944, 19326947, 19327176, 19327529, 19329583, 19329702, + 19329703, 19329745, 19329746, 19329754, 19329758, 19330909, 19330912, 19331006, 19331009, 19331094, 19331095, 19331200, 19331224, + 19331676, 19331678, 19331729, 19331732, 19332246, 19332827, 19332934, 19332935, 19333061, 19358286, 19358287, 19358310, 19360688, + 19360690, 19360794, 19360932, 19361096, 19362472, 19362473, 19362976, 19362979, 19363289, 19363291, 19363391, 19363719, 19364350, + 19364366, 19364392, 19364402, 19364936, 19364944, 19365015, 19365017, 19365059, 19365710, 19365714, 19365844, 19366349, 19366686, + 19366920, 19366924, 19367057, 19367062, 19367152, 19367158, 19367216, 19367219, 19367501, 19367504, 19368429, 19368434, 19368444, + 19368449, 19368461, 19368484, 19368500, 19368501, 19368676, 19368680, 19368783, 19368797, 19368801, 19368942, 19368948, 19368949, + 19368955, 19368966, 19369066, 19369075, 19369217, 19369229, 19369302, 19369310, 19369314, 19369341, 19369343, 19369598, 19369600, + 19369688, 19369690, 19369879, 19369904, 19369907, 19369914, 19369919, 19369924, 19370031, 19373906, 19373910, 19373914, 19373996, + 19374015, 19374165, 19374181, 19374182, 19374198, 19374266, 19374299, 19374800, 19375006, 19375010, 19375171, 19375174, 19375178, + 19375183, 19375189, 19375203, 19375209, 19375252, 19375259, 19375260, 19375719, 19375788, 19375789, 19376019, 19376020, 19376061, + 19385710, 19385787, 19389326, 19389328, 19389440, 19389442, 19389987, 19390185, 19390188, 19390245, 19390250, 19390286, 19390313, + 19390322, 19390345, 19390352, 19390586, 19390710, 19392042, 19392044, 19410405, 19410437, 19410449, 19410488, 19410489, 19410496, + 19410497, 19410510, 19410916, 19411000, 19411002, 19411204, 19411937, 19411939, 19411997, 19512944, 19513029, 19513189, 19513202, + 19513396, 19513538, 19513695, 19513945, 19513992, 19516059, 19516062, 19516075, 19516084, 19516968, 19517224, 19554953, 19558472, + 19609701, 19609719, 19609892, 19609947, 19610025, 19610494, 19610647, 19610652, 19610959, 19611209, 19611291, 19612269, 19612444, + 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285, 19613989, 19614239, 19614595, 19614600, + 19614607, 19615112, 19615114, 19615248, 19726042, 19726057, 19748242, 19748244, 19748269, 19748278, 19748377, 19750672, 19750695, + 19750702, 19750822, 19750833, 19751058, 19751064, 19751102, 19751108, 19751169, 19751172, 19751269, 19751854, 19751865, 19751878, + 19751936, 19752030, 19752349, 19755044, 19755063, 19755440, 19755881, 19756813, 19761538, 19761592, 19761593, 19761680, 19761685, + 19761995, 19762162, 19762167, 19763218, 19763430, 19763945, 19764280, 19764311, 19764333, 19764676, 19764744, 19765216, 19765374, + 19765479, 19767631, 19792072, 19792136, 19792139, 19793277, 19793318, 19793322, 19793528, 19793536, 19796241, 19796405, 19796407, + 19802815, 19802816, 19802881, 19804775, 19805218, 19805360, 19805515, 19807739, 19807796, 19808997, 19809396, 19809725, 19809990, + 19913194, 19913195, 19914726, 19914727, 19914735, 19914741, 19914769, 19914811, 19914876, 19914877, 19916067, 19917537, 19917540, + 19917991, 19918159, 19918171, 19918197, 19918202, 19918295, 19918302, 19918429, 19918432, 19918524, 19918639, 19918716, 19918797, + 19918799, 19918991, 19918992, 19919153, 19919287, 19919383, 19919514, 19919971, 19919995, 19920374, 19920778, 19920779, 19921528, + 19921531, 19921674, 19921675, 19921724, 19923306, 19923308, 19923480, 19923532, 19923534, 19923692, 19923702, 19923790, 19923814, + 19923818, 19923880, 19923884, 19924275, 19924279, 19924358, 19924367, 19924384, 19925554, 19925869, 19926582, 19926586, 19926619, + 19926620, 19926687, 19926859, 19926884, 19926887, 19926891, 19926959, 19927302, 19927422, 19928859, 19929054, 19932992, 19933015, + 19933313, 19933316, 19933328, 19933410, 19933760, 19933818, 19933876, 19934184, 19934490, 19934606, 19934621, 19934741, 19959354, + 19959578, 19960026, 19960122, 19962154, 19962536 +]; +export const PEG_CROSS_BLOCKS_LAST: u32 = 19962536; +export const PEG_CROSS_BLOCKS: u32[] = [ + 12974091, 12975421, 12978538, 12978615, 12978680, 12978911, 12979148, 12979149, 12979167, 12979171, 12979228, 12979230, 12979607, + 12983847, 12983871, 12983895, 12983897, 12983926, 12984038, 12984104, 12984170, 12984257, 12984310, 12984929, 12986590, 12986603, + 12986901, 12987603, 12990064, 12991358, 12991399, 12992193, 12992519, 12993217, 12993281, 12998537, 12998539, 12998546, 12998550, + 12998551, 12998553, 12999530, 12999585, 12999767, 12999776, 12999777, 12999779, 12999817, 12999840, 13000158, 13000196, 13000305, + 13000309, 13000334, 13000347, 13000356, 13000377, 13000577, 13000587, 13001082, 13001089, 13001396, 13001414, 13001894, 13001913, + 13001956, 13002009, 13002735, 13002738, 13003196, 13003198, 13004037, 13004045, 13004360, 13004364, 13004638, 13004646, 13004655, + 13004657, 13004817, 13004839, 13004843, 13004883, 13005075, 13005103, 13005107, 13005109, 13005372, 13005380, 13005673, 13005715, + 13005730, 13005733, 13005944, 13005946, 13006200, 13006202, 13006203, 13006321, 13006487, 13006488, 13006499, 13006546, 13006708, + 13006709, 13006980, 13007010, 13007245, 13007246, 13007274, 13007275, 13007509, 13007525, 13007574, 13007607, 13007780, 13007798, + 13007859, 13007898, 13008063, 13008065, 13008117, 13008191, 13008375, 13008387, 13008617, 13008671, 13008712, 13008736, 13008895, + 13008901, 13008906, 13008912, 13009163, 13009169, 13009190, 13009193, 13009199, 13009203, 13009381, 13009423, 13009669, 13009671, + 13009676, 13009679, 13009681, 13009687, 13009958, 13009972, 13009973, 13010009, 13010222, 13010231, 13010492, 13010556, 13010779, + 13014211, 13016266, 13018933, 13019023, 13019754, 13020690, 13020782, 13022699, 13022701, 13022825, 13023185, 13023247, 13023922, + 13025396, 13025666, 13026184, 13026256, 13026638, 13026640, 13027512, 13029384, 13030010, 13030107, 13030123, 13030393, 13030528, + 13031004, 13031259, 13032695, 13032731, 13032942, 13033010, 13033033, 13033210, 13034517, 13034543, 13035839, 13035922, 13035929, + 13036165, 13036689, 13036884, 13036897, 13036926, 13037135, 13037615, 13037642, 13038069, 13038108, 13038138, 13038145, 13038184, + 13039743, 13043682, 13043699, 13044756, 13044762, 13044770, 13044955, 13045801, 13046502, 13051141, 13051348, 13056233, 13056234, + 13057499, 13057501, 13057527, 13057595, 13058927, 13059717, 13059983, 13060079, 13060086, 13060118, 13060119, 13060121, 13060123, + 13060132, 13060160, 13060198, 13060449, 13060450, 13060479, 13060489, 13060492, 13060680, 13060716, 13060796, 13060802, 13060842, + 13060960, 13062059, 13062295, 13062299, 13062306, 13062319, 13062333, 13062352, 13062366, 13063788, 13063838, 13063861, 13063878, + 13075770, 13075888, 13076058, 13076195, 13076316, 13076435, 13076636, 13076662, 13076679, 13076703, 13076890, 13076891, 13076899, + 13076947, 13076964, 13076972, 13077164, 13077246, 13077426, 13077429, 13077495, 13077503, 13077730, 13077736, 13078272, 13078287, + 13078449, 13078457, 13078466, 13078470, 13078482, 13078487, 13078488, 13078519, 13078541, 13078561, 13078796, 13078810, 13078813, + 13078834, 13079299, 13079303, 13079572, 13079587, 13079588, 13079596, 13079620, 13079642, 13079648, 13079683, 13079724, 13079755, + 13079814, 13079885, 13079887, 13079895, 13079899, 13079919, 13079920, 13079941, 13080074, 13080179, 13080198, 13080229, 13080352, + 13080375, 13080400, 13080408, 13080634, 13080637, 13080648, 13080660, 13080672, 13080677, 13080678, 13080680, 13080768, 13080770, + 13080887, 13080888, 13080932, 13080934, 13080937, 13080958, 13080977, 13080990, 13080996, 13080999, 13081011, 13081057, 13081145, + 13081209, 13081632, 13081635, 13081700, 13081721, 13081750, 13081754, 13081766, 13081895, 13081963, 13081977, 13081992, 13081994, + 13082000, 13082006, 13082094, 13082163, 13082230, 13082282, 13082300, 13082301, 13082504, 13082507, 13082510, 13082555, 13082863, + 13082876, 13082878, 13082888, 13082969, 13083844, 13084930, 13084956, 13084984, 13085212, 13085233, 13085236, 13085311, 13085508, + 13085645, 13085877, 13086288, 13086337, 13086338, 13086356, 13086362, 13086369, 13086376, 13086400, 13086422, 13086440, 13086459, + 13086461, 13087211, 13087217, 13087221, 13087225, 13087231, 13087377, 13087393, 13087405, 13087410, 13087411, 13087527, 13088104, + 13088272, 13093705, 13093899, 13093903, 13093921, 13093932, 13093971, 13093975, 13099188, 13099189, 13099353, 13099362, 13099414, + 13099461, 13099465, 13099710, 13099714, 13099747, 13100289, 13100319, 13100358, 13100371, 13100898, 13100923, 13102868, 13102939, + 13107071, 13107096, 13110581, 13110588, 13110634, 13110706, 13110819, 13110844, 13111074, 13113042, 13113109, 13113110, 13113423, + 13113442, 13113448, 13113452, 13113453, 13113553, 13114481, 13114574, 13115940, 13115946, 13115955, 13115972, 13115989, 13115990, + 13117862, 13118077, 13118145, 13118291, 13118320, 13118321, 13118355, 13118356, 13118402, 13118413, 13118423, 13118428, 13118436, + 13118467, 13121070, 13121089, 13121099, 13121128, 13121178, 13121244, 13121307, 13121310, 13122225, 13122395, 13122407, 13122455, + 13122874, 13122951, 13122985, 13124397, 13124895, 13129783, 13129786, 13129854, 13129981, 13129991, 13130001, 13130094, 13130178, + 13131625, 13131662, 13131722, 13131929, 13137125, 13137568, 13138520, 13138647, 13138700, 13138778, 13138782, 13138813, 13138856, + 13138858, 13139212, 13139273, 13139367, 13139407, 13139408, 13139410, 13139609, 13140003, 13140015, 13140024, 13140027, 13140327, + 13140447, 13140687, 13141148, 13141156, 13141160, 13141165, 13141195, 13141863, 13141869, 13141870, 13141940, 13142135, 13143729, + 13143754, 13143760, 13143762, 13143763, 13143816, 13144293, 13144300, 13144362, 13144364, 13144774, 13144823, 13145005, 13145190, + 13145194, 13145195, 13145198, 13145206, 13145220, 13145747, 13146082, 13146089, 13147016, 13147028, 13147044, 13147045, 13148291, + 13148316, 13149112, 13150275, 13150279, 13150280, 13151314, 13151333, 13151356, 13151443, 13151450, 13151451, 13151460, 13151462, + 13151595, 13151598, 13151696, 13151700, 13151863, 13151867, 13152103, 13152260, 13152269, 13153306, 13153325, 13155620, 13156284, + 13156748, 13156781, 13157326, 13158957, 13159234, 13159235, 13159247, 13159248, 13159486, 13159495, 13161064, 13161086, 13161299, + 13161376, 13161392, 13161406, 13161416, 13161423, 13161487, 13161550, 13161611, 13161634, 13161636, 13162200, 13162208, 13162329, + 13162331, 13163395, 13163536, 13163565, 13163567, 13163596, 13163597, 13163604, 13163670, 13163995, 13164187, 13164189, 13164192, + 13164658, 13164746, 13165237, 13165391, 13165408, 13165727, 13165897, 13165996, 13166015, 13166072, 13166219, 13166222, 13166242, + 13166250, 13166251, 13166258, 13166259, 13166283, 13166287, 13166319, 13166381, 13166437, 13167205, 13167549, 13167575, 13167591, + 13167742, 13167972, 13168519, 13168524, 13169110, 13171988, 13175038, 13175053, 13175058, 13175064, 13175069, 13175146, 13175397, + 13175452, 13175497, 13175514, 13175520, 13175609, 13177587, 13177589, 13177597, 13177615, 13177647, 13177659, 13177660, 13177714, + 13177758, 13178360, 13178584, 13178652, 13179149, 13179177, 13179251, 13179252, 13179253, 13179274, 13179308, 13179337, 13179353, + 13179400, 13180079, 13180083, 13180101, 13180102, 13180117, 13180145, 13180189, 13180216, 13180664, 13180692, 13180713, 13180715, + 13180730, 13180758, 13180833, 13180888, 13180897, 13180909, 13181023, 13181155, 13181755, 13181777, 13181802, 13181820, 13182646, + 13182655, 13183890, 13183894, 13183955, 13183956, 13183957, 13184012, 13184973, 13184974, 13185191, 13185260, 13185321, 13185384, + 13185495, 13185703, 13185732, 13185850, 13187086, 13187116, 13187178, 13187233, 13188042, 13189001, 13189010, 13189082, 13191072, + 13191091, 13191099, 13191106, 13191522, 13191635, 13191637, 13191644, 13192232, 13192596, 13192599, 13192604, 13193031, 13193802, + 13194379, 13194410, 13194615, 13194717, 13194719, 13194824, 13196049, 13196067, 13196141, 13196190, 13196445, 13196459, 13196460, + 13198164, 13198273, 13198316, 13198557, 13198899, 13198902, 13198907, 13198909, 13198925, 13199052, 13199074, 13199086, 13199099, + 13199116, 13199129, 13199131, 13199260, 13199361, 13199363, 13200193, 13200194, 13200216, 13200219, 13200224, 13201208, 13201289, + 13201290, 13201321, 13201322, 13206138, 13206229, 13206338, 13206947, 13207266, 13207395, 13207435, 13207444, 13207445, 13207578, + 13207663, 13208184, 13211822, 13211897, 13211967, 13213641, 13214042, 13214163, 13214206, 13215008, 13215982, 13217044, 13217061, + 13217222, 13217341, 13217478, 13217783, 13217784, 13217810, 13217953, 13217970, 13217973, 13218020, 13218050, 13218279, 13218810, + 13218815, 13218816, 13218909, 13218949, 13218953, 13218954, 13225077, 13225299, 13226246, 13226559, 13226732, 13226957, 13227000, + 13229110, 13229499, 13229747, 13232674, 13232699, 13232717, 13233025, 13234172, 13234178, 13234264, 13234554, 13236246, 13236247, + 13236250, 13236319, 13237109, 13237552, 13244459, 13244462, 13245028, 13245032, 13245040, 13245162, 13245172, 13245175, 13245180, + 13245275, 13245545, 13245546, 13246387, 13246388, 13246647, 13246651, 13246920, 13246926, 13246980, 13246983, 13247415, 13247416, + 13247678, 13247695, 13247947, 13247952, 13248208, 13248209, 13248470, 13248473, 13249273, 13249276, 13249292, 13249294, 13249543, + 13249561, 13249800, 13249818, 13249822, 13250039, 13250057, 13250059, 13256813, 13256815, 13257386, 13257389, 13258210, 13258214, + 13259590, 13259594, 13259863, 13259865, 13260039, 13260056, 13260062, 13260063, 13260114, 13260126, 13260381, 13260386, 13260388, + 13260389, 13260884, 13260886, 13261140, 13261142, 13261145, 13261155, 13261156, 13261186, 13261206, 13261363, 13261373, 13261399, + 13262381, 13262382, 13262425, 13262428, 13262440, 13262442, 13262455, 13262462, 13262465, 13262469, 13262553, 13262554, 13262569, + 13262592, 13262593, 13262713, 13262719, 13262729, 13262748, 13262896, 13262899, 13262913, 13263080, 13263772, 13263871, 13264127, + 13264135, 13264139, 13264149, 13272546, 13272560, 13272905, 13272934, 13273058, 13273061, 13273064, 13273373, 13273436, 13273458, + 13273503, 13273513, 13273717, 13273719, 13274023, 13274030, 13274057, 13274064, 13274105, 13274148, 13274189, 13274198, 13274217, + 13274220, 13274242, 13274248, 13335750, 13335755, 13335869, 13336244, 13336323, 13336461, 13336505, 13336560, 13336618, 13336695, + 13336714, 13336777, 13336959, 13337532, 13337559, 13337935, 13337937, 13337959, 13340698, 13340781, 13340820, 13340947, 13341028, + 13341076, 13341108, 13341147, 13341156, 13341366, 13341373, 13342047, 13342121, 13342224, 13342548, 13376585, 13376710, 13376778, + 13378143, 13378793, 13378816, 13378829, 13379464, 13434006, 13434877, 13435565, 13435971, 13436006, 13436018, 13436025, 13436035, + 13436049, 13436107, 13437998, 13438644, 13438667, 13440517, 13442086, 13442913, 13443210, 13443231, 13443232, 13443239, 13443256, + 13443258, 13443270, 13443271, 13444653, 13444660, 13444712, 13446459, 13448008, 13449065, 13449128, 13449167, 13449303, 13449313, + 13449493, 13449495, 13449505, 13449506, 13449551, 13449634, 13449650, 13449705, 13449790, 13449821, 13449841, 13449855, 13449875, + 13449913, 13450052, 13450154, 13450187, 13450472, 13450507, 13450522, 13451061, 13451131, 13451155, 13451468, 13451543, 13451544, + 13451550, 13451555, 13451564, 13451596, 13451598, 13451649, 13451671, 13451675, 13455280, 13455282, 13455557, 13455600, 13455618, + 13455860, 13455891, 13455896, 13455911, 13461738, 13462027, 13462049, 13462066, 13462165, 13463379, 13463381, 13464408, 13466451, + 13467419, 13467691, 13468508, 13468675, 13468784, 13469000, 13469007, 13469012, 13469034, 13470634, 13470770, 13471747, 13474744, + 13474934, 13475341, 13475377, 13475394, 13475519, 13475523, 13475746, 13476174, 13476209, 13476325, 13476418, 13476419, 13479133, + 13479136, 13479138, 13479152, 13479196, 13479242, 13479941, 13480370, 13480372, 13480449, 13480647, 13480648, 13480717, 13481304, + 13481717, 13481988, 13482011, 13482102, 13483897, 13483977, 13483982, 13483998, 13484811, 13484846, 13484847, 13486887, 13486969, + 13488473, 13488482, 13489574, 13489977, 13490465, 13490505, 13490507, 13490517, 13490518, 13491374, 13494424, 13494752, 13494754, + 13495520, 13495854, 13497794, 13497797, 13497803, 13497820, 13497844, 13497868, 13498035, 13503686, 13503690, 13503704, 13503709, + 13503751, 13503763, 13503770, 13503813, 13503910, 13508461, 13508666, 13508680, 13508728, 13508759, 13508780, 13510297, 13510507, + 13510508, 13510514, 13510516, 13510518, 13510520, 13510556, 13510590, 13510603, 13510605, 13510610, 13510727, 13511700, 13511890, + 13511907, 13512045, 13512048, 13512304, 13512305, 13512359, 13512365, 13514281, 13514282, 13514705, 13514719, 13514721, 13514734, + 13515060, 13516318, 13516526, 13516569, 13517036, 13517567, 13518970, 13519495, 13519497, 13519756, 13521882, 13522133, 13523828, + 13523847, 13523862, 13523885, 13523912, 13523967, 13523969, 13524379, 13524397, 13525787, 13525872, 13525873, 13528534, 13528544, + 13528546, 13528558, 13528574, 13528579, 13528967, 13529028, 13531631, 13531875, 13531910, 13531954, 13531961, 13531990, 13532016, + 13532023, 13532081, 13532126, 13532137, 13532138, 13532143, 13532151, 13532161, 13532176, 13532179, 13532198, 13532239, 13532920, + 13532929, 13532946, 13533454, 13533933, 13535490, 13535493, 13535494, 13535499, 13538211, 13538232, 13538866, 13538895, 13539218, + 13539249, 13539673, 13539923, 13539946, 13539951, 13540826, 13540841, 13541140, 13541325, 13541849, 13541933, 13541958, 13541980, + 13541997, 13542002, 13542077, 13542086, 13542175, 13542179, 13542232, 13542254, 13543917, 13544624, 13545832, 13545837, 13545858, + 13546411, 13547018, 13547059, 13547095, 13547595, 13547630, 13548233, 13548387, 13550252, 13550987, 13551029, 13551119, 13551280, + 13551291, 13552190, 13552241, 13552260, 13552307, 13552675, 13552678, 13552681, 13552684, 13552688, 13552701, 13552704, 13552750, + 13552752, 13552754, 13552943, 13553661, 13553662, 13553676, 13553677, 13553853, 13554976, 13555095, 13555457, 13557196, 13557954, + 13558105, 13558112, 13558113, 13558114, 13558116, 13558121, 13558735, 13558752, 13558776, 13559078, 13559084, 13559255, 13559291, + 13559303, 13559410, 13559415, 13559416, 13559425, 13559561, 13559568, 13559602, 13559647, 13559656, 13559658, 13559791, 13559882, + 13560317, 13560318, 13560937, 13564634, 13564681, 13564697, 13564713, 13564837, 13564852, 13564859, 13564871, 13564879, 13564889, + 13564891, 13566648, 13568113, 13568302, 13568342, 13568345, 13568357, 13568484, 13568492, 13568495, 13568667, 13570256, 13570277, + 13570284, 13570300, 13570316, 13570318, 13570944, 13570952, 13571175, 13572652, 13572673, 13572674, 13572854, 13572856, 13572884, + 13572895, 13572918, 13572923, 13572958, 13572969, 13573024, 13573028, 13573096, 13573097, 13573405, 13573522, 13573523, 13573686, + 13573687, 13573693, 13573695, 13574201, 13574213, 13574289, 13574294, 13575376, 13575377, 13576614, 13576620, 13576635, 13576661, + 13576663, 13577153, 13577969, 13578897, 13578901, 13578940, 13578947, 13579158, 13579160, 13579235, 13579351, 13579385, 13579447, + 13579490, 13579530, 13579565, 13579572, 13579588, 13579894, 13579900, 13579911, 13579912, 13579914, 13579918, 13579942, 13580072, + 13580087, 13580260, 13580280, 13581920, 13582005, 13582060, 13582068, 13582069, 13582090, 13582096, 13582336, 13582467, 13582468, + 13582749, 13583449, 13583933, 13584045, 13584069, 13584076, 13584080, 13584082, 13584102, 13584104, 13584107, 13584126, 13584153, + 13584183, 13584184, 13584192, 13584195, 13584208, 13584209, 13584211, 13584243, 13584286, 13584294, 13584296, 13584485, 13584486, + 13585001, 13585594, 13585602, 13585607, 13585610, 13585641, 13585748, 13585775, 13585976, 13585992, 13586067, 13587038, 13587054, + 13587160, 13589367, 13589405, 13589454, 13589471, 13589485, 13589486, 13589512, 13589515, 13589527, 13589532, 13589574, 13589656, + 13589661, 13589867, 13590103, 13592391, 13594358, 13595502, 13595599, 13595883, 13596659, 13596666, 13596668, 13596671, 13598662, + 13599510, 13599974, 13600003, 13600116, 13600221, 13600229, 13600230, 13600343, 13600344, 13600519, 13602309, 13602377, 13602479, + 13602483, 13602486, 13602488, 13602489, 13602490, 13602493, 13602978, 13603574, 13603586, 13603652, 13603887, 13604255, 13605773, + 13605779, 13606896, 13607198, 13607202, 13607203, 13608420, 13608519, 13608665, 13608681, 13608968, 13610066, 13611161, 13614876, + 13614927, 13614991, 13614998, 13615404, 13617630, 13618342, 13621035, 13622147, 13623486, 13623495, 13623499, 13623577, 13623590, + 13623764, 13624270, 13624355, 13624363, 13624366, 13624383, 13624517, 13625958, 13625960, 13625982, 13626112, 13626125, 13626166, + 13626170, 13626212, 13628785, 13628854, 13628864, 13628865, 13629661, 13629662, 13629784, 13629785, 13629852, 13630011, 13630129, + 13630230, 13630429, 13630583, 13630683, 13630775, 13630780, 13630796, 13631292, 13631331, 13640082, 13640087, 13640104, 13640132, + 13640218, 13640556, 13640587, 13640615, 13641928, 13641929, 13642057, 13642071, 13642137, 13642155, 13642160, 13642167, 13642168, + 13642207, 13642212, 13642215, 13642216, 13642265, 13642911, 13644410, 13646116, 13646163, 13647476, 13647732, 13647733, 13647905, + 13657931, 13657936, 13658078, 13658083, 13658088, 13658106, 13666892, 13666908, 13667064, 13667842, 13671879, 13672266, 13685409, + 13685501, 13687313, 13687327, 13688700, 13688718, 13688728, 13688770, 13688773, 13689077, 13693941, 13693995, 13694143, 13694177, + 13703288, 13703407, 13704796, 13704804, 13704850, 13704871, 13710244, 13710333, 13710534, 13710568, 13717643, 13717686, 13720847, + 13720981, 13721138, 13721150, 13721209, 13721255, 13721263, 13721265, 13721279, 13721280, 13722372, 13722456, 13722731, 13722854, + 13722860, 13722861, 13722883, 13722884, 13722898, 13722924, 13723078, 13723597, 13723611, 13723617, 13724121, 13724580, 13724940, + 13724949, 13724958, 13725168, 13725481, 13725714, 13725715, 13725761, 13726532, 13728022, 13728049, 13729075, 13729079, 13729488, + 13729572, 13729622, 13729660, 13729666, 13729719, 13729765, 13729836, 13731361, 13731396, 13731754, 13731765, 13731769, 13731770, + 13731798, 13731966, 13732954, 13732957, 13732964, 13734204, 13734565, 13734582, 13734613, 13734671, 13735055, 13735059, 13735060, + 13735378, 13740278, 13740773, 13740781, 13740808, 13740821, 13740879, 13741264, 13742045, 13742386, 13742413, 13742433, 13742461, + 13742522, 13743142, 13743432, 13743636, 13743643, 13743676, 13744107, 13744604, 13800996, 13800999, 13801241, 13801243, 13804633, + 13804667, 13804672, 13804727, 13812443, 13812884, 13812892, 13812903, 13813249, 13813688, 13829732, 13829784, 13844956, 13844964, + 13845655, 13845657, 13845739, 13845745, 13845757, 13845780, 13848953, 13851591, 13851617, 13852217, 13852286, 13852519, 13853027, + 13854735, 13854789, 13854927, 13854932, 13854936, 13854950, 13854954, 13856012, 13856028, 13856077, 13856953, 13856955, 13857267, + 13857323, 13857365, 13857466, 13857469, 13857483, 13857490, 13857624, 13857918, 13858695, 13858898, 13858902, 13858904, 13858923, + 13858924, 13859670, 13859826, 13859936, 13860025, 13860899, 13861827, 13861932, 13861937, 13862044, 13862064, 13862197, 13862355, + 13862374, 13863113, 13864512, 13864522, 13864530, 13864926, 13864941, 13864946, 13864969, 13865001, 13865043, 13865070, 13865081, + 13865342, 13865516, 13865553, 13865581, 13865604, 13865623, 13865647, 13865678, 13866062, 13869401, 13869405, 13869422, 13869451, + 13869457, 13869834, 13870311, 13870632, 13871204, 13871210, 13871302, 13871334, 13871339, 13871363, 13871424, 13871435, 13871497, + 13871551, 13871568, 13871570, 13871583, 13871761, 13872175, 13872207, 13872240, 13872304, 13872378, 13872402, 13872443, 13872834, + 13872889, 13872979, 13873525, 13873669, 13874108, 13874137, 13874154, 13874198, 13874244, 13874484, 13875063, 13875708, 13875709, + 13876095, 13876631, 13876822, 13876828, 13876980, 13877074, 13877075, 13877496, 13877517, 13877520, 13877638, 13877848, 13878148, + 13882302, 13882360, 13882365, 13882591, 13882592, 13882597, 13882599, 13882806, 13882807, 13883051, 13883360, 13883433, 13884709, + 13885349, 13885866, 13885918, 13886883, 13887001, 13887338, 13887344, 13887380, 13887548, 13887611, 13888142, 13888577, 13888593, + 13888668, 13888746, 13889461, 13889503, 13889510, 13889524, 13889539, 13889649, 13890458, 13891050, 13891076, 13891081, 13891130, + 13891135, 13891138, 13902888, 13902992, 13906563, 13906944, 13908405, 13908630, 13912128, 13912739, 13913099, 13913121, 13913454, + 13913585, 13913596, 13914008, 13926989, 13926996, 13927003, 13927014, 13927024, 13927479, 13927483, 13927492, 13938606, 13938669, + 13939585, 13939590, 13939599, 13939708, 13939849, 13939850, 13942560, 13942563, 13942611, 13954079, 13954146, 13954148, 13954178, + 13985645, 13985651, 13992100, 14005135, 14005139, 14005140, 14005142, 14005185, 14009388, 14009390, 14038443, 14043167, 14043168, + 14098158, 14098190, 14098343, 14098347, 14098363, 14098372, 14098448, 14098510, 14099411, 14099421, 14111704, 14111988, 14112175, + 14112178, 14112222, 14112272, 14112281, 14112322, 14112332, 14112523, 14112534, 14112721, 14112870, 14113018, 14113027, 14113380, + 14113524, 14113544, 14113990, 14114153, 14114184, 14114266, 14114286, 14114342, 14114380, 14114399, 14114404, 14114436, 14114512, + 14114628, 14114673, 14114833, 14114886, 14114898, 14115278, 14115362, 14115372, 14115446, 14115500, 14115574, 14116384, 14116406, + 14116506, 14116797, 14116986, 14117002, 14117059, 14117070, 14117097, 14117135, 14117265, 14117322, 14117503, 14117521, 14117550, + 14118001, 14118142, 14118146, 14118158, 14118197, 14118368, 14118496, 14118533, 14118647, 14118701, 14118714, 14118937, 14119187, + 14119295, 14119413, 14119877, 14119901, 14119970, 14120278, 14120281, 14120282, 14120389, 14120437, 14120542, 14120552, 14120595, + 14121317, 14121366, 14121432, 14121455, 14121577, 14121580, 14121596, 14121601, 14121630, 14121638, 14121679, 14121684, 14121722, + 14121856, 14122382, 14122403, 14122483, 14122757, 14122763, 14122767, 14122824, 14122827, 14122833, 14122844, 14122853, 14122877, + 14123193, 14123200, 14123302, 14123407, 14124143, 14124163, 14124204, 14124296, 14124337, 14124352, 14124366, 14124368, 14124374, + 14124391, 14124991, 14125047, 14126549, 14126762, 14126770, 14126771, 14126782, 14126791, 14126823, 14126841, 14128740, 14128817, + 14128883, 14128944, 14129293, 14129452, 14129553, 14129573, 14129597, 14129617, 14129837, 14129898, 14129913, 14129915, 14129939, + 14130007, 14130296, 14130298, 14130316, 14130334, 14130355, 14130372, 14130378, 14130387, 14130388, 14130423, 14130440, 14130465, + 14130641, 14131066, 14131081, 14131115, 14131324, 14131407, 14131588, 14132136, 14132310, 14133768, 14133783, 14133786, 14133815, + 14133830, 14133981, 14134041, 14135528, 14135807, 14135812, 14135828, 14137560, 14137824, 14137853, 14138293, 14138307, 14138600, + 14138669, 14138825, 14138845, 14138888, 14139112, 14139816, 14140071, 14140079, 14140134, 14140318, 14140343, 14140597, 14140903, + 14140910, 14141386, 14141418, 14141461, 14141473, 14141478, 14141480, 14141489, 14141517, 14141541, 14141549, 14141628, 14141732, + 14141733, 14141780, 14141786, 14141800, 14142398, 14142742, 14142749, 14143111, 14143196, 14143745, 14143763, 14143828, 14143864, + 14144282, 14144473, 14145076, 14145285, 14145784, 14145908, 14145935, 14145988, 14146061, 14146091, 14146109, 14146166, 14146173, + 14146182, 14146184, 14146190, 14146207, 14146234, 14146754, 14146771, 14146832, 14147019, 14147204, 14147423, 14147483, 14147519, + 14147526, 14147554, 14147587, 14147607, 14147732, 14148521, 14148714, 14149592, 14149619, 14149789, 14149804, 14149812, 14149940, + 14149961, 14149966, 14149992, 14151350, 14151353, 14153570, 14154639, 14154760, 14154939, 14155463, 14155476, 14155742, 14155762, + 14155771, 14155906, 14155935, 14156644, 14156695, 14156824, 14157718, 14158023, 14158178, 14158179, 14158192, 14158225, 14158234, + 14160434, 14160448, 14160484, 14160591, 14160631, 14160678, 14161007, 14161029, 14161053, 14161067, 14161227, 14161241, 14161396, + 14161541, 14161546, 14161548, 14161549, 14161604, 14161618, 14161833, 14161976, 14161996, 14162133, 14162387, 14162615, 14162897, + 14163117, 14163286, 14163301, 14163309, 14163900, 14163967, 14164571, 14165063, 14165098, 14165182, 14165193, 14165728, 14165832, + 14166064, 14166499, 14166555, 14166559, 14166586, 14167320, 14167457, 14167507, 14167584, 14167707, 14167751, 14167792, 14167806, + 14167809, 14167830, 14167859, 14167868, 14167877, 14167979, 14167980, 14171368, 14171777, 14171890, 14171953, 14172042, 14172047, + 14172089, 14172170, 14172332, 14172456, 14172572, 14172639, 14173001, 14174547, 14174910, 14175087, 14175109, 14175111, 14175869, + 14175907, 14176246, 14176253, 14176343, 14176607, 14177124, 14177447, 14177503, 14177734, 14178614, 14178630, 14178820, 14178821, + 14178839, 14179074, 14179192, 14179237, 14179326, 14180592, 14180796, 14180851, 14181128, 14181137, 14181693, 14181698, 14181762, + 14181792, 14182209, 14182468, 14182581, 14183420, 14183543, 14183809, 14183872, 14184752, 14184842, 14185023, 14185412, 14185453, + 14185501, 14185653, 14185710, 14185798, 14186682, 14186733, 14187745, 14187752, 14187757, 14187821, 14188264, 14188460, 14188465, + 14188729, 14188778, 14189095, 14189171, 14191103, 14191217, 14191927, 14192000, 14192052, 14192242, 14192398, 14192827, 14192854, + 14193065, 14193073, 14193103, 14193143, 14193158, 14193482, 14193580, 14194305, 14194319, 14194412, 14194419, 14194484, 14194546, + 14194595, 14199795, 14199935, 14199983, 14199986, 14200044, 14200084, 14200111, 14200139, 14200182, 14200190, 14204347, 14204418, + 14204510, 14204511, 14204779, 14204797, 14204839, 14205356, 14205469, 14205477, 14205495, 14206818, 14206853, 14207065, 14207638, + 14207651, 14207666, 14207674, 14207769, 14208925, 14208929, 14208933, 14209218, 14209304, 14209336, 14209575, 14209637, 14209654, + 14209658, 14209756, 14209776, 14209798, 14209927, 14210583, 14210845, 14211495, 14211541, 14211907, 14211929, 14212341, 14212472, + 14212477, 14212690, 14213033, 14213418, 14213497, 14213514, 14213530, 14213652, 14213946, 14213953, 14213972, 14214116, 14214142, + 14214143, 14214366, 14214977, 14214987, 14215167, 14215207, 14215399, 14215416, 14215450, 14215516, 14217199, 14217219, 14217260, + 14217509, 14218325, 14218896, 14218935, 14219106, 14219113, 14219114, 14219119, 14219130, 14219957, 14219958, 14220038, 14220087, + 14220173, 14220219, 14220804, 14221341, 14222488, 14222500, 14222878, 14222894, 14222935, 14223004, 14223669, 14223764, 14227432, + 14227444, 14227445, 14227450, 14227692, 14227697, 14228042, 14228163, 14228181, 14228408, 14228421, 14228485, 14228486, 14228491, + 14228508, 14228587, 14228717, 14228762, 14228769, 14228773, 14228791, 14228792, 14228804, 14228903, 14229010, 14229018, 14229159, + 14231125, 14231300, 14231443, 14231448, 14232109, 14232208, 14232209, 14232381, 14232406, 14232802, 14232810, 14232864, 14232909, + 14233312, 14233318, 14233470, 14233715, 14233727, 14233759, 14235991, 14236061, 14236156, 14236267, 14236301, 14236377, 14236429, + 14236512, 14236650, 14236713, 14236756, 14236769, 14236824, 14236825, 14237021, 14237138, 14237249, 14237357, 14237367, 14237368, + 14237405, 14237422, 14237465, 14237979, 14238006, 14238047, 14238053, 14238054, 14238064, 14238210, 14241229, 14242371, 14242374, + 14242376, 14242495, 14242761, 14242796, 14242807, 14242848, 14242857, 14242860, 14242895, 14242902, 14242903, 14243742, 14243745, + 14243747, 14243828, 14243830, 14243898, 14243995, 14244554, 14244572, 14244661, 14244663, 14245554, 14245560, 14245614, 14245629, + 14245794, 14246045, 14246318, 14246687, 14246846, 14247108, 14247338, 14247826, 14247928, 14247954, 14247963, 14247985, 14248202, + 14248403, 14248732, 14249055, 14249278, 14249875, 14250216, 14250927, 14250928, 14251116, 14251143, 14251320, 14251343, 14251406, + 14251457, 14251569, 14251635, 14251874, 14251884, 14251898, 14252039, 14252092, 14252144, 14252246, 14252318, 14252972, 14253022, + 14255299, 14255310, 14255475, 14255516, 14255543, 14255556, 14255822, 14255995, 14256057, 14256504, 14256561, 14256571, 14256620, + 14258923, 14258985, 14259150, 14259607, 14259661, 14260250, 14260264, 14261054, 14261145, 14261150, 14261244, 14261398, 14261838, + 14261932, 14261969, 14262054, 14262427, 14262460, 14262621, 14263627, 14263682, 14267276, 14267288, 14267519, 14267528, 14267529, + 14267548, 14267622, 14267663, 14268607, 14268629, 14268630, 14268672, 14268685, 14268744, 14268750, 14268751, 14268755, 14269086, + 14269140, 14269168, 14269178, 14269347, 14269356, 14269543, 14269547, 14269776, 14269820, 14270276, 14270280, 14270283, 14270286, + 14270294, 14270310, 14270354, 14270419, 14270466, 14270486, 14270530, 14270550, 14270654, 14270738, 14270744, 14270751, 14270757, + 14270778, 14270784, 14270811, 14270841, 14270889, 14270897, 14270940, 14270943, 14270967, 14270972, 14271360, 14271401, 14271992, + 14271999, 14272079, 14272130, 14272289, 14272325, 14272717, 14272750, 14274773, 14274777, 14274997, 14275001, 14275127, 14275130, + 14275146, 14275323, 14275353, 14275424, 14275668, 14276086, 14276123, 14276168, 14276309, 14276370, 14276458, 14276520, 14277427, + 14277434, 14277438, 14277439, 14277514, 14277581, 14277637, 14278054, 14278075, 14278093, 14278096, 14278100, 14278142, 14278209, + 14278267, 14278302, 14278331, 14278429, 14278440, 14278687, 14278756, 14278811, 14279537, 14279693, 14279798, 14280053, 14280185, + 14280204, 14280267, 14280452, 14280583, 14280616, 14280703, 14281278, 14281362, 14281532, 14281603, 14281860, 14281911, 14282559, + 14283530, 14283550, 14283560, 14283564, 14283579, 14283595, 14283598, 14283613, 14283697, 14283746, 14284070, 14284218, 14284578, + 14284847, 14286487, 14286490, 14286613, 14286765, 14287334, 14287353, 14287608, 14287664, 14287752, 14287787, 14287796, 14287799, + 14287800, 14287802, 14287945, 14288161, 14288307, 14288451, 14288502, 14288846, 14288983, 14289001, 14289005, 14289016, 14289060, + 14289723, 14290173, 14290424, 14290457, 14290459, 14290506, 14290571, 14290766, 14290801, 14290962, 14291669, 14291708, 14291718, + 14291815, 14292939, 14292956, 14293247, 14293268, 14293297, 14293393, 14293441, 14293602, 14293740, 14293803, 14294518, 14294563, + 14294601, 14294625, 14295118, 14295131, 14295183, 14295205, 14295233, 14295243, 14295256, 14295279, 14295325, 14295328, 14295332, + 14295394, 14295420, 14295683, 14295688, 14295809, 14296174, 14296471, 14296495, 14296520, 14296596, 14296598, 14296727, 14296803, + 14296887, 14296913, 14296925, 14297069, 14297070, 14297260, 14297371, 14297452, 14297529, 14297538, 14297676, 14297759, 14297807, + 14297822, 14298409, 14298639, 14298896, 14298903, 14298932, 14299363, 14299554, 14300286, 14300298, 14300301, 14300495, 14300640, + 14300659, 14301074, 14301263, 14301438, 14301472, 14301639, 14301663, 14301665, 14301705, 14301827, 14302166, 14302216, 14302438, + 14302631, 14302782, 14302982, 14303337, 14303485, 14303928, 14304191, 14304195, 14304374, 14304577, 14304591, 14304640, 14305416, + 14305568, 14305668, 14305702, 14305917, 14305920, 14306074, 14306134, 14306454, 14307152, 14307386, 14307402, 14307413, 14307462, + 14307466, 14307547, 14307632, 14307804, 14307929, 14308045, 14308232, 14308345, 14308437, 14308448, 14309558, 14309627, 14309634, + 14309679, 14309714, 14309805, 14309832, 14309939, 14310154, 14310541, 14310658, 14310887, 14310987, 14311341, 14312039, 14312218, + 14312227, 14312251, 14312317, 14312327, 14312447, 14312532, 14313179, 14313565, 14313860, 14313880, 14313896, 14313985, 14314069, + 14314262, 14314503, 14314504, 14315064, 14315149, 14315158, 14315195, 14315406, 14315429, 14315534, 14315796, 14316030, 14316190, + 14316259, 14316600, 14316647, 14316861, 14317147, 14317635, 14317647, 14317657, 14317734, 14317812, 14317833, 14317844, 14317921, + 14317930, 14317937, 14317942, 14317945, 14317982, 14317988, 14318921, 14318922, 14319270, 14319315, 14319942, 14320162, 14320227, + 14320284, 14320753, 14320763, 14322722, 14322745, 14322786, 14322880, 14322990, 14323725, 14323744, 14324520, 14324584, 14324706, + 14324707, 14328007, 14328024, 14331549, 14331550, 14331679, 14332651, 14332653, 14332760, 14332764, 14332800, 14332809, 14333294, + 14333328, 14333336, 14333346, 14333551, 14333562, 14334351, 14334509, 14334540, 14334564, 14337693, 14340622, 14342084, 14342092, + 14342313, 14342321, 14342457, 14342462, 14343083, 14343087, 14343141, 14343154, 14343161, 14343551, 14343566, 14343577, 14343609, + 14343647, 14343803, 14343938, 14343962, 14344087, 14344928, 14344933, 14345088, 14345153, 14345161, 14345601, 14345744, 14345777, + 14346561, 14346614, 14346765, 14346782, 14346783, 14347126, 14347150, 14347420, 14347452, 14347570, 14347598, 14347626, 14347635, + 14347637, 14347725, 14347781, 14348725, 14348905, 14349352, 14349447, 14351917, 14352564, 14352616, 14352773, 14352923, 14353039, + 14354130, 14354236, 14354276, 14354277, 14354290, 14354327, 14354329, 14354337, 14354362, 14354420, 14354429, 14354456, 14354679, + 14354688, 14354691, 14354801, 14354829, 14354874, 14354902, 14354918, 14355487, 14355501, 14355611, 14355907, 14356212, 14356334, + 14356358, 14356391, 14356876, 14357035, 14357313, 14357658, 14357681, 14357718, 14357730, 14357799, 14357850, 14357987, 14358091, + 14358190, 14358267, 14358722, 14359057, 14359213, 14359358, 14359371, 14359465, 14359589, 14359597, 14359648, 14359654, 14360676, + 14360709, 14360796, 14361052, 14361484, 14361538, 14361631, 14361731, 14362244, 14362395, 14362428, 14362460, 14362496, 14362567, + 14362798, 14362805, 14362808, 14363004, 14363041, 14363050, 14363058, 14363068, 14363172, 14363510, 14363570, 14363734, 14364469, + 14364510, 14364518, 14365738, 14365742, 14365752, 14365867, 14365890, 14366055, 14366116, 14366211, 14366224, 14366233, 14366246, + 14366288, 14366309, 14366329, 14366429, 14366430, 14366443, 14366448, 14366472, 14366539, 14366589, 14366750, 14366765, 14366794, + 14366934, 14367112, 14367251, 14367272, 14367282, 14367466, 14367467, 14367468, 14367469, 14367477, 14367496, 14367530, 14367687, + 14367800, 14367833, 14367960, 14368004, 14368015, 14368024, 14368061, 14368069, 14368160, 14368167, 14368170, 14368194, 14368302, + 14368786, 14368797, 14368798, 14368810, 14368823, 14370205, 14370209, 14370844, 14370852, 14371635, 14371854, 14372502, 14372811, + 14375059, 14375196, 14375337, 14375353, 14376850, 14377162, 14377188, 14378134, 14378139, 14378142, 14378262, 14378276, 14378281, + 14378284, 14378300, 14378310, 14378366, 14378380, 14378433, 14380203, 14380358, 14380376, 14380432, 14380454, 14380479, 14380500, + 14380502, 14380511, 14380523, 14380526, 14380576, 14381101, 14381108, 14381116, 14381149, 14381187, 14381336, 14381643, 14381650, + 14384971, 14385017, 14385299, 14385327, 14385345, 14385346, 14385398, 14385409, 14386643, 14386717, 14387783, 14387792, 14387814, + 14387938, 14388060, 14388082, 14388164, 14388173, 14388184, 14388185, 14388190, 14388205, 14388211, 14388234, 14388244, 14388337, + 14388466, 14389756, 14389760, 14391505, 14391529, 14392389, 14392425, 14392444, 14392452, 14392466, 14392654, 14393420, 14393502, + 14393594, 14393595, 14393599, 14393671, 14394385, 14395110, 14395112, 14395122, 14395139, 14395232, 14395237, 14395341, 14395364, + 14395414, 14395416, 14397686, 14397758, 14397792, 14397865, 14398937, 14398955, 14398982, 14399110, 14399114, 14399131, 14399141, + 14399198, 14399200, 14399218, 14399248, 14399251, 14399276, 14399914, 14399919, 14399960, 14399989, 14399992, 14400040, 14400043, + 14400048, 14400097, 14400128, 14400131, 14402470, 14402526, 14402741, 14402794, 14402800, 14402805, 14402891, 14402926, 14404738, + 14404762, 14404988, 14405199, 14405204, 14405237, 14405348, 14406107, 14406164, 14406177, 14406665, 14406666, 14406887, 14406900, + 14406901, 14406982, 14406984, 14407108, 14407204, 14407309, 14407326, 14408372, 14408387, 14408522, 14408523, 14408534, 14408798, + 14408824, 14408858, 14410649, 14410860, 14410915, 14410986, 14411113, 14411190, 14411745, 14411764, 14412210, 14412275, 14412297, + 14412428, 14412434, 14412741, 14412857, 14412866, 14412869, 14413198, 14413199, 14413906, 14413934, 14414045, 14414168, 14414430, + 14414443, 14414710, 14415221, 14415252, 14415388, 14415429, 14415469, 14415513, 14415554, 14415608, 14415656, 14415660, 14415666, + 14415927, 14415975, 14416165, 14417518, 14418203, 14418277, 14418301, 14418317, 14418392, 14418533, 14418543, 14418546, 14419038, + 14419373, 14419466, 14419469, 14419481, 14419488, 14419499, 14419512, 14419521, 14419616, 14419697, 14419698, 14419805, 14419900, + 14419928, 14419929, 14419941, 14419942, 14419962, 14420023, 14420069, 14420082, 14420084, 14420086, 14420091, 14420094, 14420112, + 14420116, 14420129, 14420131, 14420180, 14420183, 14420193, 14420247, 14420253, 14420256, 14420275, 14420293, 14420303, 14420341, + 14420348, 14420480, 14420699, 14420814, 14420849, 14420851, 14420971, 14421014, 14421036, 14421045, 14421046, 14421169, 14421176, + 14421440, 14421858, 14421886, 14421920, 14422148, 14422321, 14422453, 14422593, 14422767, 14422856, 14423018, 14423133, 14423196, + 14423206, 14423268, 14423271, 14423515, 14423532, 14423583, 14423860, 14423881, 14423932, 14424014, 14424043, 14424067, 14424296, + 14424429, 14424452, 14424558, 14424562, 14424571, 14424585, 14424586, 14424589, 14424636, 14424685, 14424736, 14424750, 14424769, + 14425463, 14425546, 14425574, 14425575, 14425633, 14425767, 14425781, 14425849, 14425993, 14426028, 14426072, 14426221, 14426583, + 14427051, 14427197, 14427202, 14427208, 14427399, 14427441, 14427452, 14427473, 14427870, 14428817, 14428898, 14428920, 14429168, + 14429174, 14429180, 14429324, 14430071, 14430108, 14430138, 14430143, 14430231, 14430255, 14430816, 14430855, 14430886, 14430899, + 14430901, 14430902, 14430905, 14430924, 14430965, 14431006, 14431063, 14431282, 14431502, 14431545, 14431559, 14431720, 14431721, + 14432038, 14432172, 14432192, 14432201, 14432626, 14432636, 14432638, 14433023, 14433345, 14433362, 14433891, 14433944, 14434390, + 14434409, 14434414, 14434471, 14434649, 14436439, 14436511, 14436521, 14436616, 14436975, 14437026, 14437134, 14437167, 14437191, + 14437201, 14437204, 14437205, 14437268, 14437527, 14437534, 14437547, 14437565, 14437613, 14437807, 14437820, 14438118, 14438156, + 14438160, 14438162, 14438168, 14438215, 14438333, 14438365, 14438531, 14438538, 14438956, 14439014, 14439085, 14439105, 14439107, + 14439173, 14439501, 14439515, 14439776, 14439868, 14440295, 14440312, 14440363, 14440392, 14440418, 14440420, 14440431, 14440986, + 14440993, 14441010, 14441090, 14441114, 14441175, 14441182, 14441421, 14441424, 14441436, 14441455, 14442331, 14442410, 14442412, + 14442499, 14442590, 14443032, 14443124, 14443702, 14443783, 14443785, 14443880, 14443986, 14443987, 14443996, 14444016, 14444291, + 14444335, 14444348, 14444958, 14445106, 14445730, 14445744, 14445796, 14445857, 14445956, 14445960, 14449012, 14449107, 14449279, + 14449287, 14450086, 14450107, 14450169, 14450196, 14451369, 14451491, 14451664, 14451679, 14452080, 14452088, 14452158, 14452281, + 14452377, 14452464, 14454060, 14454100, 14454259, 14454284, 14455932, 14455937, 14456161, 14456169, 14456173, 14456215, 14456220, + 14456251, 14456262, 14456272, 14456374, 14456386, 14456389, 14456408, 14456422, 14456596, 14456654, 14456697, 14456714, 14457226, + 14457236, 14457251, 14457272, 14457294, 14457295, 14457323, 14457332, 14457341, 14457872, 14457925, 14458268, 14458361, 14462180, + 14462204, 14462241, 14462308, 14464172, 14464255, 14466306, 14466331, 14466411, 14466425, 14466470, 14466488, 14466497, 14466523, + 14466972, 14466984, 14467004, 14467023, 14468341, 14468496, 14469581, 14469604, 14469619, 14469675, 14470339, 14470341, 14470456, + 14470514, 14470520, 14470622, 14470887, 14470888, 14471412, 14471417, 14471591, 14471594, 14473086, 14473092, 14473096, 14473097, + 14473637, 14473642, 14475479, 14475496, 14475695, 14475733, 14476630, 14476676, 14476712, 14476812, 14477122, 14477145, 14477588, + 14477589, 14477594, 14477605, 14477607, 14477633, 14477742, 14477772, 14477777, 14478030, 14478043, 14478624, 14478666, 14479141, + 14479784, 14479865, 14479943, 14479950, 14479961, 14481636, 14481637, 14481722, 14481726, 14481758, 14481986, 14481997, 14482096, + 14482102, 14482118, 14482138, 14482420, 14482427, 14482457, 14482487, 14482508, 14482687, 14482693, 14482834, 14482845, 14483435, + 14483438, 14483442, 14483453, 14483471, 14483605, 14483834, 14483839, 14484322, 14484339, 14484341, 14484392, 14484412, 14484498, + 14484698, 14484752, 14484755, 14488867, 14488878, 14488894, 14488896, 14489287, 14489291, 14489510, 14489549, 14490029, 14490073, + 14490084, 14490085, 14490086, 14490088, 14490123, 14490128, 14490190, 14490213, 14490644, 14490652, 14490708, 14490728, 14490903, + 14490908, 14491415, 14491754, 14491757, 14491758, 14491805, 14492838, 14493628, 14494367, 14494372, 14494373, 14494376, 14494379, + 14494381, 14494646, 14494656, 14494661, 14494752, 14494868, 14494907, 14494921, 14494941, 14494953, 14494954, 14495034, 14495065, + 14495075, 14495076, 14495135, 14495154, 14495165, 14495173, 14495188, 14495192, 14495488, 14495493, 14495495, 14495501, 14495644, + 14495687, 14495688, 14495840, 14495967, 14495968, 14496394, 14496406, 14496408, 14496432, 14496500, 14496551, 14496604, 14496966, + 14497034, 14497038, 14497550, 14497568, 14497570, 14497668, 14497702, 14497706, 14497708, 14497820, 14497848, 14497895, 14497913, + 14497935, 14497937, 14498323, 14498354, 14498355, 14501002, 14501005, 14501526, 14502186, 14502208, 14502215, 14502229, 14502284, + 14502295, 14502315, 14502353, 14502605, 14502627, 14502635, 14502663, 14502758, 14502769, 14503020, 14503058, 14503061, 14503068, + 14503086, 14503134, 14503288, 14503395, 14503429, 14503435, 14503522, 14503525, 14504153, 14504162, 14504169, 14504173, 14504371, + 14504422, 14504432, 14504442, 14507145, 14507147, 14507476, 14507486, 14507489, 14507515, 14507520, 14507570, 14507702, 14507732, + 14508208, 14508212, 14509089, 14509103, 14509612, 14509623, 14511370, 14511373, 14511378, 14511379, 14511768, 14511773, 14512246, + 14512248, 14514087, 14514094, 14514100, 14514117, 14514130, 14514133, 14514156, 14514162, 14514508, 14514588, 14514908, 14514918, + 14514964, 14514971, 14514989, 14515007, 14515063, 14515165, 14515419, 14515421, 14515591, 14515593, 14515714, 14515716, 14515719, + 14515720, 14515748, 14515749, 14515854, 14515860, 14515903, 14515904, 14515951, 14515955, 14515993, 14515997, 14516253, 14516270, + 14516372, 14516412, 14516497, 14516503, 14517397, 14517439, 14519618, 14519619, 14519694, 14519701, 14519702, 14519714, 14519776, + 14519782, 14519803, 14519804, 14519955, 14519996, 14520020, 14520024, 14520043, 14520060, 14520061, 14520062, 14520115, 14520126, + 14520159, 14520172, 14520186, 14520190, 14520198, 14520212, 14520222, 14520227, 14520235, 14520497, 14520498, 14520746, 14520774, + 14520977, 14520982, 14520986, 14521011, 14521066, 14521069, 14522110, 14522112, 14522118, 14522165, 14522218, 14522219, 14522733, + 14522797, 14523118, 14523126, 14523830, 14523835, 14524242, 14524243, 14524259, 14524266, 14526070, 14526077, 14526083, 14526086, + 14526087, 14526099, 14526120, 14526126, 14526141, 14526211, 14526215, 14526221, 14526244, 14526255, 14526300, 14526321, 14526332, + 14526340, 14526344, 14526346, 14526356, 14526363, 14526380, 14526442, 14526463, 14527065, 14527080, 14527084, 14527176, 14527178, + 14527369, 14527370, 14527424, 14527431, 14527447, 14527451, 14527599, 14527626, 14527627, 14527633, 14527696, 14527715, 14527723, + 14527735, 14527839, 14528084, 14528085, 14528093, 14528124, 14528171, 14528614, 14528712, 14528723, 14528757, 14528758, 14528864, + 14528925, 14528961, 14528969, 14528986, 14528993, 14528997, 14529009, 14529012, 14529017, 14529021, 14529024, 14529026, 14529029, + 14529033, 14529037, 14529046, 14529100, 14529124, 14529557, 14530096, 14530149, 14531104, 14531141, 14531213, 14531235, 14531744, + 14531775, 14531956, 14531968, 14531999, 14532026, 14532066, 14532097, 14532696, 14532706, 14532729, 14532730, 14532739, 14532749, + 14532758, 14532838, 14532843, 14533032, 14533035, 14533049, 14533066, 14533070, 14533079, 14533136, 14533141, 14533267, 14533299, + 14533319, 14533321, 14533346, 14533372, 14533410, 14533430, 14533442, 14533526, 14533548, 14533722, 14533805, 14533836, 14533847, + 14533860, 14533861, 14533873, 14533878, 14533920, 14534184, 14534185, 14534191, 14534193, 14534233, 14534256, 14534343, 14534366, + 14534397, 14534426, 14535016, 14535017, 14535020, 14535028, 14535045, 14535083, 14535119, 14535180, 14535199, 14535394, 14535426, + 14535428, 14535456, 14535475, 14535634, 14535662, 14535688, 14535691, 14535692, 14535702, 14536479, 14536480, 14536489, 14536490, + 14536492, 14536493, 14538931, 14538950, 14539037, 14539038, 14539216, 14539309, 14539334, 14539344, 14539390, 14539420, 14539473, + 14539534, 14539537, 14539564, 14540149, 14540166, 14540656, 14540667, 14540769, 14540796, 14541039, 14541063, 14541069, 14541071, + 14541159, 14541165, 14541181, 14541201, 14541315, 14541323, 14541325, 14541328, 14541535, 14542840, 14542888, 14542906, 14542907, + 14543190, 14543248, 14543853, 14543908, 14544590, 14544596, 14544603, 14544616, 14544670, 14544671, 14544700, 14544710, 14544746, + 14544754, 14544827, 14544828, 14544837, 14544856, 14544877, 14544962, 14545025, 14545172, 14545204, 14545224, 14545226, 14545234, + 14545464, 14545483, 14545723, 14545743, 14545958, 14545994, 14546116, 14546131, 14546151, 14546163, 14546371, 14546380, 14546408, + 14546419, 14546448, 14546450, 14546509, 14546553, 14546560, 14546608, 14546630, 14546636, 14546678, 14546684, 14546867, 14546869, + 14547247, 14547249, 14547565, 14547577, 14547724, 14547850, 14547854, 14547861, 14547962, 14548000, 14550132, 14550221, 14552498, + 14552506, 14552667, 14552671, 14552813, 14552828, 14553470, 14553472, 14553476, 14554183, 14554188, 14554192, 14554225, 14554740, + 14554785, 14555988, 14556013, 14556021, 14556022, 14556083, 14556084, 14556089, 14556092, 14556100, 14556103, 14556108, 14556140, + 14556651, 14558534, 14559061, 14559072, 14559085, 14559733, 14559791, 14560016, 14560026, 14560028, 14560038, 14560040, 14560076, + 14560273, 14560275, 14560303, 14560306, 14560310, 14560322, 14560576, 14560577, 14560582, 14560595, 14560608, 14560622, 14560728, + 14560734, 14561795, 14561825, 14561840, 14562587, 14562623, 14562630, 14562645, 14563527, 14563541, 14563542, 14563549, 14563729, + 14563739, 14563740, 14563748, 14563749, 14563755, 14563766, 14563768, 14563774, 14563775, 14563894, 14563959, 14563963, 14563967, + 14564050, 14564054, 14564058, 14564075, 14564164, 14564730, 14564733, 14565457, 14565462, 14565943, 14566817, 14566822, 14588081, + 15278993, 15298860, 15299275, 15299420, 15299520, 15299715, 15299731, 15299757, 15301708, 15301850, 15301875, 15302455, 15302967, + 15304019, 15305121, 15305561, 15307407, 15307490, 15307868, 15308032, 15311107, 15311210, 15311599, 15316343, 15316528, 15316535, + 15317411, 15318069, 15318235, 15318288, 15318437, 15318758, 15319019, 15319366, 15319403, 15320313, 15321005, 15321511, 15321634, + 15321707, 15321890, 15322055, 15322136, 15323088, 15323182, 15323543, 15324636, 15327600, 15328789, 15328903, 15328961, 15329151, + 15330358, 15330441, 15330468, 15331215, 15331280, 15333764, 15333830, 15335397, 15336059, 15337247, 15337395, 15337630, 15339099, + 15340038, 15340971, 15341319, 15341479, 15341544, 15342783, 15343155, 15343302, 15343551, 15343809, 15344150, 15344169, 15344370, + 15344584, 15346218, 15346421, 15346604, 15346684, 15346714, 15346716, 15350123, 15350143, 15350966, 15351041, 15351346, 15351348, + 15352316, 15352341, 15353576, 15353802, 15354436, 15354503, 15354708, 15354744, 15355751, 15355938, 15356263, 15356464, 15357773, + 15357806, 15357836, 15357870, 15359242, 15359261, 15359409, 15359557, 15359701, 15359731, 15359846, 15359932, 15360348, 15360351, + 15360966, 15360968, 15360998, 15361018, 15363267, 15363312, 15363413, 15363420, 15363920, 15364070, 15364136, 15364150, 15364663, + 15364715, 15367310, 15367326, 15368095, 15368104, 15368537, 15368541, 15368874, 15368881, 15369797, 15369898, 15370883, 15370885, + 15371463, 15371516, 15372941, 15373029, 15373035, 15373039, 15373489, 15373548, 15374297, 15374326, 15374448, 15374596, 15375231, + 15375318, 15375776, 15375803, 15376049, 15376057, 15377278, 15377371, 15378036, 15378043, 15378052, 15378059, 15378164, 15378166, + 15379378, 15379430, 15379848, 15379863, 15379880, 15379890, 15381333, 15381472, 15381587, 15381594, 15382319, 15382335, 15382622, + 15382689, 15384884, 15384889, 15386453, 15386482, 15386506, 15386762, 15386943, 15387036, 15387461, 15387465, 15387752, 15387804, + 15388394, 15388486, 15388606, 15388617, 15389904, 15390109, 15390434, 15390437, 15390816, 15390866, 15393023, 15393050, 15393079, + 15393299, 15393785, 15393789, 15394171, 15394184, 15394223, 15394363, 15397304, 15397311, 15397367, 15397572, 15398540, 15398542, + 15398966, 15398984, 15400273, 15400276, 15400610, 15400638, 15401565, 15401650, 15404521, 15404620, 15406007, 15406017, 15406624, + 15406687, 15407958, 15407964, 15408278, 15408287, 15410615, 15410769, 15411104, 15411119, 15411326, 15411591, 15411833, 15411836, + 15413038, 15413046, 15413111, 15413148, 15413371, 15413374, 15413483, 15413499, 15415282, 15415416, 15417725, 15417802, 15417896, + 15417906, 15419558, 15419604, 15419797, 15419800, 15419980, 15420000, 15420016, 15420019, 15421514, 15421544, 15423424, 15423558, + 15423661, 15423673, 15424869, 15424873, 15425240, 15425382, 15425895, 15425897, 15426289, 15426372, 15427195, 15427225, 15427230, + 15427233, 15427289, 15427298, 15427993, 15427999, 15428176, 15428217, 15428227, 15428516, 15428529, 15428567, 15428784, 15429008, + 15429020, 15429026, 15429032, 15429281, 15430344, 15430346, 15430706, 15430735, 15430879, 15430885, 15431260, 15431365, 15432397, + 15432422, 15432649, 15432654, 15432804, 15432819, 15433923, 15433932, 15435272, 15435298, 15437041, 15437050, 15438105, 15438114, + 15440121, 15440253, 15441104, 15441282, 15442199, 15442584, 15443871, 15444142, 15444188, 15444408, 15444685, 15444690, 15445733, + 15445736, 15445863, 15445878, 15447031, 15447065, 15448796, 15448816, 15449403, 15449413, 15449587, 15449609, 15449711, 15449878, + 15449962, 15449964, 15450263, 15450405, 15450446, 15450450, 15451400, 15451408, 15451819, 15451857, 15452179, 15452192, 15452979, + 15453020, 15453357, 15453514, 15455431, 15455434, 15455761, 15455880, 15456762, 15456784, 15457983, 15459043, 15459439, 15459567, + 15459814, 15459822, 15460508, 15460591, 15461069, 15461082, 15462424, 15462426, 15462594, 15462656, 15462690, 15462696, 15463436, + 15463936, 15464266, 15465784, 15465839, 15465937, 15466610, 15466631, 15467021, 15467085, 15467103, 15467109, 15467756, 15467851, + 15468430, 15468503, 15468511, 15468652, 15469184, 15469200, 15469285, 15469458, 15469754, 15469759, 15470276, 15470283, 15470370, + 15470392, 15471545, 15471785, 15473261, 15473269, 15473454, 15473460, 15474422, 15474425, 15474922, 15475151, 15475640, 15475643, + 15476163, 15476405, 15476427, 15476439, 15477009, 15477179, 15477640, 15477649, 15479093, 15479107, 15480142, 15480151, 15480580, + 15480814, 15481022, 15481026, 15481035, 15481037, 15481562, 15481565, 15481590, 15481591, 15481741, 15481744, 15482067, 15482078, + 15482616, 15482683, 15486561, 15486564, 15486616, 15486617, 15486666, 15486668, 15486678, 15486680, 15487459, 15487500, 15488119, + 15488127, 15488401, 15488409, 15488440, 15488442, 15488965, 15488970, 15489694, 15489700, 15490595, 15490615, 15491720, 15491760, + 15492016, 15492020, 15492072, 15492087, 15492855, 15492857, 15493002, 15493004, 15493071, 15493074, 15493106, 15493108, 15493360, + 15493365, 15494319, 15494332, 15496258, 15496263, 15497235, 15497254, 15497321, 15497338, 15498352, 15498354, 15499365, 15499369, + 15501348, 15501354, 15502470, 15502478, 15503665, 15503673, 15504523, 15504537, 15504621, 15504628, 15504938, 15505080, 15506069, + 15506072, 15506112, 15506113, 15506426, 15506436, 15507433, 15507435, 15508130, 15508192, 15508250, 15508358, 15510418, 15510430, + 15510706, 15510712, 15511523, 15511526, 15511628, 15511629, 15512065, 15512071, 15512120, 15512121, 15513126, 15513199, 15513214, + 15513441, 15514260, 15514460, 15515518, 15515520, 15515699, 15515701, 15516480, 15516482, 15517627, 15517654, 15518075, 15518102, + 15519576, 15519578, 15520859, 15520864, 15521342, 15521351, 15521537, 15521553, 15521701, 15521707, 15522808, 15523015, 15523483, + 15523488, 15524388, 15524397, 15524703, 15524713, 15525341, 15525343, 15525349, 15525353, 15526412, 15526559, 15527127, 15527133, + 15527672, 15527675, 15528231, 15528248, 15528274, 15528307, 15529512, 15529522, 15529961, 15530071, 15530915, 15530926, 15531367, + 15531370, 15533472, 15533487, 15534560, 15534786, 15535306, 15535318, 15535392, 15535522, 15538116, 15539371, 15540337, 15540602, + 15541064, 15541071, 15541659, 15541666, 15541681, 15541719, 15541771, 15541777, 15542276, 15542282, 15542576, 15542585, 15542589, + 15542594, 15542886, 15542896, 15543880, 15543976, 15544196, 15546926, 15547006, 15547018, 15547117, 15547119, 15547436, 15547520, + 15547554, 15547587, 15547642, 15547644, 15549036, 15549039, 15549429, 15549448, 15550823, 15550828, 15551147, 15551381, 15551716, + 15551720, 15552150, 15552267, 15554087, 15554090, 15554449, 15554456, 15555207, 15555210, 15556032, 15556037, 15556177, 15556184, + 15557755, 15557761, 15558433, 15558443, 15559082, 15559107, 15560806, 15560890, 15561941, 15562075, 15562258, 15562260, 15563500, + 15563507, 15563620, 15563624, 15565974, 15565985, 15566159, 15566161, 15566675, 15567720, 15567772, 15697646, 15698252, 15699048, + 15699049, 15699308, 15699355, 15701033, 15701037, 15701139, 15701868, 15722361, 15723839, 15725644, 15726602, 15726621, 15726727, + 15726730, 15728420, 15728425, 15729973, 15729986, 15731110, 15731125, 15732349, 15732819, 15733345, 15733382, 15736966, 15741478, + 15742747, 15743712, 15744541, 15746902, 15748357, 15751438, 15751801, 15754322, 15755697, 15768595, 15768635, 15768636, 15771170, + 15771235, 15771418, 15771566, 15772511, 15772514, 15773217, 15773287, 15773693, 15775062, 15775162, 15775170, 15775628, 15775748, + 15777966, 15778518, 15780571, 15780590, 15781334, 15781414, 15783805, 15784103, 15784218, 15784222, 15784336, 15786288, 15786350, + 15786412, 15786880, 15787424, 15791418, 15791577, 15791945, 15792759, 15792904, 15792905, 15793375, 15799982, 15800147, 15800148, + 15800738, 15800739, 15801497, 15801498, 15803568, 15803571, 15805641, 15808771, 15809000, 15815539, 15815540, 15815571, 15816365, + 15816366, 15820482, 15820483, 15820930, 15820933, 15822783, 15822784, 15823306, 15823308, 15823485, 15823486, 15827101, 15827102, + 15830019, 15830020, 15830105, 15830106, 15835137, 15835138, 15838243, 15839723, 15840576, 15841503, 15841688, 15841690, 15847048, + 15847050, 15847745, 15848829, 15850375, 15855827, 15859288, 15859289, 15860023, 15860373, 15860606, 15860607, 15860828, 15860829, + 15861647, 15861648, 15861982, 15861983, 15863539, 15865475, 15865811, 15865812, 15865814, 15865819, 15865939, 15865940, 15866722, + 15866723, 15867794, 15869548, 15870297, 15870823, 15870956, 15870957, 15871190, 15871197, 15871254, 15871766, 15872132, 15873270, + 15875334, 15875634, 15875797, 15876025, 15876802, 15876803, 15876808, 15876810, 15876831, 15876833, 15876844, 15876845, 15876858, + 15876859, 15876865, 15876866, 15876996, 15877054, 15877147, 15878253, 15878396, 15878397, 15878409, 15878410, 15880251, 15880252, + 15880976, 15883223, 15883257, 15883258, 15883267, 15883268, 15883338, 15883366, 15883572, 15883573, 15883704, 15883705, 15883815, + 15883866, 15884708, 15885134, 15886585, 15886948, 15889015, 15889135, 15889263, 15889264, 15889297, 15890107, 15890836, 15890856, + 15891258, 15891259, 15891595, 15891596, 15898995, 15899413, 15900484, 15900485, 15900856, 15900857, 15900999, 15901784, 15902052, + 15902074, 15903287, 15904479, 15904560, 15904561, 15904756, 15904948, 15905428, 15905429, 15908728, 15908729, 15908732, 15908733, + 15908737, 15908739, 15911168, 15911169, 15911465, 15911466, 15912295, 15912378, 15912429, 15912435, 15912645, 15913367, 15915228, + 15915229, 15915232, 15915233, 15915473, 15915474, 15915509, 15915510, 15915885, 15915886, 15916207, 15916208, 15916906, 15916907, + 15917200, 15917202, 15917206, 15917207, 15921490, 15921491, 15921519, 15922789, 15923115, 15923117, 15924339, 15924525, 15924533, + 15926434, 15927196, 15928263, 15929673, 15929674, 15929698, 15929766, 15930272, 15941143, 15941944, 15941945, 15941949, 15941950, + 15941954, 15941955, 15941966, 15941967, 15942041, 15942242, 15943918, 15944225, 15944958, 15948423, 15948742, 15948893, 15948934, + 15948935, 15948952, 15948953, 15948974, 15948975, 15948980, 15948981, 15948984, 15948985, 15948995, 15948996, 15949061, 15949062, + 15950050, 15950051, 15950637, 15950638, 15950642, 15950643, 15950646, 15950647, 15950650, 15950651, 15950666, 15950667, 15950686, + 15950687, 15951694, 15951695, 15951941, 15951942, 15951970, 15951971, 15951974, 15951975, 15951978, 15951979, 15952040, 15954672, + 15956700, 15956815, 15957170, 15957963, 15965549, 15968309, 15969082, 15969120, 15970110, 15970111, 15970828, 15970854, 15971891, + 15971916, 15971980, 15972006, 15973526, 15973527, 15973835, 15974371, 15976265, 15977379, 15978362, 15978948, 15979197, 15980087, + 15980290, 15980299, 15981105, 15981106, 15981914, 15981915, 15982995, 15985005, 15985847, 15986020, 15986468, 15990277, 15990962, + 15991688, 15992374, 15992627, 15992966, 15994933, 15995140, 15995217, 15998964, 16006307, 16010481, 16011214, 16012893, 16013844, + 16015906, 17636688, 17637873, 17638275, 17638348, 17638487, 17638892, 17664726, 17667175, 17673330, 17673544, 17673816, 17681905, + 17685084, 17685085, 17687705, 17691885, 17692405, 17693311, 17694199, 17698519, 17699421, 17699575, 17699776, 17704976, 17705868, + 17707335, 17707490, 17710949, 17711356, 17711906, 17712444, 17720306, 17720567, 17723439, 17723538, 17729149, 17729172, 17730669, + 17735353, 17738506, 17739593, 17742978, 17746144, 17752865, 17759547, 17770240, 17774229, 17774250, 17778606, 17779105, 17782179, + 17783310, 17783420, 17784087, 17791119, 17792330, 17793195, 17795208, 17796208, 17798702, 17803925, 17806758, 17808553, 17811929, + 17815836, 17818217, 17853647, 17855162, 17855180, 17874661, 17881967, 17886031, 17886472, 17886499, 17892400, 17892586, 17893593, + 17918105, 17920208, 17923983, 17932312, 17940478, 17949572, 17950256, 17978577, 17978638, 17979243, 17981913, 17981914, 17986345, + 17995612, 17998455, 18001936, 18018601, 18019359, 18020832, 18020852, 18020857, 18021161, 18024791, 18028665, 18028982, 18029024, + 18029065, 18029402, 18029410, 18029412, 18029430, 18029461, 18029535, 18029709, 18029941, 18030109, 18030158, 18030174, 18030618, + 18030897, 18031010, 18031050, 18031102, 18031119, 18033407, 18033471, 18033519, 18034800, 18035522, 18035524, 18035558, 18035587, + 18035592, 18035611, 18035718, 18036283, 18037159, 18037177, 18037518, 18037756, 18037831, 18038107, 18038314, 18040137, 18040830, + 18042044, 18042107, 18042113, 18042989, 18044136, 18044214, 18045284, 18046457, 18046504, 18046619, 18046757, 18047186, 18047597, + 18047661, 18047776, 18047878, 18047880, 18048688, 18049264, 18050153, 18050586, 18050926, 18051022, 18052532, 18052575, 18052827, + 18053165, 18053676, 18053753, 18054135, 18055170, 18056994, 18057401, 18057693, 18057697, 18058403, 18058457, 18058779, 18058896, + 18059950, 18059951, 18061046, 18061130, 18061163, 18061330, 18062045, 18062047, 18062332, 18063045, 18063475, 18063531, 18063738, + 18064294, 18065075, 18065242, 18065980, 18066212, 18066443, 18066962, 18067060, 18067533, 18067720, 18067880, 18067908, 18067926, + 18069030, 18069287, 18069478, 18069486, 18070682, 18070696, 18070945, 18070960, 18071100, 18071247, 18071778, 18071877, 18071965, + 18072000, 18072080, 18072170, 18072197, 18072238, 18072391, 18072987, 18073243, 18074765, 18075302, 18075625, 18075780, 18075781, + 18075911, 18075915, 18075944, 18075961, 18078850, 18079649, 18082360, 18084867, 18084911, 18085324, 18085709, 18087962, 18087963, + 18088191, 18088242, 18088250, 18088280, 18088356, 18088559, 18088585, 18088685, 18088801, 18089141, 18089688, 18089823, 18090573, + 18092942, 18093321, 18093525, 18093792, 18094278, 18094280, 18094353, 18094818, 18095086, 18096830, 18096870, 18096945, 18099264, + 18099563, 18103567, 18105534, 18105712, 18105730, 18106676, 18106758, 18107898, 18108072, 18108109, 18108251, 18108364, 18108366, + 18108385, 18108608, 18109192, 18109630, 18109736, 18109886, 18110216, 18111914, 18117472, 18120015, 18121451, 18121461, 18123475, + 18126178, 18127068, 18127313, 18128050, 18128330, 18128335, 18128741, 18129173, 18129186, 18129274, 18129299, 18129598, 18129647, + 18130999, 18131052, 18132357, 18132384, 18132993, 18133129, 18133459, 18134121, 18134494, 18134563, 18134668, 18134725, 18135378, + 18135538, 18135637, 18136098, 18136421, 18136723, 18136850, 18138655, 18138798, 18139149, 18139266, 18139885, 18144618, 18145061, + 18145076, 18145167, 18145171, 18145489, 18145498, 18151530, 18154233, 18157193, 18157230, 18157352, 18157653, 18158227, 18159887, + 18160433, 18160599, 18163130, 18167158, 18167584, 18167696, 18168147, 18168194, 18169252, 18169257, 18169269, 18171907, 18171970, + 18173270, 18173746, 18173941, 18173950, 18174259, 18174963, 18176304, 18176339, 18176342, 18177237, 18177283, 18177395, 18177473, + 18177557, 18177648, 18178048, 18178068, 18179144, 18179923, 18180023, 18180031, 18182471, 18182554, 18183350, 18185302, 18186630, + 18189759, 18191550, 18191572, 18191690, 18191760, 18209428, 18209658, 18210069, 18210134, 18211447, 18211680, 18213658, 18214305, + 18226915, 18227231, 18233695, 18234036, 18234679, 18237160, 18237345, 18237354, 18237447, 18238159, 18238169, 18238305, 18238306, + 18238341, 18239452, 18239552, 18239591, 18242107, 18243775, 18247187, 18248062, 18248090, 18248152, 18248702, 18248948, 18251287, + 18253159, 18253172, 18253256, 18253494, 18253674, 18253702, 18253731, 18253737, 18254465, 18254579, 18254961, 18255157, 18255423, + 18255953, 18255964, 18255975, 18256059, 18256119, 18256175, 18256361, 18258481, 18258531, 18258617, 18258894, 18258898, 18258975, + 18259049, 18259278, 18259287, 18259310, 18260016, 18261458, 18261488, 18261623, 18262488, 18262528, 18262642, 18262749, 18262798, + 18262808, 18262813, 18262819, 18262827, 18262860, 18263274, 18265073, 18265373, 18274127, 18274713, 18274727, 18275088, 18275112, + 18275130, 18278505, 18278955, 18279067, 18279081, 18282620, 18282661, 18283406, 18283563, 18283848, 18284148, 18284248, 18284447, + 18284548, 18285101, 18285102, 18285296, 18285465, 18285587, 18286538, 18286732, 18286922, 18287028, 18287423, 18287435, 18288316, + 18288614, 18288684, 18289315, 18289388, 18289811, 18290157, 18291493, 18291622, 18291700, 18291765, 18292103, 18292104, 18292192, + 18292266, 18293383, 18293550, 18293680, 18293751, 18293811, 18294213, 18294759, 18299826, 18299990, 18300398, 18301246, 18301327, + 18303702, 18303813, 18304121, 18306402, 18306490, 18306738, 18307134, 18307258, 18307380, 18307382, 18307680, 18308694, 18308707, + 18308744, 18308789, 18308936, 18309470, 18309756, 18310124, 18310324, 18310679, 18313272, 18313276, 18313936, 18313942, 18314463, + 18314471, 18314489, 18314786, 18314944, 18314957, 18315430, 18315905, 18315975, 18316319, 18316622, 18316913, 18317424, 18317507, + 18317562, 18317614, 18318101, 18318833, 18319890, 18320642, 18320688, 18322258, 18322526, 18322711, 18323528, 18323546, 18324258, + 18326071, 18328517, 18329261, 18333428, 18334440, 18334468, 18340005, 18340701, 18341515, 18342104, 18343985, 18344306, 18344387, + 18344445, 18349782, 18354524, 18354532, 18354567, 18354647, 18355784, 18355800, 18355890, 18356093, 18356174, 18357105, 18358907, + 18359179, 18360540, 18360761, 18361109, 18362474, 18362701, 18363071, 18363333, 18363353, 18363359, 18363669, 18363849, 18364852, + 18365537, 18365642, 18370037, 18374101, 18374518, 18374703, 18378858, 18378979, 18379121, 18388650, 18392831, 18392906, 18393035, + 18393498, 18395705, 18396655, 18396696, 18399717, 18399721, 18399791, 18399885, 18400237, 18400318, 18401555, 18403896, 18403898, + 18403948, 18403950, 18404071, 18404074, 18404115, 18404117, 18404169, 18404170, 18404177, 18404214, 18408893, 18409021, 18409026, + 18409046, 18409296, 18409304, 18409332, 18409338, 18409342, 18409356, 18409383, 18409396, 18409511, 18409551, 18409567, 18409579, + 18409581, 18409638, 18409642, 18409660, 18409669, 18409705, 18409710, 18409737, 18410309, 18410336, 18410366, 18410382, 18410392, + 18410418, 18410426, 18410429, 18410929, 18410976, 18411158, 18414923, 18414966, 18414967, 18414971, 18414973, 18414996, 18415012, + 18415335, 18415343, 18415344, 18415372, 18415383, 18415401, 18415404, 18415409, 18415410, 18415439, 18415463, 18415730, 18415734, + 18415751, 18415752, 18415755, 18415762, 18415770, 18415789, 18415907, 18415911, 18415914, 18415915, 18415918, 18415919, 18415924, + 18415934, 18415935, 18415948, 18415951, 18415960, 18415962, 18415969, 18415974, 18415988, 18415996, 18416003, 18416007, 18416096, + 18416097, 18416098, 18416099, 18416110, 18416111, 18416121, 18417000, 18417004, 18417110, 18417111, 18417153, 18417223, 18417250, + 18417254, 18417255, 18417271, 18417276, 18417298, 18417306, 18418074, 18418081, 18419778, 18419803, 18419847, 18419867, 18419982, + 18420104, 18420138, 18420139, 18420149, 18420289, 18420295, 18421340, 18421341, 18421351, 18421354, 18421396, 18422027, 18422036, + 18422039, 18422146, 18422232, 18422238, 18422335, 18422473, 18422479, 18422569, 18422577, 18422932, 18423232, 18423233, 18423380, + 18423386, 18423801, 18423803, 18424005, 18424006, 18424106, 18424119, 18427918, 18428063, 18428188, 18428190, 18428341, 18428344, + 18428376, 18428378, 18428415, 18429089, 18429190, 18429191, 18429295, 18429301, 18429401, 18429408, 18429419, 18429425, 18429515, + 18429526, 18429763, 18430201, 18430203, 18430403, 18431180, 18431188, 18431554, 18431563, 18431586, 18431622, 18431858, 18431859, + 18432040, 18432050, 18432832, 18433010, 18433079, 18433119, 18459655, 18461356, 18461857, 18462173, 18463453, 18463531, 18479349, + 18479433, 18479437, 18479545, 18479547, 18479583, 18479584, 18479595, 18479615, 18479616, 18479622, 18481099, 18481103, 18481144, + 18481145, 18481150, 18481262, 18481457, 18481554, 18481769, 18485920, 18501825, 18501901, 18501914, 18503176, 18503321, 18503324, + 18503327, 18503748, 18503861, 18505085, 18505121, 18505795, 18505826, 18505827, 18505942, 18507352, 18507393, 18507395, 18507485, + 18507493, 18513155, 18513195, 18513450, 18513477, 18513488, 18513513, 18513532, 18513740, 18535188, 18535211, 18535223, 18535504, + 18535506, 18535511, 18535523, 18535526, 18535693, 18535863, 18535867, 18535950, 18535960, 18536171, 18536855, 18536862, 18536866, + 18536868, 18536869, 18537563, 18537686, 18537828, 18537830, 18539322, 18539428, 18539449, 18539565, 18539569, 18542957, 18549853, + 18549867, 18614667, 18614674, 18614685, 18614689, 18629129, 18629130, 18629263, 18629369, 18629370, 18629490, 18629492, 18630041, + 18630174, 18630284, 18640752, 18640754, 18640811, 18640900, 18640907, 18640943, 18640945, 18641080, 18641081, 18641157, 18641158, + 18641209, 18641401, 18642300, 18642313, 18642314, 18642405, 18642455, 18642533, 18642534, 18642593, 18642798, 18642799, 18644754, + 18690658, 18690699, 18692929, 18692939, 18698953, 18698954, 18699153, 18699427, 18699430, 18700378, 18700541, 18700543, 18700746, + 18700748, 18700766, 18700833, 18700834, 18700841, 18700842, 18701022, 18701473, 18701507, 18701522, 18701524, 18701573, 18701579, + 18701583, 18701911, 18702014, 18702025, 18702055, 18702094, 18702904, 18703319, 18703328, 18703920, 18704157, 18704427, 18704428, + 18705700, 18706080, 18707114, 18707117, 18707253, 18707486, 18707577, 18707592, 18707596, 18707946, 18707947, 18707956, 18707959, + 18707960, 18708017, 18708020, 18708754, 18708755, 18708938, 18709230, 18709237, 18709605, 18709606, 18709614, 18709621, 18709666, + 18709675, 18709742, 18709754, 18709760, 18709875, 18709881, 18709972, 18709987, 18710107, 18710153, 18710156, 18710159, 18710194, + 18710203, 18710456, 18710530, 18710672, 18722404, 18722407, 18722441, 18722444, 18722474, 18722476, 18722661, 18722684, 18722853, + 18722855, 18722857, 18722860, 18722964, 18722965, 18722991, 18723370, 18723413, 18723704, 18723707, 18723764, 18723766, 18723857, + 18723860, 18723916, 18723941, 18723981, 18735304, 18735677, 18737090, 18737199, 18737256, 18737264, 18737394, 18737400, 18738534, + 18738537, 18738632, 18738633, 18738690, 18738691, 18738755, 18739002, 18739014, 18739017, 18739026, 18739095, 18739204, 18739715, + 18739719, 18739774, 18739780, 18741326, 18741377, 18742319, 18742321, 18742401, 18743044, 18743049, 18743102, 18743109, 18743127, + 18743150, 18743153, 18744034, 18744038, 18744047, 18744053, 18744099, 18744100, 18744161, 18744178, 18744272, 18744440, 18744448, + 18744503, 18744507, 18744957, 18744963, 18745309, 18746182, 18746720, 18746766, 18746769, 18747055, 18747115, 18747509, 18748208, + 18748215, 18748216, 18748616, 18748632, 18748881, 18748930, 18749143, 18749153, 18749347, 18749597, 18749859, 18749862, 18749865, + 18750557, 18750566, 18750749, 18751180, 18751334, 18751358, 18751444, 18751733, 18751772, 18751777, 18751784, 18751800, 18751962, + 18751964, 18751967, 18751970, 18751974, 18751975, 18751977, 18752073, 18752085, 18752241, 18752245, 18752369, 18752782, 18752796, + 18753020, 18753025, 18753230, 18753299, 18753321, 18753444, 18754157, 18754468, 18754629, 18754632, 18755348, 18755580, 18755647, + 18756137, 18756196, 18757143, 18757175, 18757227, 18757294, 18757300, 18757544, 18757547, 18757917, 18757930, 18758219, 18758228, + 18758428, 18783923, 18784255, 18784257, 18784278, 18784506, 18784512, 18785925, 18785928, 18786059, 18787397, 18787805, 18787842, + 18840505, 18840540, 18842111, 18842255, 18842546, 18842613, 18843081, 18843086, 18843202, 18877846, 18877886, 18877938, 18877995, + 18878286, 18878288, 18878602, 18878604, 18878910, 18879022, 18879087, 18879201, 18879299, 18879376, 18879694, 18879819, 18879825, + 18879959, 18879963, 18880086, 18880208, 18880209, 18880253, 18880256, 18880438, 18880477, 18880478, 18880579, 18880588, 18880589, + 18880590, 18880674, 18880675, 18880688, 18880690, 18880698, 18880703, 18880710, 18880723, 18880777, 18880778, 18880818, 18880829, + 18880956, 18880957, 18880961, 18880971, 18881047, 18881049, 18881057, 18881059, 18881244, 18881250, 18881271, 18881309, 18881313, + 18881413, 18881417, 18881470, 18881473, 18881573, 18881588, 18881603, 18881665, 18881667, 18881833, 18881834, 18881875, 18881876, + 18881945, 18881946, 18882110, 18882201, 18882333, 18882334, 18882600, 18882620, 18882747, 18882795, 18882797, 18882825, 18882827, + 18882864, 18882874, 18883468, 18883469, 18883511, 18883515, 18883910, 18884107, 18884303, 18884455, 18884839, 18884840, 18884853, + 18885134, 18885240, 18885713, 18885715, 18885719, 18885720, 18890921, 18890923, 18890924, 18891002, 18891007, 18891013, 18891073, + 18891226, 18891230, 18891902, 18892071, 18916117, 18916500, 18917173, 18917229, 18917481, 18917487, 18917714, 18918454, 18918700, + 18919243, 18919244, 18919304, 18919307, 18919365, 18919372, 18919534, 18919859, 18919932, 18920320, 18934396, 18934399, 18934421, + 18934700, 18935088, 18935417, 18935420, 18935494, 18935501, 18936000, 18936103, 18936391, 18936459, 18936570, 18936578, 18936587, + 18936614, 18936649, 18936673, 18962602, 18962613, 18962625, 18962645, 18962662, 18962676, 18963370, 18963420, 18963833, 18963836, + 18963887, 18963911, 18964240, 18964303, 18964451, 18964454, 18964458, 18964500, 18964761, 18965395, 18965426, 18965875, 18965880, + 18965881, 18965931, 18965958, 18965959, 18965984, 18965985, 18967428, 18967463, 18967632, 18968583, 18968607, 18972151, 18972181, + 18972195, 18972196, 18972221, 18972231, 18972471, 18972549, 18972554, 18972611, 18972613, 18972651, 18972928, 18972929, 18972973, + 18972974, 18972992, 18972993, 18973042, 18973044, 18973048, 18973096, 18973098, 18973116, 18973218, 18973912, 18973952, 18973955, + 18974076, 18974093, 18974104, 18974117, 18974129, 18974206, 18974209, 18974419, 18974465, 18974797, 18974894, 18975162, 18975166, + 18975316, 18975374, 18975576, 18975578, 18976376, 18976386, 18976399, 18976405, 18977338, 18977345, 18977358, 18977728, 18977730, + 18977734, 18977736, 18978127, 18978129, 18978246, 18978494, 18978496, 18978826, 18978859, 18978866, 18978868, 18978873, 18978921, + 18978923, 18978933, 18978935, 18979157, 18979213, 18979247, 18979362, 18979627, 18979629, 18979659, 18979665, 18979666, 18979668, + 18979670, 18979746, 18979760, 18979767, 18979772, 18979782, 18979798, 18979820, 18979833, 18979855, 18979857, 18979955, 18979956, + 18980169, 18980439, 18980547, 18980548, 18980554, 18980591, 18980595, 18980691, 18980698, 18980831, 18980853, 18981626, 18981703, + 18981830, 18981937, 18981943, 18982171, 18982176, 18982186, 18982188, 18982196, 18982429, 18982431, 18982437, 18982740, 18982825, + 18982829, 18982867, 18982883, 18982926, 18983055, 18983244, 18983397, 18983401, 18983612, 18983619, 18983620, 18983932, 18983935, + 18983996, 18984329, 18984386, 18984405, 18984407, 18984413, 18984431, 18984501, 18984511, 18984763, 18984769, 18984913, 18984991, + 18985047, 18985161, 18985246, 18985248, 18985301, 18985304, 18985312, 18985520, 18985521, 18985726, 18985822, 18985850, 18986106, + 18986173, 18986174, 18986252, 18986266, 18986267, 18987017, 18987031, 18987048, 18987053, 18987081, 18987680, 18988159, 18988166, + 18988194, 18988205, 18988573, 18988712, 18988715, 18988857, 18988982, 18988984, 18988985, 18989012, 18989013, 18989018, 18989086, + 18989099, 18989125, 18989132, 18989165, 18989462, 18989464, 18989759, 18989899, 18989954, 18989955, 18990839, 18990846, 18990863, + 18990866, 18991105, 18991433, 18991452, 18991456, 18991462, 18991467, 18991469, 18991662, 18992464, 18992650, 18992774, 18992801, + 18992856, 18992860, 18992906, 18999657, 18999676, 18999686, 18999697, 18999881, 18999886, 19000091, 19000224, 19000241, 19000489, + 19000503, 19001195, 19001201, 19001347, 19001359, 19007968, 19007971, 19008121, 19011401, 19011569, 19011588, 19011656, 19011677, + 19011754, 19011759, 19012403, 19012416, 19012603, 19012613, 19012746, 19012747, 19014099, 19014206, 19020339, 19020428, 19020735, + 19020954, 19020959, 19021745, 19021748, 19021802, 19021803, 19022518, 19022523, 19157469, 19157470, 19157562, 19157597, 19157681, + 19157693, 19157727, 19157735, 19177628, 19177631, 19179127, 19180014, 19180478, 19180496, 19180576, 19180594, 19180601, 19180609, + 19182388, 19182390, 19182566, 19182598, 19183939, 19184062, 19184172, 19184613, 19187655, 19187674, 19187949, 19187959, 19189135, + 19190233, 19190353, 19190502, 19190504, 19190594, 19191003, 19191043, 19191046, 19191091, 19191098, 19191118, 19191122, 19191234, + 19191237, 19191305, 19191307, 19191407, 19191408, 19191453, 19191858, 19192015, 19192485, 19192487, 19192606, 19192607, 19192611, + 19192615, 19192896, 19192903, 19193680, 19193768, 19193789, 19193876, 19193879, 19194492, 19195385, 19200168, 19200172, 19200274, + 19200290, 19200578, 19200583, 19202205, 19202286, 19202388, 19202392, 19202403, 19202424, 19202450, 19202506, 19202509, 19203134, + 19203366, 19203572, 19203746, 19203752, 19204197, 19206989, 19207000, 19207077, 19207171, 19207271, 19207272, 19208337, 19208345, + 19208730, 19212689, 19212690, 19212744, 19212946, 19212947, 19213039, 19213045, 19213048, 19213301, 19213303, 19213574, 19213575, + 19213942, 19214581, 19214583, 19214681, 19214684, 19214905, 19215052, 19215418, 19216089, 19216095, 19218331, 19218601, 19218604, + 19218875, 19219205, 19220095, 19220100, 19221680, 19221683, 19221894, 19222484, 19222586, 19222590, 19224624, 19224626, 19225180, + 19226142, 19226145, 19226595, 19226609, 19226890, 19226896, 19226910, 19226911, 19226927, 19227005, 19227837, 19227907, 19227909, + 19228054, 19228056, 19228106, 19228107, 19228121, 19228123, 19228259, 19228261, 19228302, 19228304, 19229883, 19229890, 19230123, + 19233910, 19234320, 19234345, 19234424, 19234537, 19234956, 19235288, 19235308, 19237190, 19237199, 19237208, 19237233, 19239254, + 19239258, 19239376, 19239377, 19239389, 19239407, 19240001, 19240024, 19240499, 19240901, 19250124, 19250127, 19250230, 19250239, + 19252820, 19252824, 19252856, 19252859, 19253253, 19253258, 19253341, 19253648, 19253658, 19254248, 19254257, 19254261, 19254273, + 19255415, 19255483, 19255486, 19256056, 19256595, 19256596, 19257023, 19257421, 19257656, 19257794, 19257795, 19257825, 19257827, + 19257973, 19258287, 19258305, 19259424, 19259426, 19260016, 19260028, 19260034, 19260047, 19260053, 19260136, 19260185, 19260252, + 19260535, 19260539, 19263045, 19263046, 19263072, 19263297, 19263547, 19264542, 19264897, 19268898, 19268900, 19268986, 19268990, + 19269163, 19269421, 19269423, 19271598, 19271984, 19272062, 19272201, 19272203, 19272401, 19272409, 19272445, 19272449, 19281870, + 19281883, 19282504, 19285192, 19285575, 19285576, 19285624, 19301651, 19301652, 19301719, 19301721, 19302758, 19302769, 19302830, + 19302832, 19302846, 19304733, 19304737, 19304857, 19304863, 19304956, 19304961, 19305572, 19306684, 19306759, 19306763, 19306795, + 19306821, 19306844, 19306849, 19307117, 19307412, 19307778, 19307893, 19308083, 19308148, 19308304, 19314020, 19314021, 19314052, + 19314238, 19314253, 19315712, 19316333, 19317997, 19317999, 19318269, 19318271, 19318527, 19318529, 19318536, 19318578, 19318582, + 19318880, 19318881, 19319054, 19319328, 19319330, 19319376, 19324587, 19324593, 19324769, 19324771, 19324874, 19324883, 19324952, + 19324954, 19325006, 19325007, 19325008, 19325103, 19325184, 19325185, 19325391, 19325392, 19325399, 19325401, 19325570, 19325804, + 19326308, 19326329, 19326348, 19326618, 19326756, 19326757, 19326935, 19326944, 19326947, 19327176, 19327529, 19329583, 19329702, + 19329703, 19329745, 19329746, 19329754, 19329758, 19330909, 19330912, 19331006, 19331009, 19331094, 19331095, 19331200, 19331224, + 19331676, 19331678, 19331729, 19331732, 19332246, 19332827, 19332934, 19332935, 19333061, 19358286, 19358287, 19358310, 19360688, + 19360690, 19360794, 19360932, 19361096, 19362472, 19362473, 19362976, 19362979, 19363289, 19363291, 19363391, 19363719, 19364350, + 19364366, 19364392, 19364402, 19364936, 19364944, 19365015, 19365017, 19365059, 19365710, 19365714, 19365844, 19366349, 19366686, + 19366920, 19366924, 19367057, 19367062, 19367152, 19367158, 19367216, 19367219, 19367501, 19367504, 19368429, 19368434, 19368444, + 19368449, 19368461, 19368484, 19368500, 19368501, 19368676, 19368680, 19368783, 19368797, 19368801, 19368942, 19368948, 19368949, + 19368955, 19368966, 19369066, 19369075, 19369217, 19369229, 19369302, 19369310, 19369314, 19369341, 19369343, 19369598, 19369600, + 19369688, 19369690, 19369879, 19369904, 19369907, 19369914, 19369919, 19369924, 19370031, 19373906, 19373910, 19373914, 19373996, + 19374015, 19374165, 19374181, 19374182, 19374198, 19374266, 19374299, 19374800, 19375006, 19375010, 19375171, 19375174, 19375178, + 19375183, 19375189, 19375203, 19375209, 19375252, 19375259, 19375260, 19375719, 19375788, 19375789, 19376019, 19376020, 19376061, + 19385710, 19385787, 19389326, 19389328, 19389440, 19389442, 19389987, 19390185, 19390188, 19390245, 19390250, 19390286, 19390313, + 19390322, 19390345, 19390352, 19390586, 19390710, 19392042, 19392044, 19410405, 19410437, 19410449, 19410488, 19410489, 19410496, + 19410497, 19410510, 19410916, 19411000, 19411002, 19411204, 19411937, 19411939, 19411997, 19512944, 19513029, 19513189, 19513202, + 19513396, 19513538, 19513695, 19513945, 19513992, 19516059, 19516062, 19516075, 19516084, 19516968, 19517224, 19554953, 19558472, + 19609701, 19609719, 19609892, 19609947, 19610025, 19610494, 19610647, 19610652, 19610959, 19611209, 19611291, 19612269, 19612444, + 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285, 19613989, 19614239, 19614595, 19614600, + 19614607, 19615112, 19615114, 19615248, 19726042, 19726057, 19748242, 19748244, 19748269, 19748278, 19748377, 19750672, 19750695, + 19750702, 19750822, 19750833, 19751058, 19751064, 19751102, 19751108, 19751169, 19751172, 19751269, 19751854, 19751865, 19751878, + 19751936, 19752030, 19752349, 19755044, 19755063, 19755440, 19755881, 19756813, 19761538, 19761592, 19761593, 19761680, 19761685, + 19761995, 19762162, 19762167, 19763218, 19763430, 19763945, 19764280, 19764311, 19764333, 19764676, 19764744, 19765216, 19765374, + 19765479, 19767631, 19792072, 19792136, 19792139, 19793277, 19793318, 19793322, 19793528, 19793536, 19796241, 19796405, 19796407, + 19802815, 19802816, 19802881, 19804775, 19805218, 19805360, 19805515, 19807739, 19807796, 19808997, 19809396, 19809725, 19809990, + 19913194, 19913195, 19914726, 19914727, 19914735, 19914741, 19914769, 19914811, 19914876, 19914877, 19916067, 19917537, 19917540, + 19917991, 19918159, 19918171, 19918197, 19918202, 19918295, 19918302, 19918429, 19918432, 19918524, 19918639, 19918716, 19918797, + 19918799, 19918991, 19918992, 19919153, 19919287, 19919383, 19919514, 19919971, 19919995, 19920374, 19920778, 19920779, 19921528, + 19921531, 19921674, 19921675, 19921724, 19923306, 19923308, 19923480, 19923532, 19923534, 19923692, 19923702, 19923790, 19923814, + 19923818, 19923880, 19923884, 19924275, 19924279, 19924358, 19924367, 19924384, 19925554, 19925869, 19926582, 19926586, 19926619, + 19926620, 19926687, 19926859, 19926884, 19926887, 19926891, 19926959, 19927302, 19927422, 19928859, 19929054, 19932992, 19933015, + 19933313, 19933316, 19933328, 19933410, 19933760, 19933818, 19933876, 19934184, 19934490, 19934606, 19934621, 19934741, 19959354, + 19959578, 19960026, 19960122, 19962154, 19962536 +]; +export const PEG_CROSS_BLOCKS_LAST: u32 = 19962536; diff --git a/projects/subgraph-bean/cache-builder/results/PegCrossBlocks2.ts b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks2.ts deleted file mode 100644 index 4a5663d38a..0000000000 --- a/projects/subgraph-bean/cache-builder/results/PegCrossBlocks2.ts +++ /dev/null @@ -1,624 +0,0 @@ -export const PEG_CROSS_BLOCKS: u32[] = [ - 12974091, 12975421, 12978538, 12978615, 12978680, 12978911, 12979148, 12979149, 12979167, 12979171, 12979228, 12979230, 12979607, - 12983847, 12983871, 12983895, 12983897, 12983926, 12984038, 12984104, 12984170, 12984257, 12984310, 12984929, 12986590, 12986603, - 12986901, 12987603, 12990064, 12991358, 12991399, 12992193, 12992519, 12993217, 12993281, 12998537, 12998539, 12998546, 12998550, - 12998551, 12998553, 12999530, 12999585, 12999767, 12999776, 12999777, 12999779, 12999817, 12999840, 13000158, 13000196, 13000305, - 13000309, 13000334, 13000347, 13000356, 13000377, 13000577, 13000587, 13001082, 13001089, 13001396, 13001414, 13001894, 13001913, - 13001956, 13002009, 13002735, 13002738, 13003196, 13003198, 13004037, 13004045, 13004360, 13004364, 13004638, 13004646, 13004655, - 13004657, 13004817, 13004839, 13004843, 13004883, 13005075, 13005103, 13005107, 13005109, 13005372, 13005380, 13005673, 13005715, - 13005730, 13005733, 13005944, 13005946, 13006200, 13006202, 13006203, 13006321, 13006487, 13006488, 13006499, 13006546, 13006708, - 13006709, 13006980, 13007010, 13007245, 13007246, 13007274, 13007275, 13007509, 13007525, 13007574, 13007607, 13007780, 13007798, - 13007859, 13007898, 13008063, 13008065, 13008117, 13008191, 13008375, 13008387, 13008617, 13008671, 13008712, 13008736, 13008895, - 13008901, 13008906, 13008912, 13009163, 13009169, 13009190, 13009193, 13009199, 13009203, 13009381, 13009423, 13009669, 13009671, - 13009676, 13009679, 13009681, 13009687, 13009958, 13009972, 13009973, 13010009, 13010222, 13010231, 13010492, 13010556, 13010779, - 13014211, 13016266, 13018933, 13019023, 13019754, 13020690, 13020782, 13022699, 13022701, 13022825, 13023185, 13023247, 13023922, - 13025396, 13025666, 13026184, 13026256, 13026638, 13026640, 13027512, 13029384, 13030010, 13030107, 13030123, 13030393, 13030528, - 13031004, 13031259, 13032695, 13032731, 13032942, 13033010, 13033033, 13033210, 13034517, 13034543, 13035839, 13035922, 13035929, - 13036165, 13036689, 13036884, 13036897, 13036926, 13037135, 13037615, 13037642, 13038069, 13038108, 13038138, 13038145, 13038184, - 13039743, 13043682, 13043699, 13044756, 13044762, 13044770, 13044955, 13045801, 13046502, 13051141, 13051348, 13056233, 13056234, - 13057499, 13057501, 13057527, 13057595, 13058927, 13059717, 13059983, 13060079, 13060086, 13060118, 13060119, 13060121, 13060123, - 13060132, 13060160, 13060198, 13060449, 13060450, 13060479, 13060489, 13060492, 13060680, 13060716, 13060796, 13060802, 13060842, - 13060960, 13062059, 13062295, 13062299, 13062306, 13062319, 13062333, 13062352, 13062366, 13063788, 13063838, 13063861, 13063878, - 13075770, 13075888, 13076058, 13076195, 13076316, 13076435, 13076636, 13076662, 13076679, 13076703, 13076890, 13076891, 13076899, - 13076947, 13076964, 13076972, 13077164, 13077246, 13077426, 13077429, 13077495, 13077503, 13077730, 13077736, 13078272, 13078287, - 13078449, 13078457, 13078466, 13078470, 13078482, 13078487, 13078488, 13078519, 13078541, 13078561, 13078796, 13078810, 13078813, - 13078834, 13079299, 13079303, 13079572, 13079587, 13079588, 13079596, 13079620, 13079642, 13079648, 13079683, 13079724, 13079755, - 13079814, 13079885, 13079887, 13079895, 13079899, 13079919, 13079920, 13079941, 13080074, 13080179, 13080198, 13080229, 13080352, - 13080375, 13080400, 13080408, 13080634, 13080637, 13080648, 13080660, 13080672, 13080677, 13080678, 13080680, 13080768, 13080770, - 13080887, 13080888, 13080932, 13080934, 13080937, 13080958, 13080977, 13080990, 13080996, 13080999, 13081011, 13081057, 13081145, - 13081209, 13081632, 13081635, 13081700, 13081721, 13081750, 13081754, 13081766, 13081895, 13081963, 13081977, 13081992, 13081994, - 13082000, 13082006, 13082094, 13082163, 13082230, 13082282, 13082300, 13082301, 13082504, 13082507, 13082510, 13082555, 13082863, - 13082876, 13082878, 13082888, 13082969, 13083844, 13084930, 13084956, 13084984, 13085212, 13085233, 13085236, 13085311, 13085508, - 13085645, 13085877, 13086288, 13086337, 13086338, 13086356, 13086362, 13086369, 13086376, 13086400, 13086422, 13086440, 13086459, - 13086461, 13087211, 13087217, 13087221, 13087225, 13087231, 13087377, 13087393, 13087405, 13087410, 13087411, 13087527, 13088104, - 13088272, 13093705, 13093899, 13093903, 13093921, 13093932, 13093971, 13093975, 13099188, 13099189, 13099353, 13099362, 13099414, - 13099461, 13099465, 13099710, 13099714, 13099747, 13100289, 13100319, 13100358, 13100371, 13100898, 13100923, 13102868, 13102939, - 13107071, 13107096, 13110581, 13110588, 13110634, 13110706, 13110819, 13110844, 13111074, 13113042, 13113109, 13113110, 13113423, - 13113442, 13113448, 13113452, 13113453, 13113553, 13114481, 13114574, 13115940, 13115946, 13115955, 13115972, 13115989, 13115990, - 13117862, 13118077, 13118145, 13118291, 13118320, 13118321, 13118355, 13118356, 13118402, 13118413, 13118423, 13118428, 13118436, - 13118467, 13121070, 13121089, 13121099, 13121128, 13121178, 13121244, 13121307, 13121310, 13122225, 13122395, 13122407, 13122455, - 13122874, 13122951, 13122985, 13124397, 13124895, 13129783, 13129786, 13129854, 13129981, 13129991, 13130001, 13130094, 13130178, - 13131625, 13131662, 13131722, 13131929, 13137125, 13137568, 13138520, 13138647, 13138700, 13138778, 13138782, 13138813, 13138856, - 13138858, 13139212, 13139273, 13139367, 13139407, 13139408, 13139410, 13139609, 13140003, 13140015, 13140024, 13140027, 13140327, - 13140447, 13140687, 13141148, 13141156, 13141160, 13141165, 13141195, 13141863, 13141869, 13141870, 13141940, 13142135, 13143729, - 13143754, 13143760, 13143762, 13143763, 13143816, 13144293, 13144300, 13144362, 13144364, 13144774, 13144823, 13145005, 13145190, - 13145194, 13145195, 13145198, 13145206, 13145220, 13145747, 13146082, 13146089, 13147016, 13147028, 13147044, 13147045, 13148291, - 13148316, 13149112, 13150275, 13150279, 13150280, 13151314, 13151333, 13151356, 13151443, 13151450, 13151451, 13151460, 13151462, - 13151595, 13151598, 13151696, 13151700, 13151863, 13151867, 13152103, 13152260, 13152269, 13153306, 13153325, 13155620, 13156284, - 13156748, 13156781, 13157326, 13158957, 13159234, 13159235, 13159247, 13159248, 13159486, 13159495, 13161064, 13161086, 13161299, - 13161376, 13161392, 13161406, 13161416, 13161423, 13161487, 13161550, 13161611, 13161634, 13161636, 13162200, 13162208, 13162329, - 13162331, 13163395, 13163536, 13163565, 13163567, 13163596, 13163597, 13163604, 13163670, 13163995, 13164187, 13164189, 13164192, - 13164658, 13164746, 13165237, 13165391, 13165408, 13165727, 13165897, 13165996, 13166015, 13166072, 13166219, 13166222, 13166242, - 13166250, 13166251, 13166258, 13166259, 13166283, 13166287, 13166319, 13166381, 13166437, 13167205, 13167549, 13167575, 13167591, - 13167742, 13167972, 13168519, 13168524, 13169110, 13171988, 13175038, 13175053, 13175058, 13175064, 13175069, 13175146, 13175397, - 13175452, 13175497, 13175514, 13175520, 13175609, 13177587, 13177589, 13177597, 13177615, 13177647, 13177659, 13177660, 13177714, - 13177758, 13178360, 13178584, 13178652, 13179149, 13179177, 13179251, 13179252, 13179253, 13179274, 13179308, 13179337, 13179353, - 13179400, 13180079, 13180083, 13180101, 13180102, 13180117, 13180145, 13180189, 13180216, 13180664, 13180692, 13180713, 13180715, - 13180730, 13180758, 13180833, 13180888, 13180897, 13180909, 13181023, 13181155, 13181755, 13181777, 13181802, 13181820, 13182646, - 13182655, 13183890, 13183894, 13183955, 13183956, 13183957, 13184012, 13184973, 13184974, 13185191, 13185260, 13185321, 13185384, - 13185495, 13185703, 13185732, 13185850, 13187086, 13187116, 13187178, 13187233, 13188042, 13189001, 13189010, 13189082, 13191072, - 13191091, 13191099, 13191106, 13191522, 13191635, 13191637, 13191644, 13192232, 13192596, 13192599, 13192604, 13193031, 13193802, - 13194379, 13194410, 13194615, 13194717, 13194719, 13194824, 13196049, 13196067, 13196141, 13196190, 13196445, 13196459, 13196460, - 13198164, 13198273, 13198316, 13198557, 13198899, 13198902, 13198907, 13198909, 13198925, 13199052, 13199074, 13199086, 13199099, - 13199116, 13199129, 13199131, 13199260, 13199361, 13199363, 13200193, 13200194, 13200216, 13200219, 13200224, 13201208, 13201289, - 13201290, 13201321, 13201322, 13206138, 13206229, 13206338, 13206947, 13207266, 13207395, 13207435, 13207444, 13207445, 13207578, - 13207663, 13208184, 13211822, 13211897, 13211967, 13213641, 13214042, 13214163, 13214206, 13215008, 13215982, 13217044, 13217061, - 13217222, 13217341, 13217478, 13217783, 13217784, 13217810, 13217953, 13217970, 13217973, 13218020, 13218050, 13218279, 13218810, - 13218815, 13218816, 13218909, 13218949, 13218953, 13218954, 13225077, 13225299, 13226246, 13226559, 13226732, 13226957, 13227000, - 13229110, 13229499, 13229747, 13232674, 13232699, 13232717, 13233025, 13234172, 13234178, 13234264, 13234554, 13236246, 13236247, - 13236250, 13236319, 13237109, 13237552, 13244459, 13244462, 13245028, 13245032, 13245040, 13245162, 13245172, 13245175, 13245180, - 13245275, 13245545, 13245546, 13246387, 13246388, 13246647, 13246651, 13246920, 13246926, 13246980, 13246983, 13247415, 13247416, - 13247678, 13247695, 13247947, 13247952, 13248208, 13248209, 13248470, 13248473, 13249273, 13249276, 13249292, 13249294, 13249543, - 13249561, 13249800, 13249818, 13249822, 13250039, 13250057, 13250059, 13256813, 13256815, 13257386, 13257389, 13258210, 13258214, - 13259590, 13259594, 13259863, 13259865, 13260039, 13260056, 13260062, 13260063, 13260114, 13260126, 13260381, 13260386, 13260388, - 13260389, 13260884, 13260886, 13261140, 13261142, 13261145, 13261155, 13261156, 13261186, 13261206, 13261363, 13261373, 13261399, - 13262381, 13262382, 13262425, 13262428, 13262440, 13262442, 13262455, 13262462, 13262465, 13262469, 13262553, 13262554, 13262569, - 13262592, 13262593, 13262713, 13262719, 13262729, 13262748, 13262896, 13262899, 13262913, 13263080, 13263772, 13263871, 13264127, - 13264135, 13264139, 13264149, 13272546, 13272560, 13272905, 13272934, 13273058, 13273061, 13273064, 13273373, 13273436, 13273458, - 13273503, 13273513, 13273717, 13273719, 13274023, 13274030, 13274057, 13274064, 13274105, 13274148, 13274189, 13274198, 13274217, - 13274220, 13274242, 13274248, 13335750, 13335755, 13335869, 13336244, 13336323, 13336461, 13336505, 13336560, 13336618, 13336695, - 13336714, 13336777, 13336959, 13337532, 13337559, 13337935, 13337937, 13337959, 13340698, 13340781, 13340820, 13340947, 13341028, - 13341076, 13341108, 13341147, 13341156, 13341366, 13341373, 13342047, 13342121, 13342224, 13342548, 13376585, 13376710, 13376778, - 13378143, 13378793, 13378816, 13378829, 13379464, 13434006, 13434877, 13435565, 13435971, 13436006, 13436018, 13436025, 13436035, - 13436049, 13436107, 13437998, 13438644, 13438667, 13440517, 13442086, 13442913, 13443210, 13443231, 13443232, 13443239, 13443256, - 13443258, 13443270, 13443271, 13444653, 13444660, 13444712, 13446459, 13448008, 13449065, 13449128, 13449167, 13449303, 13449313, - 13449493, 13449495, 13449505, 13449506, 13449551, 13449634, 13449650, 13449705, 13449790, 13449821, 13449841, 13449855, 13449875, - 13449913, 13450052, 13450154, 13450187, 13450472, 13450507, 13450522, 13451061, 13451131, 13451155, 13451468, 13451543, 13451544, - 13451550, 13451555, 13451564, 13451596, 13451598, 13451649, 13451671, 13451675, 13455280, 13455282, 13455557, 13455600, 13455618, - 13455860, 13455891, 13455896, 13455911, 13461738, 13462027, 13462049, 13462066, 13462165, 13463379, 13463381, 13464408, 13466451, - 13467419, 13467691, 13468508, 13468675, 13468784, 13469000, 13469007, 13469012, 13469034, 13470634, 13470770, 13471747, 13474744, - 13474934, 13475341, 13475377, 13475394, 13475519, 13475523, 13475746, 13476174, 13476209, 13476325, 13476418, 13476419, 13479133, - 13479136, 13479138, 13479152, 13479196, 13479242, 13479941, 13480370, 13480372, 13480449, 13480647, 13480648, 13480717, 13481304, - 13481717, 13481988, 13482011, 13482102, 13483897, 13483977, 13483982, 13483998, 13484811, 13484846, 13484847, 13486887, 13486969, - 13488473, 13488482, 13489574, 13489977, 13490465, 13490505, 13490507, 13490517, 13490518, 13491374, 13494424, 13494752, 13494754, - 13495520, 13495854, 13497794, 13497797, 13497803, 13497820, 13497844, 13497868, 13498035, 13503686, 13503690, 13503704, 13503709, - 13503751, 13503763, 13503770, 13503813, 13503910, 13508461, 13508666, 13508680, 13508728, 13508759, 13508780, 13510297, 13510507, - 13510508, 13510514, 13510516, 13510518, 13510520, 13510556, 13510590, 13510603, 13510605, 13510610, 13510727, 13511700, 13511890, - 13511907, 13512045, 13512048, 13512304, 13512305, 13512359, 13512365, 13514281, 13514282, 13514705, 13514719, 13514721, 13514734, - 13515060, 13516318, 13516526, 13516569, 13517036, 13517567, 13518970, 13519495, 13519497, 13519756, 13521882, 13522133, 13523828, - 13523847, 13523862, 13523885, 13523912, 13523967, 13523969, 13524379, 13524397, 13525787, 13525872, 13525873, 13528534, 13528544, - 13528546, 13528558, 13528574, 13528579, 13528967, 13529028, 13531631, 13531875, 13531910, 13531954, 13531961, 13531990, 13532016, - 13532023, 13532081, 13532126, 13532137, 13532138, 13532143, 13532151, 13532161, 13532176, 13532179, 13532198, 13532239, 13532920, - 13532929, 13532946, 13533454, 13533933, 13535490, 13535493, 13535494, 13535499, 13538211, 13538232, 13538866, 13538895, 13539218, - 13539249, 13539673, 13539923, 13539946, 13539951, 13540826, 13540841, 13541140, 13541325, 13541849, 13541933, 13541958, 13541980, - 13541997, 13542002, 13542077, 13542086, 13542175, 13542179, 13542232, 13542254, 13543917, 13544624, 13545832, 13545837, 13545858, - 13546411, 13547018, 13547059, 13547095, 13547595, 13547630, 13548233, 13548387, 13550252, 13550987, 13551029, 13551119, 13551280, - 13551291, 13552190, 13552241, 13552260, 13552307, 13552675, 13552678, 13552681, 13552684, 13552688, 13552701, 13552704, 13552750, - 13552752, 13552754, 13552943, 13553661, 13553662, 13553676, 13553677, 13553853, 13554976, 13555095, 13555457, 13557196, 13557954, - 13558105, 13558112, 13558113, 13558114, 13558116, 13558121, 13558735, 13558752, 13558776, 13559078, 13559084, 13559255, 13559291, - 13559303, 13559410, 13559415, 13559416, 13559425, 13559561, 13559568, 13559602, 13559647, 13559656, 13559658, 13559791, 13559882, - 13560317, 13560318, 13560937, 13564634, 13564681, 13564697, 13564713, 13564837, 13564852, 13564859, 13564871, 13564879, 13564889, - 13564891, 13566648, 13568113, 13568302, 13568342, 13568345, 13568357, 13568484, 13568492, 13568495, 13568667, 13570256, 13570277, - 13570284, 13570300, 13570316, 13570318, 13570944, 13570952, 13571175, 13572652, 13572673, 13572674, 13572854, 13572856, 13572884, - 13572895, 13572918, 13572923, 13572958, 13572969, 13573024, 13573028, 13573096, 13573097, 13573405, 13573522, 13573523, 13573686, - 13573687, 13573693, 13573695, 13574201, 13574213, 13574289, 13574294, 13575376, 13575377, 13576614, 13576620, 13576635, 13576661, - 13576663, 13577153, 13577969, 13578897, 13578901, 13578940, 13578947, 13579158, 13579160, 13579235, 13579351, 13579385, 13579447, - 13579490, 13579530, 13579565, 13579572, 13579588, 13579894, 13579900, 13579911, 13579912, 13579914, 13579918, 13579942, 13580072, - 13580087, 13580260, 13580280, 13581920, 13582005, 13582060, 13582068, 13582069, 13582090, 13582096, 13582336, 13582467, 13582468, - 13582749, 13583449, 13583933, 13584045, 13584069, 13584076, 13584080, 13584082, 13584102, 13584104, 13584107, 13584126, 13584153, - 13584183, 13584184, 13584192, 13584195, 13584208, 13584209, 13584211, 13584243, 13584286, 13584294, 13584296, 13584485, 13584486, - 13585001, 13585594, 13585602, 13585607, 13585610, 13585641, 13585748, 13585775, 13585976, 13585992, 13586067, 13587038, 13587054, - 13587160, 13589367, 13589405, 13589454, 13589471, 13589485, 13589486, 13589512, 13589515, 13589527, 13589532, 13589574, 13589656, - 13589661, 13589867, 13590103, 13592391, 13594358, 13595502, 13595599, 13595883, 13596659, 13596666, 13596668, 13596671, 13598662, - 13599510, 13599974, 13600003, 13600116, 13600221, 13600229, 13600230, 13600343, 13600344, 13600519, 13602309, 13602377, 13602479, - 13602483, 13602486, 13602488, 13602489, 13602490, 13602493, 13602978, 13603574, 13603586, 13603652, 13603887, 13604255, 13605773, - 13605779, 13606896, 13607198, 13607202, 13607203, 13608420, 13608519, 13608665, 13608681, 13608968, 13610066, 13611161, 13614876, - 13614927, 13614991, 13614998, 13615404, 13617630, 13618342, 13621035, 13622147, 13623486, 13623495, 13623499, 13623577, 13623590, - 13623764, 13624270, 13624355, 13624363, 13624366, 13624383, 13624517, 13625958, 13625960, 13625982, 13626112, 13626125, 13626166, - 13626170, 13626212, 13628785, 13628854, 13628864, 13628865, 13629661, 13629662, 13629784, 13629785, 13629852, 13630011, 13630129, - 13630230, 13630429, 13630583, 13630683, 13630775, 13630780, 13630796, 13631292, 13631331, 13640082, 13640087, 13640104, 13640132, - 13640218, 13640556, 13640587, 13640615, 13641928, 13641929, 13642057, 13642071, 13642137, 13642155, 13642160, 13642167, 13642168, - 13642207, 13642212, 13642215, 13642216, 13642265, 13642911, 13644410, 13646116, 13646163, 13647476, 13647732, 13647733, 13647905, - 13657931, 13657936, 13658078, 13658083, 13658088, 13658106, 13666892, 13666908, 13667064, 13667842, 13671879, 13672266, 13685409, - 13685501, 13687313, 13687327, 13688700, 13688718, 13688728, 13688770, 13688773, 13689077, 13693941, 13693995, 13694143, 13694177, - 13703288, 13703407, 13704796, 13704804, 13704850, 13704871, 13710244, 13710333, 13710534, 13710568, 13717643, 13717686, 13720847, - 13720981, 13721138, 13721150, 13721209, 13721255, 13721263, 13721265, 13721279, 13721280, 13722372, 13722456, 13722731, 13722854, - 13722860, 13722861, 13722883, 13722884, 13722898, 13722924, 13723078, 13723597, 13723611, 13723617, 13724121, 13724580, 13724940, - 13724949, 13724958, 13725168, 13725481, 13725714, 13725715, 13725761, 13726532, 13728022, 13728049, 13729075, 13729079, 13729488, - 13729572, 13729622, 13729660, 13729666, 13729719, 13729765, 13729836, 13731361, 13731396, 13731754, 13731765, 13731769, 13731770, - 13731798, 13731966, 13732954, 13732957, 13732964, 13734204, 13734565, 13734582, 13734613, 13734671, 13735055, 13735059, 13735060, - 13735378, 13740278, 13740773, 13740781, 13740808, 13740821, 13740879, 13741264, 13742045, 13742386, 13742413, 13742433, 13742461, - 13742522, 13743142, 13743432, 13743636, 13743643, 13743676, 13744107, 13744604, 13800996, 13800999, 13801241, 13801243, 13804633, - 13804667, 13804672, 13804727, 13812443, 13812884, 13812892, 13812903, 13813249, 13813688, 13829732, 13829784, 13844956, 13844964, - 13845655, 13845657, 13845739, 13845745, 13845757, 13845780, 13848953, 13851591, 13851617, 13852217, 13852286, 13852519, 13853027, - 13854735, 13854789, 13854927, 13854932, 13854936, 13854950, 13854954, 13856012, 13856028, 13856077, 13856953, 13856955, 13857267, - 13857323, 13857365, 13857466, 13857469, 13857483, 13857490, 13857624, 13857918, 13858695, 13858898, 13858902, 13858904, 13858923, - 13858924, 13859670, 13859826, 13859936, 13860025, 13860899, 13861827, 13861932, 13861937, 13862044, 13862064, 13862197, 13862355, - 13862374, 13863113, 13864512, 13864522, 13864530, 13864926, 13864941, 13864946, 13864969, 13865001, 13865043, 13865070, 13865081, - 13865342, 13865516, 13865553, 13865581, 13865604, 13865623, 13865647, 13865678, 13866062, 13869401, 13869405, 13869422, 13869451, - 13869457, 13869834, 13870311, 13870632, 13871204, 13871210, 13871302, 13871334, 13871339, 13871363, 13871424, 13871435, 13871497, - 13871551, 13871568, 13871570, 13871583, 13871761, 13872175, 13872207, 13872240, 13872304, 13872378, 13872402, 13872443, 13872834, - 13872889, 13872979, 13873525, 13873669, 13874108, 13874137, 13874154, 13874198, 13874244, 13874484, 13875063, 13875708, 13875709, - 13876095, 13876631, 13876822, 13876828, 13876980, 13877074, 13877075, 13877496, 13877517, 13877520, 13877638, 13877848, 13878148, - 13882302, 13882360, 13882365, 13882591, 13882592, 13882597, 13882599, 13882806, 13882807, 13883051, 13883360, 13883433, 13884709, - 13885349, 13885866, 13885918, 13886883, 13887001, 13887338, 13887344, 13887380, 13887548, 13887611, 13888142, 13888577, 13888593, - 13888668, 13888746, 13889461, 13889503, 13889510, 13889524, 13889539, 13889649, 13890458, 13891050, 13891076, 13891081, 13891130, - 13891135, 13891138, 13902888, 13902992, 13906563, 13906944, 13908405, 13908630, 13912128, 13912739, 13913099, 13913121, 13913454, - 13913585, 13913596, 13914008, 13926989, 13926996, 13927003, 13927014, 13927024, 13927479, 13927483, 13927492, 13938606, 13938669, - 13939585, 13939590, 13939599, 13939708, 13939849, 13939850, 13942560, 13942563, 13942611, 13954079, 13954146, 13954148, 13954178, - 13985645, 13985651, 13992100, 14005135, 14005139, 14005140, 14005142, 14005185, 14009388, 14009390, 14038443, 14043167, 14043168, - 14098158, 14098190, 14098343, 14098347, 14098363, 14098372, 14098448, 14098510, 14099411, 14099421, 14111704, 14111988, 14112175, - 14112178, 14112222, 14112272, 14112281, 14112322, 14112332, 14112523, 14112534, 14112721, 14112870, 14113018, 14113027, 14113380, - 14113524, 14113544, 14113990, 14114153, 14114184, 14114266, 14114286, 14114342, 14114380, 14114399, 14114404, 14114436, 14114512, - 14114628, 14114673, 14114833, 14114886, 14114898, 14115278, 14115362, 14115372, 14115446, 14115500, 14115574, 14116384, 14116406, - 14116506, 14116797, 14116986, 14117002, 14117059, 14117070, 14117097, 14117135, 14117265, 14117322, 14117503, 14117521, 14117550, - 14118001, 14118142, 14118146, 14118158, 14118197, 14118368, 14118496, 14118533, 14118647, 14118701, 14118714, 14118937, 14119187, - 14119295, 14119413, 14119877, 14119901, 14119970, 14120278, 14120281, 14120282, 14120389, 14120437, 14120542, 14120552, 14120595, - 14121317, 14121366, 14121432, 14121455, 14121577, 14121580, 14121596, 14121601, 14121630, 14121638, 14121679, 14121684, 14121722, - 14121856, 14122382, 14122403, 14122483, 14122757, 14122763, 14122767, 14122824, 14122827, 14122833, 14122844, 14122853, 14122877, - 14123193, 14123200, 14123302, 14123407, 14124143, 14124163, 14124204, 14124296, 14124337, 14124352, 14124366, 14124368, 14124374, - 14124391, 14124991, 14125047, 14126549, 14126762, 14126770, 14126771, 14126782, 14126791, 14126823, 14126841, 14128740, 14128817, - 14128883, 14128944, 14129293, 14129452, 14129553, 14129573, 14129597, 14129617, 14129837, 14129898, 14129913, 14129915, 14129939, - 14130007, 14130296, 14130298, 14130316, 14130334, 14130355, 14130372, 14130378, 14130387, 14130388, 14130423, 14130440, 14130465, - 14130641, 14131066, 14131081, 14131115, 14131324, 14131407, 14131588, 14132136, 14132310, 14133768, 14133783, 14133786, 14133815, - 14133830, 14133981, 14134041, 14135528, 14135807, 14135812, 14135828, 14137560, 14137824, 14137853, 14138293, 14138307, 14138600, - 14138669, 14138825, 14138845, 14138888, 14139112, 14139816, 14140071, 14140079, 14140134, 14140318, 14140343, 14140597, 14140903, - 14140910, 14141386, 14141418, 14141461, 14141473, 14141478, 14141480, 14141489, 14141517, 14141541, 14141549, 14141628, 14141732, - 14141733, 14141780, 14141786, 14141800, 14142398, 14142742, 14142749, 14143111, 14143196, 14143745, 14143763, 14143828, 14143864, - 14144282, 14144473, 14145076, 14145285, 14145784, 14145908, 14145935, 14145988, 14146061, 14146091, 14146109, 14146166, 14146173, - 14146182, 14146184, 14146190, 14146207, 14146234, 14146754, 14146771, 14146832, 14147019, 14147204, 14147423, 14147483, 14147519, - 14147526, 14147554, 14147587, 14147607, 14147732, 14148521, 14148714, 14149592, 14149619, 14149789, 14149804, 14149812, 14149940, - 14149961, 14149966, 14149992, 14151350, 14151353, 14153570, 14154639, 14154760, 14154939, 14155463, 14155476, 14155742, 14155762, - 14155771, 14155906, 14155935, 14156644, 14156695, 14156824, 14157718, 14158023, 14158178, 14158179, 14158192, 14158225, 14158234, - 14160434, 14160448, 14160484, 14160591, 14160631, 14160678, 14161007, 14161029, 14161053, 14161067, 14161227, 14161241, 14161396, - 14161541, 14161546, 14161548, 14161549, 14161604, 14161618, 14161833, 14161976, 14161996, 14162133, 14162387, 14162615, 14162897, - 14163117, 14163286, 14163301, 14163309, 14163900, 14163967, 14164571, 14165063, 14165098, 14165182, 14165193, 14165728, 14165832, - 14166064, 14166499, 14166555, 14166559, 14166586, 14167320, 14167457, 14167507, 14167584, 14167707, 14167751, 14167792, 14167806, - 14167809, 14167830, 14167859, 14167868, 14167877, 14167979, 14167980, 14171368, 14171777, 14171890, 14171953, 14172042, 14172047, - 14172089, 14172170, 14172332, 14172456, 14172572, 14172639, 14173001, 14174547, 14174910, 14175087, 14175109, 14175111, 14175869, - 14175907, 14176246, 14176253, 14176343, 14176607, 14177124, 14177447, 14177503, 14177734, 14178614, 14178630, 14178820, 14178821, - 14178839, 14179074, 14179192, 14179237, 14179326, 14180592, 14180796, 14180851, 14181128, 14181137, 14181693, 14181698, 14181762, - 14181792, 14182209, 14182468, 14182581, 14183420, 14183543, 14183809, 14183872, 14184752, 14184842, 14185023, 14185412, 14185453, - 14185501, 14185653, 14185710, 14185798, 14186682, 14186733, 14187745, 14187752, 14187757, 14187821, 14188264, 14188460, 14188465, - 14188729, 14188778, 14189095, 14189171, 14191103, 14191217, 14191927, 14192000, 14192052, 14192242, 14192398, 14192827, 14192854, - 14193065, 14193073, 14193103, 14193143, 14193158, 14193482, 14193580, 14194305, 14194319, 14194412, 14194419, 14194484, 14194546, - 14194595, 14199795, 14199935, 14199983, 14199986, 14200044, 14200084, 14200111, 14200139, 14200182, 14200190, 14204347, 14204418, - 14204510, 14204511, 14204779, 14204797, 14204839, 14205356, 14205469, 14205477, 14205495, 14206818, 14206853, 14207065, 14207638, - 14207651, 14207666, 14207674, 14207769, 14208925, 14208929, 14208933, 14209218, 14209304, 14209336, 14209575, 14209637, 14209654, - 14209658, 14209756, 14209776, 14209798, 14209927, 14210583, 14210845, 14211495, 14211541, 14211907, 14211929, 14212341, 14212472, - 14212477, 14212690, 14213033, 14213418, 14213497, 14213514, 14213530, 14213652, 14213946, 14213953, 14213972, 14214116, 14214142, - 14214143, 14214366, 14214977, 14214987, 14215167, 14215207, 14215399, 14215416, 14215450, 14215516, 14217199, 14217219, 14217260, - 14217509, 14218325, 14218896, 14218935, 14219106, 14219113, 14219114, 14219119, 14219130, 14219957, 14219958, 14220038, 14220087, - 14220173, 14220219, 14220804, 14221341, 14222488, 14222500, 14222878, 14222894, 14222935, 14223004, 14223669, 14223764, 14227432, - 14227444, 14227445, 14227450, 14227692, 14227697, 14228042, 14228163, 14228181, 14228408, 14228421, 14228485, 14228486, 14228491, - 14228508, 14228587, 14228717, 14228762, 14228769, 14228773, 14228791, 14228792, 14228804, 14228903, 14229010, 14229018, 14229159, - 14231125, 14231300, 14231443, 14231448, 14232109, 14232208, 14232209, 14232381, 14232406, 14232802, 14232810, 14232864, 14232909, - 14233312, 14233318, 14233470, 14233715, 14233727, 14233759, 14235991, 14236061, 14236156, 14236267, 14236301, 14236377, 14236429, - 14236512, 14236650, 14236713, 14236756, 14236769, 14236824, 14236825, 14237021, 14237138, 14237249, 14237357, 14237367, 14237368, - 14237405, 14237422, 14237465, 14237979, 14238006, 14238047, 14238053, 14238054, 14238064, 14238210, 14241229, 14242371, 14242374, - 14242376, 14242495, 14242761, 14242796, 14242807, 14242848, 14242857, 14242860, 14242895, 14242902, 14242903, 14243742, 14243745, - 14243747, 14243828, 14243830, 14243898, 14243995, 14244554, 14244572, 14244661, 14244663, 14245554, 14245560, 14245614, 14245629, - 14245794, 14246045, 14246318, 14246687, 14246846, 14247108, 14247338, 14247826, 14247928, 14247954, 14247963, 14247985, 14248202, - 14248403, 14248732, 14249055, 14249278, 14249875, 14250216, 14250927, 14250928, 14251116, 14251143, 14251320, 14251343, 14251406, - 14251457, 14251569, 14251635, 14251874, 14251884, 14251898, 14252039, 14252092, 14252144, 14252246, 14252318, 14252972, 14253022, - 14255299, 14255310, 14255475, 14255516, 14255543, 14255556, 14255822, 14255995, 14256057, 14256504, 14256561, 14256571, 14256620, - 14258923, 14258985, 14259150, 14259607, 14259661, 14260250, 14260264, 14261054, 14261145, 14261150, 14261244, 14261398, 14261838, - 14261932, 14261969, 14262054, 14262427, 14262460, 14262621, 14263627, 14263682, 14267276, 14267288, 14267519, 14267528, 14267529, - 14267548, 14267622, 14267663, 14268607, 14268629, 14268630, 14268672, 14268685, 14268744, 14268750, 14268751, 14268755, 14269086, - 14269140, 14269168, 14269178, 14269347, 14269356, 14269543, 14269547, 14269776, 14269820, 14270276, 14270280, 14270283, 14270286, - 14270294, 14270310, 14270354, 14270419, 14270466, 14270486, 14270530, 14270550, 14270654, 14270738, 14270744, 14270751, 14270757, - 14270778, 14270784, 14270811, 14270841, 14270889, 14270897, 14270940, 14270943, 14270967, 14270972, 14271360, 14271401, 14271992, - 14271999, 14272079, 14272130, 14272289, 14272325, 14272717, 14272750, 14274773, 14274777, 14274997, 14275001, 14275127, 14275130, - 14275146, 14275323, 14275353, 14275424, 14275668, 14276086, 14276123, 14276168, 14276309, 14276370, 14276458, 14276520, 14277427, - 14277434, 14277438, 14277439, 14277514, 14277581, 14277637, 14278054, 14278075, 14278093, 14278096, 14278100, 14278142, 14278209, - 14278267, 14278302, 14278331, 14278429, 14278440, 14278687, 14278756, 14278811, 14279537, 14279693, 14279798, 14280053, 14280185, - 14280204, 14280267, 14280452, 14280583, 14280616, 14280703, 14281278, 14281362, 14281532, 14281603, 14281860, 14281911, 14282559, - 14283530, 14283550, 14283560, 14283564, 14283579, 14283595, 14283598, 14283613, 14283697, 14283746, 14284070, 14284218, 14284578, - 14284847, 14286487, 14286490, 14286613, 14286765, 14287334, 14287353, 14287608, 14287664, 14287752, 14287787, 14287796, 14287799, - 14287800, 14287802, 14287945, 14288161, 14288307, 14288451, 14288502, 14288846, 14288983, 14289001, 14289005, 14289016, 14289060, - 14289723, 14290173, 14290424, 14290457, 14290459, 14290506, 14290571, 14290766, 14290801, 14290962, 14291669, 14291708, 14291718, - 14291815, 14292939, 14292956, 14293247, 14293268, 14293297, 14293393, 14293441, 14293602, 14293740, 14293803, 14294518, 14294563, - 14294601, 14294625, 14295118, 14295131, 14295183, 14295205, 14295233, 14295243, 14295256, 14295279, 14295325, 14295328, 14295332, - 14295394, 14295420, 14295683, 14295688, 14295809, 14296174, 14296471, 14296495, 14296520, 14296596, 14296598, 14296727, 14296803, - 14296887, 14296913, 14296925, 14297069, 14297070, 14297260, 14297371, 14297452, 14297529, 14297538, 14297676, 14297759, 14297807, - 14297822, 14298409, 14298639, 14298896, 14298903, 14298932, 14299363, 14299554, 14300286, 14300298, 14300301, 14300495, 14300640, - 14300659, 14301074, 14301263, 14301438, 14301472, 14301639, 14301663, 14301665, 14301705, 14301827, 14302166, 14302216, 14302438, - 14302631, 14302782, 14302982, 14303337, 14303485, 14303928, 14304191, 14304195, 14304374, 14304577, 14304591, 14304640, 14305416, - 14305568, 14305668, 14305702, 14305917, 14305920, 14306074, 14306134, 14306454, 14307152, 14307386, 14307402, 14307413, 14307462, - 14307466, 14307547, 14307632, 14307804, 14307929, 14308045, 14308232, 14308345, 14308437, 14308448, 14309558, 14309627, 14309634, - 14309679, 14309714, 14309805, 14309832, 14309939, 14310154, 14310541, 14310658, 14310887, 14310987, 14311341, 14312039, 14312218, - 14312227, 14312251, 14312317, 14312327, 14312447, 14312532, 14313179, 14313565, 14313860, 14313880, 14313896, 14313985, 14314069, - 14314262, 14314503, 14314504, 14315064, 14315149, 14315158, 14315195, 14315406, 14315429, 14315534, 14315796, 14316030, 14316190, - 14316259, 14316600, 14316647, 14316861, 14317147, 14317635, 14317647, 14317657, 14317734, 14317812, 14317833, 14317844, 14317921, - 14317930, 14317937, 14317942, 14317945, 14317982, 14317988, 14318921, 14318922, 14319270, 14319315, 14319942, 14320162, 14320227, - 14320284, 14320753, 14320763, 14322722, 14322745, 14322786, 14322880, 14322990, 14323725, 14323744, 14324520, 14324584, 14324706, - 14324707, 14328007, 14328024, 14331549, 14331550, 14331679, 14332651, 14332653, 14332760, 14332764, 14332800, 14332809, 14333294, - 14333328, 14333336, 14333346, 14333551, 14333562, 14334351, 14334509, 14334540, 14334564, 14337693, 14340622, 14342084, 14342092, - 14342313, 14342321, 14342457, 14342462, 14343083, 14343087, 14343141, 14343154, 14343161, 14343551, 14343566, 14343577, 14343609, - 14343647, 14343803, 14343938, 14343962, 14344087, 14344928, 14344933, 14345088, 14345153, 14345161, 14345601, 14345744, 14345777, - 14346561, 14346614, 14346765, 14346782, 14346783, 14347126, 14347150, 14347420, 14347452, 14347570, 14347598, 14347626, 14347635, - 14347637, 14347725, 14347781, 14348725, 14348905, 14349352, 14349447, 14351917, 14352564, 14352616, 14352773, 14352923, 14353039, - 14354130, 14354236, 14354276, 14354277, 14354290, 14354327, 14354329, 14354337, 14354362, 14354420, 14354429, 14354456, 14354679, - 14354688, 14354691, 14354801, 14354829, 14354874, 14354902, 14354918, 14355487, 14355501, 14355611, 14355907, 14356212, 14356334, - 14356358, 14356391, 14356876, 14357035, 14357313, 14357658, 14357681, 14357718, 14357730, 14357799, 14357850, 14357987, 14358091, - 14358190, 14358267, 14358722, 14359057, 14359213, 14359358, 14359371, 14359465, 14359589, 14359597, 14359648, 14359654, 14360676, - 14360709, 14360796, 14361052, 14361484, 14361538, 14361631, 14361731, 14362244, 14362395, 14362428, 14362460, 14362496, 14362567, - 14362798, 14362805, 14362808, 14363004, 14363041, 14363050, 14363058, 14363068, 14363172, 14363510, 14363570, 14363734, 14364469, - 14364510, 14364518, 14365738, 14365742, 14365752, 14365867, 14365890, 14366055, 14366116, 14366211, 14366224, 14366233, 14366246, - 14366288, 14366309, 14366329, 14366429, 14366430, 14366443, 14366448, 14366472, 14366539, 14366589, 14366750, 14366765, 14366794, - 14366934, 14367112, 14367251, 14367272, 14367282, 14367466, 14367467, 14367468, 14367469, 14367477, 14367496, 14367530, 14367687, - 14367800, 14367833, 14367960, 14368004, 14368015, 14368024, 14368061, 14368069, 14368160, 14368167, 14368170, 14368194, 14368302, - 14368786, 14368797, 14368798, 14368810, 14368823, 14370205, 14370209, 14370844, 14370852, 14371635, 14371854, 14372502, 14372811, - 14375059, 14375196, 14375337, 14375353, 14376850, 14377162, 14377188, 14378134, 14378139, 14378142, 14378262, 14378276, 14378281, - 14378284, 14378300, 14378310, 14378366, 14378380, 14378433, 14380203, 14380358, 14380376, 14380432, 14380454, 14380479, 14380500, - 14380502, 14380511, 14380523, 14380526, 14380576, 14381101, 14381108, 14381116, 14381149, 14381187, 14381336, 14381643, 14381650, - 14384971, 14385017, 14385299, 14385327, 14385345, 14385346, 14385398, 14385409, 14386643, 14386717, 14387783, 14387792, 14387814, - 14387938, 14388060, 14388082, 14388164, 14388173, 14388184, 14388185, 14388190, 14388205, 14388211, 14388234, 14388244, 14388337, - 14388466, 14389756, 14389760, 14391505, 14391529, 14392389, 14392425, 14392444, 14392452, 14392466, 14392654, 14393420, 14393502, - 14393594, 14393595, 14393599, 14393671, 14394385, 14395110, 14395112, 14395122, 14395139, 14395232, 14395237, 14395341, 14395364, - 14395414, 14395416, 14397686, 14397758, 14397792, 14397865, 14398937, 14398955, 14398982, 14399110, 14399114, 14399131, 14399141, - 14399198, 14399200, 14399218, 14399248, 14399251, 14399276, 14399914, 14399919, 14399960, 14399989, 14399992, 14400040, 14400043, - 14400048, 14400097, 14400128, 14400131, 14402470, 14402526, 14402741, 14402794, 14402800, 14402805, 14402891, 14402926, 14404738, - 14404762, 14404988, 14405199, 14405204, 14405237, 14405348, 14406107, 14406164, 14406177, 14406665, 14406666, 14406887, 14406900, - 14406901, 14406982, 14406984, 14407108, 14407204, 14407309, 14407326, 14408372, 14408387, 14408522, 14408523, 14408534, 14408798, - 14408824, 14408858, 14410649, 14410860, 14410915, 14410986, 14411113, 14411190, 14411745, 14411764, 14412210, 14412275, 14412297, - 14412428, 14412434, 14412741, 14412857, 14412866, 14412869, 14413198, 14413199, 14413906, 14413934, 14414045, 14414168, 14414430, - 14414443, 14414710, 14415221, 14415252, 14415388, 14415429, 14415469, 14415513, 14415554, 14415608, 14415656, 14415660, 14415666, - 14415927, 14415975, 14416165, 14417518, 14418203, 14418277, 14418301, 14418317, 14418392, 14418533, 14418543, 14418546, 14419038, - 14419373, 14419466, 14419469, 14419481, 14419488, 14419499, 14419512, 14419521, 14419616, 14419697, 14419698, 14419805, 14419900, - 14419928, 14419929, 14419941, 14419942, 14419962, 14420023, 14420069, 14420082, 14420084, 14420086, 14420091, 14420094, 14420112, - 14420116, 14420129, 14420131, 14420180, 14420183, 14420193, 14420247, 14420253, 14420256, 14420275, 14420293, 14420303, 14420341, - 14420348, 14420480, 14420699, 14420814, 14420849, 14420851, 14420971, 14421014, 14421036, 14421045, 14421046, 14421169, 14421176, - 14421440, 14421858, 14421886, 14421920, 14422148, 14422321, 14422453, 14422593, 14422767, 14422856, 14423018, 14423133, 14423196, - 14423206, 14423268, 14423271, 14423515, 14423532, 14423583, 14423860, 14423881, 14423932, 14424014, 14424043, 14424067, 14424296, - 14424429, 14424452, 14424558, 14424562, 14424571, 14424585, 14424586, 14424589, 14424636, 14424685, 14424736, 14424750, 14424769, - 14425463, 14425546, 14425574, 14425575, 14425633, 14425767, 14425781, 14425849, 14425993, 14426028, 14426072, 14426221, 14426583, - 14427051, 14427197, 14427202, 14427208, 14427399, 14427441, 14427452, 14427473, 14427870, 14428817, 14428898, 14428920, 14429168, - 14429174, 14429180, 14429324, 14430071, 14430108, 14430138, 14430143, 14430231, 14430255, 14430816, 14430855, 14430886, 14430899, - 14430901, 14430902, 14430905, 14430924, 14430965, 14431006, 14431063, 14431282, 14431502, 14431545, 14431559, 14431720, 14431721, - 14432038, 14432172, 14432192, 14432201, 14432626, 14432636, 14432638, 14433023, 14433345, 14433362, 14433891, 14433944, 14434390, - 14434409, 14434414, 14434471, 14434649, 14436439, 14436511, 14436521, 14436616, 14436975, 14437026, 14437134, 14437167, 14437191, - 14437201, 14437204, 14437205, 14437268, 14437527, 14437534, 14437547, 14437565, 14437613, 14437807, 14437820, 14438118, 14438156, - 14438160, 14438162, 14438168, 14438215, 14438333, 14438365, 14438531, 14438538, 14438956, 14439014, 14439085, 14439105, 14439107, - 14439173, 14439501, 14439515, 14439776, 14439868, 14440295, 14440312, 14440363, 14440392, 14440418, 14440420, 14440431, 14440986, - 14440993, 14441010, 14441090, 14441114, 14441175, 14441182, 14441421, 14441424, 14441436, 14441455, 14442331, 14442410, 14442412, - 14442499, 14442590, 14443032, 14443124, 14443702, 14443783, 14443785, 14443880, 14443986, 14443987, 14443996, 14444016, 14444291, - 14444335, 14444348, 14444958, 14445106, 14445730, 14445744, 14445796, 14445857, 14445956, 14445960, 14449012, 14449107, 14449279, - 14449287, 14450086, 14450107, 14450169, 14450196, 14451369, 14451491, 14451664, 14451679, 14452080, 14452088, 14452158, 14452281, - 14452377, 14452464, 14454060, 14454100, 14454259, 14454284, 14455932, 14455937, 14456161, 14456169, 14456173, 14456215, 14456220, - 14456251, 14456262, 14456272, 14456374, 14456386, 14456389, 14456408, 14456422, 14456596, 14456654, 14456697, 14456714, 14457226, - 14457236, 14457251, 14457272, 14457294, 14457295, 14457323, 14457332, 14457341, 14457872, 14457925, 14458268, 14458361, 14462180, - 14462204, 14462241, 14462308, 14464172, 14464255, 14466306, 14466331, 14466411, 14466425, 14466470, 14466488, 14466497, 14466523, - 14466972, 14466984, 14467004, 14467023, 14468341, 14468496, 14469581, 14469604, 14469619, 14469675, 14470339, 14470341, 14470456, - 14470514, 14470520, 14470622, 14470887, 14470888, 14471412, 14471417, 14471591, 14471594, 14473086, 14473092, 14473096, 14473097, - 14473637, 14473642, 14475479, 14475496, 14475695, 14475733, 14476630, 14476676, 14476712, 14476812, 14477122, 14477145, 14477588, - 14477589, 14477594, 14477605, 14477607, 14477633, 14477742, 14477772, 14477777, 14478030, 14478043, 14478624, 14478666, 14479141, - 14479784, 14479865, 14479943, 14479950, 14479961, 14481636, 14481637, 14481722, 14481726, 14481758, 14481986, 14481997, 14482096, - 14482102, 14482118, 14482138, 14482420, 14482427, 14482457, 14482487, 14482508, 14482687, 14482693, 14482834, 14482845, 14483435, - 14483438, 14483442, 14483453, 14483471, 14483605, 14483834, 14483839, 14484322, 14484339, 14484341, 14484392, 14484412, 14484498, - 14484698, 14484752, 14484755, 14488867, 14488878, 14488894, 14488896, 14489287, 14489291, 14489510, 14489549, 14490029, 14490073, - 14490084, 14490085, 14490086, 14490088, 14490123, 14490128, 14490190, 14490213, 14490644, 14490652, 14490708, 14490728, 14490903, - 14490908, 14491415, 14491754, 14491757, 14491758, 14491805, 14492838, 14493628, 14494367, 14494372, 14494373, 14494376, 14494379, - 14494381, 14494646, 14494656, 14494661, 14494752, 14494868, 14494907, 14494921, 14494941, 14494953, 14494954, 14495034, 14495065, - 14495075, 14495076, 14495135, 14495154, 14495165, 14495173, 14495188, 14495192, 14495488, 14495493, 14495495, 14495501, 14495644, - 14495687, 14495688, 14495840, 14495967, 14495968, 14496394, 14496406, 14496408, 14496432, 14496500, 14496551, 14496604, 14496966, - 14497034, 14497038, 14497550, 14497568, 14497570, 14497668, 14497702, 14497706, 14497708, 14497820, 14497848, 14497895, 14497913, - 14497935, 14497937, 14498323, 14498354, 14498355, 14501002, 14501005, 14501526, 14502186, 14502208, 14502215, 14502229, 14502284, - 14502295, 14502315, 14502353, 14502605, 14502627, 14502635, 14502663, 14502758, 14502769, 14503020, 14503058, 14503061, 14503068, - 14503086, 14503134, 14503288, 14503395, 14503429, 14503435, 14503522, 14503525, 14504153, 14504162, 14504169, 14504173, 14504371, - 14504422, 14504432, 14504442, 14507145, 14507147, 14507476, 14507486, 14507489, 14507515, 14507520, 14507570, 14507702, 14507732, - 14508208, 14508212, 14509089, 14509103, 14509612, 14509623, 14511370, 14511373, 14511378, 14511379, 14511768, 14511773, 14512246, - 14512248, 14514087, 14514094, 14514100, 14514117, 14514130, 14514133, 14514156, 14514162, 14514508, 14514588, 14514908, 14514918, - 14514964, 14514971, 14514989, 14515007, 14515063, 14515165, 14515419, 14515421, 14515591, 14515593, 14515714, 14515716, 14515719, - 14515720, 14515748, 14515749, 14515854, 14515860, 14515903, 14515904, 14515951, 14515955, 14515993, 14515997, 14516253, 14516270, - 14516372, 14516412, 14516497, 14516503, 14517397, 14517439, 14519618, 14519619, 14519694, 14519701, 14519702, 14519714, 14519776, - 14519782, 14519803, 14519804, 14519955, 14519996, 14520020, 14520024, 14520043, 14520060, 14520061, 14520062, 14520115, 14520126, - 14520159, 14520172, 14520186, 14520190, 14520198, 14520212, 14520222, 14520227, 14520235, 14520497, 14520498, 14520746, 14520774, - 14520977, 14520982, 14520986, 14521011, 14521066, 14521069, 14522110, 14522112, 14522118, 14522165, 14522218, 14522219, 14522733, - 14522797, 14523118, 14523126, 14523830, 14523835, 14524242, 14524243, 14524259, 14524266, 14526070, 14526077, 14526083, 14526086, - 14526087, 14526099, 14526120, 14526126, 14526141, 14526211, 14526215, 14526221, 14526244, 14526255, 14526300, 14526321, 14526332, - 14526340, 14526344, 14526346, 14526356, 14526363, 14526380, 14526442, 14526463, 14527065, 14527080, 14527084, 14527176, 14527178, - 14527369, 14527370, 14527424, 14527431, 14527447, 14527451, 14527599, 14527626, 14527627, 14527633, 14527696, 14527715, 14527723, - 14527735, 14527839, 14528084, 14528085, 14528093, 14528124, 14528171, 14528614, 14528712, 14528723, 14528757, 14528758, 14528864, - 14528925, 14528961, 14528969, 14528986, 14528993, 14528997, 14529009, 14529012, 14529017, 14529021, 14529024, 14529026, 14529029, - 14529033, 14529037, 14529046, 14529100, 14529124, 14529557, 14530096, 14530149, 14531104, 14531141, 14531213, 14531235, 14531744, - 14531775, 14531956, 14531968, 14531999, 14532026, 14532066, 14532097, 14532696, 14532706, 14532729, 14532730, 14532739, 14532749, - 14532758, 14532838, 14532843, 14533032, 14533035, 14533049, 14533066, 14533070, 14533079, 14533136, 14533141, 14533267, 14533299, - 14533319, 14533321, 14533346, 14533372, 14533410, 14533430, 14533442, 14533526, 14533548, 14533722, 14533805, 14533836, 14533847, - 14533860, 14533861, 14533873, 14533878, 14533920, 14534184, 14534185, 14534191, 14534193, 14534233, 14534256, 14534343, 14534366, - 14534397, 14534426, 14535016, 14535017, 14535020, 14535028, 14535045, 14535083, 14535119, 14535180, 14535199, 14535394, 14535426, - 14535428, 14535456, 14535475, 14535634, 14535662, 14535688, 14535691, 14535692, 14535702, 14536479, 14536480, 14536489, 14536490, - 14536492, 14536493, 14538931, 14538950, 14539037, 14539038, 14539216, 14539309, 14539334, 14539344, 14539390, 14539420, 14539473, - 14539534, 14539537, 14539564, 14540149, 14540166, 14540656, 14540667, 14540769, 14540796, 14541039, 14541063, 14541069, 14541071, - 14541159, 14541165, 14541181, 14541201, 14541315, 14541323, 14541325, 14541328, 14541535, 14542840, 14542888, 14542906, 14542907, - 14543190, 14543248, 14543853, 14543908, 14544590, 14544596, 14544603, 14544616, 14544670, 14544671, 14544700, 14544710, 14544746, - 14544754, 14544827, 14544828, 14544837, 14544856, 14544877, 14544962, 14545025, 14545172, 14545204, 14545224, 14545226, 14545234, - 14545464, 14545483, 14545723, 14545743, 14545958, 14545994, 14546116, 14546131, 14546151, 14546163, 14546371, 14546380, 14546408, - 14546419, 14546448, 14546450, 14546509, 14546553, 14546560, 14546608, 14546630, 14546636, 14546678, 14546684, 14546867, 14546869, - 14547247, 14547249, 14547565, 14547577, 14547724, 14547850, 14547854, 14547861, 14547962, 14548000, 14550132, 14550221, 14552498, - 14552506, 14552667, 14552671, 14552813, 14552828, 14553470, 14553472, 14553476, 14554183, 14554188, 14554192, 14554225, 14554740, - 14554785, 14555988, 14556013, 14556021, 14556022, 14556083, 14556084, 14556089, 14556092, 14556100, 14556103, 14556108, 14556140, - 14556651, 14558534, 14559061, 14559072, 14559085, 14559733, 14559791, 14560016, 14560026, 14560028, 14560038, 14560040, 14560076, - 14560273, 14560275, 14560303, 14560306, 14560310, 14560322, 14560576, 14560577, 14560582, 14560595, 14560608, 14560622, 14560728, - 14560734, 14561795, 14561825, 14561840, 14562587, 14562623, 14562630, 14562645, 14563527, 14563541, 14563542, 14563549, 14563729, - 14563739, 14563740, 14563748, 14563749, 14563755, 14563766, 14563768, 14563774, 14563775, 14563894, 14563959, 14563963, 14563967, - 14564050, 14564054, 14564058, 14564075, 14564164, 14564730, 14564733, 14565457, 14565462, 14565943, 14566817, 14566822, 14588081, - 15278993, 15298860, 15299275, 15299420, 15299520, 15299715, 15299731, 15299757, 15301708, 15301850, 15301875, 15302455, 15302967, - 15304019, 15305121, 15305561, 15307407, 15307490, 15307868, 15308032, 15311107, 15311210, 15311599, 15316343, 15316528, 15316535, - 15317411, 15318069, 15318235, 15318288, 15318437, 15318758, 15319019, 15319366, 15319403, 15320313, 15321005, 15321511, 15321634, - 15321707, 15321890, 15322055, 15322136, 15323088, 15323182, 15323543, 15324636, 15327600, 15328789, 15328903, 15328961, 15329151, - 15330358, 15330441, 15330468, 15331215, 15331280, 15333764, 15333830, 15335397, 15336059, 15337247, 15337395, 15337630, 15339099, - 15340038, 15340971, 15341319, 15341479, 15341544, 15342783, 15343155, 15343302, 15343551, 15343809, 15344150, 15344169, 15344370, - 15344584, 15346218, 15346421, 15346604, 15346684, 15346714, 15346716, 15350123, 15350143, 15350966, 15351041, 15351346, 15351348, - 15352316, 15352341, 15353576, 15353802, 15354436, 15354503, 15354708, 15354744, 15355751, 15355938, 15356263, 15356464, 15357773, - 15357806, 15357836, 15357870, 15359242, 15359261, 15359409, 15359557, 15359701, 15359731, 15359846, 15359932, 15360348, 15360351, - 15360966, 15360968, 15360998, 15361018, 15363267, 15363312, 15363413, 15363420, 15363920, 15364070, 15364136, 15364150, 15364663, - 15364715, 15367310, 15367326, 15368095, 15368104, 15368537, 15368541, 15368874, 15368881, 15369797, 15369898, 15370883, 15370885, - 15371463, 15371516, 15372941, 15373029, 15373035, 15373039, 15373489, 15373548, 15374297, 15374326, 15374448, 15374596, 15375231, - 15375318, 15375776, 15375803, 15376049, 15376057, 15377278, 15377371, 15378036, 15378043, 15378052, 15378059, 15378164, 15378166, - 15379378, 15379430, 15379848, 15379863, 15379880, 15379890, 15381333, 15381472, 15381587, 15381594, 15382319, 15382335, 15382622, - 15382689, 15384884, 15384889, 15386453, 15386482, 15386506, 15386762, 15386943, 15387036, 15387461, 15387465, 15387752, 15387804, - 15388394, 15388486, 15388606, 15388617, 15389904, 15390109, 15390434, 15390437, 15390816, 15390866, 15393023, 15393050, 15393079, - 15393299, 15393785, 15393789, 15394171, 15394184, 15394223, 15394363, 15397304, 15397311, 15397367, 15397572, 15398540, 15398542, - 15398966, 15398984, 15400273, 15400276, 15400610, 15400638, 15401565, 15401650, 15404521, 15404620, 15406007, 15406017, 15406624, - 15406687, 15407958, 15407964, 15408278, 15408287, 15410615, 15410769, 15411104, 15411119, 15411326, 15411591, 15411833, 15411836, - 15413038, 15413046, 15413111, 15413148, 15413371, 15413374, 15413483, 15413499, 15415282, 15415416, 15417725, 15417802, 15417896, - 15417906, 15419558, 15419604, 15419797, 15419800, 15419980, 15420000, 15420016, 15420019, 15421514, 15421544, 15423424, 15423558, - 15423661, 15423673, 15424869, 15424873, 15425240, 15425382, 15425895, 15425897, 15426289, 15426372, 15427195, 15427225, 15427230, - 15427233, 15427289, 15427298, 15427993, 15427999, 15428176, 15428217, 15428227, 15428516, 15428529, 15428567, 15428784, 15429008, - 15429020, 15429026, 15429032, 15429281, 15430344, 15430346, 15430706, 15430735, 15430879, 15430885, 15431260, 15431365, 15432397, - 15432422, 15432649, 15432654, 15432804, 15432819, 15433923, 15433932, 15435272, 15435298, 15437041, 15437050, 15438105, 15438114, - 15440121, 15440253, 15441104, 15441282, 15442199, 15442584, 15443871, 15444142, 15444188, 15444408, 15444685, 15444690, 15445733, - 15445736, 15445863, 15445878, 15447031, 15447065, 15448796, 15448816, 15449403, 15449413, 15449587, 15449609, 15449711, 15449878, - 15449962, 15449964, 15450263, 15450405, 15450446, 15450450, 15451400, 15451408, 15451819, 15451857, 15452179, 15452192, 15452979, - 15453020, 15453357, 15453514, 15455431, 15455434, 15455761, 15455880, 15456762, 15456784, 15457983, 15459043, 15459439, 15459567, - 15459814, 15459822, 15460508, 15460591, 15461069, 15461082, 15462424, 15462426, 15462594, 15462656, 15462690, 15462696, 15463436, - 15463936, 15464266, 15465784, 15465839, 15465937, 15466610, 15466631, 15467021, 15467085, 15467103, 15467109, 15467756, 15467851, - 15468430, 15468503, 15468511, 15468652, 15469184, 15469200, 15469285, 15469458, 15469754, 15469759, 15470276, 15470283, 15470370, - 15470392, 15471545, 15471785, 15473261, 15473269, 15473454, 15473460, 15474422, 15474425, 15474922, 15475151, 15475640, 15475643, - 15476163, 15476405, 15476427, 15476439, 15477009, 15477179, 15477640, 15477649, 15479093, 15479107, 15480142, 15480151, 15480580, - 15480814, 15481022, 15481026, 15481035, 15481037, 15481562, 15481565, 15481590, 15481591, 15481741, 15481744, 15482067, 15482078, - 15482616, 15482683, 15486561, 15486564, 15486616, 15486617, 15486666, 15486668, 15486678, 15486680, 15487459, 15487500, 15488119, - 15488127, 15488401, 15488409, 15488440, 15488442, 15488965, 15488970, 15489694, 15489700, 15490595, 15490615, 15491720, 15491760, - 15492016, 15492020, 15492072, 15492087, 15492855, 15492857, 15493002, 15493004, 15493071, 15493074, 15493106, 15493108, 15493360, - 15493365, 15494319, 15494332, 15496258, 15496263, 15497235, 15497254, 15497321, 15497338, 15498352, 15498354, 15499365, 15499369, - 15501348, 15501354, 15502470, 15502478, 15503665, 15503673, 15504523, 15504537, 15504621, 15504628, 15504938, 15505080, 15506069, - 15506072, 15506112, 15506113, 15506426, 15506436, 15507433, 15507435, 15508130, 15508192, 15508250, 15508358, 15510418, 15510430, - 15510706, 15510712, 15511523, 15511526, 15511628, 15511629, 15512065, 15512071, 15512120, 15512121, 15513126, 15513199, 15513214, - 15513441, 15514260, 15514460, 15515518, 15515520, 15515699, 15515701, 15516480, 15516482, 15517627, 15517654, 15518075, 15518102, - 15519576, 15519578, 15520859, 15520864, 15521342, 15521351, 15521537, 15521553, 15521701, 15521707, 15522808, 15523015, 15523483, - 15523488, 15524388, 15524397, 15524703, 15524713, 15525341, 15525343, 15525349, 15525353, 15526412, 15526559, 15527127, 15527133, - 15527672, 15527675, 15528231, 15528248, 15528274, 15528307, 15529512, 15529522, 15529961, 15530071, 15530915, 15530926, 15531367, - 15531370, 15533472, 15533487, 15534560, 15534786, 15535306, 15535318, 15535392, 15535522, 15538116, 15539371, 15540337, 15540602, - 15541064, 15541071, 15541659, 15541666, 15541681, 15541719, 15541771, 15541777, 15542276, 15542282, 15542576, 15542585, 15542589, - 15542594, 15542886, 15542896, 15543880, 15543976, 15544196, 15546926, 15547006, 15547018, 15547117, 15547119, 15547436, 15547520, - 15547554, 15547587, 15547642, 15547644, 15549036, 15549039, 15549429, 15549448, 15550823, 15550828, 15551147, 15551381, 15551716, - 15551720, 15552150, 15552267, 15554087, 15554090, 15554449, 15554456, 15555207, 15555210, 15556032, 15556037, 15556177, 15556184, - 15557755, 15557761, 15558433, 15558443, 15559082, 15559107, 15560806, 15560890, 15561941, 15562075, 15562258, 15562260, 15563500, - 15563507, 15563620, 15563624, 15565974, 15565985, 15566159, 15566161, 15566675, 15567720, 15567772, 15697646, 15698252, 15699048, - 15699049, 15699308, 15699355, 15701033, 15701037, 15701139, 15701868, 15722361, 15723839, 15725644, 15726602, 15726621, 15726727, - 15726730, 15728420, 15728425, 15729973, 15729986, 15731110, 15731125, 15732349, 15732819, 15733345, 15733382, 15736966, 15741478, - 15742747, 15743712, 15744541, 15746902, 15748357, 15751438, 15751801, 15754322, 15755697, 15768595, 15768635, 15768636, 15771170, - 15771235, 15771418, 15771566, 15772511, 15772514, 15773217, 15773287, 15773693, 15775062, 15775162, 15775170, 15775628, 15775748, - 15777966, 15778518, 15780571, 15780590, 15781334, 15781414, 15783805, 15784103, 15784218, 15784222, 15784336, 15786288, 15786350, - 15786412, 15786880, 15787424, 15791418, 15791577, 15791945, 15792759, 15792904, 15792905, 15793375, 15799982, 15800147, 15800148, - 15800738, 15800739, 15801497, 15801498, 15803568, 15803571, 15805641, 15808771, 15809000, 15815539, 15815540, 15815571, 15816365, - 15816366, 15820482, 15820483, 15820930, 15820933, 15822783, 15822784, 15823306, 15823308, 15823485, 15823486, 15827101, 15827102, - 15830019, 15830020, 15830105, 15830106, 15835137, 15835138, 15838243, 15839723, 15840576, 15841503, 15841688, 15841690, 15847048, - 15847050, 15847745, 15848829, 15850375, 15855827, 15859288, 15859289, 15860023, 15860373, 15860606, 15860607, 15860828, 15860829, - 15861647, 15861648, 15861982, 15861983, 15863539, 15865475, 15865811, 15865812, 15865814, 15865819, 15865939, 15865940, 15866722, - 15866723, 15867794, 15869548, 15870297, 15870823, 15870956, 15870957, 15871190, 15871197, 15871254, 15871766, 15872132, 15873270, - 15875334, 15875634, 15875797, 15876025, 15876802, 15876803, 15876808, 15876810, 15876831, 15876833, 15876844, 15876845, 15876858, - 15876859, 15876865, 15876866, 15876996, 15877054, 15877147, 15878253, 15878396, 15878397, 15878409, 15878410, 15880251, 15880252, - 15880976, 15883223, 15883257, 15883258, 15883267, 15883268, 15883338, 15883366, 15883572, 15883573, 15883704, 15883705, 15883815, - 15883866, 15884708, 15885134, 15886585, 15886948, 15889015, 15889135, 15889263, 15889264, 15889297, 15890107, 15890836, 15890856, - 15891258, 15891259, 15891595, 15891596, 15898995, 15899413, 15900484, 15900485, 15900856, 15900857, 15900999, 15901784, 15902052, - 15902074, 15903287, 15904479, 15904560, 15904561, 15904756, 15904948, 15905428, 15905429, 15908728, 15908729, 15908732, 15908733, - 15908737, 15908739, 15911168, 15911169, 15911465, 15911466, 15912295, 15912378, 15912429, 15912435, 15912645, 15913367, 15915228, - 15915229, 15915232, 15915233, 15915473, 15915474, 15915509, 15915510, 15915885, 15915886, 15916207, 15916208, 15916906, 15916907, - 15917200, 15917202, 15917206, 15917207, 15921490, 15921491, 15921519, 15922789, 15923115, 15923117, 15924339, 15924525, 15924533, - 15926434, 15927196, 15928263, 15929673, 15929674, 15929698, 15929766, 15930272, 15941143, 15941944, 15941945, 15941949, 15941950, - 15941954, 15941955, 15941966, 15941967, 15942041, 15942242, 15943918, 15944225, 15944958, 15948423, 15948742, 15948893, 15948934, - 15948935, 15948952, 15948953, 15948974, 15948975, 15948980, 15948981, 15948984, 15948985, 15948995, 15948996, 15949061, 15949062, - 15950050, 15950051, 15950637, 15950638, 15950642, 15950643, 15950646, 15950647, 15950650, 15950651, 15950666, 15950667, 15950686, - 15950687, 15951694, 15951695, 15951941, 15951942, 15951970, 15951971, 15951974, 15951975, 15951978, 15951979, 15952040, 15954672, - 15956700, 15956815, 15957170, 15957963, 15965549, 15968309, 15969082, 15969120, 15970110, 15970111, 15970828, 15970854, 15971891, - 15971916, 15971980, 15972006, 15973526, 15973527, 15973835, 15974371, 15976265, 15977379, 15978362, 15978948, 15979197, 15980087, - 15980290, 15980299, 15981105, 15981106, 15981914, 15981915, 15982995, 15985005, 15985847, 15986020, 15986468, 15990277, 15990962, - 15991688, 15992374, 15992627, 15992966, 15994933, 15995140, 15995217, 15998964, 16006307, 16010481, 16011214, 16012893, 16013844, - 16015906, 17636688, 17637873, 17638275, 17638348, 17638487, 17638892, 17664726, 17667175, 17673330, 17673544, 17673816, 17681905, - 17685084, 17685085, 17687705, 17691885, 17692405, 17693311, 17694199, 17698519, 17699421, 17699575, 17699776, 17704976, 17705868, - 17707335, 17707490, 17710949, 17711356, 17711906, 17712444, 17720306, 17720567, 17723439, 17723538, 17729149, 17729172, 17730669, - 17735353, 17738506, 17739593, 17742978, 17746144, 17752865, 17759547, 17770240, 17774229, 17774250, 17778606, 17779105, 17782179, - 17783310, 17783420, 17784087, 17791119, 17792330, 17793195, 17795208, 17796208, 17798702, 17803925, 17806758, 17808553, 17811929, - 17815836, 17818217, 17853647, 17855162, 17855180, 17874661, 17881967, 17886031, 17886472, 17886499, 17892400, 17892586, 17893593, - 17918105, 17920208, 17923983, 17932312, 17940478, 17949572, 17950256, 17978577, 17978638, 17979243, 17981913, 17981914, 17986345, - 17995612, 17998455, 18001936, 18018601, 18019359, 18020832, 18020852, 18020857, 18021161, 18024791, 18028665, 18028982, 18029024, - 18029065, 18029402, 18029410, 18029412, 18029430, 18029461, 18029535, 18029709, 18029941, 18030109, 18030158, 18030174, 18030618, - 18030897, 18031010, 18031050, 18031102, 18031119, 18033407, 18033471, 18033519, 18034800, 18035522, 18035524, 18035558, 18035587, - 18035592, 18035611, 18035718, 18036283, 18037159, 18037177, 18037518, 18037756, 18037831, 18038107, 18038314, 18040137, 18040830, - 18042044, 18042107, 18042113, 18042989, 18044136, 18044214, 18045284, 18046457, 18046504, 18046619, 18046757, 18047186, 18047597, - 18047661, 18047776, 18047878, 18047880, 18048688, 18049264, 18050153, 18050586, 18050926, 18051022, 18052532, 18052575, 18052827, - 18053165, 18053676, 18053753, 18054135, 18055170, 18056994, 18057401, 18057693, 18057697, 18058403, 18058457, 18058779, 18058896, - 18059950, 18059951, 18061046, 18061130, 18061163, 18061330, 18062045, 18062047, 18062332, 18063045, 18063475, 18063531, 18063738, - 18064294, 18065075, 18065242, 18065980, 18066212, 18066443, 18066962, 18067060, 18067533, 18067720, 18067880, 18067908, 18067926, - 18069030, 18069287, 18069478, 18069486, 18070682, 18070696, 18070945, 18070960, 18071100, 18071247, 18071778, 18071877, 18071965, - 18072000, 18072080, 18072170, 18072197, 18072238, 18072391, 18072987, 18073243, 18074765, 18075302, 18075625, 18075780, 18075781, - 18075911, 18075915, 18075944, 18075961, 18078850, 18079649, 18082360, 18084867, 18084911, 18085324, 18085709, 18087962, 18087963, - 18088191, 18088242, 18088250, 18088280, 18088356, 18088559, 18088585, 18088685, 18088801, 18089141, 18089688, 18089823, 18090573, - 18092942, 18093321, 18093525, 18093792, 18094278, 18094280, 18094353, 18094818, 18095086, 18096830, 18096870, 18096945, 18099264, - 18099563, 18103567, 18105534, 18105712, 18105730, 18106676, 18106758, 18107898, 18108072, 18108109, 18108251, 18108364, 18108366, - 18108385, 18108608, 18109192, 18109630, 18109736, 18109886, 18110216, 18111914, 18117472, 18120015, 18121451, 18121461, 18123475, - 18126178, 18127068, 18127313, 18128050, 18128330, 18128335, 18128741, 18129173, 18129186, 18129274, 18129299, 18129598, 18129647, - 18130999, 18131052, 18132357, 18132384, 18132993, 18133129, 18133459, 18134121, 18134494, 18134563, 18134668, 18134725, 18135378, - 18135538, 18135637, 18136098, 18136421, 18136723, 18136850, 18138655, 18138798, 18139149, 18139266, 18139885, 18144618, 18145061, - 18145076, 18145167, 18145171, 18145489, 18145498, 18151530, 18154233, 18157193, 18157230, 18157352, 18157653, 18158227, 18159887, - 18160433, 18160599, 18163130, 18167158, 18167584, 18167696, 18168147, 18168194, 18169252, 18169257, 18169269, 18171907, 18171970, - 18173270, 18173746, 18173941, 18173950, 18174259, 18174963, 18176304, 18176339, 18176342, 18177237, 18177283, 18177395, 18177473, - 18177557, 18177648, 18178048, 18178068, 18179144, 18179923, 18180023, 18180031, 18182471, 18182554, 18183350, 18185302, 18186630, - 18189759, 18191550, 18191572, 18191690, 18191760, 18209428, 18209658, 18210069, 18210134, 18211447, 18211680, 18213658, 18214305, - 18226915, 18227231, 18233695, 18234036, 18234679, 18237160, 18237345, 18237354, 18237447, 18238159, 18238169, 18238305, 18238306, - 18238341, 18239452, 18239552, 18239591, 18242107, 18243775, 18247187, 18248062, 18248090, 18248152, 18248702, 18248948, 18251287, - 18253159, 18253172, 18253256, 18253494, 18253674, 18253702, 18253731, 18253737, 18254465, 18254579, 18254961, 18255157, 18255423, - 18255953, 18255964, 18255975, 18256059, 18256119, 18256175, 18256361, 18258481, 18258531, 18258617, 18258894, 18258898, 18258975, - 18259049, 18259278, 18259287, 18259310, 18260016, 18261458, 18261488, 18261623, 18262488, 18262528, 18262642, 18262749, 18262798, - 18262808, 18262813, 18262819, 18262827, 18262860, 18263274, 18265073, 18265373, 18274127, 18274713, 18274727, 18275088, 18275112, - 18275130, 18278505, 18278955, 18279067, 18279081, 18282620, 18282661, 18283406, 18283563, 18283848, 18284148, 18284248, 18284447, - 18284548, 18285101, 18285102, 18285296, 18285465, 18285587, 18286538, 18286732, 18286922, 18287028, 18287423, 18287435, 18288316, - 18288614, 18288684, 18289315, 18289388, 18289811, 18290157, 18291493, 18291622, 18291700, 18291765, 18292103, 18292104, 18292192, - 18292266, 18293383, 18293550, 18293680, 18293751, 18293811, 18294213, 18294759, 18299826, 18299990, 18300398, 18301246, 18301327, - 18303702, 18303813, 18304121, 18306402, 18306490, 18306738, 18307134, 18307258, 18307380, 18307382, 18307680, 18308694, 18308707, - 18308744, 18308789, 18308936, 18309470, 18309756, 18310124, 18310324, 18310679, 18313272, 18313276, 18313936, 18313942, 18314463, - 18314471, 18314489, 18314786, 18314944, 18314957, 18315430, 18315905, 18315975, 18316319, 18316622, 18316913, 18317424, 18317507, - 18317562, 18317614, 18318101, 18318833, 18319890, 18320642, 18320688, 18322258, 18322526, 18322711, 18323528, 18323546, 18324258, - 18326071, 18328517, 18329261, 18333428, 18334440, 18334468, 18340005, 18340701, 18341515, 18342104, 18343985, 18344306, 18344387, - 18344445, 18349782, 18354524, 18354532, 18354567, 18354647, 18355784, 18355800, 18355890, 18356093, 18356174, 18357105, 18358907, - 18359179, 18360540, 18360761, 18361109, 18362474, 18362701, 18363071, 18363333, 18363353, 18363359, 18363669, 18363849, 18364852, - 18365537, 18365642, 18370037, 18374101, 18374518, 18374703, 18378858, 18378979, 18379121, 18388650, 18392831, 18392906, 18393035, - 18393498, 18395705, 18396655, 18396696, 18399717, 18399721, 18399791, 18399885, 18400237, 18400318, 18401555, 18403896, 18403898, - 18403948, 18403950, 18404071, 18404074, 18404115, 18404117, 18404169, 18404170, 18404177, 18404214, 18408893, 18409021, 18409026, - 18409046, 18409296, 18409304, 18409332, 18409338, 18409342, 18409356, 18409383, 18409396, 18409511, 18409551, 18409567, 18409579, - 18409581, 18409638, 18409642, 18409660, 18409669, 18409705, 18409710, 18409737, 18410309, 18410336, 18410366, 18410382, 18410392, - 18410418, 18410426, 18410429, 18410929, 18410976, 18411158, 18414923, 18414966, 18414967, 18414971, 18414973, 18414996, 18415012, - 18415335, 18415343, 18415344, 18415372, 18415383, 18415401, 18415404, 18415409, 18415410, 18415439, 18415463, 18415730, 18415734, - 18415751, 18415752, 18415755, 18415762, 18415770, 18415789, 18415907, 18415911, 18415914, 18415915, 18415918, 18415919, 18415924, - 18415934, 18415935, 18415948, 18415951, 18415960, 18415962, 18415969, 18415974, 18415988, 18415996, 18416003, 18416007, 18416096, - 18416097, 18416098, 18416099, 18416110, 18416111, 18416121, 18417000, 18417004, 18417110, 18417111, 18417153, 18417223, 18417250, - 18417254, 18417255, 18417271, 18417276, 18417298, 18417306, 18418074, 18418081, 18419778, 18419803, 18419847, 18419867, 18419982, - 18420104, 18420138, 18420139, 18420149, 18420289, 18420295, 18421340, 18421341, 18421351, 18421354, 18421396, 18422027, 18422036, - 18422039, 18422146, 18422232, 18422238, 18422335, 18422473, 18422479, 18422569, 18422577, 18422932, 18423232, 18423233, 18423380, - 18423386, 18423801, 18423803, 18424005, 18424006, 18424106, 18424119, 18427918, 18428063, 18428188, 18428190, 18428341, 18428344, - 18428376, 18428378, 18428415, 18429089, 18429190, 18429191, 18429295, 18429301, 18429401, 18429408, 18429419, 18429425, 18429515, - 18429526, 18429763, 18430201, 18430203, 18430403, 18431180, 18431188, 18431554, 18431563, 18431586, 18431622, 18431858, 18431859, - 18432040, 18432050, 18432832, 18433010, 18433079, 18433119, 18459655, 18461356, 18461857, 18462173, 18463453, 18463531, 18479349, - 18479433, 18479437, 18479545, 18479547, 18479583, 18479584, 18479595, 18479615, 18479616, 18479622, 18481099, 18481103, 18481144, - 18481145, 18481150, 18481262, 18481457, 18481554, 18481769, 18485920, 18501825, 18501901, 18501914, 18503176, 18503321, 18503324, - 18503327, 18503748, 18503861, 18505085, 18505121, 18505795, 18505826, 18505827, 18505942, 18507352, 18507393, 18507395, 18507485, - 18507493, 18513155, 18513195, 18513450, 18513477, 18513488, 18513513, 18513532, 18513740, 18535188, 18535211, 18535223, 18535504, - 18535506, 18535511, 18535523, 18535526, 18535693, 18535863, 18535867, 18535950, 18535960, 18536171, 18536855, 18536862, 18536866, - 18536868, 18536869, 18537563, 18537686, 18537828, 18537830, 18539322, 18539428, 18539449, 18539565, 18539569, 18542957, 18549853, - 18549867, 18614667, 18614674, 18614685, 18614689, 18629129, 18629130, 18629263, 18629369, 18629370, 18629490, 18629492, 18630041, - 18630174, 18630284, 18640752, 18640754, 18640811, 18640900, 18640907, 18640943, 18640945, 18641080, 18641081, 18641157, 18641158, - 18641209, 18641401, 18642300, 18642313, 18642314, 18642405, 18642455, 18642533, 18642534, 18642593, 18642798, 18642799, 18644754, - 18690658, 18690699, 18692929, 18692939, 18698953, 18698954, 18699153, 18699427, 18699430, 18700378, 18700541, 18700543, 18700746, - 18700748, 18700766, 18700833, 18700834, 18700841, 18700842, 18701022, 18701473, 18701507, 18701522, 18701524, 18701573, 18701579, - 18701583, 18701911, 18702014, 18702025, 18702055, 18702094, 18702904, 18703319, 18703328, 18703920, 18704157, 18704427, 18704428, - 18705700, 18706080, 18707114, 18707117, 18707253, 18707486, 18707577, 18707592, 18707596, 18707946, 18707947, 18707956, 18707959, - 18707960, 18708017, 18708020, 18708754, 18708755, 18708938, 18709230, 18709237, 18709605, 18709606, 18709614, 18709621, 18709666, - 18709675, 18709742, 18709754, 18709760, 18709875, 18709881, 18709972, 18709987, 18710107, 18710153, 18710156, 18710159, 18710194, - 18710203, 18710456, 18710530, 18710672, 18722404, 18722407, 18722441, 18722444, 18722474, 18722476, 18722661, 18722684, 18722853, - 18722855, 18722857, 18722860, 18722964, 18722965, 18722991, 18723370, 18723413, 18723704, 18723707, 18723764, 18723766, 18723857, - 18723860, 18723916, 18723941, 18723981, 18735304, 18735677, 18737090, 18737199, 18737256, 18737264, 18737394, 18737400, 18738534, - 18738537, 18738632, 18738633, 18738690, 18738691, 18738755, 18739002, 18739014, 18739017, 18739026, 18739095, 18739204, 18739715, - 18739719, 18739774, 18739780, 18741326, 18741377, 18742319, 18742321, 18742401, 18743044, 18743049, 18743102, 18743109, 18743127, - 18743150, 18743153, 18744034, 18744038, 18744047, 18744053, 18744099, 18744100, 18744161, 18744178, 18744272, 18744440, 18744448, - 18744503, 18744507, 18744957, 18744963, 18745309, 18746182, 18746720, 18746766, 18746769, 18747055, 18747115, 18747509, 18748208, - 18748215, 18748216, 18748616, 18748632, 18748881, 18748930, 18749143, 18749153, 18749347, 18749597, 18749859, 18749862, 18749865, - 18750557, 18750566, 18750749, 18751180, 18751334, 18751358, 18751444, 18751733, 18751772, 18751777, 18751784, 18751800, 18751962, - 18751964, 18751967, 18751970, 18751974, 18751975, 18751977, 18752073, 18752085, 18752241, 18752245, 18752369, 18752782, 18752796, - 18753020, 18753025, 18753230, 18753299, 18753321, 18753444, 18754157, 18754468, 18754629, 18754632, 18755348, 18755580, 18755647, - 18756137, 18756196, 18757143, 18757175, 18757227, 18757294, 18757300, 18757544, 18757547, 18757917, 18757930, 18758219, 18758228, - 18758428, 18783923, 18784255, 18784257, 18784278, 18784506, 18784512, 18785925, 18785928, 18786059, 18787397, 18787805, 18787842, - 18840505, 18840540, 18842111, 18842255, 18842546, 18842613, 18843081, 18843086, 18843202, 18877846, 18877886, 18877938, 18877995, - 18878286, 18878288, 18878602, 18878604, 18878910, 18879022, 18879087, 18879201, 18879299, 18879376, 18879694, 18879819, 18879825, - 18879959, 18879963, 18880086, 18880208, 18880209, 18880253, 18880256, 18880438, 18880477, 18880478, 18880579, 18880588, 18880589, - 18880590, 18880674, 18880675, 18880688, 18880690, 18880698, 18880703, 18880710, 18880723, 18880777, 18880778, 18880818, 18880829, - 18880956, 18880957, 18880961, 18880971, 18881047, 18881049, 18881057, 18881059, 18881244, 18881250, 18881271, 18881309, 18881313, - 18881413, 18881417, 18881470, 18881473, 18881573, 18881588, 18881603, 18881665, 18881667, 18881833, 18881834, 18881875, 18881876, - 18881945, 18881946, 18882110, 18882201, 18882333, 18882334, 18882600, 18882620, 18882747, 18882795, 18882797, 18882825, 18882827, - 18882864, 18882874, 18883468, 18883469, 18883511, 18883515, 18883910, 18884107, 18884303, 18884455, 18884839, 18884840, 18884853, - 18885134, 18885240, 18885713, 18885715, 18885719, 18885720, 18890921, 18890923, 18890924, 18891002, 18891007, 18891013, 18891073, - 18891226, 18891230, 18891902, 18892071, 18916117, 18916500, 18917173, 18917229, 18917481, 18917487, 18917714, 18918454, 18918700, - 18919243, 18919244, 18919304, 18919307, 18919365, 18919372, 18919534, 18919859, 18919932, 18920320, 18934396, 18934399, 18934421, - 18934700, 18935088, 18935417, 18935420, 18935494, 18935501, 18936000, 18936103, 18936391, 18936459, 18936570, 18936578, 18936587, - 18936614, 18936649, 18936673, 18962602, 18962613, 18962625, 18962645, 18962662, 18962676, 18963370, 18963420, 18963833, 18963836, - 18963887, 18963911, 18964240, 18964303, 18964451, 18964454, 18964458, 18964500, 18964761, 18965395, 18965426, 18965875, 18965880, - 18965881, 18965931, 18965958, 18965959, 18965984, 18965985, 18967428, 18967463, 18967632, 18968583, 18968607, 18972151, 18972181, - 18972195, 18972196, 18972221, 18972231, 18972471, 18972549, 18972554, 18972611, 18972613, 18972651, 18972928, 18972929, 18972973, - 18972974, 18972992, 18972993, 18973042, 18973044, 18973048, 18973096, 18973098, 18973116, 18973218, 18973912, 18973952, 18973955, - 18974076, 18974093, 18974104, 18974117, 18974129, 18974206, 18974209, 18974419, 18974465, 18974797, 18974894, 18975162, 18975166, - 18975316, 18975374, 18975576, 18975578, 18976376, 18976386, 18976399, 18976405, 18977338, 18977345, 18977358, 18977728, 18977730, - 18977734, 18977736, 18978127, 18978129, 18978246, 18978494, 18978496, 18978826, 18978859, 18978866, 18978868, 18978873, 18978921, - 18978923, 18978933, 18978935, 18979157, 18979213, 18979247, 18979362, 18979627, 18979629, 18979659, 18979665, 18979666, 18979668, - 18979670, 18979746, 18979760, 18979767, 18979772, 18979782, 18979798, 18979820, 18979833, 18979855, 18979857, 18979955, 18979956, - 18980169, 18980439, 18980547, 18980548, 18980554, 18980591, 18980595, 18980691, 18980698, 18980831, 18980853, 18981626, 18981703, - 18981830, 18981937, 18981943, 18982171, 18982176, 18982186, 18982188, 18982196, 18982429, 18982431, 18982437, 18982740, 18982825, - 18982829, 18982867, 18982883, 18982926, 18983055, 18983244, 18983397, 18983401, 18983612, 18983619, 18983620, 18983932, 18983935, - 18983996, 18984329, 18984386, 18984405, 18984407, 18984413, 18984431, 18984501, 18984511, 18984763, 18984769, 18984913, 18984991, - 18985047, 18985161, 18985246, 18985248, 18985301, 18985304, 18985312, 18985520, 18985521, 18985726, 18985822, 18985850, 18986106, - 18986173, 18986174, 18986252, 18986266, 18986267, 18987017, 18987031, 18987048, 18987053, 18987081, 18987680, 18988159, 18988166, - 18988194, 18988205, 18988573, 18988712, 18988715, 18988857, 18988982, 18988984, 18988985, 18989012, 18989013, 18989018, 18989086, - 18989099, 18989125, 18989132, 18989165, 18989462, 18989464, 18989759, 18989899, 18989954, 18989955, 18990839, 18990846, 18990863, - 18990866, 18991105, 18991433, 18991452, 18991456, 18991462, 18991467, 18991469, 18991662, 18992464, 18992650, 18992774, 18992801, - 18992856, 18992860, 18992906, 18999657, 18999676, 18999686, 18999697, 18999881, 18999886, 19000091, 19000224, 19000241, 19000489, - 19000503, 19001195, 19001201, 19001347, 19001359, 19007968, 19007971, 19008121, 19011401, 19011569, 19011588, 19011656, 19011677, - 19011754, 19011759, 19012403, 19012416, 19012603, 19012613, 19012746, 19012747, 19014099, 19014206, 19020339, 19020428, 19020735, - 19020954, 19020959, 19021745, 19021748, 19021802, 19021803, 19022518, 19022523, 19157469, 19157470, 19157562, 19157597, 19157681, - 19157693, 19157727, 19157735, 19177628, 19177631, 19179127, 19180014, 19180478, 19180496, 19180576, 19180594, 19180601, 19180609, - 19182388, 19182390, 19182566, 19182598, 19183939, 19184062, 19184172, 19184613, 19187655, 19187674, 19187949, 19187959, 19189135, - 19190233, 19190353, 19190502, 19190504, 19190594, 19191003, 19191043, 19191046, 19191091, 19191098, 19191118, 19191122, 19191234, - 19191237, 19191305, 19191307, 19191407, 19191408, 19191453, 19191858, 19192015, 19192485, 19192487, 19192606, 19192607, 19192611, - 19192615, 19192896, 19192903, 19193680, 19193768, 19193789, 19193876, 19193879, 19194492, 19195385, 19200168, 19200172, 19200274, - 19200290, 19200578, 19200583, 19202205, 19202286, 19202388, 19202392, 19202403, 19202424, 19202450, 19202506, 19202509, 19203134, - 19203366, 19203572, 19203746, 19203752, 19204197, 19206989, 19207000, 19207077, 19207171, 19207271, 19207272, 19208337, 19208345, - 19208730, 19212689, 19212690, 19212744, 19212946, 19212947, 19213039, 19213045, 19213048, 19213301, 19213303, 19213574, 19213575, - 19213942, 19214581, 19214583, 19214681, 19214684, 19214905, 19215052, 19215418, 19216089, 19216095, 19218331, 19218601, 19218604, - 19218875, 19219205, 19220095, 19220100, 19221680, 19221683, 19221894, 19222484, 19222586, 19222590, 19224624, 19224626, 19225180, - 19226142, 19226145, 19226595, 19226609, 19226890, 19226896, 19226910, 19226911, 19226927, 19227005, 19227837, 19227907, 19227909, - 19228054, 19228056, 19228106, 19228107, 19228121, 19228123, 19228259, 19228261, 19228302, 19228304, 19229883, 19229890, 19230123, - 19233910, 19234320, 19234345, 19234424, 19234537, 19234956, 19235288, 19235308, 19237190, 19237199, 19237208, 19237233, 19239254, - 19239258, 19239376, 19239377, 19239389, 19239407, 19240001, 19240024, 19240499, 19240901, 19250124, 19250127, 19250230, 19250239, - 19252820, 19252824, 19252856, 19252859, 19253253, 19253258, 19253341, 19253648, 19253658, 19254248, 19254257, 19254261, 19254273, - 19255415, 19255483, 19255486, 19256056, 19256595, 19256596, 19257023, 19257421, 19257656, 19257794, 19257795, 19257825, 19257827, - 19257973, 19258287, 19258305, 19259424, 19259426, 19260016, 19260028, 19260034, 19260047, 19260053, 19260136, 19260185, 19260252, - 19260535, 19260539, 19263045, 19263046, 19263072, 19263297, 19263547, 19264542, 19264897, 19268898, 19268900, 19268986, 19268990, - 19269163, 19269421, 19269423, 19271598, 19271984, 19272062, 19272201, 19272203, 19272401, 19272409, 19272445, 19272449, 19281870, - 19281883, 19282504, 19285192, 19285575, 19285576, 19285624, 19301651, 19301652, 19301719, 19301721, 19302758, 19302769, 19302830, - 19302832, 19302846, 19304733, 19304737, 19304857, 19304863, 19304956, 19304961, 19305572, 19306684, 19306759, 19306763, 19306795, - 19306821, 19306844, 19306849, 19307117, 19307412, 19307778, 19307893, 19308083, 19308148, 19308304, 19314020, 19314021, 19314052, - 19314238, 19314253, 19315712, 19316333, 19317997, 19317999, 19318269, 19318271, 19318527, 19318529, 19318536, 19318578, 19318582, - 19318880, 19318881, 19319054, 19319328, 19319330, 19319376, 19324587, 19324593, 19324769, 19324771, 19324874, 19324883, 19324952, - 19324954, 19325006, 19325007, 19325008, 19325103, 19325184, 19325185, 19325391, 19325392, 19325399, 19325401, 19325570, 19325804, - 19326308, 19326329, 19326348, 19326618, 19326756, 19326757, 19326935, 19326944, 19326947, 19327176, 19327529, 19329583, 19329702, - 19329703, 19329745, 19329746, 19329754, 19329758, 19330909, 19330912, 19331006, 19331009, 19331094, 19331095, 19331200, 19331224, - 19331676, 19331678, 19331729, 19331732, 19332246, 19332827, 19332934, 19332935, 19333061, 19358286, 19358287, 19358310, 19360688, - 19360690, 19360794, 19360932, 19361096, 19362472, 19362473, 19362976, 19362979, 19363289, 19363291, 19363391, 19363719, 19364350, - 19364366, 19364392, 19364402, 19364936, 19364944, 19365015, 19365017, 19365059, 19365710, 19365714, 19365844, 19366349, 19366686, - 19366920, 19366924, 19367057, 19367062, 19367152, 19367158, 19367216, 19367219, 19367501, 19367504, 19368429, 19368434, 19368444, - 19368449, 19368461, 19368484, 19368500, 19368501, 19368676, 19368680, 19368783, 19368797, 19368801, 19368942, 19368948, 19368949, - 19368955, 19368966, 19369066, 19369075, 19369217, 19369229, 19369302, 19369310, 19369314, 19369341, 19369343, 19369598, 19369600, - 19369688, 19369690, 19369879, 19369904, 19369907, 19369914, 19369919, 19369924, 19370031, 19373906, 19373910, 19373914, 19373996, - 19374015, 19374165, 19374181, 19374182, 19374198, 19374266, 19374299, 19374800, 19375006, 19375010, 19375171, 19375174, 19375178, - 19375183, 19375189, 19375203, 19375209, 19375252, 19375259, 19375260, 19375719, 19375788, 19375789, 19376019, 19376020, 19376061, - 19385710, 19385787, 19389326, 19389328, 19389440, 19389442, 19389987, 19390185, 19390188, 19390245, 19390250, 19390286, 19390313, - 19390322, 19390345, 19390352, 19390586, 19390710, 19392042, 19392044, 19410405, 19410437, 19410449, 19410488, 19410489, 19410496, - 19410497, 19410510, 19410916, 19411000, 19411002, 19411204, 19411937, 19411939, 19411997, 19512944, 19513029, 19513189, 19513202, - 19513396, 19513538, 19513695, 19513945, 19513992, 19516059, 19516062, 19516075, 19516084, 19516968, 19517224, 19554953, 19558472, - 19609701, 19609719, 19609892, 19609947, 19610025, 19610494, 19610647, 19610652, 19610959, 19611209, 19611291, 19612269, 19612444, - 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285, 19613989, 19614239, 19614595, 19614600, - 19614607, 19615112, 19615114, 19615248, 19726042, 19726057, 19748242, 19748244, 19748269, 19748278, 19748377, 19750672, 19750695, - 19750702, 19750822, 19750833, 19751058, 19751064, 19751102, 19751108, 19751169, 19751172, 19751269, 19751854, 19751865, 19751878, - 19751936, 19752030, 19752349, 19755044, 19755063, 19755440, 19755881, 19756813, 19761538, 19761592, 19761593, 19761680, 19761685, - 19761995, 19762162, 19762167, 19763218, 19763430, 19763945, 19764280, 19764311, 19764333, 19764676, 19764744, 19765216, 19765374, - 19765479, 19767631, 19792072, 19792136, 19792139, 19793277, 19793318, 19793322, 19793528, 19793536, 19796241, 19796405, 19796407, - 19802815, 19802816, 19802881, 19804775, 19805218, 19805360, 19805515, 19807739, 19807796, 19808997, 19809396, 19809725, 19809990, - 19913194, 19913195, 19914726, 19914727, 19914735, 19914741, 19914769, 19914811, 19914876, 19914877, 19916067, 19917537, 19917540, - 19917991, 19918159, 19918171, 19918197, 19918202, 19918295, 19918302, 19918429, 19918432, 19918524, 19918639, 19918716, 19918797, - 19918799, 19918991, 19918992, 19919153, 19919287, 19919383, 19919514, 19919971, 19919995, 19920374, 19920778, 19920779, 19921528, - 19921531, 19921674, 19921675, 19921724, 19923306, 19923308, 19923480, 19923532, 19923534, 19923692, 19923702, 19923790, 19923814, - 19923818, 19923880, 19923884, 19924275, 19924279, 19924358, 19924367, 19924384, 19925554, 19925869, 19926582, 19926586, 19926619, - 19926620, 19926687, 19926859, 19926884, 19926887, 19926891, 19926959, 19927302, 19927422, 19928859, 19929054, 19932992, 19933015, - 19933313, 19933316, 19933328, 19933410, 19933760, 19933818, 19933876, 19934184, 19934490, 19934606, 19934621, 19934741, 19959354, - 19959578, 19960026, 19960122, 19962154, 19962536 -]; -export const PEG_CROSS_BLOCKS_LAST: u32 = 19962536; diff --git a/projects/subgraph-bean/package.json b/projects/subgraph-bean/package.json index 208f145674..8b1f3b1dd4 100644 --- a/projects/subgraph-bean/package.json +++ b/projects/subgraph-bean/package.json @@ -13,6 +13,7 @@ "test": "graph test", "testd": "docker run -it --rm --mount type=bind,source=\"$(pwd)\"/matchstick-docker.yaml,target=/matchstick/matchstick.yaml --mount type=bind,source=\"$(pwd)\"/../../,target=/matchstick/repo-mounted/ matchstick", "testd-named": "../subgraph-core/tests/scripts/docker-run-named.sh", + "build-cache": "sh -c 'for file in ./cache-builder/*.js; do node \"$file\"; done'", "create-local": "echo Using manifest at ./manifests/$1.yaml && graph create --node http://127.0.0.1:8020/ bean_$1", "remove-local": "echo Using manifest at ./manifests/$1.yaml && graph remove --node http://127.0.0.1:8020/ bean_$1", "deploy-local": "echo Using manifest at ./manifests/$1.yaml && yarn codegen && graph deploy --node http://127.0.0.1:8020/ --ipfs http://127.0.0.1:5001 bean_$1 ./manifests/$1.yaml" diff --git a/projects/subgraph-bean/src/BlockHandler.ts b/projects/subgraph-bean/src/BlockHandler.ts index 2690b902be..4a49335d42 100644 --- a/projects/subgraph-bean/src/BlockHandler.ts +++ b/projects/subgraph-bean/src/BlockHandler.ts @@ -6,7 +6,7 @@ import { toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals" import { checkBeanCross, checkPoolCross } from "./utils/Cross"; import { loadOrCreatePool, updatePoolPrice, updatePoolValues } from "./utils/Pool"; import { BeanstalkPrice_try_price } from "./utils/price/BeanstalkPrice"; -import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "./cache/PegCrossBlocks"; +import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "../cache-builder/results/PegCrossBlocks"; import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; // Processing as each new ethereum block is created diff --git a/projects/subgraph-bean/tests/Cross.test.ts b/projects/subgraph-bean/tests/Cross.test.ts index 401c43c2c9..21d6c924ef 100644 --- a/projects/subgraph-bean/tests/Cross.test.ts +++ b/projects/subgraph-bean/tests/Cross.test.ts @@ -15,7 +15,7 @@ import { getPreReplantPriceETH, constantProductPrice, uniswapV2Reserves } from " import { mockPoolPriceAndLiquidity, mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves } from "./entity-mocking/MockPool"; import { updatePricesAndCheckCrosses as crv_updatePricesAndCheckCrosses } from "../src/Bean3CRVHandler_V1"; import { setWhitelistedPools } from "./entity-mocking/MockBean"; -import { PEG_CROSS_BLOCKS } from "../src/cache/PegCrossBlocks"; +import { PEG_CROSS_BLOCKS } from "../cache-builder/results/PegCrossBlocks"; import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; const wellCrossId = (n: u32): string => { From 03381ca9774ddad5d452ca0183328acc3c5fead4 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:41:50 -0700 Subject: [PATCH 03/88] updated readme with cache instructions --- projects/subgraph-bean/README.md | 4 +- .../cache-builder/peg-crosses.js | 2 +- .../cache-builder/results/PegCrossBlocks.ts | 1872 ----------------- .../results/PegCrossBlocks_eth.ts | 624 ++++++ projects/subgraph-bean/src/BlockHandler.ts | 2 +- projects/subgraph-bean/tests/Cross.test.ts | 2 +- 6 files changed, 630 insertions(+), 1876 deletions(-) delete mode 100644 projects/subgraph-bean/cache-builder/results/PegCrossBlocks.ts create mode 100644 projects/subgraph-bean/cache-builder/results/PegCrossBlocks_eth.ts diff --git a/projects/subgraph-bean/README.md b/projects/subgraph-bean/README.md index 080f10c896..e1780ae8ed 100644 --- a/projects/subgraph-bean/README.md +++ b/projects/subgraph-bean/README.md @@ -26,4 +26,6 @@ To test with Docker, the first time you will need to run `yarn run graph test -d ### Deploying -When using graph cli commands, you will often need to specify which manifest file should be used. This is necessary to support multiple chains in the same codebase. The commands which need it will be evident - as they will fail when unable to find a `subgraph.yaml` file. In those commands, include `./manifest/${chain}.yaml` as the final argument to the command. See scripts inside `package.json` for examples. \ No newline at end of file +When using graph cli commands, you will often need to specify which manifest file should be used. This is necessary to support multiple chains in the same codebase. The commands which need it will be evident - as they will fail when unable to find a `subgraph.yaml` file. In those commands, include `./manifest/${chain}.yaml` as the final argument to the command. See scripts inside `package.json` for examples. + +It may be necessary to run `yarn build-cache` prior to a new deployment build. This updates historical cached values, particularly as it pertains to the L1 -> L2 migration. It will be necessary to re-run these scripts if updates to the L1 subgraph are made that need to have some values carried to the L2 subgraph. Note that it may not always be appropriate to run every script in the corresponding `cache-builder` directory, use with caution. diff --git a/projects/subgraph-bean/cache-builder/peg-crosses.js b/projects/subgraph-bean/cache-builder/peg-crosses.js index 6ee85915b3..adc6167215 100644 --- a/projects/subgraph-bean/cache-builder/peg-crosses.js +++ b/projects/subgraph-bean/cache-builder/peg-crosses.js @@ -39,7 +39,7 @@ async function getAllPegCrossBlocks() { } allCrossBlocks.sort(); - const outFile = `${__dirname}/results/PegCrossBlocks.ts`; + const outFile = `${__dirname}/results/PegCrossBlocks_eth.ts`; await fs.promises.appendFile( outFile, `export const PEG_CROSS_BLOCKS: u32[] = [${allCrossBlocks.join(",")}]; diff --git a/projects/subgraph-bean/cache-builder/results/PegCrossBlocks.ts b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks.ts deleted file mode 100644 index eafddd4971..0000000000 --- a/projects/subgraph-bean/cache-builder/results/PegCrossBlocks.ts +++ /dev/null @@ -1,1872 +0,0 @@ -export const PEG_CROSS_BLOCKS: u32[] = [ - 12974091, 12975421, 12978538, 12978615, 12978680, 12978911, 12979148, 12979149, 12979167, 12979171, 12979228, 12979230, 12979607, - 12983847, 12983871, 12983895, 12983897, 12983926, 12984038, 12984104, 12984170, 12984257, 12984310, 12984929, 12986590, 12986603, - 12986901, 12987603, 12990064, 12991358, 12991399, 12992193, 12992519, 12993217, 12993281, 12998537, 12998539, 12998546, 12998550, - 12998551, 12998553, 12999530, 12999585, 12999767, 12999776, 12999777, 12999779, 12999817, 12999840, 13000158, 13000196, 13000305, - 13000309, 13000334, 13000347, 13000356, 13000377, 13000577, 13000587, 13001082, 13001089, 13001396, 13001414, 13001894, 13001913, - 13001956, 13002009, 13002735, 13002738, 13003196, 13003198, 13004037, 13004045, 13004360, 13004364, 13004638, 13004646, 13004655, - 13004657, 13004817, 13004839, 13004843, 13004883, 13005075, 13005103, 13005107, 13005109, 13005372, 13005380, 13005673, 13005715, - 13005730, 13005733, 13005944, 13005946, 13006200, 13006202, 13006203, 13006321, 13006487, 13006488, 13006499, 13006546, 13006708, - 13006709, 13006980, 13007010, 13007245, 13007246, 13007274, 13007275, 13007509, 13007525, 13007574, 13007607, 13007780, 13007798, - 13007859, 13007898, 13008063, 13008065, 13008117, 13008191, 13008375, 13008387, 13008617, 13008671, 13008712, 13008736, 13008895, - 13008901, 13008906, 13008912, 13009163, 13009169, 13009190, 13009193, 13009199, 13009203, 13009381, 13009423, 13009669, 13009671, - 13009676, 13009679, 13009681, 13009687, 13009958, 13009972, 13009973, 13010009, 13010222, 13010231, 13010492, 13010556, 13010779, - 13014211, 13016266, 13018933, 13019023, 13019754, 13020690, 13020782, 13022699, 13022701, 13022825, 13023185, 13023247, 13023922, - 13025396, 13025666, 13026184, 13026256, 13026638, 13026640, 13027512, 13029384, 13030010, 13030107, 13030123, 13030393, 13030528, - 13031004, 13031259, 13032695, 13032731, 13032942, 13033010, 13033033, 13033210, 13034517, 13034543, 13035839, 13035922, 13035929, - 13036165, 13036689, 13036884, 13036897, 13036926, 13037135, 13037615, 13037642, 13038069, 13038108, 13038138, 13038145, 13038184, - 13039743, 13043682, 13043699, 13044756, 13044762, 13044770, 13044955, 13045801, 13046502, 13051141, 13051348, 13056233, 13056234, - 13057499, 13057501, 13057527, 13057595, 13058927, 13059717, 13059983, 13060079, 13060086, 13060118, 13060119, 13060121, 13060123, - 13060132, 13060160, 13060198, 13060449, 13060450, 13060479, 13060489, 13060492, 13060680, 13060716, 13060796, 13060802, 13060842, - 13060960, 13062059, 13062295, 13062299, 13062306, 13062319, 13062333, 13062352, 13062366, 13063788, 13063838, 13063861, 13063878, - 13075770, 13075888, 13076058, 13076195, 13076316, 13076435, 13076636, 13076662, 13076679, 13076703, 13076890, 13076891, 13076899, - 13076947, 13076964, 13076972, 13077164, 13077246, 13077426, 13077429, 13077495, 13077503, 13077730, 13077736, 13078272, 13078287, - 13078449, 13078457, 13078466, 13078470, 13078482, 13078487, 13078488, 13078519, 13078541, 13078561, 13078796, 13078810, 13078813, - 13078834, 13079299, 13079303, 13079572, 13079587, 13079588, 13079596, 13079620, 13079642, 13079648, 13079683, 13079724, 13079755, - 13079814, 13079885, 13079887, 13079895, 13079899, 13079919, 13079920, 13079941, 13080074, 13080179, 13080198, 13080229, 13080352, - 13080375, 13080400, 13080408, 13080634, 13080637, 13080648, 13080660, 13080672, 13080677, 13080678, 13080680, 13080768, 13080770, - 13080887, 13080888, 13080932, 13080934, 13080937, 13080958, 13080977, 13080990, 13080996, 13080999, 13081011, 13081057, 13081145, - 13081209, 13081632, 13081635, 13081700, 13081721, 13081750, 13081754, 13081766, 13081895, 13081963, 13081977, 13081992, 13081994, - 13082000, 13082006, 13082094, 13082163, 13082230, 13082282, 13082300, 13082301, 13082504, 13082507, 13082510, 13082555, 13082863, - 13082876, 13082878, 13082888, 13082969, 13083844, 13084930, 13084956, 13084984, 13085212, 13085233, 13085236, 13085311, 13085508, - 13085645, 13085877, 13086288, 13086337, 13086338, 13086356, 13086362, 13086369, 13086376, 13086400, 13086422, 13086440, 13086459, - 13086461, 13087211, 13087217, 13087221, 13087225, 13087231, 13087377, 13087393, 13087405, 13087410, 13087411, 13087527, 13088104, - 13088272, 13093705, 13093899, 13093903, 13093921, 13093932, 13093971, 13093975, 13099188, 13099189, 13099353, 13099362, 13099414, - 13099461, 13099465, 13099710, 13099714, 13099747, 13100289, 13100319, 13100358, 13100371, 13100898, 13100923, 13102868, 13102939, - 13107071, 13107096, 13110581, 13110588, 13110634, 13110706, 13110819, 13110844, 13111074, 13113042, 13113109, 13113110, 13113423, - 13113442, 13113448, 13113452, 13113453, 13113553, 13114481, 13114574, 13115940, 13115946, 13115955, 13115972, 13115989, 13115990, - 13117862, 13118077, 13118145, 13118291, 13118320, 13118321, 13118355, 13118356, 13118402, 13118413, 13118423, 13118428, 13118436, - 13118467, 13121070, 13121089, 13121099, 13121128, 13121178, 13121244, 13121307, 13121310, 13122225, 13122395, 13122407, 13122455, - 13122874, 13122951, 13122985, 13124397, 13124895, 13129783, 13129786, 13129854, 13129981, 13129991, 13130001, 13130094, 13130178, - 13131625, 13131662, 13131722, 13131929, 13137125, 13137568, 13138520, 13138647, 13138700, 13138778, 13138782, 13138813, 13138856, - 13138858, 13139212, 13139273, 13139367, 13139407, 13139408, 13139410, 13139609, 13140003, 13140015, 13140024, 13140027, 13140327, - 13140447, 13140687, 13141148, 13141156, 13141160, 13141165, 13141195, 13141863, 13141869, 13141870, 13141940, 13142135, 13143729, - 13143754, 13143760, 13143762, 13143763, 13143816, 13144293, 13144300, 13144362, 13144364, 13144774, 13144823, 13145005, 13145190, - 13145194, 13145195, 13145198, 13145206, 13145220, 13145747, 13146082, 13146089, 13147016, 13147028, 13147044, 13147045, 13148291, - 13148316, 13149112, 13150275, 13150279, 13150280, 13151314, 13151333, 13151356, 13151443, 13151450, 13151451, 13151460, 13151462, - 13151595, 13151598, 13151696, 13151700, 13151863, 13151867, 13152103, 13152260, 13152269, 13153306, 13153325, 13155620, 13156284, - 13156748, 13156781, 13157326, 13158957, 13159234, 13159235, 13159247, 13159248, 13159486, 13159495, 13161064, 13161086, 13161299, - 13161376, 13161392, 13161406, 13161416, 13161423, 13161487, 13161550, 13161611, 13161634, 13161636, 13162200, 13162208, 13162329, - 13162331, 13163395, 13163536, 13163565, 13163567, 13163596, 13163597, 13163604, 13163670, 13163995, 13164187, 13164189, 13164192, - 13164658, 13164746, 13165237, 13165391, 13165408, 13165727, 13165897, 13165996, 13166015, 13166072, 13166219, 13166222, 13166242, - 13166250, 13166251, 13166258, 13166259, 13166283, 13166287, 13166319, 13166381, 13166437, 13167205, 13167549, 13167575, 13167591, - 13167742, 13167972, 13168519, 13168524, 13169110, 13171988, 13175038, 13175053, 13175058, 13175064, 13175069, 13175146, 13175397, - 13175452, 13175497, 13175514, 13175520, 13175609, 13177587, 13177589, 13177597, 13177615, 13177647, 13177659, 13177660, 13177714, - 13177758, 13178360, 13178584, 13178652, 13179149, 13179177, 13179251, 13179252, 13179253, 13179274, 13179308, 13179337, 13179353, - 13179400, 13180079, 13180083, 13180101, 13180102, 13180117, 13180145, 13180189, 13180216, 13180664, 13180692, 13180713, 13180715, - 13180730, 13180758, 13180833, 13180888, 13180897, 13180909, 13181023, 13181155, 13181755, 13181777, 13181802, 13181820, 13182646, - 13182655, 13183890, 13183894, 13183955, 13183956, 13183957, 13184012, 13184973, 13184974, 13185191, 13185260, 13185321, 13185384, - 13185495, 13185703, 13185732, 13185850, 13187086, 13187116, 13187178, 13187233, 13188042, 13189001, 13189010, 13189082, 13191072, - 13191091, 13191099, 13191106, 13191522, 13191635, 13191637, 13191644, 13192232, 13192596, 13192599, 13192604, 13193031, 13193802, - 13194379, 13194410, 13194615, 13194717, 13194719, 13194824, 13196049, 13196067, 13196141, 13196190, 13196445, 13196459, 13196460, - 13198164, 13198273, 13198316, 13198557, 13198899, 13198902, 13198907, 13198909, 13198925, 13199052, 13199074, 13199086, 13199099, - 13199116, 13199129, 13199131, 13199260, 13199361, 13199363, 13200193, 13200194, 13200216, 13200219, 13200224, 13201208, 13201289, - 13201290, 13201321, 13201322, 13206138, 13206229, 13206338, 13206947, 13207266, 13207395, 13207435, 13207444, 13207445, 13207578, - 13207663, 13208184, 13211822, 13211897, 13211967, 13213641, 13214042, 13214163, 13214206, 13215008, 13215982, 13217044, 13217061, - 13217222, 13217341, 13217478, 13217783, 13217784, 13217810, 13217953, 13217970, 13217973, 13218020, 13218050, 13218279, 13218810, - 13218815, 13218816, 13218909, 13218949, 13218953, 13218954, 13225077, 13225299, 13226246, 13226559, 13226732, 13226957, 13227000, - 13229110, 13229499, 13229747, 13232674, 13232699, 13232717, 13233025, 13234172, 13234178, 13234264, 13234554, 13236246, 13236247, - 13236250, 13236319, 13237109, 13237552, 13244459, 13244462, 13245028, 13245032, 13245040, 13245162, 13245172, 13245175, 13245180, - 13245275, 13245545, 13245546, 13246387, 13246388, 13246647, 13246651, 13246920, 13246926, 13246980, 13246983, 13247415, 13247416, - 13247678, 13247695, 13247947, 13247952, 13248208, 13248209, 13248470, 13248473, 13249273, 13249276, 13249292, 13249294, 13249543, - 13249561, 13249800, 13249818, 13249822, 13250039, 13250057, 13250059, 13256813, 13256815, 13257386, 13257389, 13258210, 13258214, - 13259590, 13259594, 13259863, 13259865, 13260039, 13260056, 13260062, 13260063, 13260114, 13260126, 13260381, 13260386, 13260388, - 13260389, 13260884, 13260886, 13261140, 13261142, 13261145, 13261155, 13261156, 13261186, 13261206, 13261363, 13261373, 13261399, - 13262381, 13262382, 13262425, 13262428, 13262440, 13262442, 13262455, 13262462, 13262465, 13262469, 13262553, 13262554, 13262569, - 13262592, 13262593, 13262713, 13262719, 13262729, 13262748, 13262896, 13262899, 13262913, 13263080, 13263772, 13263871, 13264127, - 13264135, 13264139, 13264149, 13272546, 13272560, 13272905, 13272934, 13273058, 13273061, 13273064, 13273373, 13273436, 13273458, - 13273503, 13273513, 13273717, 13273719, 13274023, 13274030, 13274057, 13274064, 13274105, 13274148, 13274189, 13274198, 13274217, - 13274220, 13274242, 13274248, 13335750, 13335755, 13335869, 13336244, 13336323, 13336461, 13336505, 13336560, 13336618, 13336695, - 13336714, 13336777, 13336959, 13337532, 13337559, 13337935, 13337937, 13337959, 13340698, 13340781, 13340820, 13340947, 13341028, - 13341076, 13341108, 13341147, 13341156, 13341366, 13341373, 13342047, 13342121, 13342224, 13342548, 13376585, 13376710, 13376778, - 13378143, 13378793, 13378816, 13378829, 13379464, 13434006, 13434877, 13435565, 13435971, 13436006, 13436018, 13436025, 13436035, - 13436049, 13436107, 13437998, 13438644, 13438667, 13440517, 13442086, 13442913, 13443210, 13443231, 13443232, 13443239, 13443256, - 13443258, 13443270, 13443271, 13444653, 13444660, 13444712, 13446459, 13448008, 13449065, 13449128, 13449167, 13449303, 13449313, - 13449493, 13449495, 13449505, 13449506, 13449551, 13449634, 13449650, 13449705, 13449790, 13449821, 13449841, 13449855, 13449875, - 13449913, 13450052, 13450154, 13450187, 13450472, 13450507, 13450522, 13451061, 13451131, 13451155, 13451468, 13451543, 13451544, - 13451550, 13451555, 13451564, 13451596, 13451598, 13451649, 13451671, 13451675, 13455280, 13455282, 13455557, 13455600, 13455618, - 13455860, 13455891, 13455896, 13455911, 13461738, 13462027, 13462049, 13462066, 13462165, 13463379, 13463381, 13464408, 13466451, - 13467419, 13467691, 13468508, 13468675, 13468784, 13469000, 13469007, 13469012, 13469034, 13470634, 13470770, 13471747, 13474744, - 13474934, 13475341, 13475377, 13475394, 13475519, 13475523, 13475746, 13476174, 13476209, 13476325, 13476418, 13476419, 13479133, - 13479136, 13479138, 13479152, 13479196, 13479242, 13479941, 13480370, 13480372, 13480449, 13480647, 13480648, 13480717, 13481304, - 13481717, 13481988, 13482011, 13482102, 13483897, 13483977, 13483982, 13483998, 13484811, 13484846, 13484847, 13486887, 13486969, - 13488473, 13488482, 13489574, 13489977, 13490465, 13490505, 13490507, 13490517, 13490518, 13491374, 13494424, 13494752, 13494754, - 13495520, 13495854, 13497794, 13497797, 13497803, 13497820, 13497844, 13497868, 13498035, 13503686, 13503690, 13503704, 13503709, - 13503751, 13503763, 13503770, 13503813, 13503910, 13508461, 13508666, 13508680, 13508728, 13508759, 13508780, 13510297, 13510507, - 13510508, 13510514, 13510516, 13510518, 13510520, 13510556, 13510590, 13510603, 13510605, 13510610, 13510727, 13511700, 13511890, - 13511907, 13512045, 13512048, 13512304, 13512305, 13512359, 13512365, 13514281, 13514282, 13514705, 13514719, 13514721, 13514734, - 13515060, 13516318, 13516526, 13516569, 13517036, 13517567, 13518970, 13519495, 13519497, 13519756, 13521882, 13522133, 13523828, - 13523847, 13523862, 13523885, 13523912, 13523967, 13523969, 13524379, 13524397, 13525787, 13525872, 13525873, 13528534, 13528544, - 13528546, 13528558, 13528574, 13528579, 13528967, 13529028, 13531631, 13531875, 13531910, 13531954, 13531961, 13531990, 13532016, - 13532023, 13532081, 13532126, 13532137, 13532138, 13532143, 13532151, 13532161, 13532176, 13532179, 13532198, 13532239, 13532920, - 13532929, 13532946, 13533454, 13533933, 13535490, 13535493, 13535494, 13535499, 13538211, 13538232, 13538866, 13538895, 13539218, - 13539249, 13539673, 13539923, 13539946, 13539951, 13540826, 13540841, 13541140, 13541325, 13541849, 13541933, 13541958, 13541980, - 13541997, 13542002, 13542077, 13542086, 13542175, 13542179, 13542232, 13542254, 13543917, 13544624, 13545832, 13545837, 13545858, - 13546411, 13547018, 13547059, 13547095, 13547595, 13547630, 13548233, 13548387, 13550252, 13550987, 13551029, 13551119, 13551280, - 13551291, 13552190, 13552241, 13552260, 13552307, 13552675, 13552678, 13552681, 13552684, 13552688, 13552701, 13552704, 13552750, - 13552752, 13552754, 13552943, 13553661, 13553662, 13553676, 13553677, 13553853, 13554976, 13555095, 13555457, 13557196, 13557954, - 13558105, 13558112, 13558113, 13558114, 13558116, 13558121, 13558735, 13558752, 13558776, 13559078, 13559084, 13559255, 13559291, - 13559303, 13559410, 13559415, 13559416, 13559425, 13559561, 13559568, 13559602, 13559647, 13559656, 13559658, 13559791, 13559882, - 13560317, 13560318, 13560937, 13564634, 13564681, 13564697, 13564713, 13564837, 13564852, 13564859, 13564871, 13564879, 13564889, - 13564891, 13566648, 13568113, 13568302, 13568342, 13568345, 13568357, 13568484, 13568492, 13568495, 13568667, 13570256, 13570277, - 13570284, 13570300, 13570316, 13570318, 13570944, 13570952, 13571175, 13572652, 13572673, 13572674, 13572854, 13572856, 13572884, - 13572895, 13572918, 13572923, 13572958, 13572969, 13573024, 13573028, 13573096, 13573097, 13573405, 13573522, 13573523, 13573686, - 13573687, 13573693, 13573695, 13574201, 13574213, 13574289, 13574294, 13575376, 13575377, 13576614, 13576620, 13576635, 13576661, - 13576663, 13577153, 13577969, 13578897, 13578901, 13578940, 13578947, 13579158, 13579160, 13579235, 13579351, 13579385, 13579447, - 13579490, 13579530, 13579565, 13579572, 13579588, 13579894, 13579900, 13579911, 13579912, 13579914, 13579918, 13579942, 13580072, - 13580087, 13580260, 13580280, 13581920, 13582005, 13582060, 13582068, 13582069, 13582090, 13582096, 13582336, 13582467, 13582468, - 13582749, 13583449, 13583933, 13584045, 13584069, 13584076, 13584080, 13584082, 13584102, 13584104, 13584107, 13584126, 13584153, - 13584183, 13584184, 13584192, 13584195, 13584208, 13584209, 13584211, 13584243, 13584286, 13584294, 13584296, 13584485, 13584486, - 13585001, 13585594, 13585602, 13585607, 13585610, 13585641, 13585748, 13585775, 13585976, 13585992, 13586067, 13587038, 13587054, - 13587160, 13589367, 13589405, 13589454, 13589471, 13589485, 13589486, 13589512, 13589515, 13589527, 13589532, 13589574, 13589656, - 13589661, 13589867, 13590103, 13592391, 13594358, 13595502, 13595599, 13595883, 13596659, 13596666, 13596668, 13596671, 13598662, - 13599510, 13599974, 13600003, 13600116, 13600221, 13600229, 13600230, 13600343, 13600344, 13600519, 13602309, 13602377, 13602479, - 13602483, 13602486, 13602488, 13602489, 13602490, 13602493, 13602978, 13603574, 13603586, 13603652, 13603887, 13604255, 13605773, - 13605779, 13606896, 13607198, 13607202, 13607203, 13608420, 13608519, 13608665, 13608681, 13608968, 13610066, 13611161, 13614876, - 13614927, 13614991, 13614998, 13615404, 13617630, 13618342, 13621035, 13622147, 13623486, 13623495, 13623499, 13623577, 13623590, - 13623764, 13624270, 13624355, 13624363, 13624366, 13624383, 13624517, 13625958, 13625960, 13625982, 13626112, 13626125, 13626166, - 13626170, 13626212, 13628785, 13628854, 13628864, 13628865, 13629661, 13629662, 13629784, 13629785, 13629852, 13630011, 13630129, - 13630230, 13630429, 13630583, 13630683, 13630775, 13630780, 13630796, 13631292, 13631331, 13640082, 13640087, 13640104, 13640132, - 13640218, 13640556, 13640587, 13640615, 13641928, 13641929, 13642057, 13642071, 13642137, 13642155, 13642160, 13642167, 13642168, - 13642207, 13642212, 13642215, 13642216, 13642265, 13642911, 13644410, 13646116, 13646163, 13647476, 13647732, 13647733, 13647905, - 13657931, 13657936, 13658078, 13658083, 13658088, 13658106, 13666892, 13666908, 13667064, 13667842, 13671879, 13672266, 13685409, - 13685501, 13687313, 13687327, 13688700, 13688718, 13688728, 13688770, 13688773, 13689077, 13693941, 13693995, 13694143, 13694177, - 13703288, 13703407, 13704796, 13704804, 13704850, 13704871, 13710244, 13710333, 13710534, 13710568, 13717643, 13717686, 13720847, - 13720981, 13721138, 13721150, 13721209, 13721255, 13721263, 13721265, 13721279, 13721280, 13722372, 13722456, 13722731, 13722854, - 13722860, 13722861, 13722883, 13722884, 13722898, 13722924, 13723078, 13723597, 13723611, 13723617, 13724121, 13724580, 13724940, - 13724949, 13724958, 13725168, 13725481, 13725714, 13725715, 13725761, 13726532, 13728022, 13728049, 13729075, 13729079, 13729488, - 13729572, 13729622, 13729660, 13729666, 13729719, 13729765, 13729836, 13731361, 13731396, 13731754, 13731765, 13731769, 13731770, - 13731798, 13731966, 13732954, 13732957, 13732964, 13734204, 13734565, 13734582, 13734613, 13734671, 13735055, 13735059, 13735060, - 13735378, 13740278, 13740773, 13740781, 13740808, 13740821, 13740879, 13741264, 13742045, 13742386, 13742413, 13742433, 13742461, - 13742522, 13743142, 13743432, 13743636, 13743643, 13743676, 13744107, 13744604, 13800996, 13800999, 13801241, 13801243, 13804633, - 13804667, 13804672, 13804727, 13812443, 13812884, 13812892, 13812903, 13813249, 13813688, 13829732, 13829784, 13844956, 13844964, - 13845655, 13845657, 13845739, 13845745, 13845757, 13845780, 13848953, 13851591, 13851617, 13852217, 13852286, 13852519, 13853027, - 13854735, 13854789, 13854927, 13854932, 13854936, 13854950, 13854954, 13856012, 13856028, 13856077, 13856953, 13856955, 13857267, - 13857323, 13857365, 13857466, 13857469, 13857483, 13857490, 13857624, 13857918, 13858695, 13858898, 13858902, 13858904, 13858923, - 13858924, 13859670, 13859826, 13859936, 13860025, 13860899, 13861827, 13861932, 13861937, 13862044, 13862064, 13862197, 13862355, - 13862374, 13863113, 13864512, 13864522, 13864530, 13864926, 13864941, 13864946, 13864969, 13865001, 13865043, 13865070, 13865081, - 13865342, 13865516, 13865553, 13865581, 13865604, 13865623, 13865647, 13865678, 13866062, 13869401, 13869405, 13869422, 13869451, - 13869457, 13869834, 13870311, 13870632, 13871204, 13871210, 13871302, 13871334, 13871339, 13871363, 13871424, 13871435, 13871497, - 13871551, 13871568, 13871570, 13871583, 13871761, 13872175, 13872207, 13872240, 13872304, 13872378, 13872402, 13872443, 13872834, - 13872889, 13872979, 13873525, 13873669, 13874108, 13874137, 13874154, 13874198, 13874244, 13874484, 13875063, 13875708, 13875709, - 13876095, 13876631, 13876822, 13876828, 13876980, 13877074, 13877075, 13877496, 13877517, 13877520, 13877638, 13877848, 13878148, - 13882302, 13882360, 13882365, 13882591, 13882592, 13882597, 13882599, 13882806, 13882807, 13883051, 13883360, 13883433, 13884709, - 13885349, 13885866, 13885918, 13886883, 13887001, 13887338, 13887344, 13887380, 13887548, 13887611, 13888142, 13888577, 13888593, - 13888668, 13888746, 13889461, 13889503, 13889510, 13889524, 13889539, 13889649, 13890458, 13891050, 13891076, 13891081, 13891130, - 13891135, 13891138, 13902888, 13902992, 13906563, 13906944, 13908405, 13908630, 13912128, 13912739, 13913099, 13913121, 13913454, - 13913585, 13913596, 13914008, 13926989, 13926996, 13927003, 13927014, 13927024, 13927479, 13927483, 13927492, 13938606, 13938669, - 13939585, 13939590, 13939599, 13939708, 13939849, 13939850, 13942560, 13942563, 13942611, 13954079, 13954146, 13954148, 13954178, - 13985645, 13985651, 13992100, 14005135, 14005139, 14005140, 14005142, 14005185, 14009388, 14009390, 14038443, 14043167, 14043168, - 14098158, 14098190, 14098343, 14098347, 14098363, 14098372, 14098448, 14098510, 14099411, 14099421, 14111704, 14111988, 14112175, - 14112178, 14112222, 14112272, 14112281, 14112322, 14112332, 14112523, 14112534, 14112721, 14112870, 14113018, 14113027, 14113380, - 14113524, 14113544, 14113990, 14114153, 14114184, 14114266, 14114286, 14114342, 14114380, 14114399, 14114404, 14114436, 14114512, - 14114628, 14114673, 14114833, 14114886, 14114898, 14115278, 14115362, 14115372, 14115446, 14115500, 14115574, 14116384, 14116406, - 14116506, 14116797, 14116986, 14117002, 14117059, 14117070, 14117097, 14117135, 14117265, 14117322, 14117503, 14117521, 14117550, - 14118001, 14118142, 14118146, 14118158, 14118197, 14118368, 14118496, 14118533, 14118647, 14118701, 14118714, 14118937, 14119187, - 14119295, 14119413, 14119877, 14119901, 14119970, 14120278, 14120281, 14120282, 14120389, 14120437, 14120542, 14120552, 14120595, - 14121317, 14121366, 14121432, 14121455, 14121577, 14121580, 14121596, 14121601, 14121630, 14121638, 14121679, 14121684, 14121722, - 14121856, 14122382, 14122403, 14122483, 14122757, 14122763, 14122767, 14122824, 14122827, 14122833, 14122844, 14122853, 14122877, - 14123193, 14123200, 14123302, 14123407, 14124143, 14124163, 14124204, 14124296, 14124337, 14124352, 14124366, 14124368, 14124374, - 14124391, 14124991, 14125047, 14126549, 14126762, 14126770, 14126771, 14126782, 14126791, 14126823, 14126841, 14128740, 14128817, - 14128883, 14128944, 14129293, 14129452, 14129553, 14129573, 14129597, 14129617, 14129837, 14129898, 14129913, 14129915, 14129939, - 14130007, 14130296, 14130298, 14130316, 14130334, 14130355, 14130372, 14130378, 14130387, 14130388, 14130423, 14130440, 14130465, - 14130641, 14131066, 14131081, 14131115, 14131324, 14131407, 14131588, 14132136, 14132310, 14133768, 14133783, 14133786, 14133815, - 14133830, 14133981, 14134041, 14135528, 14135807, 14135812, 14135828, 14137560, 14137824, 14137853, 14138293, 14138307, 14138600, - 14138669, 14138825, 14138845, 14138888, 14139112, 14139816, 14140071, 14140079, 14140134, 14140318, 14140343, 14140597, 14140903, - 14140910, 14141386, 14141418, 14141461, 14141473, 14141478, 14141480, 14141489, 14141517, 14141541, 14141549, 14141628, 14141732, - 14141733, 14141780, 14141786, 14141800, 14142398, 14142742, 14142749, 14143111, 14143196, 14143745, 14143763, 14143828, 14143864, - 14144282, 14144473, 14145076, 14145285, 14145784, 14145908, 14145935, 14145988, 14146061, 14146091, 14146109, 14146166, 14146173, - 14146182, 14146184, 14146190, 14146207, 14146234, 14146754, 14146771, 14146832, 14147019, 14147204, 14147423, 14147483, 14147519, - 14147526, 14147554, 14147587, 14147607, 14147732, 14148521, 14148714, 14149592, 14149619, 14149789, 14149804, 14149812, 14149940, - 14149961, 14149966, 14149992, 14151350, 14151353, 14153570, 14154639, 14154760, 14154939, 14155463, 14155476, 14155742, 14155762, - 14155771, 14155906, 14155935, 14156644, 14156695, 14156824, 14157718, 14158023, 14158178, 14158179, 14158192, 14158225, 14158234, - 14160434, 14160448, 14160484, 14160591, 14160631, 14160678, 14161007, 14161029, 14161053, 14161067, 14161227, 14161241, 14161396, - 14161541, 14161546, 14161548, 14161549, 14161604, 14161618, 14161833, 14161976, 14161996, 14162133, 14162387, 14162615, 14162897, - 14163117, 14163286, 14163301, 14163309, 14163900, 14163967, 14164571, 14165063, 14165098, 14165182, 14165193, 14165728, 14165832, - 14166064, 14166499, 14166555, 14166559, 14166586, 14167320, 14167457, 14167507, 14167584, 14167707, 14167751, 14167792, 14167806, - 14167809, 14167830, 14167859, 14167868, 14167877, 14167979, 14167980, 14171368, 14171777, 14171890, 14171953, 14172042, 14172047, - 14172089, 14172170, 14172332, 14172456, 14172572, 14172639, 14173001, 14174547, 14174910, 14175087, 14175109, 14175111, 14175869, - 14175907, 14176246, 14176253, 14176343, 14176607, 14177124, 14177447, 14177503, 14177734, 14178614, 14178630, 14178820, 14178821, - 14178839, 14179074, 14179192, 14179237, 14179326, 14180592, 14180796, 14180851, 14181128, 14181137, 14181693, 14181698, 14181762, - 14181792, 14182209, 14182468, 14182581, 14183420, 14183543, 14183809, 14183872, 14184752, 14184842, 14185023, 14185412, 14185453, - 14185501, 14185653, 14185710, 14185798, 14186682, 14186733, 14187745, 14187752, 14187757, 14187821, 14188264, 14188460, 14188465, - 14188729, 14188778, 14189095, 14189171, 14191103, 14191217, 14191927, 14192000, 14192052, 14192242, 14192398, 14192827, 14192854, - 14193065, 14193073, 14193103, 14193143, 14193158, 14193482, 14193580, 14194305, 14194319, 14194412, 14194419, 14194484, 14194546, - 14194595, 14199795, 14199935, 14199983, 14199986, 14200044, 14200084, 14200111, 14200139, 14200182, 14200190, 14204347, 14204418, - 14204510, 14204511, 14204779, 14204797, 14204839, 14205356, 14205469, 14205477, 14205495, 14206818, 14206853, 14207065, 14207638, - 14207651, 14207666, 14207674, 14207769, 14208925, 14208929, 14208933, 14209218, 14209304, 14209336, 14209575, 14209637, 14209654, - 14209658, 14209756, 14209776, 14209798, 14209927, 14210583, 14210845, 14211495, 14211541, 14211907, 14211929, 14212341, 14212472, - 14212477, 14212690, 14213033, 14213418, 14213497, 14213514, 14213530, 14213652, 14213946, 14213953, 14213972, 14214116, 14214142, - 14214143, 14214366, 14214977, 14214987, 14215167, 14215207, 14215399, 14215416, 14215450, 14215516, 14217199, 14217219, 14217260, - 14217509, 14218325, 14218896, 14218935, 14219106, 14219113, 14219114, 14219119, 14219130, 14219957, 14219958, 14220038, 14220087, - 14220173, 14220219, 14220804, 14221341, 14222488, 14222500, 14222878, 14222894, 14222935, 14223004, 14223669, 14223764, 14227432, - 14227444, 14227445, 14227450, 14227692, 14227697, 14228042, 14228163, 14228181, 14228408, 14228421, 14228485, 14228486, 14228491, - 14228508, 14228587, 14228717, 14228762, 14228769, 14228773, 14228791, 14228792, 14228804, 14228903, 14229010, 14229018, 14229159, - 14231125, 14231300, 14231443, 14231448, 14232109, 14232208, 14232209, 14232381, 14232406, 14232802, 14232810, 14232864, 14232909, - 14233312, 14233318, 14233470, 14233715, 14233727, 14233759, 14235991, 14236061, 14236156, 14236267, 14236301, 14236377, 14236429, - 14236512, 14236650, 14236713, 14236756, 14236769, 14236824, 14236825, 14237021, 14237138, 14237249, 14237357, 14237367, 14237368, - 14237405, 14237422, 14237465, 14237979, 14238006, 14238047, 14238053, 14238054, 14238064, 14238210, 14241229, 14242371, 14242374, - 14242376, 14242495, 14242761, 14242796, 14242807, 14242848, 14242857, 14242860, 14242895, 14242902, 14242903, 14243742, 14243745, - 14243747, 14243828, 14243830, 14243898, 14243995, 14244554, 14244572, 14244661, 14244663, 14245554, 14245560, 14245614, 14245629, - 14245794, 14246045, 14246318, 14246687, 14246846, 14247108, 14247338, 14247826, 14247928, 14247954, 14247963, 14247985, 14248202, - 14248403, 14248732, 14249055, 14249278, 14249875, 14250216, 14250927, 14250928, 14251116, 14251143, 14251320, 14251343, 14251406, - 14251457, 14251569, 14251635, 14251874, 14251884, 14251898, 14252039, 14252092, 14252144, 14252246, 14252318, 14252972, 14253022, - 14255299, 14255310, 14255475, 14255516, 14255543, 14255556, 14255822, 14255995, 14256057, 14256504, 14256561, 14256571, 14256620, - 14258923, 14258985, 14259150, 14259607, 14259661, 14260250, 14260264, 14261054, 14261145, 14261150, 14261244, 14261398, 14261838, - 14261932, 14261969, 14262054, 14262427, 14262460, 14262621, 14263627, 14263682, 14267276, 14267288, 14267519, 14267528, 14267529, - 14267548, 14267622, 14267663, 14268607, 14268629, 14268630, 14268672, 14268685, 14268744, 14268750, 14268751, 14268755, 14269086, - 14269140, 14269168, 14269178, 14269347, 14269356, 14269543, 14269547, 14269776, 14269820, 14270276, 14270280, 14270283, 14270286, - 14270294, 14270310, 14270354, 14270419, 14270466, 14270486, 14270530, 14270550, 14270654, 14270738, 14270744, 14270751, 14270757, - 14270778, 14270784, 14270811, 14270841, 14270889, 14270897, 14270940, 14270943, 14270967, 14270972, 14271360, 14271401, 14271992, - 14271999, 14272079, 14272130, 14272289, 14272325, 14272717, 14272750, 14274773, 14274777, 14274997, 14275001, 14275127, 14275130, - 14275146, 14275323, 14275353, 14275424, 14275668, 14276086, 14276123, 14276168, 14276309, 14276370, 14276458, 14276520, 14277427, - 14277434, 14277438, 14277439, 14277514, 14277581, 14277637, 14278054, 14278075, 14278093, 14278096, 14278100, 14278142, 14278209, - 14278267, 14278302, 14278331, 14278429, 14278440, 14278687, 14278756, 14278811, 14279537, 14279693, 14279798, 14280053, 14280185, - 14280204, 14280267, 14280452, 14280583, 14280616, 14280703, 14281278, 14281362, 14281532, 14281603, 14281860, 14281911, 14282559, - 14283530, 14283550, 14283560, 14283564, 14283579, 14283595, 14283598, 14283613, 14283697, 14283746, 14284070, 14284218, 14284578, - 14284847, 14286487, 14286490, 14286613, 14286765, 14287334, 14287353, 14287608, 14287664, 14287752, 14287787, 14287796, 14287799, - 14287800, 14287802, 14287945, 14288161, 14288307, 14288451, 14288502, 14288846, 14288983, 14289001, 14289005, 14289016, 14289060, - 14289723, 14290173, 14290424, 14290457, 14290459, 14290506, 14290571, 14290766, 14290801, 14290962, 14291669, 14291708, 14291718, - 14291815, 14292939, 14292956, 14293247, 14293268, 14293297, 14293393, 14293441, 14293602, 14293740, 14293803, 14294518, 14294563, - 14294601, 14294625, 14295118, 14295131, 14295183, 14295205, 14295233, 14295243, 14295256, 14295279, 14295325, 14295328, 14295332, - 14295394, 14295420, 14295683, 14295688, 14295809, 14296174, 14296471, 14296495, 14296520, 14296596, 14296598, 14296727, 14296803, - 14296887, 14296913, 14296925, 14297069, 14297070, 14297260, 14297371, 14297452, 14297529, 14297538, 14297676, 14297759, 14297807, - 14297822, 14298409, 14298639, 14298896, 14298903, 14298932, 14299363, 14299554, 14300286, 14300298, 14300301, 14300495, 14300640, - 14300659, 14301074, 14301263, 14301438, 14301472, 14301639, 14301663, 14301665, 14301705, 14301827, 14302166, 14302216, 14302438, - 14302631, 14302782, 14302982, 14303337, 14303485, 14303928, 14304191, 14304195, 14304374, 14304577, 14304591, 14304640, 14305416, - 14305568, 14305668, 14305702, 14305917, 14305920, 14306074, 14306134, 14306454, 14307152, 14307386, 14307402, 14307413, 14307462, - 14307466, 14307547, 14307632, 14307804, 14307929, 14308045, 14308232, 14308345, 14308437, 14308448, 14309558, 14309627, 14309634, - 14309679, 14309714, 14309805, 14309832, 14309939, 14310154, 14310541, 14310658, 14310887, 14310987, 14311341, 14312039, 14312218, - 14312227, 14312251, 14312317, 14312327, 14312447, 14312532, 14313179, 14313565, 14313860, 14313880, 14313896, 14313985, 14314069, - 14314262, 14314503, 14314504, 14315064, 14315149, 14315158, 14315195, 14315406, 14315429, 14315534, 14315796, 14316030, 14316190, - 14316259, 14316600, 14316647, 14316861, 14317147, 14317635, 14317647, 14317657, 14317734, 14317812, 14317833, 14317844, 14317921, - 14317930, 14317937, 14317942, 14317945, 14317982, 14317988, 14318921, 14318922, 14319270, 14319315, 14319942, 14320162, 14320227, - 14320284, 14320753, 14320763, 14322722, 14322745, 14322786, 14322880, 14322990, 14323725, 14323744, 14324520, 14324584, 14324706, - 14324707, 14328007, 14328024, 14331549, 14331550, 14331679, 14332651, 14332653, 14332760, 14332764, 14332800, 14332809, 14333294, - 14333328, 14333336, 14333346, 14333551, 14333562, 14334351, 14334509, 14334540, 14334564, 14337693, 14340622, 14342084, 14342092, - 14342313, 14342321, 14342457, 14342462, 14343083, 14343087, 14343141, 14343154, 14343161, 14343551, 14343566, 14343577, 14343609, - 14343647, 14343803, 14343938, 14343962, 14344087, 14344928, 14344933, 14345088, 14345153, 14345161, 14345601, 14345744, 14345777, - 14346561, 14346614, 14346765, 14346782, 14346783, 14347126, 14347150, 14347420, 14347452, 14347570, 14347598, 14347626, 14347635, - 14347637, 14347725, 14347781, 14348725, 14348905, 14349352, 14349447, 14351917, 14352564, 14352616, 14352773, 14352923, 14353039, - 14354130, 14354236, 14354276, 14354277, 14354290, 14354327, 14354329, 14354337, 14354362, 14354420, 14354429, 14354456, 14354679, - 14354688, 14354691, 14354801, 14354829, 14354874, 14354902, 14354918, 14355487, 14355501, 14355611, 14355907, 14356212, 14356334, - 14356358, 14356391, 14356876, 14357035, 14357313, 14357658, 14357681, 14357718, 14357730, 14357799, 14357850, 14357987, 14358091, - 14358190, 14358267, 14358722, 14359057, 14359213, 14359358, 14359371, 14359465, 14359589, 14359597, 14359648, 14359654, 14360676, - 14360709, 14360796, 14361052, 14361484, 14361538, 14361631, 14361731, 14362244, 14362395, 14362428, 14362460, 14362496, 14362567, - 14362798, 14362805, 14362808, 14363004, 14363041, 14363050, 14363058, 14363068, 14363172, 14363510, 14363570, 14363734, 14364469, - 14364510, 14364518, 14365738, 14365742, 14365752, 14365867, 14365890, 14366055, 14366116, 14366211, 14366224, 14366233, 14366246, - 14366288, 14366309, 14366329, 14366429, 14366430, 14366443, 14366448, 14366472, 14366539, 14366589, 14366750, 14366765, 14366794, - 14366934, 14367112, 14367251, 14367272, 14367282, 14367466, 14367467, 14367468, 14367469, 14367477, 14367496, 14367530, 14367687, - 14367800, 14367833, 14367960, 14368004, 14368015, 14368024, 14368061, 14368069, 14368160, 14368167, 14368170, 14368194, 14368302, - 14368786, 14368797, 14368798, 14368810, 14368823, 14370205, 14370209, 14370844, 14370852, 14371635, 14371854, 14372502, 14372811, - 14375059, 14375196, 14375337, 14375353, 14376850, 14377162, 14377188, 14378134, 14378139, 14378142, 14378262, 14378276, 14378281, - 14378284, 14378300, 14378310, 14378366, 14378380, 14378433, 14380203, 14380358, 14380376, 14380432, 14380454, 14380479, 14380500, - 14380502, 14380511, 14380523, 14380526, 14380576, 14381101, 14381108, 14381116, 14381149, 14381187, 14381336, 14381643, 14381650, - 14384971, 14385017, 14385299, 14385327, 14385345, 14385346, 14385398, 14385409, 14386643, 14386717, 14387783, 14387792, 14387814, - 14387938, 14388060, 14388082, 14388164, 14388173, 14388184, 14388185, 14388190, 14388205, 14388211, 14388234, 14388244, 14388337, - 14388466, 14389756, 14389760, 14391505, 14391529, 14392389, 14392425, 14392444, 14392452, 14392466, 14392654, 14393420, 14393502, - 14393594, 14393595, 14393599, 14393671, 14394385, 14395110, 14395112, 14395122, 14395139, 14395232, 14395237, 14395341, 14395364, - 14395414, 14395416, 14397686, 14397758, 14397792, 14397865, 14398937, 14398955, 14398982, 14399110, 14399114, 14399131, 14399141, - 14399198, 14399200, 14399218, 14399248, 14399251, 14399276, 14399914, 14399919, 14399960, 14399989, 14399992, 14400040, 14400043, - 14400048, 14400097, 14400128, 14400131, 14402470, 14402526, 14402741, 14402794, 14402800, 14402805, 14402891, 14402926, 14404738, - 14404762, 14404988, 14405199, 14405204, 14405237, 14405348, 14406107, 14406164, 14406177, 14406665, 14406666, 14406887, 14406900, - 14406901, 14406982, 14406984, 14407108, 14407204, 14407309, 14407326, 14408372, 14408387, 14408522, 14408523, 14408534, 14408798, - 14408824, 14408858, 14410649, 14410860, 14410915, 14410986, 14411113, 14411190, 14411745, 14411764, 14412210, 14412275, 14412297, - 14412428, 14412434, 14412741, 14412857, 14412866, 14412869, 14413198, 14413199, 14413906, 14413934, 14414045, 14414168, 14414430, - 14414443, 14414710, 14415221, 14415252, 14415388, 14415429, 14415469, 14415513, 14415554, 14415608, 14415656, 14415660, 14415666, - 14415927, 14415975, 14416165, 14417518, 14418203, 14418277, 14418301, 14418317, 14418392, 14418533, 14418543, 14418546, 14419038, - 14419373, 14419466, 14419469, 14419481, 14419488, 14419499, 14419512, 14419521, 14419616, 14419697, 14419698, 14419805, 14419900, - 14419928, 14419929, 14419941, 14419942, 14419962, 14420023, 14420069, 14420082, 14420084, 14420086, 14420091, 14420094, 14420112, - 14420116, 14420129, 14420131, 14420180, 14420183, 14420193, 14420247, 14420253, 14420256, 14420275, 14420293, 14420303, 14420341, - 14420348, 14420480, 14420699, 14420814, 14420849, 14420851, 14420971, 14421014, 14421036, 14421045, 14421046, 14421169, 14421176, - 14421440, 14421858, 14421886, 14421920, 14422148, 14422321, 14422453, 14422593, 14422767, 14422856, 14423018, 14423133, 14423196, - 14423206, 14423268, 14423271, 14423515, 14423532, 14423583, 14423860, 14423881, 14423932, 14424014, 14424043, 14424067, 14424296, - 14424429, 14424452, 14424558, 14424562, 14424571, 14424585, 14424586, 14424589, 14424636, 14424685, 14424736, 14424750, 14424769, - 14425463, 14425546, 14425574, 14425575, 14425633, 14425767, 14425781, 14425849, 14425993, 14426028, 14426072, 14426221, 14426583, - 14427051, 14427197, 14427202, 14427208, 14427399, 14427441, 14427452, 14427473, 14427870, 14428817, 14428898, 14428920, 14429168, - 14429174, 14429180, 14429324, 14430071, 14430108, 14430138, 14430143, 14430231, 14430255, 14430816, 14430855, 14430886, 14430899, - 14430901, 14430902, 14430905, 14430924, 14430965, 14431006, 14431063, 14431282, 14431502, 14431545, 14431559, 14431720, 14431721, - 14432038, 14432172, 14432192, 14432201, 14432626, 14432636, 14432638, 14433023, 14433345, 14433362, 14433891, 14433944, 14434390, - 14434409, 14434414, 14434471, 14434649, 14436439, 14436511, 14436521, 14436616, 14436975, 14437026, 14437134, 14437167, 14437191, - 14437201, 14437204, 14437205, 14437268, 14437527, 14437534, 14437547, 14437565, 14437613, 14437807, 14437820, 14438118, 14438156, - 14438160, 14438162, 14438168, 14438215, 14438333, 14438365, 14438531, 14438538, 14438956, 14439014, 14439085, 14439105, 14439107, - 14439173, 14439501, 14439515, 14439776, 14439868, 14440295, 14440312, 14440363, 14440392, 14440418, 14440420, 14440431, 14440986, - 14440993, 14441010, 14441090, 14441114, 14441175, 14441182, 14441421, 14441424, 14441436, 14441455, 14442331, 14442410, 14442412, - 14442499, 14442590, 14443032, 14443124, 14443702, 14443783, 14443785, 14443880, 14443986, 14443987, 14443996, 14444016, 14444291, - 14444335, 14444348, 14444958, 14445106, 14445730, 14445744, 14445796, 14445857, 14445956, 14445960, 14449012, 14449107, 14449279, - 14449287, 14450086, 14450107, 14450169, 14450196, 14451369, 14451491, 14451664, 14451679, 14452080, 14452088, 14452158, 14452281, - 14452377, 14452464, 14454060, 14454100, 14454259, 14454284, 14455932, 14455937, 14456161, 14456169, 14456173, 14456215, 14456220, - 14456251, 14456262, 14456272, 14456374, 14456386, 14456389, 14456408, 14456422, 14456596, 14456654, 14456697, 14456714, 14457226, - 14457236, 14457251, 14457272, 14457294, 14457295, 14457323, 14457332, 14457341, 14457872, 14457925, 14458268, 14458361, 14462180, - 14462204, 14462241, 14462308, 14464172, 14464255, 14466306, 14466331, 14466411, 14466425, 14466470, 14466488, 14466497, 14466523, - 14466972, 14466984, 14467004, 14467023, 14468341, 14468496, 14469581, 14469604, 14469619, 14469675, 14470339, 14470341, 14470456, - 14470514, 14470520, 14470622, 14470887, 14470888, 14471412, 14471417, 14471591, 14471594, 14473086, 14473092, 14473096, 14473097, - 14473637, 14473642, 14475479, 14475496, 14475695, 14475733, 14476630, 14476676, 14476712, 14476812, 14477122, 14477145, 14477588, - 14477589, 14477594, 14477605, 14477607, 14477633, 14477742, 14477772, 14477777, 14478030, 14478043, 14478624, 14478666, 14479141, - 14479784, 14479865, 14479943, 14479950, 14479961, 14481636, 14481637, 14481722, 14481726, 14481758, 14481986, 14481997, 14482096, - 14482102, 14482118, 14482138, 14482420, 14482427, 14482457, 14482487, 14482508, 14482687, 14482693, 14482834, 14482845, 14483435, - 14483438, 14483442, 14483453, 14483471, 14483605, 14483834, 14483839, 14484322, 14484339, 14484341, 14484392, 14484412, 14484498, - 14484698, 14484752, 14484755, 14488867, 14488878, 14488894, 14488896, 14489287, 14489291, 14489510, 14489549, 14490029, 14490073, - 14490084, 14490085, 14490086, 14490088, 14490123, 14490128, 14490190, 14490213, 14490644, 14490652, 14490708, 14490728, 14490903, - 14490908, 14491415, 14491754, 14491757, 14491758, 14491805, 14492838, 14493628, 14494367, 14494372, 14494373, 14494376, 14494379, - 14494381, 14494646, 14494656, 14494661, 14494752, 14494868, 14494907, 14494921, 14494941, 14494953, 14494954, 14495034, 14495065, - 14495075, 14495076, 14495135, 14495154, 14495165, 14495173, 14495188, 14495192, 14495488, 14495493, 14495495, 14495501, 14495644, - 14495687, 14495688, 14495840, 14495967, 14495968, 14496394, 14496406, 14496408, 14496432, 14496500, 14496551, 14496604, 14496966, - 14497034, 14497038, 14497550, 14497568, 14497570, 14497668, 14497702, 14497706, 14497708, 14497820, 14497848, 14497895, 14497913, - 14497935, 14497937, 14498323, 14498354, 14498355, 14501002, 14501005, 14501526, 14502186, 14502208, 14502215, 14502229, 14502284, - 14502295, 14502315, 14502353, 14502605, 14502627, 14502635, 14502663, 14502758, 14502769, 14503020, 14503058, 14503061, 14503068, - 14503086, 14503134, 14503288, 14503395, 14503429, 14503435, 14503522, 14503525, 14504153, 14504162, 14504169, 14504173, 14504371, - 14504422, 14504432, 14504442, 14507145, 14507147, 14507476, 14507486, 14507489, 14507515, 14507520, 14507570, 14507702, 14507732, - 14508208, 14508212, 14509089, 14509103, 14509612, 14509623, 14511370, 14511373, 14511378, 14511379, 14511768, 14511773, 14512246, - 14512248, 14514087, 14514094, 14514100, 14514117, 14514130, 14514133, 14514156, 14514162, 14514508, 14514588, 14514908, 14514918, - 14514964, 14514971, 14514989, 14515007, 14515063, 14515165, 14515419, 14515421, 14515591, 14515593, 14515714, 14515716, 14515719, - 14515720, 14515748, 14515749, 14515854, 14515860, 14515903, 14515904, 14515951, 14515955, 14515993, 14515997, 14516253, 14516270, - 14516372, 14516412, 14516497, 14516503, 14517397, 14517439, 14519618, 14519619, 14519694, 14519701, 14519702, 14519714, 14519776, - 14519782, 14519803, 14519804, 14519955, 14519996, 14520020, 14520024, 14520043, 14520060, 14520061, 14520062, 14520115, 14520126, - 14520159, 14520172, 14520186, 14520190, 14520198, 14520212, 14520222, 14520227, 14520235, 14520497, 14520498, 14520746, 14520774, - 14520977, 14520982, 14520986, 14521011, 14521066, 14521069, 14522110, 14522112, 14522118, 14522165, 14522218, 14522219, 14522733, - 14522797, 14523118, 14523126, 14523830, 14523835, 14524242, 14524243, 14524259, 14524266, 14526070, 14526077, 14526083, 14526086, - 14526087, 14526099, 14526120, 14526126, 14526141, 14526211, 14526215, 14526221, 14526244, 14526255, 14526300, 14526321, 14526332, - 14526340, 14526344, 14526346, 14526356, 14526363, 14526380, 14526442, 14526463, 14527065, 14527080, 14527084, 14527176, 14527178, - 14527369, 14527370, 14527424, 14527431, 14527447, 14527451, 14527599, 14527626, 14527627, 14527633, 14527696, 14527715, 14527723, - 14527735, 14527839, 14528084, 14528085, 14528093, 14528124, 14528171, 14528614, 14528712, 14528723, 14528757, 14528758, 14528864, - 14528925, 14528961, 14528969, 14528986, 14528993, 14528997, 14529009, 14529012, 14529017, 14529021, 14529024, 14529026, 14529029, - 14529033, 14529037, 14529046, 14529100, 14529124, 14529557, 14530096, 14530149, 14531104, 14531141, 14531213, 14531235, 14531744, - 14531775, 14531956, 14531968, 14531999, 14532026, 14532066, 14532097, 14532696, 14532706, 14532729, 14532730, 14532739, 14532749, - 14532758, 14532838, 14532843, 14533032, 14533035, 14533049, 14533066, 14533070, 14533079, 14533136, 14533141, 14533267, 14533299, - 14533319, 14533321, 14533346, 14533372, 14533410, 14533430, 14533442, 14533526, 14533548, 14533722, 14533805, 14533836, 14533847, - 14533860, 14533861, 14533873, 14533878, 14533920, 14534184, 14534185, 14534191, 14534193, 14534233, 14534256, 14534343, 14534366, - 14534397, 14534426, 14535016, 14535017, 14535020, 14535028, 14535045, 14535083, 14535119, 14535180, 14535199, 14535394, 14535426, - 14535428, 14535456, 14535475, 14535634, 14535662, 14535688, 14535691, 14535692, 14535702, 14536479, 14536480, 14536489, 14536490, - 14536492, 14536493, 14538931, 14538950, 14539037, 14539038, 14539216, 14539309, 14539334, 14539344, 14539390, 14539420, 14539473, - 14539534, 14539537, 14539564, 14540149, 14540166, 14540656, 14540667, 14540769, 14540796, 14541039, 14541063, 14541069, 14541071, - 14541159, 14541165, 14541181, 14541201, 14541315, 14541323, 14541325, 14541328, 14541535, 14542840, 14542888, 14542906, 14542907, - 14543190, 14543248, 14543853, 14543908, 14544590, 14544596, 14544603, 14544616, 14544670, 14544671, 14544700, 14544710, 14544746, - 14544754, 14544827, 14544828, 14544837, 14544856, 14544877, 14544962, 14545025, 14545172, 14545204, 14545224, 14545226, 14545234, - 14545464, 14545483, 14545723, 14545743, 14545958, 14545994, 14546116, 14546131, 14546151, 14546163, 14546371, 14546380, 14546408, - 14546419, 14546448, 14546450, 14546509, 14546553, 14546560, 14546608, 14546630, 14546636, 14546678, 14546684, 14546867, 14546869, - 14547247, 14547249, 14547565, 14547577, 14547724, 14547850, 14547854, 14547861, 14547962, 14548000, 14550132, 14550221, 14552498, - 14552506, 14552667, 14552671, 14552813, 14552828, 14553470, 14553472, 14553476, 14554183, 14554188, 14554192, 14554225, 14554740, - 14554785, 14555988, 14556013, 14556021, 14556022, 14556083, 14556084, 14556089, 14556092, 14556100, 14556103, 14556108, 14556140, - 14556651, 14558534, 14559061, 14559072, 14559085, 14559733, 14559791, 14560016, 14560026, 14560028, 14560038, 14560040, 14560076, - 14560273, 14560275, 14560303, 14560306, 14560310, 14560322, 14560576, 14560577, 14560582, 14560595, 14560608, 14560622, 14560728, - 14560734, 14561795, 14561825, 14561840, 14562587, 14562623, 14562630, 14562645, 14563527, 14563541, 14563542, 14563549, 14563729, - 14563739, 14563740, 14563748, 14563749, 14563755, 14563766, 14563768, 14563774, 14563775, 14563894, 14563959, 14563963, 14563967, - 14564050, 14564054, 14564058, 14564075, 14564164, 14564730, 14564733, 14565457, 14565462, 14565943, 14566817, 14566822, 14588081, - 15278993, 15298860, 15299275, 15299420, 15299520, 15299715, 15299731, 15299757, 15301708, 15301850, 15301875, 15302455, 15302967, - 15304019, 15305121, 15305561, 15307407, 15307490, 15307868, 15308032, 15311107, 15311210, 15311599, 15316343, 15316528, 15316535, - 15317411, 15318069, 15318235, 15318288, 15318437, 15318758, 15319019, 15319366, 15319403, 15320313, 15321005, 15321511, 15321634, - 15321707, 15321890, 15322055, 15322136, 15323088, 15323182, 15323543, 15324636, 15327600, 15328789, 15328903, 15328961, 15329151, - 15330358, 15330441, 15330468, 15331215, 15331280, 15333764, 15333830, 15335397, 15336059, 15337247, 15337395, 15337630, 15339099, - 15340038, 15340971, 15341319, 15341479, 15341544, 15342783, 15343155, 15343302, 15343551, 15343809, 15344150, 15344169, 15344370, - 15344584, 15346218, 15346421, 15346604, 15346684, 15346714, 15346716, 15350123, 15350143, 15350966, 15351041, 15351346, 15351348, - 15352316, 15352341, 15353576, 15353802, 15354436, 15354503, 15354708, 15354744, 15355751, 15355938, 15356263, 15356464, 15357773, - 15357806, 15357836, 15357870, 15359242, 15359261, 15359409, 15359557, 15359701, 15359731, 15359846, 15359932, 15360348, 15360351, - 15360966, 15360968, 15360998, 15361018, 15363267, 15363312, 15363413, 15363420, 15363920, 15364070, 15364136, 15364150, 15364663, - 15364715, 15367310, 15367326, 15368095, 15368104, 15368537, 15368541, 15368874, 15368881, 15369797, 15369898, 15370883, 15370885, - 15371463, 15371516, 15372941, 15373029, 15373035, 15373039, 15373489, 15373548, 15374297, 15374326, 15374448, 15374596, 15375231, - 15375318, 15375776, 15375803, 15376049, 15376057, 15377278, 15377371, 15378036, 15378043, 15378052, 15378059, 15378164, 15378166, - 15379378, 15379430, 15379848, 15379863, 15379880, 15379890, 15381333, 15381472, 15381587, 15381594, 15382319, 15382335, 15382622, - 15382689, 15384884, 15384889, 15386453, 15386482, 15386506, 15386762, 15386943, 15387036, 15387461, 15387465, 15387752, 15387804, - 15388394, 15388486, 15388606, 15388617, 15389904, 15390109, 15390434, 15390437, 15390816, 15390866, 15393023, 15393050, 15393079, - 15393299, 15393785, 15393789, 15394171, 15394184, 15394223, 15394363, 15397304, 15397311, 15397367, 15397572, 15398540, 15398542, - 15398966, 15398984, 15400273, 15400276, 15400610, 15400638, 15401565, 15401650, 15404521, 15404620, 15406007, 15406017, 15406624, - 15406687, 15407958, 15407964, 15408278, 15408287, 15410615, 15410769, 15411104, 15411119, 15411326, 15411591, 15411833, 15411836, - 15413038, 15413046, 15413111, 15413148, 15413371, 15413374, 15413483, 15413499, 15415282, 15415416, 15417725, 15417802, 15417896, - 15417906, 15419558, 15419604, 15419797, 15419800, 15419980, 15420000, 15420016, 15420019, 15421514, 15421544, 15423424, 15423558, - 15423661, 15423673, 15424869, 15424873, 15425240, 15425382, 15425895, 15425897, 15426289, 15426372, 15427195, 15427225, 15427230, - 15427233, 15427289, 15427298, 15427993, 15427999, 15428176, 15428217, 15428227, 15428516, 15428529, 15428567, 15428784, 15429008, - 15429020, 15429026, 15429032, 15429281, 15430344, 15430346, 15430706, 15430735, 15430879, 15430885, 15431260, 15431365, 15432397, - 15432422, 15432649, 15432654, 15432804, 15432819, 15433923, 15433932, 15435272, 15435298, 15437041, 15437050, 15438105, 15438114, - 15440121, 15440253, 15441104, 15441282, 15442199, 15442584, 15443871, 15444142, 15444188, 15444408, 15444685, 15444690, 15445733, - 15445736, 15445863, 15445878, 15447031, 15447065, 15448796, 15448816, 15449403, 15449413, 15449587, 15449609, 15449711, 15449878, - 15449962, 15449964, 15450263, 15450405, 15450446, 15450450, 15451400, 15451408, 15451819, 15451857, 15452179, 15452192, 15452979, - 15453020, 15453357, 15453514, 15455431, 15455434, 15455761, 15455880, 15456762, 15456784, 15457983, 15459043, 15459439, 15459567, - 15459814, 15459822, 15460508, 15460591, 15461069, 15461082, 15462424, 15462426, 15462594, 15462656, 15462690, 15462696, 15463436, - 15463936, 15464266, 15465784, 15465839, 15465937, 15466610, 15466631, 15467021, 15467085, 15467103, 15467109, 15467756, 15467851, - 15468430, 15468503, 15468511, 15468652, 15469184, 15469200, 15469285, 15469458, 15469754, 15469759, 15470276, 15470283, 15470370, - 15470392, 15471545, 15471785, 15473261, 15473269, 15473454, 15473460, 15474422, 15474425, 15474922, 15475151, 15475640, 15475643, - 15476163, 15476405, 15476427, 15476439, 15477009, 15477179, 15477640, 15477649, 15479093, 15479107, 15480142, 15480151, 15480580, - 15480814, 15481022, 15481026, 15481035, 15481037, 15481562, 15481565, 15481590, 15481591, 15481741, 15481744, 15482067, 15482078, - 15482616, 15482683, 15486561, 15486564, 15486616, 15486617, 15486666, 15486668, 15486678, 15486680, 15487459, 15487500, 15488119, - 15488127, 15488401, 15488409, 15488440, 15488442, 15488965, 15488970, 15489694, 15489700, 15490595, 15490615, 15491720, 15491760, - 15492016, 15492020, 15492072, 15492087, 15492855, 15492857, 15493002, 15493004, 15493071, 15493074, 15493106, 15493108, 15493360, - 15493365, 15494319, 15494332, 15496258, 15496263, 15497235, 15497254, 15497321, 15497338, 15498352, 15498354, 15499365, 15499369, - 15501348, 15501354, 15502470, 15502478, 15503665, 15503673, 15504523, 15504537, 15504621, 15504628, 15504938, 15505080, 15506069, - 15506072, 15506112, 15506113, 15506426, 15506436, 15507433, 15507435, 15508130, 15508192, 15508250, 15508358, 15510418, 15510430, - 15510706, 15510712, 15511523, 15511526, 15511628, 15511629, 15512065, 15512071, 15512120, 15512121, 15513126, 15513199, 15513214, - 15513441, 15514260, 15514460, 15515518, 15515520, 15515699, 15515701, 15516480, 15516482, 15517627, 15517654, 15518075, 15518102, - 15519576, 15519578, 15520859, 15520864, 15521342, 15521351, 15521537, 15521553, 15521701, 15521707, 15522808, 15523015, 15523483, - 15523488, 15524388, 15524397, 15524703, 15524713, 15525341, 15525343, 15525349, 15525353, 15526412, 15526559, 15527127, 15527133, - 15527672, 15527675, 15528231, 15528248, 15528274, 15528307, 15529512, 15529522, 15529961, 15530071, 15530915, 15530926, 15531367, - 15531370, 15533472, 15533487, 15534560, 15534786, 15535306, 15535318, 15535392, 15535522, 15538116, 15539371, 15540337, 15540602, - 15541064, 15541071, 15541659, 15541666, 15541681, 15541719, 15541771, 15541777, 15542276, 15542282, 15542576, 15542585, 15542589, - 15542594, 15542886, 15542896, 15543880, 15543976, 15544196, 15546926, 15547006, 15547018, 15547117, 15547119, 15547436, 15547520, - 15547554, 15547587, 15547642, 15547644, 15549036, 15549039, 15549429, 15549448, 15550823, 15550828, 15551147, 15551381, 15551716, - 15551720, 15552150, 15552267, 15554087, 15554090, 15554449, 15554456, 15555207, 15555210, 15556032, 15556037, 15556177, 15556184, - 15557755, 15557761, 15558433, 15558443, 15559082, 15559107, 15560806, 15560890, 15561941, 15562075, 15562258, 15562260, 15563500, - 15563507, 15563620, 15563624, 15565974, 15565985, 15566159, 15566161, 15566675, 15567720, 15567772, 15697646, 15698252, 15699048, - 15699049, 15699308, 15699355, 15701033, 15701037, 15701139, 15701868, 15722361, 15723839, 15725644, 15726602, 15726621, 15726727, - 15726730, 15728420, 15728425, 15729973, 15729986, 15731110, 15731125, 15732349, 15732819, 15733345, 15733382, 15736966, 15741478, - 15742747, 15743712, 15744541, 15746902, 15748357, 15751438, 15751801, 15754322, 15755697, 15768595, 15768635, 15768636, 15771170, - 15771235, 15771418, 15771566, 15772511, 15772514, 15773217, 15773287, 15773693, 15775062, 15775162, 15775170, 15775628, 15775748, - 15777966, 15778518, 15780571, 15780590, 15781334, 15781414, 15783805, 15784103, 15784218, 15784222, 15784336, 15786288, 15786350, - 15786412, 15786880, 15787424, 15791418, 15791577, 15791945, 15792759, 15792904, 15792905, 15793375, 15799982, 15800147, 15800148, - 15800738, 15800739, 15801497, 15801498, 15803568, 15803571, 15805641, 15808771, 15809000, 15815539, 15815540, 15815571, 15816365, - 15816366, 15820482, 15820483, 15820930, 15820933, 15822783, 15822784, 15823306, 15823308, 15823485, 15823486, 15827101, 15827102, - 15830019, 15830020, 15830105, 15830106, 15835137, 15835138, 15838243, 15839723, 15840576, 15841503, 15841688, 15841690, 15847048, - 15847050, 15847745, 15848829, 15850375, 15855827, 15859288, 15859289, 15860023, 15860373, 15860606, 15860607, 15860828, 15860829, - 15861647, 15861648, 15861982, 15861983, 15863539, 15865475, 15865811, 15865812, 15865814, 15865819, 15865939, 15865940, 15866722, - 15866723, 15867794, 15869548, 15870297, 15870823, 15870956, 15870957, 15871190, 15871197, 15871254, 15871766, 15872132, 15873270, - 15875334, 15875634, 15875797, 15876025, 15876802, 15876803, 15876808, 15876810, 15876831, 15876833, 15876844, 15876845, 15876858, - 15876859, 15876865, 15876866, 15876996, 15877054, 15877147, 15878253, 15878396, 15878397, 15878409, 15878410, 15880251, 15880252, - 15880976, 15883223, 15883257, 15883258, 15883267, 15883268, 15883338, 15883366, 15883572, 15883573, 15883704, 15883705, 15883815, - 15883866, 15884708, 15885134, 15886585, 15886948, 15889015, 15889135, 15889263, 15889264, 15889297, 15890107, 15890836, 15890856, - 15891258, 15891259, 15891595, 15891596, 15898995, 15899413, 15900484, 15900485, 15900856, 15900857, 15900999, 15901784, 15902052, - 15902074, 15903287, 15904479, 15904560, 15904561, 15904756, 15904948, 15905428, 15905429, 15908728, 15908729, 15908732, 15908733, - 15908737, 15908739, 15911168, 15911169, 15911465, 15911466, 15912295, 15912378, 15912429, 15912435, 15912645, 15913367, 15915228, - 15915229, 15915232, 15915233, 15915473, 15915474, 15915509, 15915510, 15915885, 15915886, 15916207, 15916208, 15916906, 15916907, - 15917200, 15917202, 15917206, 15917207, 15921490, 15921491, 15921519, 15922789, 15923115, 15923117, 15924339, 15924525, 15924533, - 15926434, 15927196, 15928263, 15929673, 15929674, 15929698, 15929766, 15930272, 15941143, 15941944, 15941945, 15941949, 15941950, - 15941954, 15941955, 15941966, 15941967, 15942041, 15942242, 15943918, 15944225, 15944958, 15948423, 15948742, 15948893, 15948934, - 15948935, 15948952, 15948953, 15948974, 15948975, 15948980, 15948981, 15948984, 15948985, 15948995, 15948996, 15949061, 15949062, - 15950050, 15950051, 15950637, 15950638, 15950642, 15950643, 15950646, 15950647, 15950650, 15950651, 15950666, 15950667, 15950686, - 15950687, 15951694, 15951695, 15951941, 15951942, 15951970, 15951971, 15951974, 15951975, 15951978, 15951979, 15952040, 15954672, - 15956700, 15956815, 15957170, 15957963, 15965549, 15968309, 15969082, 15969120, 15970110, 15970111, 15970828, 15970854, 15971891, - 15971916, 15971980, 15972006, 15973526, 15973527, 15973835, 15974371, 15976265, 15977379, 15978362, 15978948, 15979197, 15980087, - 15980290, 15980299, 15981105, 15981106, 15981914, 15981915, 15982995, 15985005, 15985847, 15986020, 15986468, 15990277, 15990962, - 15991688, 15992374, 15992627, 15992966, 15994933, 15995140, 15995217, 15998964, 16006307, 16010481, 16011214, 16012893, 16013844, - 16015906, 17636688, 17637873, 17638275, 17638348, 17638487, 17638892, 17664726, 17667175, 17673330, 17673544, 17673816, 17681905, - 17685084, 17685085, 17687705, 17691885, 17692405, 17693311, 17694199, 17698519, 17699421, 17699575, 17699776, 17704976, 17705868, - 17707335, 17707490, 17710949, 17711356, 17711906, 17712444, 17720306, 17720567, 17723439, 17723538, 17729149, 17729172, 17730669, - 17735353, 17738506, 17739593, 17742978, 17746144, 17752865, 17759547, 17770240, 17774229, 17774250, 17778606, 17779105, 17782179, - 17783310, 17783420, 17784087, 17791119, 17792330, 17793195, 17795208, 17796208, 17798702, 17803925, 17806758, 17808553, 17811929, - 17815836, 17818217, 17853647, 17855162, 17855180, 17874661, 17881967, 17886031, 17886472, 17886499, 17892400, 17892586, 17893593, - 17918105, 17920208, 17923983, 17932312, 17940478, 17949572, 17950256, 17978577, 17978638, 17979243, 17981913, 17981914, 17986345, - 17995612, 17998455, 18001936, 18018601, 18019359, 18020832, 18020852, 18020857, 18021161, 18024791, 18028665, 18028982, 18029024, - 18029065, 18029402, 18029410, 18029412, 18029430, 18029461, 18029535, 18029709, 18029941, 18030109, 18030158, 18030174, 18030618, - 18030897, 18031010, 18031050, 18031102, 18031119, 18033407, 18033471, 18033519, 18034800, 18035522, 18035524, 18035558, 18035587, - 18035592, 18035611, 18035718, 18036283, 18037159, 18037177, 18037518, 18037756, 18037831, 18038107, 18038314, 18040137, 18040830, - 18042044, 18042107, 18042113, 18042989, 18044136, 18044214, 18045284, 18046457, 18046504, 18046619, 18046757, 18047186, 18047597, - 18047661, 18047776, 18047878, 18047880, 18048688, 18049264, 18050153, 18050586, 18050926, 18051022, 18052532, 18052575, 18052827, - 18053165, 18053676, 18053753, 18054135, 18055170, 18056994, 18057401, 18057693, 18057697, 18058403, 18058457, 18058779, 18058896, - 18059950, 18059951, 18061046, 18061130, 18061163, 18061330, 18062045, 18062047, 18062332, 18063045, 18063475, 18063531, 18063738, - 18064294, 18065075, 18065242, 18065980, 18066212, 18066443, 18066962, 18067060, 18067533, 18067720, 18067880, 18067908, 18067926, - 18069030, 18069287, 18069478, 18069486, 18070682, 18070696, 18070945, 18070960, 18071100, 18071247, 18071778, 18071877, 18071965, - 18072000, 18072080, 18072170, 18072197, 18072238, 18072391, 18072987, 18073243, 18074765, 18075302, 18075625, 18075780, 18075781, - 18075911, 18075915, 18075944, 18075961, 18078850, 18079649, 18082360, 18084867, 18084911, 18085324, 18085709, 18087962, 18087963, - 18088191, 18088242, 18088250, 18088280, 18088356, 18088559, 18088585, 18088685, 18088801, 18089141, 18089688, 18089823, 18090573, - 18092942, 18093321, 18093525, 18093792, 18094278, 18094280, 18094353, 18094818, 18095086, 18096830, 18096870, 18096945, 18099264, - 18099563, 18103567, 18105534, 18105712, 18105730, 18106676, 18106758, 18107898, 18108072, 18108109, 18108251, 18108364, 18108366, - 18108385, 18108608, 18109192, 18109630, 18109736, 18109886, 18110216, 18111914, 18117472, 18120015, 18121451, 18121461, 18123475, - 18126178, 18127068, 18127313, 18128050, 18128330, 18128335, 18128741, 18129173, 18129186, 18129274, 18129299, 18129598, 18129647, - 18130999, 18131052, 18132357, 18132384, 18132993, 18133129, 18133459, 18134121, 18134494, 18134563, 18134668, 18134725, 18135378, - 18135538, 18135637, 18136098, 18136421, 18136723, 18136850, 18138655, 18138798, 18139149, 18139266, 18139885, 18144618, 18145061, - 18145076, 18145167, 18145171, 18145489, 18145498, 18151530, 18154233, 18157193, 18157230, 18157352, 18157653, 18158227, 18159887, - 18160433, 18160599, 18163130, 18167158, 18167584, 18167696, 18168147, 18168194, 18169252, 18169257, 18169269, 18171907, 18171970, - 18173270, 18173746, 18173941, 18173950, 18174259, 18174963, 18176304, 18176339, 18176342, 18177237, 18177283, 18177395, 18177473, - 18177557, 18177648, 18178048, 18178068, 18179144, 18179923, 18180023, 18180031, 18182471, 18182554, 18183350, 18185302, 18186630, - 18189759, 18191550, 18191572, 18191690, 18191760, 18209428, 18209658, 18210069, 18210134, 18211447, 18211680, 18213658, 18214305, - 18226915, 18227231, 18233695, 18234036, 18234679, 18237160, 18237345, 18237354, 18237447, 18238159, 18238169, 18238305, 18238306, - 18238341, 18239452, 18239552, 18239591, 18242107, 18243775, 18247187, 18248062, 18248090, 18248152, 18248702, 18248948, 18251287, - 18253159, 18253172, 18253256, 18253494, 18253674, 18253702, 18253731, 18253737, 18254465, 18254579, 18254961, 18255157, 18255423, - 18255953, 18255964, 18255975, 18256059, 18256119, 18256175, 18256361, 18258481, 18258531, 18258617, 18258894, 18258898, 18258975, - 18259049, 18259278, 18259287, 18259310, 18260016, 18261458, 18261488, 18261623, 18262488, 18262528, 18262642, 18262749, 18262798, - 18262808, 18262813, 18262819, 18262827, 18262860, 18263274, 18265073, 18265373, 18274127, 18274713, 18274727, 18275088, 18275112, - 18275130, 18278505, 18278955, 18279067, 18279081, 18282620, 18282661, 18283406, 18283563, 18283848, 18284148, 18284248, 18284447, - 18284548, 18285101, 18285102, 18285296, 18285465, 18285587, 18286538, 18286732, 18286922, 18287028, 18287423, 18287435, 18288316, - 18288614, 18288684, 18289315, 18289388, 18289811, 18290157, 18291493, 18291622, 18291700, 18291765, 18292103, 18292104, 18292192, - 18292266, 18293383, 18293550, 18293680, 18293751, 18293811, 18294213, 18294759, 18299826, 18299990, 18300398, 18301246, 18301327, - 18303702, 18303813, 18304121, 18306402, 18306490, 18306738, 18307134, 18307258, 18307380, 18307382, 18307680, 18308694, 18308707, - 18308744, 18308789, 18308936, 18309470, 18309756, 18310124, 18310324, 18310679, 18313272, 18313276, 18313936, 18313942, 18314463, - 18314471, 18314489, 18314786, 18314944, 18314957, 18315430, 18315905, 18315975, 18316319, 18316622, 18316913, 18317424, 18317507, - 18317562, 18317614, 18318101, 18318833, 18319890, 18320642, 18320688, 18322258, 18322526, 18322711, 18323528, 18323546, 18324258, - 18326071, 18328517, 18329261, 18333428, 18334440, 18334468, 18340005, 18340701, 18341515, 18342104, 18343985, 18344306, 18344387, - 18344445, 18349782, 18354524, 18354532, 18354567, 18354647, 18355784, 18355800, 18355890, 18356093, 18356174, 18357105, 18358907, - 18359179, 18360540, 18360761, 18361109, 18362474, 18362701, 18363071, 18363333, 18363353, 18363359, 18363669, 18363849, 18364852, - 18365537, 18365642, 18370037, 18374101, 18374518, 18374703, 18378858, 18378979, 18379121, 18388650, 18392831, 18392906, 18393035, - 18393498, 18395705, 18396655, 18396696, 18399717, 18399721, 18399791, 18399885, 18400237, 18400318, 18401555, 18403896, 18403898, - 18403948, 18403950, 18404071, 18404074, 18404115, 18404117, 18404169, 18404170, 18404177, 18404214, 18408893, 18409021, 18409026, - 18409046, 18409296, 18409304, 18409332, 18409338, 18409342, 18409356, 18409383, 18409396, 18409511, 18409551, 18409567, 18409579, - 18409581, 18409638, 18409642, 18409660, 18409669, 18409705, 18409710, 18409737, 18410309, 18410336, 18410366, 18410382, 18410392, - 18410418, 18410426, 18410429, 18410929, 18410976, 18411158, 18414923, 18414966, 18414967, 18414971, 18414973, 18414996, 18415012, - 18415335, 18415343, 18415344, 18415372, 18415383, 18415401, 18415404, 18415409, 18415410, 18415439, 18415463, 18415730, 18415734, - 18415751, 18415752, 18415755, 18415762, 18415770, 18415789, 18415907, 18415911, 18415914, 18415915, 18415918, 18415919, 18415924, - 18415934, 18415935, 18415948, 18415951, 18415960, 18415962, 18415969, 18415974, 18415988, 18415996, 18416003, 18416007, 18416096, - 18416097, 18416098, 18416099, 18416110, 18416111, 18416121, 18417000, 18417004, 18417110, 18417111, 18417153, 18417223, 18417250, - 18417254, 18417255, 18417271, 18417276, 18417298, 18417306, 18418074, 18418081, 18419778, 18419803, 18419847, 18419867, 18419982, - 18420104, 18420138, 18420139, 18420149, 18420289, 18420295, 18421340, 18421341, 18421351, 18421354, 18421396, 18422027, 18422036, - 18422039, 18422146, 18422232, 18422238, 18422335, 18422473, 18422479, 18422569, 18422577, 18422932, 18423232, 18423233, 18423380, - 18423386, 18423801, 18423803, 18424005, 18424006, 18424106, 18424119, 18427918, 18428063, 18428188, 18428190, 18428341, 18428344, - 18428376, 18428378, 18428415, 18429089, 18429190, 18429191, 18429295, 18429301, 18429401, 18429408, 18429419, 18429425, 18429515, - 18429526, 18429763, 18430201, 18430203, 18430403, 18431180, 18431188, 18431554, 18431563, 18431586, 18431622, 18431858, 18431859, - 18432040, 18432050, 18432832, 18433010, 18433079, 18433119, 18459655, 18461356, 18461857, 18462173, 18463453, 18463531, 18479349, - 18479433, 18479437, 18479545, 18479547, 18479583, 18479584, 18479595, 18479615, 18479616, 18479622, 18481099, 18481103, 18481144, - 18481145, 18481150, 18481262, 18481457, 18481554, 18481769, 18485920, 18501825, 18501901, 18501914, 18503176, 18503321, 18503324, - 18503327, 18503748, 18503861, 18505085, 18505121, 18505795, 18505826, 18505827, 18505942, 18507352, 18507393, 18507395, 18507485, - 18507493, 18513155, 18513195, 18513450, 18513477, 18513488, 18513513, 18513532, 18513740, 18535188, 18535211, 18535223, 18535504, - 18535506, 18535511, 18535523, 18535526, 18535693, 18535863, 18535867, 18535950, 18535960, 18536171, 18536855, 18536862, 18536866, - 18536868, 18536869, 18537563, 18537686, 18537828, 18537830, 18539322, 18539428, 18539449, 18539565, 18539569, 18542957, 18549853, - 18549867, 18614667, 18614674, 18614685, 18614689, 18629129, 18629130, 18629263, 18629369, 18629370, 18629490, 18629492, 18630041, - 18630174, 18630284, 18640752, 18640754, 18640811, 18640900, 18640907, 18640943, 18640945, 18641080, 18641081, 18641157, 18641158, - 18641209, 18641401, 18642300, 18642313, 18642314, 18642405, 18642455, 18642533, 18642534, 18642593, 18642798, 18642799, 18644754, - 18690658, 18690699, 18692929, 18692939, 18698953, 18698954, 18699153, 18699427, 18699430, 18700378, 18700541, 18700543, 18700746, - 18700748, 18700766, 18700833, 18700834, 18700841, 18700842, 18701022, 18701473, 18701507, 18701522, 18701524, 18701573, 18701579, - 18701583, 18701911, 18702014, 18702025, 18702055, 18702094, 18702904, 18703319, 18703328, 18703920, 18704157, 18704427, 18704428, - 18705700, 18706080, 18707114, 18707117, 18707253, 18707486, 18707577, 18707592, 18707596, 18707946, 18707947, 18707956, 18707959, - 18707960, 18708017, 18708020, 18708754, 18708755, 18708938, 18709230, 18709237, 18709605, 18709606, 18709614, 18709621, 18709666, - 18709675, 18709742, 18709754, 18709760, 18709875, 18709881, 18709972, 18709987, 18710107, 18710153, 18710156, 18710159, 18710194, - 18710203, 18710456, 18710530, 18710672, 18722404, 18722407, 18722441, 18722444, 18722474, 18722476, 18722661, 18722684, 18722853, - 18722855, 18722857, 18722860, 18722964, 18722965, 18722991, 18723370, 18723413, 18723704, 18723707, 18723764, 18723766, 18723857, - 18723860, 18723916, 18723941, 18723981, 18735304, 18735677, 18737090, 18737199, 18737256, 18737264, 18737394, 18737400, 18738534, - 18738537, 18738632, 18738633, 18738690, 18738691, 18738755, 18739002, 18739014, 18739017, 18739026, 18739095, 18739204, 18739715, - 18739719, 18739774, 18739780, 18741326, 18741377, 18742319, 18742321, 18742401, 18743044, 18743049, 18743102, 18743109, 18743127, - 18743150, 18743153, 18744034, 18744038, 18744047, 18744053, 18744099, 18744100, 18744161, 18744178, 18744272, 18744440, 18744448, - 18744503, 18744507, 18744957, 18744963, 18745309, 18746182, 18746720, 18746766, 18746769, 18747055, 18747115, 18747509, 18748208, - 18748215, 18748216, 18748616, 18748632, 18748881, 18748930, 18749143, 18749153, 18749347, 18749597, 18749859, 18749862, 18749865, - 18750557, 18750566, 18750749, 18751180, 18751334, 18751358, 18751444, 18751733, 18751772, 18751777, 18751784, 18751800, 18751962, - 18751964, 18751967, 18751970, 18751974, 18751975, 18751977, 18752073, 18752085, 18752241, 18752245, 18752369, 18752782, 18752796, - 18753020, 18753025, 18753230, 18753299, 18753321, 18753444, 18754157, 18754468, 18754629, 18754632, 18755348, 18755580, 18755647, - 18756137, 18756196, 18757143, 18757175, 18757227, 18757294, 18757300, 18757544, 18757547, 18757917, 18757930, 18758219, 18758228, - 18758428, 18783923, 18784255, 18784257, 18784278, 18784506, 18784512, 18785925, 18785928, 18786059, 18787397, 18787805, 18787842, - 18840505, 18840540, 18842111, 18842255, 18842546, 18842613, 18843081, 18843086, 18843202, 18877846, 18877886, 18877938, 18877995, - 18878286, 18878288, 18878602, 18878604, 18878910, 18879022, 18879087, 18879201, 18879299, 18879376, 18879694, 18879819, 18879825, - 18879959, 18879963, 18880086, 18880208, 18880209, 18880253, 18880256, 18880438, 18880477, 18880478, 18880579, 18880588, 18880589, - 18880590, 18880674, 18880675, 18880688, 18880690, 18880698, 18880703, 18880710, 18880723, 18880777, 18880778, 18880818, 18880829, - 18880956, 18880957, 18880961, 18880971, 18881047, 18881049, 18881057, 18881059, 18881244, 18881250, 18881271, 18881309, 18881313, - 18881413, 18881417, 18881470, 18881473, 18881573, 18881588, 18881603, 18881665, 18881667, 18881833, 18881834, 18881875, 18881876, - 18881945, 18881946, 18882110, 18882201, 18882333, 18882334, 18882600, 18882620, 18882747, 18882795, 18882797, 18882825, 18882827, - 18882864, 18882874, 18883468, 18883469, 18883511, 18883515, 18883910, 18884107, 18884303, 18884455, 18884839, 18884840, 18884853, - 18885134, 18885240, 18885713, 18885715, 18885719, 18885720, 18890921, 18890923, 18890924, 18891002, 18891007, 18891013, 18891073, - 18891226, 18891230, 18891902, 18892071, 18916117, 18916500, 18917173, 18917229, 18917481, 18917487, 18917714, 18918454, 18918700, - 18919243, 18919244, 18919304, 18919307, 18919365, 18919372, 18919534, 18919859, 18919932, 18920320, 18934396, 18934399, 18934421, - 18934700, 18935088, 18935417, 18935420, 18935494, 18935501, 18936000, 18936103, 18936391, 18936459, 18936570, 18936578, 18936587, - 18936614, 18936649, 18936673, 18962602, 18962613, 18962625, 18962645, 18962662, 18962676, 18963370, 18963420, 18963833, 18963836, - 18963887, 18963911, 18964240, 18964303, 18964451, 18964454, 18964458, 18964500, 18964761, 18965395, 18965426, 18965875, 18965880, - 18965881, 18965931, 18965958, 18965959, 18965984, 18965985, 18967428, 18967463, 18967632, 18968583, 18968607, 18972151, 18972181, - 18972195, 18972196, 18972221, 18972231, 18972471, 18972549, 18972554, 18972611, 18972613, 18972651, 18972928, 18972929, 18972973, - 18972974, 18972992, 18972993, 18973042, 18973044, 18973048, 18973096, 18973098, 18973116, 18973218, 18973912, 18973952, 18973955, - 18974076, 18974093, 18974104, 18974117, 18974129, 18974206, 18974209, 18974419, 18974465, 18974797, 18974894, 18975162, 18975166, - 18975316, 18975374, 18975576, 18975578, 18976376, 18976386, 18976399, 18976405, 18977338, 18977345, 18977358, 18977728, 18977730, - 18977734, 18977736, 18978127, 18978129, 18978246, 18978494, 18978496, 18978826, 18978859, 18978866, 18978868, 18978873, 18978921, - 18978923, 18978933, 18978935, 18979157, 18979213, 18979247, 18979362, 18979627, 18979629, 18979659, 18979665, 18979666, 18979668, - 18979670, 18979746, 18979760, 18979767, 18979772, 18979782, 18979798, 18979820, 18979833, 18979855, 18979857, 18979955, 18979956, - 18980169, 18980439, 18980547, 18980548, 18980554, 18980591, 18980595, 18980691, 18980698, 18980831, 18980853, 18981626, 18981703, - 18981830, 18981937, 18981943, 18982171, 18982176, 18982186, 18982188, 18982196, 18982429, 18982431, 18982437, 18982740, 18982825, - 18982829, 18982867, 18982883, 18982926, 18983055, 18983244, 18983397, 18983401, 18983612, 18983619, 18983620, 18983932, 18983935, - 18983996, 18984329, 18984386, 18984405, 18984407, 18984413, 18984431, 18984501, 18984511, 18984763, 18984769, 18984913, 18984991, - 18985047, 18985161, 18985246, 18985248, 18985301, 18985304, 18985312, 18985520, 18985521, 18985726, 18985822, 18985850, 18986106, - 18986173, 18986174, 18986252, 18986266, 18986267, 18987017, 18987031, 18987048, 18987053, 18987081, 18987680, 18988159, 18988166, - 18988194, 18988205, 18988573, 18988712, 18988715, 18988857, 18988982, 18988984, 18988985, 18989012, 18989013, 18989018, 18989086, - 18989099, 18989125, 18989132, 18989165, 18989462, 18989464, 18989759, 18989899, 18989954, 18989955, 18990839, 18990846, 18990863, - 18990866, 18991105, 18991433, 18991452, 18991456, 18991462, 18991467, 18991469, 18991662, 18992464, 18992650, 18992774, 18992801, - 18992856, 18992860, 18992906, 18999657, 18999676, 18999686, 18999697, 18999881, 18999886, 19000091, 19000224, 19000241, 19000489, - 19000503, 19001195, 19001201, 19001347, 19001359, 19007968, 19007971, 19008121, 19011401, 19011569, 19011588, 19011656, 19011677, - 19011754, 19011759, 19012403, 19012416, 19012603, 19012613, 19012746, 19012747, 19014099, 19014206, 19020339, 19020428, 19020735, - 19020954, 19020959, 19021745, 19021748, 19021802, 19021803, 19022518, 19022523, 19157469, 19157470, 19157562, 19157597, 19157681, - 19157693, 19157727, 19157735, 19177628, 19177631, 19179127, 19180014, 19180478, 19180496, 19180576, 19180594, 19180601, 19180609, - 19182388, 19182390, 19182566, 19182598, 19183939, 19184062, 19184172, 19184613, 19187655, 19187674, 19187949, 19187959, 19189135, - 19190233, 19190353, 19190502, 19190504, 19190594, 19191003, 19191043, 19191046, 19191091, 19191098, 19191118, 19191122, 19191234, - 19191237, 19191305, 19191307, 19191407, 19191408, 19191453, 19191858, 19192015, 19192485, 19192487, 19192606, 19192607, 19192611, - 19192615, 19192896, 19192903, 19193680, 19193768, 19193789, 19193876, 19193879, 19194492, 19195385, 19200168, 19200172, 19200274, - 19200290, 19200578, 19200583, 19202205, 19202286, 19202388, 19202392, 19202403, 19202424, 19202450, 19202506, 19202509, 19203134, - 19203366, 19203572, 19203746, 19203752, 19204197, 19206989, 19207000, 19207077, 19207171, 19207271, 19207272, 19208337, 19208345, - 19208730, 19212689, 19212690, 19212744, 19212946, 19212947, 19213039, 19213045, 19213048, 19213301, 19213303, 19213574, 19213575, - 19213942, 19214581, 19214583, 19214681, 19214684, 19214905, 19215052, 19215418, 19216089, 19216095, 19218331, 19218601, 19218604, - 19218875, 19219205, 19220095, 19220100, 19221680, 19221683, 19221894, 19222484, 19222586, 19222590, 19224624, 19224626, 19225180, - 19226142, 19226145, 19226595, 19226609, 19226890, 19226896, 19226910, 19226911, 19226927, 19227005, 19227837, 19227907, 19227909, - 19228054, 19228056, 19228106, 19228107, 19228121, 19228123, 19228259, 19228261, 19228302, 19228304, 19229883, 19229890, 19230123, - 19233910, 19234320, 19234345, 19234424, 19234537, 19234956, 19235288, 19235308, 19237190, 19237199, 19237208, 19237233, 19239254, - 19239258, 19239376, 19239377, 19239389, 19239407, 19240001, 19240024, 19240499, 19240901, 19250124, 19250127, 19250230, 19250239, - 19252820, 19252824, 19252856, 19252859, 19253253, 19253258, 19253341, 19253648, 19253658, 19254248, 19254257, 19254261, 19254273, - 19255415, 19255483, 19255486, 19256056, 19256595, 19256596, 19257023, 19257421, 19257656, 19257794, 19257795, 19257825, 19257827, - 19257973, 19258287, 19258305, 19259424, 19259426, 19260016, 19260028, 19260034, 19260047, 19260053, 19260136, 19260185, 19260252, - 19260535, 19260539, 19263045, 19263046, 19263072, 19263297, 19263547, 19264542, 19264897, 19268898, 19268900, 19268986, 19268990, - 19269163, 19269421, 19269423, 19271598, 19271984, 19272062, 19272201, 19272203, 19272401, 19272409, 19272445, 19272449, 19281870, - 19281883, 19282504, 19285192, 19285575, 19285576, 19285624, 19301651, 19301652, 19301719, 19301721, 19302758, 19302769, 19302830, - 19302832, 19302846, 19304733, 19304737, 19304857, 19304863, 19304956, 19304961, 19305572, 19306684, 19306759, 19306763, 19306795, - 19306821, 19306844, 19306849, 19307117, 19307412, 19307778, 19307893, 19308083, 19308148, 19308304, 19314020, 19314021, 19314052, - 19314238, 19314253, 19315712, 19316333, 19317997, 19317999, 19318269, 19318271, 19318527, 19318529, 19318536, 19318578, 19318582, - 19318880, 19318881, 19319054, 19319328, 19319330, 19319376, 19324587, 19324593, 19324769, 19324771, 19324874, 19324883, 19324952, - 19324954, 19325006, 19325007, 19325008, 19325103, 19325184, 19325185, 19325391, 19325392, 19325399, 19325401, 19325570, 19325804, - 19326308, 19326329, 19326348, 19326618, 19326756, 19326757, 19326935, 19326944, 19326947, 19327176, 19327529, 19329583, 19329702, - 19329703, 19329745, 19329746, 19329754, 19329758, 19330909, 19330912, 19331006, 19331009, 19331094, 19331095, 19331200, 19331224, - 19331676, 19331678, 19331729, 19331732, 19332246, 19332827, 19332934, 19332935, 19333061, 19358286, 19358287, 19358310, 19360688, - 19360690, 19360794, 19360932, 19361096, 19362472, 19362473, 19362976, 19362979, 19363289, 19363291, 19363391, 19363719, 19364350, - 19364366, 19364392, 19364402, 19364936, 19364944, 19365015, 19365017, 19365059, 19365710, 19365714, 19365844, 19366349, 19366686, - 19366920, 19366924, 19367057, 19367062, 19367152, 19367158, 19367216, 19367219, 19367501, 19367504, 19368429, 19368434, 19368444, - 19368449, 19368461, 19368484, 19368500, 19368501, 19368676, 19368680, 19368783, 19368797, 19368801, 19368942, 19368948, 19368949, - 19368955, 19368966, 19369066, 19369075, 19369217, 19369229, 19369302, 19369310, 19369314, 19369341, 19369343, 19369598, 19369600, - 19369688, 19369690, 19369879, 19369904, 19369907, 19369914, 19369919, 19369924, 19370031, 19373906, 19373910, 19373914, 19373996, - 19374015, 19374165, 19374181, 19374182, 19374198, 19374266, 19374299, 19374800, 19375006, 19375010, 19375171, 19375174, 19375178, - 19375183, 19375189, 19375203, 19375209, 19375252, 19375259, 19375260, 19375719, 19375788, 19375789, 19376019, 19376020, 19376061, - 19385710, 19385787, 19389326, 19389328, 19389440, 19389442, 19389987, 19390185, 19390188, 19390245, 19390250, 19390286, 19390313, - 19390322, 19390345, 19390352, 19390586, 19390710, 19392042, 19392044, 19410405, 19410437, 19410449, 19410488, 19410489, 19410496, - 19410497, 19410510, 19410916, 19411000, 19411002, 19411204, 19411937, 19411939, 19411997, 19512944, 19513029, 19513189, 19513202, - 19513396, 19513538, 19513695, 19513945, 19513992, 19516059, 19516062, 19516075, 19516084, 19516968, 19517224, 19554953, 19558472, - 19609701, 19609719, 19609892, 19609947, 19610025, 19610494, 19610647, 19610652, 19610959, 19611209, 19611291, 19612269, 19612444, - 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285, 19613989, 19614239, 19614595, 19614600, - 19614607, 19615112, 19615114, 19615248, 19726042, 19726057, 19748242, 19748244, 19748269, 19748278, 19748377, 19750672, 19750695, - 19750702, 19750822, 19750833, 19751058, 19751064, 19751102, 19751108, 19751169, 19751172, 19751269, 19751854, 19751865, 19751878, - 19751936, 19752030, 19752349, 19755044, 19755063, 19755440, 19755881, 19756813, 19761538, 19761592, 19761593, 19761680, 19761685, - 19761995, 19762162, 19762167, 19763218, 19763430, 19763945, 19764280, 19764311, 19764333, 19764676, 19764744, 19765216, 19765374, - 19765479, 19767631, 19792072, 19792136, 19792139, 19793277, 19793318, 19793322, 19793528, 19793536, 19796241, 19796405, 19796407, - 19802815, 19802816, 19802881, 19804775, 19805218, 19805360, 19805515, 19807739, 19807796, 19808997, 19809396, 19809725, 19809990, - 19913194, 19913195, 19914726, 19914727, 19914735, 19914741, 19914769, 19914811, 19914876, 19914877, 19916067, 19917537, 19917540, - 19917991, 19918159, 19918171, 19918197, 19918202, 19918295, 19918302, 19918429, 19918432, 19918524, 19918639, 19918716, 19918797, - 19918799, 19918991, 19918992, 19919153, 19919287, 19919383, 19919514, 19919971, 19919995, 19920374, 19920778, 19920779, 19921528, - 19921531, 19921674, 19921675, 19921724, 19923306, 19923308, 19923480, 19923532, 19923534, 19923692, 19923702, 19923790, 19923814, - 19923818, 19923880, 19923884, 19924275, 19924279, 19924358, 19924367, 19924384, 19925554, 19925869, 19926582, 19926586, 19926619, - 19926620, 19926687, 19926859, 19926884, 19926887, 19926891, 19926959, 19927302, 19927422, 19928859, 19929054, 19932992, 19933015, - 19933313, 19933316, 19933328, 19933410, 19933760, 19933818, 19933876, 19934184, 19934490, 19934606, 19934621, 19934741, 19959354, - 19959578, 19960026, 19960122, 19962154, 19962536 -]; -export const PEG_CROSS_BLOCKS_LAST: u32 = 19962536; -export const PEG_CROSS_BLOCKS: u32[] = [ - 12974091, 12975421, 12978538, 12978615, 12978680, 12978911, 12979148, 12979149, 12979167, 12979171, 12979228, 12979230, 12979607, - 12983847, 12983871, 12983895, 12983897, 12983926, 12984038, 12984104, 12984170, 12984257, 12984310, 12984929, 12986590, 12986603, - 12986901, 12987603, 12990064, 12991358, 12991399, 12992193, 12992519, 12993217, 12993281, 12998537, 12998539, 12998546, 12998550, - 12998551, 12998553, 12999530, 12999585, 12999767, 12999776, 12999777, 12999779, 12999817, 12999840, 13000158, 13000196, 13000305, - 13000309, 13000334, 13000347, 13000356, 13000377, 13000577, 13000587, 13001082, 13001089, 13001396, 13001414, 13001894, 13001913, - 13001956, 13002009, 13002735, 13002738, 13003196, 13003198, 13004037, 13004045, 13004360, 13004364, 13004638, 13004646, 13004655, - 13004657, 13004817, 13004839, 13004843, 13004883, 13005075, 13005103, 13005107, 13005109, 13005372, 13005380, 13005673, 13005715, - 13005730, 13005733, 13005944, 13005946, 13006200, 13006202, 13006203, 13006321, 13006487, 13006488, 13006499, 13006546, 13006708, - 13006709, 13006980, 13007010, 13007245, 13007246, 13007274, 13007275, 13007509, 13007525, 13007574, 13007607, 13007780, 13007798, - 13007859, 13007898, 13008063, 13008065, 13008117, 13008191, 13008375, 13008387, 13008617, 13008671, 13008712, 13008736, 13008895, - 13008901, 13008906, 13008912, 13009163, 13009169, 13009190, 13009193, 13009199, 13009203, 13009381, 13009423, 13009669, 13009671, - 13009676, 13009679, 13009681, 13009687, 13009958, 13009972, 13009973, 13010009, 13010222, 13010231, 13010492, 13010556, 13010779, - 13014211, 13016266, 13018933, 13019023, 13019754, 13020690, 13020782, 13022699, 13022701, 13022825, 13023185, 13023247, 13023922, - 13025396, 13025666, 13026184, 13026256, 13026638, 13026640, 13027512, 13029384, 13030010, 13030107, 13030123, 13030393, 13030528, - 13031004, 13031259, 13032695, 13032731, 13032942, 13033010, 13033033, 13033210, 13034517, 13034543, 13035839, 13035922, 13035929, - 13036165, 13036689, 13036884, 13036897, 13036926, 13037135, 13037615, 13037642, 13038069, 13038108, 13038138, 13038145, 13038184, - 13039743, 13043682, 13043699, 13044756, 13044762, 13044770, 13044955, 13045801, 13046502, 13051141, 13051348, 13056233, 13056234, - 13057499, 13057501, 13057527, 13057595, 13058927, 13059717, 13059983, 13060079, 13060086, 13060118, 13060119, 13060121, 13060123, - 13060132, 13060160, 13060198, 13060449, 13060450, 13060479, 13060489, 13060492, 13060680, 13060716, 13060796, 13060802, 13060842, - 13060960, 13062059, 13062295, 13062299, 13062306, 13062319, 13062333, 13062352, 13062366, 13063788, 13063838, 13063861, 13063878, - 13075770, 13075888, 13076058, 13076195, 13076316, 13076435, 13076636, 13076662, 13076679, 13076703, 13076890, 13076891, 13076899, - 13076947, 13076964, 13076972, 13077164, 13077246, 13077426, 13077429, 13077495, 13077503, 13077730, 13077736, 13078272, 13078287, - 13078449, 13078457, 13078466, 13078470, 13078482, 13078487, 13078488, 13078519, 13078541, 13078561, 13078796, 13078810, 13078813, - 13078834, 13079299, 13079303, 13079572, 13079587, 13079588, 13079596, 13079620, 13079642, 13079648, 13079683, 13079724, 13079755, - 13079814, 13079885, 13079887, 13079895, 13079899, 13079919, 13079920, 13079941, 13080074, 13080179, 13080198, 13080229, 13080352, - 13080375, 13080400, 13080408, 13080634, 13080637, 13080648, 13080660, 13080672, 13080677, 13080678, 13080680, 13080768, 13080770, - 13080887, 13080888, 13080932, 13080934, 13080937, 13080958, 13080977, 13080990, 13080996, 13080999, 13081011, 13081057, 13081145, - 13081209, 13081632, 13081635, 13081700, 13081721, 13081750, 13081754, 13081766, 13081895, 13081963, 13081977, 13081992, 13081994, - 13082000, 13082006, 13082094, 13082163, 13082230, 13082282, 13082300, 13082301, 13082504, 13082507, 13082510, 13082555, 13082863, - 13082876, 13082878, 13082888, 13082969, 13083844, 13084930, 13084956, 13084984, 13085212, 13085233, 13085236, 13085311, 13085508, - 13085645, 13085877, 13086288, 13086337, 13086338, 13086356, 13086362, 13086369, 13086376, 13086400, 13086422, 13086440, 13086459, - 13086461, 13087211, 13087217, 13087221, 13087225, 13087231, 13087377, 13087393, 13087405, 13087410, 13087411, 13087527, 13088104, - 13088272, 13093705, 13093899, 13093903, 13093921, 13093932, 13093971, 13093975, 13099188, 13099189, 13099353, 13099362, 13099414, - 13099461, 13099465, 13099710, 13099714, 13099747, 13100289, 13100319, 13100358, 13100371, 13100898, 13100923, 13102868, 13102939, - 13107071, 13107096, 13110581, 13110588, 13110634, 13110706, 13110819, 13110844, 13111074, 13113042, 13113109, 13113110, 13113423, - 13113442, 13113448, 13113452, 13113453, 13113553, 13114481, 13114574, 13115940, 13115946, 13115955, 13115972, 13115989, 13115990, - 13117862, 13118077, 13118145, 13118291, 13118320, 13118321, 13118355, 13118356, 13118402, 13118413, 13118423, 13118428, 13118436, - 13118467, 13121070, 13121089, 13121099, 13121128, 13121178, 13121244, 13121307, 13121310, 13122225, 13122395, 13122407, 13122455, - 13122874, 13122951, 13122985, 13124397, 13124895, 13129783, 13129786, 13129854, 13129981, 13129991, 13130001, 13130094, 13130178, - 13131625, 13131662, 13131722, 13131929, 13137125, 13137568, 13138520, 13138647, 13138700, 13138778, 13138782, 13138813, 13138856, - 13138858, 13139212, 13139273, 13139367, 13139407, 13139408, 13139410, 13139609, 13140003, 13140015, 13140024, 13140027, 13140327, - 13140447, 13140687, 13141148, 13141156, 13141160, 13141165, 13141195, 13141863, 13141869, 13141870, 13141940, 13142135, 13143729, - 13143754, 13143760, 13143762, 13143763, 13143816, 13144293, 13144300, 13144362, 13144364, 13144774, 13144823, 13145005, 13145190, - 13145194, 13145195, 13145198, 13145206, 13145220, 13145747, 13146082, 13146089, 13147016, 13147028, 13147044, 13147045, 13148291, - 13148316, 13149112, 13150275, 13150279, 13150280, 13151314, 13151333, 13151356, 13151443, 13151450, 13151451, 13151460, 13151462, - 13151595, 13151598, 13151696, 13151700, 13151863, 13151867, 13152103, 13152260, 13152269, 13153306, 13153325, 13155620, 13156284, - 13156748, 13156781, 13157326, 13158957, 13159234, 13159235, 13159247, 13159248, 13159486, 13159495, 13161064, 13161086, 13161299, - 13161376, 13161392, 13161406, 13161416, 13161423, 13161487, 13161550, 13161611, 13161634, 13161636, 13162200, 13162208, 13162329, - 13162331, 13163395, 13163536, 13163565, 13163567, 13163596, 13163597, 13163604, 13163670, 13163995, 13164187, 13164189, 13164192, - 13164658, 13164746, 13165237, 13165391, 13165408, 13165727, 13165897, 13165996, 13166015, 13166072, 13166219, 13166222, 13166242, - 13166250, 13166251, 13166258, 13166259, 13166283, 13166287, 13166319, 13166381, 13166437, 13167205, 13167549, 13167575, 13167591, - 13167742, 13167972, 13168519, 13168524, 13169110, 13171988, 13175038, 13175053, 13175058, 13175064, 13175069, 13175146, 13175397, - 13175452, 13175497, 13175514, 13175520, 13175609, 13177587, 13177589, 13177597, 13177615, 13177647, 13177659, 13177660, 13177714, - 13177758, 13178360, 13178584, 13178652, 13179149, 13179177, 13179251, 13179252, 13179253, 13179274, 13179308, 13179337, 13179353, - 13179400, 13180079, 13180083, 13180101, 13180102, 13180117, 13180145, 13180189, 13180216, 13180664, 13180692, 13180713, 13180715, - 13180730, 13180758, 13180833, 13180888, 13180897, 13180909, 13181023, 13181155, 13181755, 13181777, 13181802, 13181820, 13182646, - 13182655, 13183890, 13183894, 13183955, 13183956, 13183957, 13184012, 13184973, 13184974, 13185191, 13185260, 13185321, 13185384, - 13185495, 13185703, 13185732, 13185850, 13187086, 13187116, 13187178, 13187233, 13188042, 13189001, 13189010, 13189082, 13191072, - 13191091, 13191099, 13191106, 13191522, 13191635, 13191637, 13191644, 13192232, 13192596, 13192599, 13192604, 13193031, 13193802, - 13194379, 13194410, 13194615, 13194717, 13194719, 13194824, 13196049, 13196067, 13196141, 13196190, 13196445, 13196459, 13196460, - 13198164, 13198273, 13198316, 13198557, 13198899, 13198902, 13198907, 13198909, 13198925, 13199052, 13199074, 13199086, 13199099, - 13199116, 13199129, 13199131, 13199260, 13199361, 13199363, 13200193, 13200194, 13200216, 13200219, 13200224, 13201208, 13201289, - 13201290, 13201321, 13201322, 13206138, 13206229, 13206338, 13206947, 13207266, 13207395, 13207435, 13207444, 13207445, 13207578, - 13207663, 13208184, 13211822, 13211897, 13211967, 13213641, 13214042, 13214163, 13214206, 13215008, 13215982, 13217044, 13217061, - 13217222, 13217341, 13217478, 13217783, 13217784, 13217810, 13217953, 13217970, 13217973, 13218020, 13218050, 13218279, 13218810, - 13218815, 13218816, 13218909, 13218949, 13218953, 13218954, 13225077, 13225299, 13226246, 13226559, 13226732, 13226957, 13227000, - 13229110, 13229499, 13229747, 13232674, 13232699, 13232717, 13233025, 13234172, 13234178, 13234264, 13234554, 13236246, 13236247, - 13236250, 13236319, 13237109, 13237552, 13244459, 13244462, 13245028, 13245032, 13245040, 13245162, 13245172, 13245175, 13245180, - 13245275, 13245545, 13245546, 13246387, 13246388, 13246647, 13246651, 13246920, 13246926, 13246980, 13246983, 13247415, 13247416, - 13247678, 13247695, 13247947, 13247952, 13248208, 13248209, 13248470, 13248473, 13249273, 13249276, 13249292, 13249294, 13249543, - 13249561, 13249800, 13249818, 13249822, 13250039, 13250057, 13250059, 13256813, 13256815, 13257386, 13257389, 13258210, 13258214, - 13259590, 13259594, 13259863, 13259865, 13260039, 13260056, 13260062, 13260063, 13260114, 13260126, 13260381, 13260386, 13260388, - 13260389, 13260884, 13260886, 13261140, 13261142, 13261145, 13261155, 13261156, 13261186, 13261206, 13261363, 13261373, 13261399, - 13262381, 13262382, 13262425, 13262428, 13262440, 13262442, 13262455, 13262462, 13262465, 13262469, 13262553, 13262554, 13262569, - 13262592, 13262593, 13262713, 13262719, 13262729, 13262748, 13262896, 13262899, 13262913, 13263080, 13263772, 13263871, 13264127, - 13264135, 13264139, 13264149, 13272546, 13272560, 13272905, 13272934, 13273058, 13273061, 13273064, 13273373, 13273436, 13273458, - 13273503, 13273513, 13273717, 13273719, 13274023, 13274030, 13274057, 13274064, 13274105, 13274148, 13274189, 13274198, 13274217, - 13274220, 13274242, 13274248, 13335750, 13335755, 13335869, 13336244, 13336323, 13336461, 13336505, 13336560, 13336618, 13336695, - 13336714, 13336777, 13336959, 13337532, 13337559, 13337935, 13337937, 13337959, 13340698, 13340781, 13340820, 13340947, 13341028, - 13341076, 13341108, 13341147, 13341156, 13341366, 13341373, 13342047, 13342121, 13342224, 13342548, 13376585, 13376710, 13376778, - 13378143, 13378793, 13378816, 13378829, 13379464, 13434006, 13434877, 13435565, 13435971, 13436006, 13436018, 13436025, 13436035, - 13436049, 13436107, 13437998, 13438644, 13438667, 13440517, 13442086, 13442913, 13443210, 13443231, 13443232, 13443239, 13443256, - 13443258, 13443270, 13443271, 13444653, 13444660, 13444712, 13446459, 13448008, 13449065, 13449128, 13449167, 13449303, 13449313, - 13449493, 13449495, 13449505, 13449506, 13449551, 13449634, 13449650, 13449705, 13449790, 13449821, 13449841, 13449855, 13449875, - 13449913, 13450052, 13450154, 13450187, 13450472, 13450507, 13450522, 13451061, 13451131, 13451155, 13451468, 13451543, 13451544, - 13451550, 13451555, 13451564, 13451596, 13451598, 13451649, 13451671, 13451675, 13455280, 13455282, 13455557, 13455600, 13455618, - 13455860, 13455891, 13455896, 13455911, 13461738, 13462027, 13462049, 13462066, 13462165, 13463379, 13463381, 13464408, 13466451, - 13467419, 13467691, 13468508, 13468675, 13468784, 13469000, 13469007, 13469012, 13469034, 13470634, 13470770, 13471747, 13474744, - 13474934, 13475341, 13475377, 13475394, 13475519, 13475523, 13475746, 13476174, 13476209, 13476325, 13476418, 13476419, 13479133, - 13479136, 13479138, 13479152, 13479196, 13479242, 13479941, 13480370, 13480372, 13480449, 13480647, 13480648, 13480717, 13481304, - 13481717, 13481988, 13482011, 13482102, 13483897, 13483977, 13483982, 13483998, 13484811, 13484846, 13484847, 13486887, 13486969, - 13488473, 13488482, 13489574, 13489977, 13490465, 13490505, 13490507, 13490517, 13490518, 13491374, 13494424, 13494752, 13494754, - 13495520, 13495854, 13497794, 13497797, 13497803, 13497820, 13497844, 13497868, 13498035, 13503686, 13503690, 13503704, 13503709, - 13503751, 13503763, 13503770, 13503813, 13503910, 13508461, 13508666, 13508680, 13508728, 13508759, 13508780, 13510297, 13510507, - 13510508, 13510514, 13510516, 13510518, 13510520, 13510556, 13510590, 13510603, 13510605, 13510610, 13510727, 13511700, 13511890, - 13511907, 13512045, 13512048, 13512304, 13512305, 13512359, 13512365, 13514281, 13514282, 13514705, 13514719, 13514721, 13514734, - 13515060, 13516318, 13516526, 13516569, 13517036, 13517567, 13518970, 13519495, 13519497, 13519756, 13521882, 13522133, 13523828, - 13523847, 13523862, 13523885, 13523912, 13523967, 13523969, 13524379, 13524397, 13525787, 13525872, 13525873, 13528534, 13528544, - 13528546, 13528558, 13528574, 13528579, 13528967, 13529028, 13531631, 13531875, 13531910, 13531954, 13531961, 13531990, 13532016, - 13532023, 13532081, 13532126, 13532137, 13532138, 13532143, 13532151, 13532161, 13532176, 13532179, 13532198, 13532239, 13532920, - 13532929, 13532946, 13533454, 13533933, 13535490, 13535493, 13535494, 13535499, 13538211, 13538232, 13538866, 13538895, 13539218, - 13539249, 13539673, 13539923, 13539946, 13539951, 13540826, 13540841, 13541140, 13541325, 13541849, 13541933, 13541958, 13541980, - 13541997, 13542002, 13542077, 13542086, 13542175, 13542179, 13542232, 13542254, 13543917, 13544624, 13545832, 13545837, 13545858, - 13546411, 13547018, 13547059, 13547095, 13547595, 13547630, 13548233, 13548387, 13550252, 13550987, 13551029, 13551119, 13551280, - 13551291, 13552190, 13552241, 13552260, 13552307, 13552675, 13552678, 13552681, 13552684, 13552688, 13552701, 13552704, 13552750, - 13552752, 13552754, 13552943, 13553661, 13553662, 13553676, 13553677, 13553853, 13554976, 13555095, 13555457, 13557196, 13557954, - 13558105, 13558112, 13558113, 13558114, 13558116, 13558121, 13558735, 13558752, 13558776, 13559078, 13559084, 13559255, 13559291, - 13559303, 13559410, 13559415, 13559416, 13559425, 13559561, 13559568, 13559602, 13559647, 13559656, 13559658, 13559791, 13559882, - 13560317, 13560318, 13560937, 13564634, 13564681, 13564697, 13564713, 13564837, 13564852, 13564859, 13564871, 13564879, 13564889, - 13564891, 13566648, 13568113, 13568302, 13568342, 13568345, 13568357, 13568484, 13568492, 13568495, 13568667, 13570256, 13570277, - 13570284, 13570300, 13570316, 13570318, 13570944, 13570952, 13571175, 13572652, 13572673, 13572674, 13572854, 13572856, 13572884, - 13572895, 13572918, 13572923, 13572958, 13572969, 13573024, 13573028, 13573096, 13573097, 13573405, 13573522, 13573523, 13573686, - 13573687, 13573693, 13573695, 13574201, 13574213, 13574289, 13574294, 13575376, 13575377, 13576614, 13576620, 13576635, 13576661, - 13576663, 13577153, 13577969, 13578897, 13578901, 13578940, 13578947, 13579158, 13579160, 13579235, 13579351, 13579385, 13579447, - 13579490, 13579530, 13579565, 13579572, 13579588, 13579894, 13579900, 13579911, 13579912, 13579914, 13579918, 13579942, 13580072, - 13580087, 13580260, 13580280, 13581920, 13582005, 13582060, 13582068, 13582069, 13582090, 13582096, 13582336, 13582467, 13582468, - 13582749, 13583449, 13583933, 13584045, 13584069, 13584076, 13584080, 13584082, 13584102, 13584104, 13584107, 13584126, 13584153, - 13584183, 13584184, 13584192, 13584195, 13584208, 13584209, 13584211, 13584243, 13584286, 13584294, 13584296, 13584485, 13584486, - 13585001, 13585594, 13585602, 13585607, 13585610, 13585641, 13585748, 13585775, 13585976, 13585992, 13586067, 13587038, 13587054, - 13587160, 13589367, 13589405, 13589454, 13589471, 13589485, 13589486, 13589512, 13589515, 13589527, 13589532, 13589574, 13589656, - 13589661, 13589867, 13590103, 13592391, 13594358, 13595502, 13595599, 13595883, 13596659, 13596666, 13596668, 13596671, 13598662, - 13599510, 13599974, 13600003, 13600116, 13600221, 13600229, 13600230, 13600343, 13600344, 13600519, 13602309, 13602377, 13602479, - 13602483, 13602486, 13602488, 13602489, 13602490, 13602493, 13602978, 13603574, 13603586, 13603652, 13603887, 13604255, 13605773, - 13605779, 13606896, 13607198, 13607202, 13607203, 13608420, 13608519, 13608665, 13608681, 13608968, 13610066, 13611161, 13614876, - 13614927, 13614991, 13614998, 13615404, 13617630, 13618342, 13621035, 13622147, 13623486, 13623495, 13623499, 13623577, 13623590, - 13623764, 13624270, 13624355, 13624363, 13624366, 13624383, 13624517, 13625958, 13625960, 13625982, 13626112, 13626125, 13626166, - 13626170, 13626212, 13628785, 13628854, 13628864, 13628865, 13629661, 13629662, 13629784, 13629785, 13629852, 13630011, 13630129, - 13630230, 13630429, 13630583, 13630683, 13630775, 13630780, 13630796, 13631292, 13631331, 13640082, 13640087, 13640104, 13640132, - 13640218, 13640556, 13640587, 13640615, 13641928, 13641929, 13642057, 13642071, 13642137, 13642155, 13642160, 13642167, 13642168, - 13642207, 13642212, 13642215, 13642216, 13642265, 13642911, 13644410, 13646116, 13646163, 13647476, 13647732, 13647733, 13647905, - 13657931, 13657936, 13658078, 13658083, 13658088, 13658106, 13666892, 13666908, 13667064, 13667842, 13671879, 13672266, 13685409, - 13685501, 13687313, 13687327, 13688700, 13688718, 13688728, 13688770, 13688773, 13689077, 13693941, 13693995, 13694143, 13694177, - 13703288, 13703407, 13704796, 13704804, 13704850, 13704871, 13710244, 13710333, 13710534, 13710568, 13717643, 13717686, 13720847, - 13720981, 13721138, 13721150, 13721209, 13721255, 13721263, 13721265, 13721279, 13721280, 13722372, 13722456, 13722731, 13722854, - 13722860, 13722861, 13722883, 13722884, 13722898, 13722924, 13723078, 13723597, 13723611, 13723617, 13724121, 13724580, 13724940, - 13724949, 13724958, 13725168, 13725481, 13725714, 13725715, 13725761, 13726532, 13728022, 13728049, 13729075, 13729079, 13729488, - 13729572, 13729622, 13729660, 13729666, 13729719, 13729765, 13729836, 13731361, 13731396, 13731754, 13731765, 13731769, 13731770, - 13731798, 13731966, 13732954, 13732957, 13732964, 13734204, 13734565, 13734582, 13734613, 13734671, 13735055, 13735059, 13735060, - 13735378, 13740278, 13740773, 13740781, 13740808, 13740821, 13740879, 13741264, 13742045, 13742386, 13742413, 13742433, 13742461, - 13742522, 13743142, 13743432, 13743636, 13743643, 13743676, 13744107, 13744604, 13800996, 13800999, 13801241, 13801243, 13804633, - 13804667, 13804672, 13804727, 13812443, 13812884, 13812892, 13812903, 13813249, 13813688, 13829732, 13829784, 13844956, 13844964, - 13845655, 13845657, 13845739, 13845745, 13845757, 13845780, 13848953, 13851591, 13851617, 13852217, 13852286, 13852519, 13853027, - 13854735, 13854789, 13854927, 13854932, 13854936, 13854950, 13854954, 13856012, 13856028, 13856077, 13856953, 13856955, 13857267, - 13857323, 13857365, 13857466, 13857469, 13857483, 13857490, 13857624, 13857918, 13858695, 13858898, 13858902, 13858904, 13858923, - 13858924, 13859670, 13859826, 13859936, 13860025, 13860899, 13861827, 13861932, 13861937, 13862044, 13862064, 13862197, 13862355, - 13862374, 13863113, 13864512, 13864522, 13864530, 13864926, 13864941, 13864946, 13864969, 13865001, 13865043, 13865070, 13865081, - 13865342, 13865516, 13865553, 13865581, 13865604, 13865623, 13865647, 13865678, 13866062, 13869401, 13869405, 13869422, 13869451, - 13869457, 13869834, 13870311, 13870632, 13871204, 13871210, 13871302, 13871334, 13871339, 13871363, 13871424, 13871435, 13871497, - 13871551, 13871568, 13871570, 13871583, 13871761, 13872175, 13872207, 13872240, 13872304, 13872378, 13872402, 13872443, 13872834, - 13872889, 13872979, 13873525, 13873669, 13874108, 13874137, 13874154, 13874198, 13874244, 13874484, 13875063, 13875708, 13875709, - 13876095, 13876631, 13876822, 13876828, 13876980, 13877074, 13877075, 13877496, 13877517, 13877520, 13877638, 13877848, 13878148, - 13882302, 13882360, 13882365, 13882591, 13882592, 13882597, 13882599, 13882806, 13882807, 13883051, 13883360, 13883433, 13884709, - 13885349, 13885866, 13885918, 13886883, 13887001, 13887338, 13887344, 13887380, 13887548, 13887611, 13888142, 13888577, 13888593, - 13888668, 13888746, 13889461, 13889503, 13889510, 13889524, 13889539, 13889649, 13890458, 13891050, 13891076, 13891081, 13891130, - 13891135, 13891138, 13902888, 13902992, 13906563, 13906944, 13908405, 13908630, 13912128, 13912739, 13913099, 13913121, 13913454, - 13913585, 13913596, 13914008, 13926989, 13926996, 13927003, 13927014, 13927024, 13927479, 13927483, 13927492, 13938606, 13938669, - 13939585, 13939590, 13939599, 13939708, 13939849, 13939850, 13942560, 13942563, 13942611, 13954079, 13954146, 13954148, 13954178, - 13985645, 13985651, 13992100, 14005135, 14005139, 14005140, 14005142, 14005185, 14009388, 14009390, 14038443, 14043167, 14043168, - 14098158, 14098190, 14098343, 14098347, 14098363, 14098372, 14098448, 14098510, 14099411, 14099421, 14111704, 14111988, 14112175, - 14112178, 14112222, 14112272, 14112281, 14112322, 14112332, 14112523, 14112534, 14112721, 14112870, 14113018, 14113027, 14113380, - 14113524, 14113544, 14113990, 14114153, 14114184, 14114266, 14114286, 14114342, 14114380, 14114399, 14114404, 14114436, 14114512, - 14114628, 14114673, 14114833, 14114886, 14114898, 14115278, 14115362, 14115372, 14115446, 14115500, 14115574, 14116384, 14116406, - 14116506, 14116797, 14116986, 14117002, 14117059, 14117070, 14117097, 14117135, 14117265, 14117322, 14117503, 14117521, 14117550, - 14118001, 14118142, 14118146, 14118158, 14118197, 14118368, 14118496, 14118533, 14118647, 14118701, 14118714, 14118937, 14119187, - 14119295, 14119413, 14119877, 14119901, 14119970, 14120278, 14120281, 14120282, 14120389, 14120437, 14120542, 14120552, 14120595, - 14121317, 14121366, 14121432, 14121455, 14121577, 14121580, 14121596, 14121601, 14121630, 14121638, 14121679, 14121684, 14121722, - 14121856, 14122382, 14122403, 14122483, 14122757, 14122763, 14122767, 14122824, 14122827, 14122833, 14122844, 14122853, 14122877, - 14123193, 14123200, 14123302, 14123407, 14124143, 14124163, 14124204, 14124296, 14124337, 14124352, 14124366, 14124368, 14124374, - 14124391, 14124991, 14125047, 14126549, 14126762, 14126770, 14126771, 14126782, 14126791, 14126823, 14126841, 14128740, 14128817, - 14128883, 14128944, 14129293, 14129452, 14129553, 14129573, 14129597, 14129617, 14129837, 14129898, 14129913, 14129915, 14129939, - 14130007, 14130296, 14130298, 14130316, 14130334, 14130355, 14130372, 14130378, 14130387, 14130388, 14130423, 14130440, 14130465, - 14130641, 14131066, 14131081, 14131115, 14131324, 14131407, 14131588, 14132136, 14132310, 14133768, 14133783, 14133786, 14133815, - 14133830, 14133981, 14134041, 14135528, 14135807, 14135812, 14135828, 14137560, 14137824, 14137853, 14138293, 14138307, 14138600, - 14138669, 14138825, 14138845, 14138888, 14139112, 14139816, 14140071, 14140079, 14140134, 14140318, 14140343, 14140597, 14140903, - 14140910, 14141386, 14141418, 14141461, 14141473, 14141478, 14141480, 14141489, 14141517, 14141541, 14141549, 14141628, 14141732, - 14141733, 14141780, 14141786, 14141800, 14142398, 14142742, 14142749, 14143111, 14143196, 14143745, 14143763, 14143828, 14143864, - 14144282, 14144473, 14145076, 14145285, 14145784, 14145908, 14145935, 14145988, 14146061, 14146091, 14146109, 14146166, 14146173, - 14146182, 14146184, 14146190, 14146207, 14146234, 14146754, 14146771, 14146832, 14147019, 14147204, 14147423, 14147483, 14147519, - 14147526, 14147554, 14147587, 14147607, 14147732, 14148521, 14148714, 14149592, 14149619, 14149789, 14149804, 14149812, 14149940, - 14149961, 14149966, 14149992, 14151350, 14151353, 14153570, 14154639, 14154760, 14154939, 14155463, 14155476, 14155742, 14155762, - 14155771, 14155906, 14155935, 14156644, 14156695, 14156824, 14157718, 14158023, 14158178, 14158179, 14158192, 14158225, 14158234, - 14160434, 14160448, 14160484, 14160591, 14160631, 14160678, 14161007, 14161029, 14161053, 14161067, 14161227, 14161241, 14161396, - 14161541, 14161546, 14161548, 14161549, 14161604, 14161618, 14161833, 14161976, 14161996, 14162133, 14162387, 14162615, 14162897, - 14163117, 14163286, 14163301, 14163309, 14163900, 14163967, 14164571, 14165063, 14165098, 14165182, 14165193, 14165728, 14165832, - 14166064, 14166499, 14166555, 14166559, 14166586, 14167320, 14167457, 14167507, 14167584, 14167707, 14167751, 14167792, 14167806, - 14167809, 14167830, 14167859, 14167868, 14167877, 14167979, 14167980, 14171368, 14171777, 14171890, 14171953, 14172042, 14172047, - 14172089, 14172170, 14172332, 14172456, 14172572, 14172639, 14173001, 14174547, 14174910, 14175087, 14175109, 14175111, 14175869, - 14175907, 14176246, 14176253, 14176343, 14176607, 14177124, 14177447, 14177503, 14177734, 14178614, 14178630, 14178820, 14178821, - 14178839, 14179074, 14179192, 14179237, 14179326, 14180592, 14180796, 14180851, 14181128, 14181137, 14181693, 14181698, 14181762, - 14181792, 14182209, 14182468, 14182581, 14183420, 14183543, 14183809, 14183872, 14184752, 14184842, 14185023, 14185412, 14185453, - 14185501, 14185653, 14185710, 14185798, 14186682, 14186733, 14187745, 14187752, 14187757, 14187821, 14188264, 14188460, 14188465, - 14188729, 14188778, 14189095, 14189171, 14191103, 14191217, 14191927, 14192000, 14192052, 14192242, 14192398, 14192827, 14192854, - 14193065, 14193073, 14193103, 14193143, 14193158, 14193482, 14193580, 14194305, 14194319, 14194412, 14194419, 14194484, 14194546, - 14194595, 14199795, 14199935, 14199983, 14199986, 14200044, 14200084, 14200111, 14200139, 14200182, 14200190, 14204347, 14204418, - 14204510, 14204511, 14204779, 14204797, 14204839, 14205356, 14205469, 14205477, 14205495, 14206818, 14206853, 14207065, 14207638, - 14207651, 14207666, 14207674, 14207769, 14208925, 14208929, 14208933, 14209218, 14209304, 14209336, 14209575, 14209637, 14209654, - 14209658, 14209756, 14209776, 14209798, 14209927, 14210583, 14210845, 14211495, 14211541, 14211907, 14211929, 14212341, 14212472, - 14212477, 14212690, 14213033, 14213418, 14213497, 14213514, 14213530, 14213652, 14213946, 14213953, 14213972, 14214116, 14214142, - 14214143, 14214366, 14214977, 14214987, 14215167, 14215207, 14215399, 14215416, 14215450, 14215516, 14217199, 14217219, 14217260, - 14217509, 14218325, 14218896, 14218935, 14219106, 14219113, 14219114, 14219119, 14219130, 14219957, 14219958, 14220038, 14220087, - 14220173, 14220219, 14220804, 14221341, 14222488, 14222500, 14222878, 14222894, 14222935, 14223004, 14223669, 14223764, 14227432, - 14227444, 14227445, 14227450, 14227692, 14227697, 14228042, 14228163, 14228181, 14228408, 14228421, 14228485, 14228486, 14228491, - 14228508, 14228587, 14228717, 14228762, 14228769, 14228773, 14228791, 14228792, 14228804, 14228903, 14229010, 14229018, 14229159, - 14231125, 14231300, 14231443, 14231448, 14232109, 14232208, 14232209, 14232381, 14232406, 14232802, 14232810, 14232864, 14232909, - 14233312, 14233318, 14233470, 14233715, 14233727, 14233759, 14235991, 14236061, 14236156, 14236267, 14236301, 14236377, 14236429, - 14236512, 14236650, 14236713, 14236756, 14236769, 14236824, 14236825, 14237021, 14237138, 14237249, 14237357, 14237367, 14237368, - 14237405, 14237422, 14237465, 14237979, 14238006, 14238047, 14238053, 14238054, 14238064, 14238210, 14241229, 14242371, 14242374, - 14242376, 14242495, 14242761, 14242796, 14242807, 14242848, 14242857, 14242860, 14242895, 14242902, 14242903, 14243742, 14243745, - 14243747, 14243828, 14243830, 14243898, 14243995, 14244554, 14244572, 14244661, 14244663, 14245554, 14245560, 14245614, 14245629, - 14245794, 14246045, 14246318, 14246687, 14246846, 14247108, 14247338, 14247826, 14247928, 14247954, 14247963, 14247985, 14248202, - 14248403, 14248732, 14249055, 14249278, 14249875, 14250216, 14250927, 14250928, 14251116, 14251143, 14251320, 14251343, 14251406, - 14251457, 14251569, 14251635, 14251874, 14251884, 14251898, 14252039, 14252092, 14252144, 14252246, 14252318, 14252972, 14253022, - 14255299, 14255310, 14255475, 14255516, 14255543, 14255556, 14255822, 14255995, 14256057, 14256504, 14256561, 14256571, 14256620, - 14258923, 14258985, 14259150, 14259607, 14259661, 14260250, 14260264, 14261054, 14261145, 14261150, 14261244, 14261398, 14261838, - 14261932, 14261969, 14262054, 14262427, 14262460, 14262621, 14263627, 14263682, 14267276, 14267288, 14267519, 14267528, 14267529, - 14267548, 14267622, 14267663, 14268607, 14268629, 14268630, 14268672, 14268685, 14268744, 14268750, 14268751, 14268755, 14269086, - 14269140, 14269168, 14269178, 14269347, 14269356, 14269543, 14269547, 14269776, 14269820, 14270276, 14270280, 14270283, 14270286, - 14270294, 14270310, 14270354, 14270419, 14270466, 14270486, 14270530, 14270550, 14270654, 14270738, 14270744, 14270751, 14270757, - 14270778, 14270784, 14270811, 14270841, 14270889, 14270897, 14270940, 14270943, 14270967, 14270972, 14271360, 14271401, 14271992, - 14271999, 14272079, 14272130, 14272289, 14272325, 14272717, 14272750, 14274773, 14274777, 14274997, 14275001, 14275127, 14275130, - 14275146, 14275323, 14275353, 14275424, 14275668, 14276086, 14276123, 14276168, 14276309, 14276370, 14276458, 14276520, 14277427, - 14277434, 14277438, 14277439, 14277514, 14277581, 14277637, 14278054, 14278075, 14278093, 14278096, 14278100, 14278142, 14278209, - 14278267, 14278302, 14278331, 14278429, 14278440, 14278687, 14278756, 14278811, 14279537, 14279693, 14279798, 14280053, 14280185, - 14280204, 14280267, 14280452, 14280583, 14280616, 14280703, 14281278, 14281362, 14281532, 14281603, 14281860, 14281911, 14282559, - 14283530, 14283550, 14283560, 14283564, 14283579, 14283595, 14283598, 14283613, 14283697, 14283746, 14284070, 14284218, 14284578, - 14284847, 14286487, 14286490, 14286613, 14286765, 14287334, 14287353, 14287608, 14287664, 14287752, 14287787, 14287796, 14287799, - 14287800, 14287802, 14287945, 14288161, 14288307, 14288451, 14288502, 14288846, 14288983, 14289001, 14289005, 14289016, 14289060, - 14289723, 14290173, 14290424, 14290457, 14290459, 14290506, 14290571, 14290766, 14290801, 14290962, 14291669, 14291708, 14291718, - 14291815, 14292939, 14292956, 14293247, 14293268, 14293297, 14293393, 14293441, 14293602, 14293740, 14293803, 14294518, 14294563, - 14294601, 14294625, 14295118, 14295131, 14295183, 14295205, 14295233, 14295243, 14295256, 14295279, 14295325, 14295328, 14295332, - 14295394, 14295420, 14295683, 14295688, 14295809, 14296174, 14296471, 14296495, 14296520, 14296596, 14296598, 14296727, 14296803, - 14296887, 14296913, 14296925, 14297069, 14297070, 14297260, 14297371, 14297452, 14297529, 14297538, 14297676, 14297759, 14297807, - 14297822, 14298409, 14298639, 14298896, 14298903, 14298932, 14299363, 14299554, 14300286, 14300298, 14300301, 14300495, 14300640, - 14300659, 14301074, 14301263, 14301438, 14301472, 14301639, 14301663, 14301665, 14301705, 14301827, 14302166, 14302216, 14302438, - 14302631, 14302782, 14302982, 14303337, 14303485, 14303928, 14304191, 14304195, 14304374, 14304577, 14304591, 14304640, 14305416, - 14305568, 14305668, 14305702, 14305917, 14305920, 14306074, 14306134, 14306454, 14307152, 14307386, 14307402, 14307413, 14307462, - 14307466, 14307547, 14307632, 14307804, 14307929, 14308045, 14308232, 14308345, 14308437, 14308448, 14309558, 14309627, 14309634, - 14309679, 14309714, 14309805, 14309832, 14309939, 14310154, 14310541, 14310658, 14310887, 14310987, 14311341, 14312039, 14312218, - 14312227, 14312251, 14312317, 14312327, 14312447, 14312532, 14313179, 14313565, 14313860, 14313880, 14313896, 14313985, 14314069, - 14314262, 14314503, 14314504, 14315064, 14315149, 14315158, 14315195, 14315406, 14315429, 14315534, 14315796, 14316030, 14316190, - 14316259, 14316600, 14316647, 14316861, 14317147, 14317635, 14317647, 14317657, 14317734, 14317812, 14317833, 14317844, 14317921, - 14317930, 14317937, 14317942, 14317945, 14317982, 14317988, 14318921, 14318922, 14319270, 14319315, 14319942, 14320162, 14320227, - 14320284, 14320753, 14320763, 14322722, 14322745, 14322786, 14322880, 14322990, 14323725, 14323744, 14324520, 14324584, 14324706, - 14324707, 14328007, 14328024, 14331549, 14331550, 14331679, 14332651, 14332653, 14332760, 14332764, 14332800, 14332809, 14333294, - 14333328, 14333336, 14333346, 14333551, 14333562, 14334351, 14334509, 14334540, 14334564, 14337693, 14340622, 14342084, 14342092, - 14342313, 14342321, 14342457, 14342462, 14343083, 14343087, 14343141, 14343154, 14343161, 14343551, 14343566, 14343577, 14343609, - 14343647, 14343803, 14343938, 14343962, 14344087, 14344928, 14344933, 14345088, 14345153, 14345161, 14345601, 14345744, 14345777, - 14346561, 14346614, 14346765, 14346782, 14346783, 14347126, 14347150, 14347420, 14347452, 14347570, 14347598, 14347626, 14347635, - 14347637, 14347725, 14347781, 14348725, 14348905, 14349352, 14349447, 14351917, 14352564, 14352616, 14352773, 14352923, 14353039, - 14354130, 14354236, 14354276, 14354277, 14354290, 14354327, 14354329, 14354337, 14354362, 14354420, 14354429, 14354456, 14354679, - 14354688, 14354691, 14354801, 14354829, 14354874, 14354902, 14354918, 14355487, 14355501, 14355611, 14355907, 14356212, 14356334, - 14356358, 14356391, 14356876, 14357035, 14357313, 14357658, 14357681, 14357718, 14357730, 14357799, 14357850, 14357987, 14358091, - 14358190, 14358267, 14358722, 14359057, 14359213, 14359358, 14359371, 14359465, 14359589, 14359597, 14359648, 14359654, 14360676, - 14360709, 14360796, 14361052, 14361484, 14361538, 14361631, 14361731, 14362244, 14362395, 14362428, 14362460, 14362496, 14362567, - 14362798, 14362805, 14362808, 14363004, 14363041, 14363050, 14363058, 14363068, 14363172, 14363510, 14363570, 14363734, 14364469, - 14364510, 14364518, 14365738, 14365742, 14365752, 14365867, 14365890, 14366055, 14366116, 14366211, 14366224, 14366233, 14366246, - 14366288, 14366309, 14366329, 14366429, 14366430, 14366443, 14366448, 14366472, 14366539, 14366589, 14366750, 14366765, 14366794, - 14366934, 14367112, 14367251, 14367272, 14367282, 14367466, 14367467, 14367468, 14367469, 14367477, 14367496, 14367530, 14367687, - 14367800, 14367833, 14367960, 14368004, 14368015, 14368024, 14368061, 14368069, 14368160, 14368167, 14368170, 14368194, 14368302, - 14368786, 14368797, 14368798, 14368810, 14368823, 14370205, 14370209, 14370844, 14370852, 14371635, 14371854, 14372502, 14372811, - 14375059, 14375196, 14375337, 14375353, 14376850, 14377162, 14377188, 14378134, 14378139, 14378142, 14378262, 14378276, 14378281, - 14378284, 14378300, 14378310, 14378366, 14378380, 14378433, 14380203, 14380358, 14380376, 14380432, 14380454, 14380479, 14380500, - 14380502, 14380511, 14380523, 14380526, 14380576, 14381101, 14381108, 14381116, 14381149, 14381187, 14381336, 14381643, 14381650, - 14384971, 14385017, 14385299, 14385327, 14385345, 14385346, 14385398, 14385409, 14386643, 14386717, 14387783, 14387792, 14387814, - 14387938, 14388060, 14388082, 14388164, 14388173, 14388184, 14388185, 14388190, 14388205, 14388211, 14388234, 14388244, 14388337, - 14388466, 14389756, 14389760, 14391505, 14391529, 14392389, 14392425, 14392444, 14392452, 14392466, 14392654, 14393420, 14393502, - 14393594, 14393595, 14393599, 14393671, 14394385, 14395110, 14395112, 14395122, 14395139, 14395232, 14395237, 14395341, 14395364, - 14395414, 14395416, 14397686, 14397758, 14397792, 14397865, 14398937, 14398955, 14398982, 14399110, 14399114, 14399131, 14399141, - 14399198, 14399200, 14399218, 14399248, 14399251, 14399276, 14399914, 14399919, 14399960, 14399989, 14399992, 14400040, 14400043, - 14400048, 14400097, 14400128, 14400131, 14402470, 14402526, 14402741, 14402794, 14402800, 14402805, 14402891, 14402926, 14404738, - 14404762, 14404988, 14405199, 14405204, 14405237, 14405348, 14406107, 14406164, 14406177, 14406665, 14406666, 14406887, 14406900, - 14406901, 14406982, 14406984, 14407108, 14407204, 14407309, 14407326, 14408372, 14408387, 14408522, 14408523, 14408534, 14408798, - 14408824, 14408858, 14410649, 14410860, 14410915, 14410986, 14411113, 14411190, 14411745, 14411764, 14412210, 14412275, 14412297, - 14412428, 14412434, 14412741, 14412857, 14412866, 14412869, 14413198, 14413199, 14413906, 14413934, 14414045, 14414168, 14414430, - 14414443, 14414710, 14415221, 14415252, 14415388, 14415429, 14415469, 14415513, 14415554, 14415608, 14415656, 14415660, 14415666, - 14415927, 14415975, 14416165, 14417518, 14418203, 14418277, 14418301, 14418317, 14418392, 14418533, 14418543, 14418546, 14419038, - 14419373, 14419466, 14419469, 14419481, 14419488, 14419499, 14419512, 14419521, 14419616, 14419697, 14419698, 14419805, 14419900, - 14419928, 14419929, 14419941, 14419942, 14419962, 14420023, 14420069, 14420082, 14420084, 14420086, 14420091, 14420094, 14420112, - 14420116, 14420129, 14420131, 14420180, 14420183, 14420193, 14420247, 14420253, 14420256, 14420275, 14420293, 14420303, 14420341, - 14420348, 14420480, 14420699, 14420814, 14420849, 14420851, 14420971, 14421014, 14421036, 14421045, 14421046, 14421169, 14421176, - 14421440, 14421858, 14421886, 14421920, 14422148, 14422321, 14422453, 14422593, 14422767, 14422856, 14423018, 14423133, 14423196, - 14423206, 14423268, 14423271, 14423515, 14423532, 14423583, 14423860, 14423881, 14423932, 14424014, 14424043, 14424067, 14424296, - 14424429, 14424452, 14424558, 14424562, 14424571, 14424585, 14424586, 14424589, 14424636, 14424685, 14424736, 14424750, 14424769, - 14425463, 14425546, 14425574, 14425575, 14425633, 14425767, 14425781, 14425849, 14425993, 14426028, 14426072, 14426221, 14426583, - 14427051, 14427197, 14427202, 14427208, 14427399, 14427441, 14427452, 14427473, 14427870, 14428817, 14428898, 14428920, 14429168, - 14429174, 14429180, 14429324, 14430071, 14430108, 14430138, 14430143, 14430231, 14430255, 14430816, 14430855, 14430886, 14430899, - 14430901, 14430902, 14430905, 14430924, 14430965, 14431006, 14431063, 14431282, 14431502, 14431545, 14431559, 14431720, 14431721, - 14432038, 14432172, 14432192, 14432201, 14432626, 14432636, 14432638, 14433023, 14433345, 14433362, 14433891, 14433944, 14434390, - 14434409, 14434414, 14434471, 14434649, 14436439, 14436511, 14436521, 14436616, 14436975, 14437026, 14437134, 14437167, 14437191, - 14437201, 14437204, 14437205, 14437268, 14437527, 14437534, 14437547, 14437565, 14437613, 14437807, 14437820, 14438118, 14438156, - 14438160, 14438162, 14438168, 14438215, 14438333, 14438365, 14438531, 14438538, 14438956, 14439014, 14439085, 14439105, 14439107, - 14439173, 14439501, 14439515, 14439776, 14439868, 14440295, 14440312, 14440363, 14440392, 14440418, 14440420, 14440431, 14440986, - 14440993, 14441010, 14441090, 14441114, 14441175, 14441182, 14441421, 14441424, 14441436, 14441455, 14442331, 14442410, 14442412, - 14442499, 14442590, 14443032, 14443124, 14443702, 14443783, 14443785, 14443880, 14443986, 14443987, 14443996, 14444016, 14444291, - 14444335, 14444348, 14444958, 14445106, 14445730, 14445744, 14445796, 14445857, 14445956, 14445960, 14449012, 14449107, 14449279, - 14449287, 14450086, 14450107, 14450169, 14450196, 14451369, 14451491, 14451664, 14451679, 14452080, 14452088, 14452158, 14452281, - 14452377, 14452464, 14454060, 14454100, 14454259, 14454284, 14455932, 14455937, 14456161, 14456169, 14456173, 14456215, 14456220, - 14456251, 14456262, 14456272, 14456374, 14456386, 14456389, 14456408, 14456422, 14456596, 14456654, 14456697, 14456714, 14457226, - 14457236, 14457251, 14457272, 14457294, 14457295, 14457323, 14457332, 14457341, 14457872, 14457925, 14458268, 14458361, 14462180, - 14462204, 14462241, 14462308, 14464172, 14464255, 14466306, 14466331, 14466411, 14466425, 14466470, 14466488, 14466497, 14466523, - 14466972, 14466984, 14467004, 14467023, 14468341, 14468496, 14469581, 14469604, 14469619, 14469675, 14470339, 14470341, 14470456, - 14470514, 14470520, 14470622, 14470887, 14470888, 14471412, 14471417, 14471591, 14471594, 14473086, 14473092, 14473096, 14473097, - 14473637, 14473642, 14475479, 14475496, 14475695, 14475733, 14476630, 14476676, 14476712, 14476812, 14477122, 14477145, 14477588, - 14477589, 14477594, 14477605, 14477607, 14477633, 14477742, 14477772, 14477777, 14478030, 14478043, 14478624, 14478666, 14479141, - 14479784, 14479865, 14479943, 14479950, 14479961, 14481636, 14481637, 14481722, 14481726, 14481758, 14481986, 14481997, 14482096, - 14482102, 14482118, 14482138, 14482420, 14482427, 14482457, 14482487, 14482508, 14482687, 14482693, 14482834, 14482845, 14483435, - 14483438, 14483442, 14483453, 14483471, 14483605, 14483834, 14483839, 14484322, 14484339, 14484341, 14484392, 14484412, 14484498, - 14484698, 14484752, 14484755, 14488867, 14488878, 14488894, 14488896, 14489287, 14489291, 14489510, 14489549, 14490029, 14490073, - 14490084, 14490085, 14490086, 14490088, 14490123, 14490128, 14490190, 14490213, 14490644, 14490652, 14490708, 14490728, 14490903, - 14490908, 14491415, 14491754, 14491757, 14491758, 14491805, 14492838, 14493628, 14494367, 14494372, 14494373, 14494376, 14494379, - 14494381, 14494646, 14494656, 14494661, 14494752, 14494868, 14494907, 14494921, 14494941, 14494953, 14494954, 14495034, 14495065, - 14495075, 14495076, 14495135, 14495154, 14495165, 14495173, 14495188, 14495192, 14495488, 14495493, 14495495, 14495501, 14495644, - 14495687, 14495688, 14495840, 14495967, 14495968, 14496394, 14496406, 14496408, 14496432, 14496500, 14496551, 14496604, 14496966, - 14497034, 14497038, 14497550, 14497568, 14497570, 14497668, 14497702, 14497706, 14497708, 14497820, 14497848, 14497895, 14497913, - 14497935, 14497937, 14498323, 14498354, 14498355, 14501002, 14501005, 14501526, 14502186, 14502208, 14502215, 14502229, 14502284, - 14502295, 14502315, 14502353, 14502605, 14502627, 14502635, 14502663, 14502758, 14502769, 14503020, 14503058, 14503061, 14503068, - 14503086, 14503134, 14503288, 14503395, 14503429, 14503435, 14503522, 14503525, 14504153, 14504162, 14504169, 14504173, 14504371, - 14504422, 14504432, 14504442, 14507145, 14507147, 14507476, 14507486, 14507489, 14507515, 14507520, 14507570, 14507702, 14507732, - 14508208, 14508212, 14509089, 14509103, 14509612, 14509623, 14511370, 14511373, 14511378, 14511379, 14511768, 14511773, 14512246, - 14512248, 14514087, 14514094, 14514100, 14514117, 14514130, 14514133, 14514156, 14514162, 14514508, 14514588, 14514908, 14514918, - 14514964, 14514971, 14514989, 14515007, 14515063, 14515165, 14515419, 14515421, 14515591, 14515593, 14515714, 14515716, 14515719, - 14515720, 14515748, 14515749, 14515854, 14515860, 14515903, 14515904, 14515951, 14515955, 14515993, 14515997, 14516253, 14516270, - 14516372, 14516412, 14516497, 14516503, 14517397, 14517439, 14519618, 14519619, 14519694, 14519701, 14519702, 14519714, 14519776, - 14519782, 14519803, 14519804, 14519955, 14519996, 14520020, 14520024, 14520043, 14520060, 14520061, 14520062, 14520115, 14520126, - 14520159, 14520172, 14520186, 14520190, 14520198, 14520212, 14520222, 14520227, 14520235, 14520497, 14520498, 14520746, 14520774, - 14520977, 14520982, 14520986, 14521011, 14521066, 14521069, 14522110, 14522112, 14522118, 14522165, 14522218, 14522219, 14522733, - 14522797, 14523118, 14523126, 14523830, 14523835, 14524242, 14524243, 14524259, 14524266, 14526070, 14526077, 14526083, 14526086, - 14526087, 14526099, 14526120, 14526126, 14526141, 14526211, 14526215, 14526221, 14526244, 14526255, 14526300, 14526321, 14526332, - 14526340, 14526344, 14526346, 14526356, 14526363, 14526380, 14526442, 14526463, 14527065, 14527080, 14527084, 14527176, 14527178, - 14527369, 14527370, 14527424, 14527431, 14527447, 14527451, 14527599, 14527626, 14527627, 14527633, 14527696, 14527715, 14527723, - 14527735, 14527839, 14528084, 14528085, 14528093, 14528124, 14528171, 14528614, 14528712, 14528723, 14528757, 14528758, 14528864, - 14528925, 14528961, 14528969, 14528986, 14528993, 14528997, 14529009, 14529012, 14529017, 14529021, 14529024, 14529026, 14529029, - 14529033, 14529037, 14529046, 14529100, 14529124, 14529557, 14530096, 14530149, 14531104, 14531141, 14531213, 14531235, 14531744, - 14531775, 14531956, 14531968, 14531999, 14532026, 14532066, 14532097, 14532696, 14532706, 14532729, 14532730, 14532739, 14532749, - 14532758, 14532838, 14532843, 14533032, 14533035, 14533049, 14533066, 14533070, 14533079, 14533136, 14533141, 14533267, 14533299, - 14533319, 14533321, 14533346, 14533372, 14533410, 14533430, 14533442, 14533526, 14533548, 14533722, 14533805, 14533836, 14533847, - 14533860, 14533861, 14533873, 14533878, 14533920, 14534184, 14534185, 14534191, 14534193, 14534233, 14534256, 14534343, 14534366, - 14534397, 14534426, 14535016, 14535017, 14535020, 14535028, 14535045, 14535083, 14535119, 14535180, 14535199, 14535394, 14535426, - 14535428, 14535456, 14535475, 14535634, 14535662, 14535688, 14535691, 14535692, 14535702, 14536479, 14536480, 14536489, 14536490, - 14536492, 14536493, 14538931, 14538950, 14539037, 14539038, 14539216, 14539309, 14539334, 14539344, 14539390, 14539420, 14539473, - 14539534, 14539537, 14539564, 14540149, 14540166, 14540656, 14540667, 14540769, 14540796, 14541039, 14541063, 14541069, 14541071, - 14541159, 14541165, 14541181, 14541201, 14541315, 14541323, 14541325, 14541328, 14541535, 14542840, 14542888, 14542906, 14542907, - 14543190, 14543248, 14543853, 14543908, 14544590, 14544596, 14544603, 14544616, 14544670, 14544671, 14544700, 14544710, 14544746, - 14544754, 14544827, 14544828, 14544837, 14544856, 14544877, 14544962, 14545025, 14545172, 14545204, 14545224, 14545226, 14545234, - 14545464, 14545483, 14545723, 14545743, 14545958, 14545994, 14546116, 14546131, 14546151, 14546163, 14546371, 14546380, 14546408, - 14546419, 14546448, 14546450, 14546509, 14546553, 14546560, 14546608, 14546630, 14546636, 14546678, 14546684, 14546867, 14546869, - 14547247, 14547249, 14547565, 14547577, 14547724, 14547850, 14547854, 14547861, 14547962, 14548000, 14550132, 14550221, 14552498, - 14552506, 14552667, 14552671, 14552813, 14552828, 14553470, 14553472, 14553476, 14554183, 14554188, 14554192, 14554225, 14554740, - 14554785, 14555988, 14556013, 14556021, 14556022, 14556083, 14556084, 14556089, 14556092, 14556100, 14556103, 14556108, 14556140, - 14556651, 14558534, 14559061, 14559072, 14559085, 14559733, 14559791, 14560016, 14560026, 14560028, 14560038, 14560040, 14560076, - 14560273, 14560275, 14560303, 14560306, 14560310, 14560322, 14560576, 14560577, 14560582, 14560595, 14560608, 14560622, 14560728, - 14560734, 14561795, 14561825, 14561840, 14562587, 14562623, 14562630, 14562645, 14563527, 14563541, 14563542, 14563549, 14563729, - 14563739, 14563740, 14563748, 14563749, 14563755, 14563766, 14563768, 14563774, 14563775, 14563894, 14563959, 14563963, 14563967, - 14564050, 14564054, 14564058, 14564075, 14564164, 14564730, 14564733, 14565457, 14565462, 14565943, 14566817, 14566822, 14588081, - 15278993, 15298860, 15299275, 15299420, 15299520, 15299715, 15299731, 15299757, 15301708, 15301850, 15301875, 15302455, 15302967, - 15304019, 15305121, 15305561, 15307407, 15307490, 15307868, 15308032, 15311107, 15311210, 15311599, 15316343, 15316528, 15316535, - 15317411, 15318069, 15318235, 15318288, 15318437, 15318758, 15319019, 15319366, 15319403, 15320313, 15321005, 15321511, 15321634, - 15321707, 15321890, 15322055, 15322136, 15323088, 15323182, 15323543, 15324636, 15327600, 15328789, 15328903, 15328961, 15329151, - 15330358, 15330441, 15330468, 15331215, 15331280, 15333764, 15333830, 15335397, 15336059, 15337247, 15337395, 15337630, 15339099, - 15340038, 15340971, 15341319, 15341479, 15341544, 15342783, 15343155, 15343302, 15343551, 15343809, 15344150, 15344169, 15344370, - 15344584, 15346218, 15346421, 15346604, 15346684, 15346714, 15346716, 15350123, 15350143, 15350966, 15351041, 15351346, 15351348, - 15352316, 15352341, 15353576, 15353802, 15354436, 15354503, 15354708, 15354744, 15355751, 15355938, 15356263, 15356464, 15357773, - 15357806, 15357836, 15357870, 15359242, 15359261, 15359409, 15359557, 15359701, 15359731, 15359846, 15359932, 15360348, 15360351, - 15360966, 15360968, 15360998, 15361018, 15363267, 15363312, 15363413, 15363420, 15363920, 15364070, 15364136, 15364150, 15364663, - 15364715, 15367310, 15367326, 15368095, 15368104, 15368537, 15368541, 15368874, 15368881, 15369797, 15369898, 15370883, 15370885, - 15371463, 15371516, 15372941, 15373029, 15373035, 15373039, 15373489, 15373548, 15374297, 15374326, 15374448, 15374596, 15375231, - 15375318, 15375776, 15375803, 15376049, 15376057, 15377278, 15377371, 15378036, 15378043, 15378052, 15378059, 15378164, 15378166, - 15379378, 15379430, 15379848, 15379863, 15379880, 15379890, 15381333, 15381472, 15381587, 15381594, 15382319, 15382335, 15382622, - 15382689, 15384884, 15384889, 15386453, 15386482, 15386506, 15386762, 15386943, 15387036, 15387461, 15387465, 15387752, 15387804, - 15388394, 15388486, 15388606, 15388617, 15389904, 15390109, 15390434, 15390437, 15390816, 15390866, 15393023, 15393050, 15393079, - 15393299, 15393785, 15393789, 15394171, 15394184, 15394223, 15394363, 15397304, 15397311, 15397367, 15397572, 15398540, 15398542, - 15398966, 15398984, 15400273, 15400276, 15400610, 15400638, 15401565, 15401650, 15404521, 15404620, 15406007, 15406017, 15406624, - 15406687, 15407958, 15407964, 15408278, 15408287, 15410615, 15410769, 15411104, 15411119, 15411326, 15411591, 15411833, 15411836, - 15413038, 15413046, 15413111, 15413148, 15413371, 15413374, 15413483, 15413499, 15415282, 15415416, 15417725, 15417802, 15417896, - 15417906, 15419558, 15419604, 15419797, 15419800, 15419980, 15420000, 15420016, 15420019, 15421514, 15421544, 15423424, 15423558, - 15423661, 15423673, 15424869, 15424873, 15425240, 15425382, 15425895, 15425897, 15426289, 15426372, 15427195, 15427225, 15427230, - 15427233, 15427289, 15427298, 15427993, 15427999, 15428176, 15428217, 15428227, 15428516, 15428529, 15428567, 15428784, 15429008, - 15429020, 15429026, 15429032, 15429281, 15430344, 15430346, 15430706, 15430735, 15430879, 15430885, 15431260, 15431365, 15432397, - 15432422, 15432649, 15432654, 15432804, 15432819, 15433923, 15433932, 15435272, 15435298, 15437041, 15437050, 15438105, 15438114, - 15440121, 15440253, 15441104, 15441282, 15442199, 15442584, 15443871, 15444142, 15444188, 15444408, 15444685, 15444690, 15445733, - 15445736, 15445863, 15445878, 15447031, 15447065, 15448796, 15448816, 15449403, 15449413, 15449587, 15449609, 15449711, 15449878, - 15449962, 15449964, 15450263, 15450405, 15450446, 15450450, 15451400, 15451408, 15451819, 15451857, 15452179, 15452192, 15452979, - 15453020, 15453357, 15453514, 15455431, 15455434, 15455761, 15455880, 15456762, 15456784, 15457983, 15459043, 15459439, 15459567, - 15459814, 15459822, 15460508, 15460591, 15461069, 15461082, 15462424, 15462426, 15462594, 15462656, 15462690, 15462696, 15463436, - 15463936, 15464266, 15465784, 15465839, 15465937, 15466610, 15466631, 15467021, 15467085, 15467103, 15467109, 15467756, 15467851, - 15468430, 15468503, 15468511, 15468652, 15469184, 15469200, 15469285, 15469458, 15469754, 15469759, 15470276, 15470283, 15470370, - 15470392, 15471545, 15471785, 15473261, 15473269, 15473454, 15473460, 15474422, 15474425, 15474922, 15475151, 15475640, 15475643, - 15476163, 15476405, 15476427, 15476439, 15477009, 15477179, 15477640, 15477649, 15479093, 15479107, 15480142, 15480151, 15480580, - 15480814, 15481022, 15481026, 15481035, 15481037, 15481562, 15481565, 15481590, 15481591, 15481741, 15481744, 15482067, 15482078, - 15482616, 15482683, 15486561, 15486564, 15486616, 15486617, 15486666, 15486668, 15486678, 15486680, 15487459, 15487500, 15488119, - 15488127, 15488401, 15488409, 15488440, 15488442, 15488965, 15488970, 15489694, 15489700, 15490595, 15490615, 15491720, 15491760, - 15492016, 15492020, 15492072, 15492087, 15492855, 15492857, 15493002, 15493004, 15493071, 15493074, 15493106, 15493108, 15493360, - 15493365, 15494319, 15494332, 15496258, 15496263, 15497235, 15497254, 15497321, 15497338, 15498352, 15498354, 15499365, 15499369, - 15501348, 15501354, 15502470, 15502478, 15503665, 15503673, 15504523, 15504537, 15504621, 15504628, 15504938, 15505080, 15506069, - 15506072, 15506112, 15506113, 15506426, 15506436, 15507433, 15507435, 15508130, 15508192, 15508250, 15508358, 15510418, 15510430, - 15510706, 15510712, 15511523, 15511526, 15511628, 15511629, 15512065, 15512071, 15512120, 15512121, 15513126, 15513199, 15513214, - 15513441, 15514260, 15514460, 15515518, 15515520, 15515699, 15515701, 15516480, 15516482, 15517627, 15517654, 15518075, 15518102, - 15519576, 15519578, 15520859, 15520864, 15521342, 15521351, 15521537, 15521553, 15521701, 15521707, 15522808, 15523015, 15523483, - 15523488, 15524388, 15524397, 15524703, 15524713, 15525341, 15525343, 15525349, 15525353, 15526412, 15526559, 15527127, 15527133, - 15527672, 15527675, 15528231, 15528248, 15528274, 15528307, 15529512, 15529522, 15529961, 15530071, 15530915, 15530926, 15531367, - 15531370, 15533472, 15533487, 15534560, 15534786, 15535306, 15535318, 15535392, 15535522, 15538116, 15539371, 15540337, 15540602, - 15541064, 15541071, 15541659, 15541666, 15541681, 15541719, 15541771, 15541777, 15542276, 15542282, 15542576, 15542585, 15542589, - 15542594, 15542886, 15542896, 15543880, 15543976, 15544196, 15546926, 15547006, 15547018, 15547117, 15547119, 15547436, 15547520, - 15547554, 15547587, 15547642, 15547644, 15549036, 15549039, 15549429, 15549448, 15550823, 15550828, 15551147, 15551381, 15551716, - 15551720, 15552150, 15552267, 15554087, 15554090, 15554449, 15554456, 15555207, 15555210, 15556032, 15556037, 15556177, 15556184, - 15557755, 15557761, 15558433, 15558443, 15559082, 15559107, 15560806, 15560890, 15561941, 15562075, 15562258, 15562260, 15563500, - 15563507, 15563620, 15563624, 15565974, 15565985, 15566159, 15566161, 15566675, 15567720, 15567772, 15697646, 15698252, 15699048, - 15699049, 15699308, 15699355, 15701033, 15701037, 15701139, 15701868, 15722361, 15723839, 15725644, 15726602, 15726621, 15726727, - 15726730, 15728420, 15728425, 15729973, 15729986, 15731110, 15731125, 15732349, 15732819, 15733345, 15733382, 15736966, 15741478, - 15742747, 15743712, 15744541, 15746902, 15748357, 15751438, 15751801, 15754322, 15755697, 15768595, 15768635, 15768636, 15771170, - 15771235, 15771418, 15771566, 15772511, 15772514, 15773217, 15773287, 15773693, 15775062, 15775162, 15775170, 15775628, 15775748, - 15777966, 15778518, 15780571, 15780590, 15781334, 15781414, 15783805, 15784103, 15784218, 15784222, 15784336, 15786288, 15786350, - 15786412, 15786880, 15787424, 15791418, 15791577, 15791945, 15792759, 15792904, 15792905, 15793375, 15799982, 15800147, 15800148, - 15800738, 15800739, 15801497, 15801498, 15803568, 15803571, 15805641, 15808771, 15809000, 15815539, 15815540, 15815571, 15816365, - 15816366, 15820482, 15820483, 15820930, 15820933, 15822783, 15822784, 15823306, 15823308, 15823485, 15823486, 15827101, 15827102, - 15830019, 15830020, 15830105, 15830106, 15835137, 15835138, 15838243, 15839723, 15840576, 15841503, 15841688, 15841690, 15847048, - 15847050, 15847745, 15848829, 15850375, 15855827, 15859288, 15859289, 15860023, 15860373, 15860606, 15860607, 15860828, 15860829, - 15861647, 15861648, 15861982, 15861983, 15863539, 15865475, 15865811, 15865812, 15865814, 15865819, 15865939, 15865940, 15866722, - 15866723, 15867794, 15869548, 15870297, 15870823, 15870956, 15870957, 15871190, 15871197, 15871254, 15871766, 15872132, 15873270, - 15875334, 15875634, 15875797, 15876025, 15876802, 15876803, 15876808, 15876810, 15876831, 15876833, 15876844, 15876845, 15876858, - 15876859, 15876865, 15876866, 15876996, 15877054, 15877147, 15878253, 15878396, 15878397, 15878409, 15878410, 15880251, 15880252, - 15880976, 15883223, 15883257, 15883258, 15883267, 15883268, 15883338, 15883366, 15883572, 15883573, 15883704, 15883705, 15883815, - 15883866, 15884708, 15885134, 15886585, 15886948, 15889015, 15889135, 15889263, 15889264, 15889297, 15890107, 15890836, 15890856, - 15891258, 15891259, 15891595, 15891596, 15898995, 15899413, 15900484, 15900485, 15900856, 15900857, 15900999, 15901784, 15902052, - 15902074, 15903287, 15904479, 15904560, 15904561, 15904756, 15904948, 15905428, 15905429, 15908728, 15908729, 15908732, 15908733, - 15908737, 15908739, 15911168, 15911169, 15911465, 15911466, 15912295, 15912378, 15912429, 15912435, 15912645, 15913367, 15915228, - 15915229, 15915232, 15915233, 15915473, 15915474, 15915509, 15915510, 15915885, 15915886, 15916207, 15916208, 15916906, 15916907, - 15917200, 15917202, 15917206, 15917207, 15921490, 15921491, 15921519, 15922789, 15923115, 15923117, 15924339, 15924525, 15924533, - 15926434, 15927196, 15928263, 15929673, 15929674, 15929698, 15929766, 15930272, 15941143, 15941944, 15941945, 15941949, 15941950, - 15941954, 15941955, 15941966, 15941967, 15942041, 15942242, 15943918, 15944225, 15944958, 15948423, 15948742, 15948893, 15948934, - 15948935, 15948952, 15948953, 15948974, 15948975, 15948980, 15948981, 15948984, 15948985, 15948995, 15948996, 15949061, 15949062, - 15950050, 15950051, 15950637, 15950638, 15950642, 15950643, 15950646, 15950647, 15950650, 15950651, 15950666, 15950667, 15950686, - 15950687, 15951694, 15951695, 15951941, 15951942, 15951970, 15951971, 15951974, 15951975, 15951978, 15951979, 15952040, 15954672, - 15956700, 15956815, 15957170, 15957963, 15965549, 15968309, 15969082, 15969120, 15970110, 15970111, 15970828, 15970854, 15971891, - 15971916, 15971980, 15972006, 15973526, 15973527, 15973835, 15974371, 15976265, 15977379, 15978362, 15978948, 15979197, 15980087, - 15980290, 15980299, 15981105, 15981106, 15981914, 15981915, 15982995, 15985005, 15985847, 15986020, 15986468, 15990277, 15990962, - 15991688, 15992374, 15992627, 15992966, 15994933, 15995140, 15995217, 15998964, 16006307, 16010481, 16011214, 16012893, 16013844, - 16015906, 17636688, 17637873, 17638275, 17638348, 17638487, 17638892, 17664726, 17667175, 17673330, 17673544, 17673816, 17681905, - 17685084, 17685085, 17687705, 17691885, 17692405, 17693311, 17694199, 17698519, 17699421, 17699575, 17699776, 17704976, 17705868, - 17707335, 17707490, 17710949, 17711356, 17711906, 17712444, 17720306, 17720567, 17723439, 17723538, 17729149, 17729172, 17730669, - 17735353, 17738506, 17739593, 17742978, 17746144, 17752865, 17759547, 17770240, 17774229, 17774250, 17778606, 17779105, 17782179, - 17783310, 17783420, 17784087, 17791119, 17792330, 17793195, 17795208, 17796208, 17798702, 17803925, 17806758, 17808553, 17811929, - 17815836, 17818217, 17853647, 17855162, 17855180, 17874661, 17881967, 17886031, 17886472, 17886499, 17892400, 17892586, 17893593, - 17918105, 17920208, 17923983, 17932312, 17940478, 17949572, 17950256, 17978577, 17978638, 17979243, 17981913, 17981914, 17986345, - 17995612, 17998455, 18001936, 18018601, 18019359, 18020832, 18020852, 18020857, 18021161, 18024791, 18028665, 18028982, 18029024, - 18029065, 18029402, 18029410, 18029412, 18029430, 18029461, 18029535, 18029709, 18029941, 18030109, 18030158, 18030174, 18030618, - 18030897, 18031010, 18031050, 18031102, 18031119, 18033407, 18033471, 18033519, 18034800, 18035522, 18035524, 18035558, 18035587, - 18035592, 18035611, 18035718, 18036283, 18037159, 18037177, 18037518, 18037756, 18037831, 18038107, 18038314, 18040137, 18040830, - 18042044, 18042107, 18042113, 18042989, 18044136, 18044214, 18045284, 18046457, 18046504, 18046619, 18046757, 18047186, 18047597, - 18047661, 18047776, 18047878, 18047880, 18048688, 18049264, 18050153, 18050586, 18050926, 18051022, 18052532, 18052575, 18052827, - 18053165, 18053676, 18053753, 18054135, 18055170, 18056994, 18057401, 18057693, 18057697, 18058403, 18058457, 18058779, 18058896, - 18059950, 18059951, 18061046, 18061130, 18061163, 18061330, 18062045, 18062047, 18062332, 18063045, 18063475, 18063531, 18063738, - 18064294, 18065075, 18065242, 18065980, 18066212, 18066443, 18066962, 18067060, 18067533, 18067720, 18067880, 18067908, 18067926, - 18069030, 18069287, 18069478, 18069486, 18070682, 18070696, 18070945, 18070960, 18071100, 18071247, 18071778, 18071877, 18071965, - 18072000, 18072080, 18072170, 18072197, 18072238, 18072391, 18072987, 18073243, 18074765, 18075302, 18075625, 18075780, 18075781, - 18075911, 18075915, 18075944, 18075961, 18078850, 18079649, 18082360, 18084867, 18084911, 18085324, 18085709, 18087962, 18087963, - 18088191, 18088242, 18088250, 18088280, 18088356, 18088559, 18088585, 18088685, 18088801, 18089141, 18089688, 18089823, 18090573, - 18092942, 18093321, 18093525, 18093792, 18094278, 18094280, 18094353, 18094818, 18095086, 18096830, 18096870, 18096945, 18099264, - 18099563, 18103567, 18105534, 18105712, 18105730, 18106676, 18106758, 18107898, 18108072, 18108109, 18108251, 18108364, 18108366, - 18108385, 18108608, 18109192, 18109630, 18109736, 18109886, 18110216, 18111914, 18117472, 18120015, 18121451, 18121461, 18123475, - 18126178, 18127068, 18127313, 18128050, 18128330, 18128335, 18128741, 18129173, 18129186, 18129274, 18129299, 18129598, 18129647, - 18130999, 18131052, 18132357, 18132384, 18132993, 18133129, 18133459, 18134121, 18134494, 18134563, 18134668, 18134725, 18135378, - 18135538, 18135637, 18136098, 18136421, 18136723, 18136850, 18138655, 18138798, 18139149, 18139266, 18139885, 18144618, 18145061, - 18145076, 18145167, 18145171, 18145489, 18145498, 18151530, 18154233, 18157193, 18157230, 18157352, 18157653, 18158227, 18159887, - 18160433, 18160599, 18163130, 18167158, 18167584, 18167696, 18168147, 18168194, 18169252, 18169257, 18169269, 18171907, 18171970, - 18173270, 18173746, 18173941, 18173950, 18174259, 18174963, 18176304, 18176339, 18176342, 18177237, 18177283, 18177395, 18177473, - 18177557, 18177648, 18178048, 18178068, 18179144, 18179923, 18180023, 18180031, 18182471, 18182554, 18183350, 18185302, 18186630, - 18189759, 18191550, 18191572, 18191690, 18191760, 18209428, 18209658, 18210069, 18210134, 18211447, 18211680, 18213658, 18214305, - 18226915, 18227231, 18233695, 18234036, 18234679, 18237160, 18237345, 18237354, 18237447, 18238159, 18238169, 18238305, 18238306, - 18238341, 18239452, 18239552, 18239591, 18242107, 18243775, 18247187, 18248062, 18248090, 18248152, 18248702, 18248948, 18251287, - 18253159, 18253172, 18253256, 18253494, 18253674, 18253702, 18253731, 18253737, 18254465, 18254579, 18254961, 18255157, 18255423, - 18255953, 18255964, 18255975, 18256059, 18256119, 18256175, 18256361, 18258481, 18258531, 18258617, 18258894, 18258898, 18258975, - 18259049, 18259278, 18259287, 18259310, 18260016, 18261458, 18261488, 18261623, 18262488, 18262528, 18262642, 18262749, 18262798, - 18262808, 18262813, 18262819, 18262827, 18262860, 18263274, 18265073, 18265373, 18274127, 18274713, 18274727, 18275088, 18275112, - 18275130, 18278505, 18278955, 18279067, 18279081, 18282620, 18282661, 18283406, 18283563, 18283848, 18284148, 18284248, 18284447, - 18284548, 18285101, 18285102, 18285296, 18285465, 18285587, 18286538, 18286732, 18286922, 18287028, 18287423, 18287435, 18288316, - 18288614, 18288684, 18289315, 18289388, 18289811, 18290157, 18291493, 18291622, 18291700, 18291765, 18292103, 18292104, 18292192, - 18292266, 18293383, 18293550, 18293680, 18293751, 18293811, 18294213, 18294759, 18299826, 18299990, 18300398, 18301246, 18301327, - 18303702, 18303813, 18304121, 18306402, 18306490, 18306738, 18307134, 18307258, 18307380, 18307382, 18307680, 18308694, 18308707, - 18308744, 18308789, 18308936, 18309470, 18309756, 18310124, 18310324, 18310679, 18313272, 18313276, 18313936, 18313942, 18314463, - 18314471, 18314489, 18314786, 18314944, 18314957, 18315430, 18315905, 18315975, 18316319, 18316622, 18316913, 18317424, 18317507, - 18317562, 18317614, 18318101, 18318833, 18319890, 18320642, 18320688, 18322258, 18322526, 18322711, 18323528, 18323546, 18324258, - 18326071, 18328517, 18329261, 18333428, 18334440, 18334468, 18340005, 18340701, 18341515, 18342104, 18343985, 18344306, 18344387, - 18344445, 18349782, 18354524, 18354532, 18354567, 18354647, 18355784, 18355800, 18355890, 18356093, 18356174, 18357105, 18358907, - 18359179, 18360540, 18360761, 18361109, 18362474, 18362701, 18363071, 18363333, 18363353, 18363359, 18363669, 18363849, 18364852, - 18365537, 18365642, 18370037, 18374101, 18374518, 18374703, 18378858, 18378979, 18379121, 18388650, 18392831, 18392906, 18393035, - 18393498, 18395705, 18396655, 18396696, 18399717, 18399721, 18399791, 18399885, 18400237, 18400318, 18401555, 18403896, 18403898, - 18403948, 18403950, 18404071, 18404074, 18404115, 18404117, 18404169, 18404170, 18404177, 18404214, 18408893, 18409021, 18409026, - 18409046, 18409296, 18409304, 18409332, 18409338, 18409342, 18409356, 18409383, 18409396, 18409511, 18409551, 18409567, 18409579, - 18409581, 18409638, 18409642, 18409660, 18409669, 18409705, 18409710, 18409737, 18410309, 18410336, 18410366, 18410382, 18410392, - 18410418, 18410426, 18410429, 18410929, 18410976, 18411158, 18414923, 18414966, 18414967, 18414971, 18414973, 18414996, 18415012, - 18415335, 18415343, 18415344, 18415372, 18415383, 18415401, 18415404, 18415409, 18415410, 18415439, 18415463, 18415730, 18415734, - 18415751, 18415752, 18415755, 18415762, 18415770, 18415789, 18415907, 18415911, 18415914, 18415915, 18415918, 18415919, 18415924, - 18415934, 18415935, 18415948, 18415951, 18415960, 18415962, 18415969, 18415974, 18415988, 18415996, 18416003, 18416007, 18416096, - 18416097, 18416098, 18416099, 18416110, 18416111, 18416121, 18417000, 18417004, 18417110, 18417111, 18417153, 18417223, 18417250, - 18417254, 18417255, 18417271, 18417276, 18417298, 18417306, 18418074, 18418081, 18419778, 18419803, 18419847, 18419867, 18419982, - 18420104, 18420138, 18420139, 18420149, 18420289, 18420295, 18421340, 18421341, 18421351, 18421354, 18421396, 18422027, 18422036, - 18422039, 18422146, 18422232, 18422238, 18422335, 18422473, 18422479, 18422569, 18422577, 18422932, 18423232, 18423233, 18423380, - 18423386, 18423801, 18423803, 18424005, 18424006, 18424106, 18424119, 18427918, 18428063, 18428188, 18428190, 18428341, 18428344, - 18428376, 18428378, 18428415, 18429089, 18429190, 18429191, 18429295, 18429301, 18429401, 18429408, 18429419, 18429425, 18429515, - 18429526, 18429763, 18430201, 18430203, 18430403, 18431180, 18431188, 18431554, 18431563, 18431586, 18431622, 18431858, 18431859, - 18432040, 18432050, 18432832, 18433010, 18433079, 18433119, 18459655, 18461356, 18461857, 18462173, 18463453, 18463531, 18479349, - 18479433, 18479437, 18479545, 18479547, 18479583, 18479584, 18479595, 18479615, 18479616, 18479622, 18481099, 18481103, 18481144, - 18481145, 18481150, 18481262, 18481457, 18481554, 18481769, 18485920, 18501825, 18501901, 18501914, 18503176, 18503321, 18503324, - 18503327, 18503748, 18503861, 18505085, 18505121, 18505795, 18505826, 18505827, 18505942, 18507352, 18507393, 18507395, 18507485, - 18507493, 18513155, 18513195, 18513450, 18513477, 18513488, 18513513, 18513532, 18513740, 18535188, 18535211, 18535223, 18535504, - 18535506, 18535511, 18535523, 18535526, 18535693, 18535863, 18535867, 18535950, 18535960, 18536171, 18536855, 18536862, 18536866, - 18536868, 18536869, 18537563, 18537686, 18537828, 18537830, 18539322, 18539428, 18539449, 18539565, 18539569, 18542957, 18549853, - 18549867, 18614667, 18614674, 18614685, 18614689, 18629129, 18629130, 18629263, 18629369, 18629370, 18629490, 18629492, 18630041, - 18630174, 18630284, 18640752, 18640754, 18640811, 18640900, 18640907, 18640943, 18640945, 18641080, 18641081, 18641157, 18641158, - 18641209, 18641401, 18642300, 18642313, 18642314, 18642405, 18642455, 18642533, 18642534, 18642593, 18642798, 18642799, 18644754, - 18690658, 18690699, 18692929, 18692939, 18698953, 18698954, 18699153, 18699427, 18699430, 18700378, 18700541, 18700543, 18700746, - 18700748, 18700766, 18700833, 18700834, 18700841, 18700842, 18701022, 18701473, 18701507, 18701522, 18701524, 18701573, 18701579, - 18701583, 18701911, 18702014, 18702025, 18702055, 18702094, 18702904, 18703319, 18703328, 18703920, 18704157, 18704427, 18704428, - 18705700, 18706080, 18707114, 18707117, 18707253, 18707486, 18707577, 18707592, 18707596, 18707946, 18707947, 18707956, 18707959, - 18707960, 18708017, 18708020, 18708754, 18708755, 18708938, 18709230, 18709237, 18709605, 18709606, 18709614, 18709621, 18709666, - 18709675, 18709742, 18709754, 18709760, 18709875, 18709881, 18709972, 18709987, 18710107, 18710153, 18710156, 18710159, 18710194, - 18710203, 18710456, 18710530, 18710672, 18722404, 18722407, 18722441, 18722444, 18722474, 18722476, 18722661, 18722684, 18722853, - 18722855, 18722857, 18722860, 18722964, 18722965, 18722991, 18723370, 18723413, 18723704, 18723707, 18723764, 18723766, 18723857, - 18723860, 18723916, 18723941, 18723981, 18735304, 18735677, 18737090, 18737199, 18737256, 18737264, 18737394, 18737400, 18738534, - 18738537, 18738632, 18738633, 18738690, 18738691, 18738755, 18739002, 18739014, 18739017, 18739026, 18739095, 18739204, 18739715, - 18739719, 18739774, 18739780, 18741326, 18741377, 18742319, 18742321, 18742401, 18743044, 18743049, 18743102, 18743109, 18743127, - 18743150, 18743153, 18744034, 18744038, 18744047, 18744053, 18744099, 18744100, 18744161, 18744178, 18744272, 18744440, 18744448, - 18744503, 18744507, 18744957, 18744963, 18745309, 18746182, 18746720, 18746766, 18746769, 18747055, 18747115, 18747509, 18748208, - 18748215, 18748216, 18748616, 18748632, 18748881, 18748930, 18749143, 18749153, 18749347, 18749597, 18749859, 18749862, 18749865, - 18750557, 18750566, 18750749, 18751180, 18751334, 18751358, 18751444, 18751733, 18751772, 18751777, 18751784, 18751800, 18751962, - 18751964, 18751967, 18751970, 18751974, 18751975, 18751977, 18752073, 18752085, 18752241, 18752245, 18752369, 18752782, 18752796, - 18753020, 18753025, 18753230, 18753299, 18753321, 18753444, 18754157, 18754468, 18754629, 18754632, 18755348, 18755580, 18755647, - 18756137, 18756196, 18757143, 18757175, 18757227, 18757294, 18757300, 18757544, 18757547, 18757917, 18757930, 18758219, 18758228, - 18758428, 18783923, 18784255, 18784257, 18784278, 18784506, 18784512, 18785925, 18785928, 18786059, 18787397, 18787805, 18787842, - 18840505, 18840540, 18842111, 18842255, 18842546, 18842613, 18843081, 18843086, 18843202, 18877846, 18877886, 18877938, 18877995, - 18878286, 18878288, 18878602, 18878604, 18878910, 18879022, 18879087, 18879201, 18879299, 18879376, 18879694, 18879819, 18879825, - 18879959, 18879963, 18880086, 18880208, 18880209, 18880253, 18880256, 18880438, 18880477, 18880478, 18880579, 18880588, 18880589, - 18880590, 18880674, 18880675, 18880688, 18880690, 18880698, 18880703, 18880710, 18880723, 18880777, 18880778, 18880818, 18880829, - 18880956, 18880957, 18880961, 18880971, 18881047, 18881049, 18881057, 18881059, 18881244, 18881250, 18881271, 18881309, 18881313, - 18881413, 18881417, 18881470, 18881473, 18881573, 18881588, 18881603, 18881665, 18881667, 18881833, 18881834, 18881875, 18881876, - 18881945, 18881946, 18882110, 18882201, 18882333, 18882334, 18882600, 18882620, 18882747, 18882795, 18882797, 18882825, 18882827, - 18882864, 18882874, 18883468, 18883469, 18883511, 18883515, 18883910, 18884107, 18884303, 18884455, 18884839, 18884840, 18884853, - 18885134, 18885240, 18885713, 18885715, 18885719, 18885720, 18890921, 18890923, 18890924, 18891002, 18891007, 18891013, 18891073, - 18891226, 18891230, 18891902, 18892071, 18916117, 18916500, 18917173, 18917229, 18917481, 18917487, 18917714, 18918454, 18918700, - 18919243, 18919244, 18919304, 18919307, 18919365, 18919372, 18919534, 18919859, 18919932, 18920320, 18934396, 18934399, 18934421, - 18934700, 18935088, 18935417, 18935420, 18935494, 18935501, 18936000, 18936103, 18936391, 18936459, 18936570, 18936578, 18936587, - 18936614, 18936649, 18936673, 18962602, 18962613, 18962625, 18962645, 18962662, 18962676, 18963370, 18963420, 18963833, 18963836, - 18963887, 18963911, 18964240, 18964303, 18964451, 18964454, 18964458, 18964500, 18964761, 18965395, 18965426, 18965875, 18965880, - 18965881, 18965931, 18965958, 18965959, 18965984, 18965985, 18967428, 18967463, 18967632, 18968583, 18968607, 18972151, 18972181, - 18972195, 18972196, 18972221, 18972231, 18972471, 18972549, 18972554, 18972611, 18972613, 18972651, 18972928, 18972929, 18972973, - 18972974, 18972992, 18972993, 18973042, 18973044, 18973048, 18973096, 18973098, 18973116, 18973218, 18973912, 18973952, 18973955, - 18974076, 18974093, 18974104, 18974117, 18974129, 18974206, 18974209, 18974419, 18974465, 18974797, 18974894, 18975162, 18975166, - 18975316, 18975374, 18975576, 18975578, 18976376, 18976386, 18976399, 18976405, 18977338, 18977345, 18977358, 18977728, 18977730, - 18977734, 18977736, 18978127, 18978129, 18978246, 18978494, 18978496, 18978826, 18978859, 18978866, 18978868, 18978873, 18978921, - 18978923, 18978933, 18978935, 18979157, 18979213, 18979247, 18979362, 18979627, 18979629, 18979659, 18979665, 18979666, 18979668, - 18979670, 18979746, 18979760, 18979767, 18979772, 18979782, 18979798, 18979820, 18979833, 18979855, 18979857, 18979955, 18979956, - 18980169, 18980439, 18980547, 18980548, 18980554, 18980591, 18980595, 18980691, 18980698, 18980831, 18980853, 18981626, 18981703, - 18981830, 18981937, 18981943, 18982171, 18982176, 18982186, 18982188, 18982196, 18982429, 18982431, 18982437, 18982740, 18982825, - 18982829, 18982867, 18982883, 18982926, 18983055, 18983244, 18983397, 18983401, 18983612, 18983619, 18983620, 18983932, 18983935, - 18983996, 18984329, 18984386, 18984405, 18984407, 18984413, 18984431, 18984501, 18984511, 18984763, 18984769, 18984913, 18984991, - 18985047, 18985161, 18985246, 18985248, 18985301, 18985304, 18985312, 18985520, 18985521, 18985726, 18985822, 18985850, 18986106, - 18986173, 18986174, 18986252, 18986266, 18986267, 18987017, 18987031, 18987048, 18987053, 18987081, 18987680, 18988159, 18988166, - 18988194, 18988205, 18988573, 18988712, 18988715, 18988857, 18988982, 18988984, 18988985, 18989012, 18989013, 18989018, 18989086, - 18989099, 18989125, 18989132, 18989165, 18989462, 18989464, 18989759, 18989899, 18989954, 18989955, 18990839, 18990846, 18990863, - 18990866, 18991105, 18991433, 18991452, 18991456, 18991462, 18991467, 18991469, 18991662, 18992464, 18992650, 18992774, 18992801, - 18992856, 18992860, 18992906, 18999657, 18999676, 18999686, 18999697, 18999881, 18999886, 19000091, 19000224, 19000241, 19000489, - 19000503, 19001195, 19001201, 19001347, 19001359, 19007968, 19007971, 19008121, 19011401, 19011569, 19011588, 19011656, 19011677, - 19011754, 19011759, 19012403, 19012416, 19012603, 19012613, 19012746, 19012747, 19014099, 19014206, 19020339, 19020428, 19020735, - 19020954, 19020959, 19021745, 19021748, 19021802, 19021803, 19022518, 19022523, 19157469, 19157470, 19157562, 19157597, 19157681, - 19157693, 19157727, 19157735, 19177628, 19177631, 19179127, 19180014, 19180478, 19180496, 19180576, 19180594, 19180601, 19180609, - 19182388, 19182390, 19182566, 19182598, 19183939, 19184062, 19184172, 19184613, 19187655, 19187674, 19187949, 19187959, 19189135, - 19190233, 19190353, 19190502, 19190504, 19190594, 19191003, 19191043, 19191046, 19191091, 19191098, 19191118, 19191122, 19191234, - 19191237, 19191305, 19191307, 19191407, 19191408, 19191453, 19191858, 19192015, 19192485, 19192487, 19192606, 19192607, 19192611, - 19192615, 19192896, 19192903, 19193680, 19193768, 19193789, 19193876, 19193879, 19194492, 19195385, 19200168, 19200172, 19200274, - 19200290, 19200578, 19200583, 19202205, 19202286, 19202388, 19202392, 19202403, 19202424, 19202450, 19202506, 19202509, 19203134, - 19203366, 19203572, 19203746, 19203752, 19204197, 19206989, 19207000, 19207077, 19207171, 19207271, 19207272, 19208337, 19208345, - 19208730, 19212689, 19212690, 19212744, 19212946, 19212947, 19213039, 19213045, 19213048, 19213301, 19213303, 19213574, 19213575, - 19213942, 19214581, 19214583, 19214681, 19214684, 19214905, 19215052, 19215418, 19216089, 19216095, 19218331, 19218601, 19218604, - 19218875, 19219205, 19220095, 19220100, 19221680, 19221683, 19221894, 19222484, 19222586, 19222590, 19224624, 19224626, 19225180, - 19226142, 19226145, 19226595, 19226609, 19226890, 19226896, 19226910, 19226911, 19226927, 19227005, 19227837, 19227907, 19227909, - 19228054, 19228056, 19228106, 19228107, 19228121, 19228123, 19228259, 19228261, 19228302, 19228304, 19229883, 19229890, 19230123, - 19233910, 19234320, 19234345, 19234424, 19234537, 19234956, 19235288, 19235308, 19237190, 19237199, 19237208, 19237233, 19239254, - 19239258, 19239376, 19239377, 19239389, 19239407, 19240001, 19240024, 19240499, 19240901, 19250124, 19250127, 19250230, 19250239, - 19252820, 19252824, 19252856, 19252859, 19253253, 19253258, 19253341, 19253648, 19253658, 19254248, 19254257, 19254261, 19254273, - 19255415, 19255483, 19255486, 19256056, 19256595, 19256596, 19257023, 19257421, 19257656, 19257794, 19257795, 19257825, 19257827, - 19257973, 19258287, 19258305, 19259424, 19259426, 19260016, 19260028, 19260034, 19260047, 19260053, 19260136, 19260185, 19260252, - 19260535, 19260539, 19263045, 19263046, 19263072, 19263297, 19263547, 19264542, 19264897, 19268898, 19268900, 19268986, 19268990, - 19269163, 19269421, 19269423, 19271598, 19271984, 19272062, 19272201, 19272203, 19272401, 19272409, 19272445, 19272449, 19281870, - 19281883, 19282504, 19285192, 19285575, 19285576, 19285624, 19301651, 19301652, 19301719, 19301721, 19302758, 19302769, 19302830, - 19302832, 19302846, 19304733, 19304737, 19304857, 19304863, 19304956, 19304961, 19305572, 19306684, 19306759, 19306763, 19306795, - 19306821, 19306844, 19306849, 19307117, 19307412, 19307778, 19307893, 19308083, 19308148, 19308304, 19314020, 19314021, 19314052, - 19314238, 19314253, 19315712, 19316333, 19317997, 19317999, 19318269, 19318271, 19318527, 19318529, 19318536, 19318578, 19318582, - 19318880, 19318881, 19319054, 19319328, 19319330, 19319376, 19324587, 19324593, 19324769, 19324771, 19324874, 19324883, 19324952, - 19324954, 19325006, 19325007, 19325008, 19325103, 19325184, 19325185, 19325391, 19325392, 19325399, 19325401, 19325570, 19325804, - 19326308, 19326329, 19326348, 19326618, 19326756, 19326757, 19326935, 19326944, 19326947, 19327176, 19327529, 19329583, 19329702, - 19329703, 19329745, 19329746, 19329754, 19329758, 19330909, 19330912, 19331006, 19331009, 19331094, 19331095, 19331200, 19331224, - 19331676, 19331678, 19331729, 19331732, 19332246, 19332827, 19332934, 19332935, 19333061, 19358286, 19358287, 19358310, 19360688, - 19360690, 19360794, 19360932, 19361096, 19362472, 19362473, 19362976, 19362979, 19363289, 19363291, 19363391, 19363719, 19364350, - 19364366, 19364392, 19364402, 19364936, 19364944, 19365015, 19365017, 19365059, 19365710, 19365714, 19365844, 19366349, 19366686, - 19366920, 19366924, 19367057, 19367062, 19367152, 19367158, 19367216, 19367219, 19367501, 19367504, 19368429, 19368434, 19368444, - 19368449, 19368461, 19368484, 19368500, 19368501, 19368676, 19368680, 19368783, 19368797, 19368801, 19368942, 19368948, 19368949, - 19368955, 19368966, 19369066, 19369075, 19369217, 19369229, 19369302, 19369310, 19369314, 19369341, 19369343, 19369598, 19369600, - 19369688, 19369690, 19369879, 19369904, 19369907, 19369914, 19369919, 19369924, 19370031, 19373906, 19373910, 19373914, 19373996, - 19374015, 19374165, 19374181, 19374182, 19374198, 19374266, 19374299, 19374800, 19375006, 19375010, 19375171, 19375174, 19375178, - 19375183, 19375189, 19375203, 19375209, 19375252, 19375259, 19375260, 19375719, 19375788, 19375789, 19376019, 19376020, 19376061, - 19385710, 19385787, 19389326, 19389328, 19389440, 19389442, 19389987, 19390185, 19390188, 19390245, 19390250, 19390286, 19390313, - 19390322, 19390345, 19390352, 19390586, 19390710, 19392042, 19392044, 19410405, 19410437, 19410449, 19410488, 19410489, 19410496, - 19410497, 19410510, 19410916, 19411000, 19411002, 19411204, 19411937, 19411939, 19411997, 19512944, 19513029, 19513189, 19513202, - 19513396, 19513538, 19513695, 19513945, 19513992, 19516059, 19516062, 19516075, 19516084, 19516968, 19517224, 19554953, 19558472, - 19609701, 19609719, 19609892, 19609947, 19610025, 19610494, 19610647, 19610652, 19610959, 19611209, 19611291, 19612269, 19612444, - 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285, 19613989, 19614239, 19614595, 19614600, - 19614607, 19615112, 19615114, 19615248, 19726042, 19726057, 19748242, 19748244, 19748269, 19748278, 19748377, 19750672, 19750695, - 19750702, 19750822, 19750833, 19751058, 19751064, 19751102, 19751108, 19751169, 19751172, 19751269, 19751854, 19751865, 19751878, - 19751936, 19752030, 19752349, 19755044, 19755063, 19755440, 19755881, 19756813, 19761538, 19761592, 19761593, 19761680, 19761685, - 19761995, 19762162, 19762167, 19763218, 19763430, 19763945, 19764280, 19764311, 19764333, 19764676, 19764744, 19765216, 19765374, - 19765479, 19767631, 19792072, 19792136, 19792139, 19793277, 19793318, 19793322, 19793528, 19793536, 19796241, 19796405, 19796407, - 19802815, 19802816, 19802881, 19804775, 19805218, 19805360, 19805515, 19807739, 19807796, 19808997, 19809396, 19809725, 19809990, - 19913194, 19913195, 19914726, 19914727, 19914735, 19914741, 19914769, 19914811, 19914876, 19914877, 19916067, 19917537, 19917540, - 19917991, 19918159, 19918171, 19918197, 19918202, 19918295, 19918302, 19918429, 19918432, 19918524, 19918639, 19918716, 19918797, - 19918799, 19918991, 19918992, 19919153, 19919287, 19919383, 19919514, 19919971, 19919995, 19920374, 19920778, 19920779, 19921528, - 19921531, 19921674, 19921675, 19921724, 19923306, 19923308, 19923480, 19923532, 19923534, 19923692, 19923702, 19923790, 19923814, - 19923818, 19923880, 19923884, 19924275, 19924279, 19924358, 19924367, 19924384, 19925554, 19925869, 19926582, 19926586, 19926619, - 19926620, 19926687, 19926859, 19926884, 19926887, 19926891, 19926959, 19927302, 19927422, 19928859, 19929054, 19932992, 19933015, - 19933313, 19933316, 19933328, 19933410, 19933760, 19933818, 19933876, 19934184, 19934490, 19934606, 19934621, 19934741, 19959354, - 19959578, 19960026, 19960122, 19962154, 19962536 -]; -export const PEG_CROSS_BLOCKS_LAST: u32 = 19962536; -export const PEG_CROSS_BLOCKS: u32[] = [ - 12974091, 12975421, 12978538, 12978615, 12978680, 12978911, 12979148, 12979149, 12979167, 12979171, 12979228, 12979230, 12979607, - 12983847, 12983871, 12983895, 12983897, 12983926, 12984038, 12984104, 12984170, 12984257, 12984310, 12984929, 12986590, 12986603, - 12986901, 12987603, 12990064, 12991358, 12991399, 12992193, 12992519, 12993217, 12993281, 12998537, 12998539, 12998546, 12998550, - 12998551, 12998553, 12999530, 12999585, 12999767, 12999776, 12999777, 12999779, 12999817, 12999840, 13000158, 13000196, 13000305, - 13000309, 13000334, 13000347, 13000356, 13000377, 13000577, 13000587, 13001082, 13001089, 13001396, 13001414, 13001894, 13001913, - 13001956, 13002009, 13002735, 13002738, 13003196, 13003198, 13004037, 13004045, 13004360, 13004364, 13004638, 13004646, 13004655, - 13004657, 13004817, 13004839, 13004843, 13004883, 13005075, 13005103, 13005107, 13005109, 13005372, 13005380, 13005673, 13005715, - 13005730, 13005733, 13005944, 13005946, 13006200, 13006202, 13006203, 13006321, 13006487, 13006488, 13006499, 13006546, 13006708, - 13006709, 13006980, 13007010, 13007245, 13007246, 13007274, 13007275, 13007509, 13007525, 13007574, 13007607, 13007780, 13007798, - 13007859, 13007898, 13008063, 13008065, 13008117, 13008191, 13008375, 13008387, 13008617, 13008671, 13008712, 13008736, 13008895, - 13008901, 13008906, 13008912, 13009163, 13009169, 13009190, 13009193, 13009199, 13009203, 13009381, 13009423, 13009669, 13009671, - 13009676, 13009679, 13009681, 13009687, 13009958, 13009972, 13009973, 13010009, 13010222, 13010231, 13010492, 13010556, 13010779, - 13014211, 13016266, 13018933, 13019023, 13019754, 13020690, 13020782, 13022699, 13022701, 13022825, 13023185, 13023247, 13023922, - 13025396, 13025666, 13026184, 13026256, 13026638, 13026640, 13027512, 13029384, 13030010, 13030107, 13030123, 13030393, 13030528, - 13031004, 13031259, 13032695, 13032731, 13032942, 13033010, 13033033, 13033210, 13034517, 13034543, 13035839, 13035922, 13035929, - 13036165, 13036689, 13036884, 13036897, 13036926, 13037135, 13037615, 13037642, 13038069, 13038108, 13038138, 13038145, 13038184, - 13039743, 13043682, 13043699, 13044756, 13044762, 13044770, 13044955, 13045801, 13046502, 13051141, 13051348, 13056233, 13056234, - 13057499, 13057501, 13057527, 13057595, 13058927, 13059717, 13059983, 13060079, 13060086, 13060118, 13060119, 13060121, 13060123, - 13060132, 13060160, 13060198, 13060449, 13060450, 13060479, 13060489, 13060492, 13060680, 13060716, 13060796, 13060802, 13060842, - 13060960, 13062059, 13062295, 13062299, 13062306, 13062319, 13062333, 13062352, 13062366, 13063788, 13063838, 13063861, 13063878, - 13075770, 13075888, 13076058, 13076195, 13076316, 13076435, 13076636, 13076662, 13076679, 13076703, 13076890, 13076891, 13076899, - 13076947, 13076964, 13076972, 13077164, 13077246, 13077426, 13077429, 13077495, 13077503, 13077730, 13077736, 13078272, 13078287, - 13078449, 13078457, 13078466, 13078470, 13078482, 13078487, 13078488, 13078519, 13078541, 13078561, 13078796, 13078810, 13078813, - 13078834, 13079299, 13079303, 13079572, 13079587, 13079588, 13079596, 13079620, 13079642, 13079648, 13079683, 13079724, 13079755, - 13079814, 13079885, 13079887, 13079895, 13079899, 13079919, 13079920, 13079941, 13080074, 13080179, 13080198, 13080229, 13080352, - 13080375, 13080400, 13080408, 13080634, 13080637, 13080648, 13080660, 13080672, 13080677, 13080678, 13080680, 13080768, 13080770, - 13080887, 13080888, 13080932, 13080934, 13080937, 13080958, 13080977, 13080990, 13080996, 13080999, 13081011, 13081057, 13081145, - 13081209, 13081632, 13081635, 13081700, 13081721, 13081750, 13081754, 13081766, 13081895, 13081963, 13081977, 13081992, 13081994, - 13082000, 13082006, 13082094, 13082163, 13082230, 13082282, 13082300, 13082301, 13082504, 13082507, 13082510, 13082555, 13082863, - 13082876, 13082878, 13082888, 13082969, 13083844, 13084930, 13084956, 13084984, 13085212, 13085233, 13085236, 13085311, 13085508, - 13085645, 13085877, 13086288, 13086337, 13086338, 13086356, 13086362, 13086369, 13086376, 13086400, 13086422, 13086440, 13086459, - 13086461, 13087211, 13087217, 13087221, 13087225, 13087231, 13087377, 13087393, 13087405, 13087410, 13087411, 13087527, 13088104, - 13088272, 13093705, 13093899, 13093903, 13093921, 13093932, 13093971, 13093975, 13099188, 13099189, 13099353, 13099362, 13099414, - 13099461, 13099465, 13099710, 13099714, 13099747, 13100289, 13100319, 13100358, 13100371, 13100898, 13100923, 13102868, 13102939, - 13107071, 13107096, 13110581, 13110588, 13110634, 13110706, 13110819, 13110844, 13111074, 13113042, 13113109, 13113110, 13113423, - 13113442, 13113448, 13113452, 13113453, 13113553, 13114481, 13114574, 13115940, 13115946, 13115955, 13115972, 13115989, 13115990, - 13117862, 13118077, 13118145, 13118291, 13118320, 13118321, 13118355, 13118356, 13118402, 13118413, 13118423, 13118428, 13118436, - 13118467, 13121070, 13121089, 13121099, 13121128, 13121178, 13121244, 13121307, 13121310, 13122225, 13122395, 13122407, 13122455, - 13122874, 13122951, 13122985, 13124397, 13124895, 13129783, 13129786, 13129854, 13129981, 13129991, 13130001, 13130094, 13130178, - 13131625, 13131662, 13131722, 13131929, 13137125, 13137568, 13138520, 13138647, 13138700, 13138778, 13138782, 13138813, 13138856, - 13138858, 13139212, 13139273, 13139367, 13139407, 13139408, 13139410, 13139609, 13140003, 13140015, 13140024, 13140027, 13140327, - 13140447, 13140687, 13141148, 13141156, 13141160, 13141165, 13141195, 13141863, 13141869, 13141870, 13141940, 13142135, 13143729, - 13143754, 13143760, 13143762, 13143763, 13143816, 13144293, 13144300, 13144362, 13144364, 13144774, 13144823, 13145005, 13145190, - 13145194, 13145195, 13145198, 13145206, 13145220, 13145747, 13146082, 13146089, 13147016, 13147028, 13147044, 13147045, 13148291, - 13148316, 13149112, 13150275, 13150279, 13150280, 13151314, 13151333, 13151356, 13151443, 13151450, 13151451, 13151460, 13151462, - 13151595, 13151598, 13151696, 13151700, 13151863, 13151867, 13152103, 13152260, 13152269, 13153306, 13153325, 13155620, 13156284, - 13156748, 13156781, 13157326, 13158957, 13159234, 13159235, 13159247, 13159248, 13159486, 13159495, 13161064, 13161086, 13161299, - 13161376, 13161392, 13161406, 13161416, 13161423, 13161487, 13161550, 13161611, 13161634, 13161636, 13162200, 13162208, 13162329, - 13162331, 13163395, 13163536, 13163565, 13163567, 13163596, 13163597, 13163604, 13163670, 13163995, 13164187, 13164189, 13164192, - 13164658, 13164746, 13165237, 13165391, 13165408, 13165727, 13165897, 13165996, 13166015, 13166072, 13166219, 13166222, 13166242, - 13166250, 13166251, 13166258, 13166259, 13166283, 13166287, 13166319, 13166381, 13166437, 13167205, 13167549, 13167575, 13167591, - 13167742, 13167972, 13168519, 13168524, 13169110, 13171988, 13175038, 13175053, 13175058, 13175064, 13175069, 13175146, 13175397, - 13175452, 13175497, 13175514, 13175520, 13175609, 13177587, 13177589, 13177597, 13177615, 13177647, 13177659, 13177660, 13177714, - 13177758, 13178360, 13178584, 13178652, 13179149, 13179177, 13179251, 13179252, 13179253, 13179274, 13179308, 13179337, 13179353, - 13179400, 13180079, 13180083, 13180101, 13180102, 13180117, 13180145, 13180189, 13180216, 13180664, 13180692, 13180713, 13180715, - 13180730, 13180758, 13180833, 13180888, 13180897, 13180909, 13181023, 13181155, 13181755, 13181777, 13181802, 13181820, 13182646, - 13182655, 13183890, 13183894, 13183955, 13183956, 13183957, 13184012, 13184973, 13184974, 13185191, 13185260, 13185321, 13185384, - 13185495, 13185703, 13185732, 13185850, 13187086, 13187116, 13187178, 13187233, 13188042, 13189001, 13189010, 13189082, 13191072, - 13191091, 13191099, 13191106, 13191522, 13191635, 13191637, 13191644, 13192232, 13192596, 13192599, 13192604, 13193031, 13193802, - 13194379, 13194410, 13194615, 13194717, 13194719, 13194824, 13196049, 13196067, 13196141, 13196190, 13196445, 13196459, 13196460, - 13198164, 13198273, 13198316, 13198557, 13198899, 13198902, 13198907, 13198909, 13198925, 13199052, 13199074, 13199086, 13199099, - 13199116, 13199129, 13199131, 13199260, 13199361, 13199363, 13200193, 13200194, 13200216, 13200219, 13200224, 13201208, 13201289, - 13201290, 13201321, 13201322, 13206138, 13206229, 13206338, 13206947, 13207266, 13207395, 13207435, 13207444, 13207445, 13207578, - 13207663, 13208184, 13211822, 13211897, 13211967, 13213641, 13214042, 13214163, 13214206, 13215008, 13215982, 13217044, 13217061, - 13217222, 13217341, 13217478, 13217783, 13217784, 13217810, 13217953, 13217970, 13217973, 13218020, 13218050, 13218279, 13218810, - 13218815, 13218816, 13218909, 13218949, 13218953, 13218954, 13225077, 13225299, 13226246, 13226559, 13226732, 13226957, 13227000, - 13229110, 13229499, 13229747, 13232674, 13232699, 13232717, 13233025, 13234172, 13234178, 13234264, 13234554, 13236246, 13236247, - 13236250, 13236319, 13237109, 13237552, 13244459, 13244462, 13245028, 13245032, 13245040, 13245162, 13245172, 13245175, 13245180, - 13245275, 13245545, 13245546, 13246387, 13246388, 13246647, 13246651, 13246920, 13246926, 13246980, 13246983, 13247415, 13247416, - 13247678, 13247695, 13247947, 13247952, 13248208, 13248209, 13248470, 13248473, 13249273, 13249276, 13249292, 13249294, 13249543, - 13249561, 13249800, 13249818, 13249822, 13250039, 13250057, 13250059, 13256813, 13256815, 13257386, 13257389, 13258210, 13258214, - 13259590, 13259594, 13259863, 13259865, 13260039, 13260056, 13260062, 13260063, 13260114, 13260126, 13260381, 13260386, 13260388, - 13260389, 13260884, 13260886, 13261140, 13261142, 13261145, 13261155, 13261156, 13261186, 13261206, 13261363, 13261373, 13261399, - 13262381, 13262382, 13262425, 13262428, 13262440, 13262442, 13262455, 13262462, 13262465, 13262469, 13262553, 13262554, 13262569, - 13262592, 13262593, 13262713, 13262719, 13262729, 13262748, 13262896, 13262899, 13262913, 13263080, 13263772, 13263871, 13264127, - 13264135, 13264139, 13264149, 13272546, 13272560, 13272905, 13272934, 13273058, 13273061, 13273064, 13273373, 13273436, 13273458, - 13273503, 13273513, 13273717, 13273719, 13274023, 13274030, 13274057, 13274064, 13274105, 13274148, 13274189, 13274198, 13274217, - 13274220, 13274242, 13274248, 13335750, 13335755, 13335869, 13336244, 13336323, 13336461, 13336505, 13336560, 13336618, 13336695, - 13336714, 13336777, 13336959, 13337532, 13337559, 13337935, 13337937, 13337959, 13340698, 13340781, 13340820, 13340947, 13341028, - 13341076, 13341108, 13341147, 13341156, 13341366, 13341373, 13342047, 13342121, 13342224, 13342548, 13376585, 13376710, 13376778, - 13378143, 13378793, 13378816, 13378829, 13379464, 13434006, 13434877, 13435565, 13435971, 13436006, 13436018, 13436025, 13436035, - 13436049, 13436107, 13437998, 13438644, 13438667, 13440517, 13442086, 13442913, 13443210, 13443231, 13443232, 13443239, 13443256, - 13443258, 13443270, 13443271, 13444653, 13444660, 13444712, 13446459, 13448008, 13449065, 13449128, 13449167, 13449303, 13449313, - 13449493, 13449495, 13449505, 13449506, 13449551, 13449634, 13449650, 13449705, 13449790, 13449821, 13449841, 13449855, 13449875, - 13449913, 13450052, 13450154, 13450187, 13450472, 13450507, 13450522, 13451061, 13451131, 13451155, 13451468, 13451543, 13451544, - 13451550, 13451555, 13451564, 13451596, 13451598, 13451649, 13451671, 13451675, 13455280, 13455282, 13455557, 13455600, 13455618, - 13455860, 13455891, 13455896, 13455911, 13461738, 13462027, 13462049, 13462066, 13462165, 13463379, 13463381, 13464408, 13466451, - 13467419, 13467691, 13468508, 13468675, 13468784, 13469000, 13469007, 13469012, 13469034, 13470634, 13470770, 13471747, 13474744, - 13474934, 13475341, 13475377, 13475394, 13475519, 13475523, 13475746, 13476174, 13476209, 13476325, 13476418, 13476419, 13479133, - 13479136, 13479138, 13479152, 13479196, 13479242, 13479941, 13480370, 13480372, 13480449, 13480647, 13480648, 13480717, 13481304, - 13481717, 13481988, 13482011, 13482102, 13483897, 13483977, 13483982, 13483998, 13484811, 13484846, 13484847, 13486887, 13486969, - 13488473, 13488482, 13489574, 13489977, 13490465, 13490505, 13490507, 13490517, 13490518, 13491374, 13494424, 13494752, 13494754, - 13495520, 13495854, 13497794, 13497797, 13497803, 13497820, 13497844, 13497868, 13498035, 13503686, 13503690, 13503704, 13503709, - 13503751, 13503763, 13503770, 13503813, 13503910, 13508461, 13508666, 13508680, 13508728, 13508759, 13508780, 13510297, 13510507, - 13510508, 13510514, 13510516, 13510518, 13510520, 13510556, 13510590, 13510603, 13510605, 13510610, 13510727, 13511700, 13511890, - 13511907, 13512045, 13512048, 13512304, 13512305, 13512359, 13512365, 13514281, 13514282, 13514705, 13514719, 13514721, 13514734, - 13515060, 13516318, 13516526, 13516569, 13517036, 13517567, 13518970, 13519495, 13519497, 13519756, 13521882, 13522133, 13523828, - 13523847, 13523862, 13523885, 13523912, 13523967, 13523969, 13524379, 13524397, 13525787, 13525872, 13525873, 13528534, 13528544, - 13528546, 13528558, 13528574, 13528579, 13528967, 13529028, 13531631, 13531875, 13531910, 13531954, 13531961, 13531990, 13532016, - 13532023, 13532081, 13532126, 13532137, 13532138, 13532143, 13532151, 13532161, 13532176, 13532179, 13532198, 13532239, 13532920, - 13532929, 13532946, 13533454, 13533933, 13535490, 13535493, 13535494, 13535499, 13538211, 13538232, 13538866, 13538895, 13539218, - 13539249, 13539673, 13539923, 13539946, 13539951, 13540826, 13540841, 13541140, 13541325, 13541849, 13541933, 13541958, 13541980, - 13541997, 13542002, 13542077, 13542086, 13542175, 13542179, 13542232, 13542254, 13543917, 13544624, 13545832, 13545837, 13545858, - 13546411, 13547018, 13547059, 13547095, 13547595, 13547630, 13548233, 13548387, 13550252, 13550987, 13551029, 13551119, 13551280, - 13551291, 13552190, 13552241, 13552260, 13552307, 13552675, 13552678, 13552681, 13552684, 13552688, 13552701, 13552704, 13552750, - 13552752, 13552754, 13552943, 13553661, 13553662, 13553676, 13553677, 13553853, 13554976, 13555095, 13555457, 13557196, 13557954, - 13558105, 13558112, 13558113, 13558114, 13558116, 13558121, 13558735, 13558752, 13558776, 13559078, 13559084, 13559255, 13559291, - 13559303, 13559410, 13559415, 13559416, 13559425, 13559561, 13559568, 13559602, 13559647, 13559656, 13559658, 13559791, 13559882, - 13560317, 13560318, 13560937, 13564634, 13564681, 13564697, 13564713, 13564837, 13564852, 13564859, 13564871, 13564879, 13564889, - 13564891, 13566648, 13568113, 13568302, 13568342, 13568345, 13568357, 13568484, 13568492, 13568495, 13568667, 13570256, 13570277, - 13570284, 13570300, 13570316, 13570318, 13570944, 13570952, 13571175, 13572652, 13572673, 13572674, 13572854, 13572856, 13572884, - 13572895, 13572918, 13572923, 13572958, 13572969, 13573024, 13573028, 13573096, 13573097, 13573405, 13573522, 13573523, 13573686, - 13573687, 13573693, 13573695, 13574201, 13574213, 13574289, 13574294, 13575376, 13575377, 13576614, 13576620, 13576635, 13576661, - 13576663, 13577153, 13577969, 13578897, 13578901, 13578940, 13578947, 13579158, 13579160, 13579235, 13579351, 13579385, 13579447, - 13579490, 13579530, 13579565, 13579572, 13579588, 13579894, 13579900, 13579911, 13579912, 13579914, 13579918, 13579942, 13580072, - 13580087, 13580260, 13580280, 13581920, 13582005, 13582060, 13582068, 13582069, 13582090, 13582096, 13582336, 13582467, 13582468, - 13582749, 13583449, 13583933, 13584045, 13584069, 13584076, 13584080, 13584082, 13584102, 13584104, 13584107, 13584126, 13584153, - 13584183, 13584184, 13584192, 13584195, 13584208, 13584209, 13584211, 13584243, 13584286, 13584294, 13584296, 13584485, 13584486, - 13585001, 13585594, 13585602, 13585607, 13585610, 13585641, 13585748, 13585775, 13585976, 13585992, 13586067, 13587038, 13587054, - 13587160, 13589367, 13589405, 13589454, 13589471, 13589485, 13589486, 13589512, 13589515, 13589527, 13589532, 13589574, 13589656, - 13589661, 13589867, 13590103, 13592391, 13594358, 13595502, 13595599, 13595883, 13596659, 13596666, 13596668, 13596671, 13598662, - 13599510, 13599974, 13600003, 13600116, 13600221, 13600229, 13600230, 13600343, 13600344, 13600519, 13602309, 13602377, 13602479, - 13602483, 13602486, 13602488, 13602489, 13602490, 13602493, 13602978, 13603574, 13603586, 13603652, 13603887, 13604255, 13605773, - 13605779, 13606896, 13607198, 13607202, 13607203, 13608420, 13608519, 13608665, 13608681, 13608968, 13610066, 13611161, 13614876, - 13614927, 13614991, 13614998, 13615404, 13617630, 13618342, 13621035, 13622147, 13623486, 13623495, 13623499, 13623577, 13623590, - 13623764, 13624270, 13624355, 13624363, 13624366, 13624383, 13624517, 13625958, 13625960, 13625982, 13626112, 13626125, 13626166, - 13626170, 13626212, 13628785, 13628854, 13628864, 13628865, 13629661, 13629662, 13629784, 13629785, 13629852, 13630011, 13630129, - 13630230, 13630429, 13630583, 13630683, 13630775, 13630780, 13630796, 13631292, 13631331, 13640082, 13640087, 13640104, 13640132, - 13640218, 13640556, 13640587, 13640615, 13641928, 13641929, 13642057, 13642071, 13642137, 13642155, 13642160, 13642167, 13642168, - 13642207, 13642212, 13642215, 13642216, 13642265, 13642911, 13644410, 13646116, 13646163, 13647476, 13647732, 13647733, 13647905, - 13657931, 13657936, 13658078, 13658083, 13658088, 13658106, 13666892, 13666908, 13667064, 13667842, 13671879, 13672266, 13685409, - 13685501, 13687313, 13687327, 13688700, 13688718, 13688728, 13688770, 13688773, 13689077, 13693941, 13693995, 13694143, 13694177, - 13703288, 13703407, 13704796, 13704804, 13704850, 13704871, 13710244, 13710333, 13710534, 13710568, 13717643, 13717686, 13720847, - 13720981, 13721138, 13721150, 13721209, 13721255, 13721263, 13721265, 13721279, 13721280, 13722372, 13722456, 13722731, 13722854, - 13722860, 13722861, 13722883, 13722884, 13722898, 13722924, 13723078, 13723597, 13723611, 13723617, 13724121, 13724580, 13724940, - 13724949, 13724958, 13725168, 13725481, 13725714, 13725715, 13725761, 13726532, 13728022, 13728049, 13729075, 13729079, 13729488, - 13729572, 13729622, 13729660, 13729666, 13729719, 13729765, 13729836, 13731361, 13731396, 13731754, 13731765, 13731769, 13731770, - 13731798, 13731966, 13732954, 13732957, 13732964, 13734204, 13734565, 13734582, 13734613, 13734671, 13735055, 13735059, 13735060, - 13735378, 13740278, 13740773, 13740781, 13740808, 13740821, 13740879, 13741264, 13742045, 13742386, 13742413, 13742433, 13742461, - 13742522, 13743142, 13743432, 13743636, 13743643, 13743676, 13744107, 13744604, 13800996, 13800999, 13801241, 13801243, 13804633, - 13804667, 13804672, 13804727, 13812443, 13812884, 13812892, 13812903, 13813249, 13813688, 13829732, 13829784, 13844956, 13844964, - 13845655, 13845657, 13845739, 13845745, 13845757, 13845780, 13848953, 13851591, 13851617, 13852217, 13852286, 13852519, 13853027, - 13854735, 13854789, 13854927, 13854932, 13854936, 13854950, 13854954, 13856012, 13856028, 13856077, 13856953, 13856955, 13857267, - 13857323, 13857365, 13857466, 13857469, 13857483, 13857490, 13857624, 13857918, 13858695, 13858898, 13858902, 13858904, 13858923, - 13858924, 13859670, 13859826, 13859936, 13860025, 13860899, 13861827, 13861932, 13861937, 13862044, 13862064, 13862197, 13862355, - 13862374, 13863113, 13864512, 13864522, 13864530, 13864926, 13864941, 13864946, 13864969, 13865001, 13865043, 13865070, 13865081, - 13865342, 13865516, 13865553, 13865581, 13865604, 13865623, 13865647, 13865678, 13866062, 13869401, 13869405, 13869422, 13869451, - 13869457, 13869834, 13870311, 13870632, 13871204, 13871210, 13871302, 13871334, 13871339, 13871363, 13871424, 13871435, 13871497, - 13871551, 13871568, 13871570, 13871583, 13871761, 13872175, 13872207, 13872240, 13872304, 13872378, 13872402, 13872443, 13872834, - 13872889, 13872979, 13873525, 13873669, 13874108, 13874137, 13874154, 13874198, 13874244, 13874484, 13875063, 13875708, 13875709, - 13876095, 13876631, 13876822, 13876828, 13876980, 13877074, 13877075, 13877496, 13877517, 13877520, 13877638, 13877848, 13878148, - 13882302, 13882360, 13882365, 13882591, 13882592, 13882597, 13882599, 13882806, 13882807, 13883051, 13883360, 13883433, 13884709, - 13885349, 13885866, 13885918, 13886883, 13887001, 13887338, 13887344, 13887380, 13887548, 13887611, 13888142, 13888577, 13888593, - 13888668, 13888746, 13889461, 13889503, 13889510, 13889524, 13889539, 13889649, 13890458, 13891050, 13891076, 13891081, 13891130, - 13891135, 13891138, 13902888, 13902992, 13906563, 13906944, 13908405, 13908630, 13912128, 13912739, 13913099, 13913121, 13913454, - 13913585, 13913596, 13914008, 13926989, 13926996, 13927003, 13927014, 13927024, 13927479, 13927483, 13927492, 13938606, 13938669, - 13939585, 13939590, 13939599, 13939708, 13939849, 13939850, 13942560, 13942563, 13942611, 13954079, 13954146, 13954148, 13954178, - 13985645, 13985651, 13992100, 14005135, 14005139, 14005140, 14005142, 14005185, 14009388, 14009390, 14038443, 14043167, 14043168, - 14098158, 14098190, 14098343, 14098347, 14098363, 14098372, 14098448, 14098510, 14099411, 14099421, 14111704, 14111988, 14112175, - 14112178, 14112222, 14112272, 14112281, 14112322, 14112332, 14112523, 14112534, 14112721, 14112870, 14113018, 14113027, 14113380, - 14113524, 14113544, 14113990, 14114153, 14114184, 14114266, 14114286, 14114342, 14114380, 14114399, 14114404, 14114436, 14114512, - 14114628, 14114673, 14114833, 14114886, 14114898, 14115278, 14115362, 14115372, 14115446, 14115500, 14115574, 14116384, 14116406, - 14116506, 14116797, 14116986, 14117002, 14117059, 14117070, 14117097, 14117135, 14117265, 14117322, 14117503, 14117521, 14117550, - 14118001, 14118142, 14118146, 14118158, 14118197, 14118368, 14118496, 14118533, 14118647, 14118701, 14118714, 14118937, 14119187, - 14119295, 14119413, 14119877, 14119901, 14119970, 14120278, 14120281, 14120282, 14120389, 14120437, 14120542, 14120552, 14120595, - 14121317, 14121366, 14121432, 14121455, 14121577, 14121580, 14121596, 14121601, 14121630, 14121638, 14121679, 14121684, 14121722, - 14121856, 14122382, 14122403, 14122483, 14122757, 14122763, 14122767, 14122824, 14122827, 14122833, 14122844, 14122853, 14122877, - 14123193, 14123200, 14123302, 14123407, 14124143, 14124163, 14124204, 14124296, 14124337, 14124352, 14124366, 14124368, 14124374, - 14124391, 14124991, 14125047, 14126549, 14126762, 14126770, 14126771, 14126782, 14126791, 14126823, 14126841, 14128740, 14128817, - 14128883, 14128944, 14129293, 14129452, 14129553, 14129573, 14129597, 14129617, 14129837, 14129898, 14129913, 14129915, 14129939, - 14130007, 14130296, 14130298, 14130316, 14130334, 14130355, 14130372, 14130378, 14130387, 14130388, 14130423, 14130440, 14130465, - 14130641, 14131066, 14131081, 14131115, 14131324, 14131407, 14131588, 14132136, 14132310, 14133768, 14133783, 14133786, 14133815, - 14133830, 14133981, 14134041, 14135528, 14135807, 14135812, 14135828, 14137560, 14137824, 14137853, 14138293, 14138307, 14138600, - 14138669, 14138825, 14138845, 14138888, 14139112, 14139816, 14140071, 14140079, 14140134, 14140318, 14140343, 14140597, 14140903, - 14140910, 14141386, 14141418, 14141461, 14141473, 14141478, 14141480, 14141489, 14141517, 14141541, 14141549, 14141628, 14141732, - 14141733, 14141780, 14141786, 14141800, 14142398, 14142742, 14142749, 14143111, 14143196, 14143745, 14143763, 14143828, 14143864, - 14144282, 14144473, 14145076, 14145285, 14145784, 14145908, 14145935, 14145988, 14146061, 14146091, 14146109, 14146166, 14146173, - 14146182, 14146184, 14146190, 14146207, 14146234, 14146754, 14146771, 14146832, 14147019, 14147204, 14147423, 14147483, 14147519, - 14147526, 14147554, 14147587, 14147607, 14147732, 14148521, 14148714, 14149592, 14149619, 14149789, 14149804, 14149812, 14149940, - 14149961, 14149966, 14149992, 14151350, 14151353, 14153570, 14154639, 14154760, 14154939, 14155463, 14155476, 14155742, 14155762, - 14155771, 14155906, 14155935, 14156644, 14156695, 14156824, 14157718, 14158023, 14158178, 14158179, 14158192, 14158225, 14158234, - 14160434, 14160448, 14160484, 14160591, 14160631, 14160678, 14161007, 14161029, 14161053, 14161067, 14161227, 14161241, 14161396, - 14161541, 14161546, 14161548, 14161549, 14161604, 14161618, 14161833, 14161976, 14161996, 14162133, 14162387, 14162615, 14162897, - 14163117, 14163286, 14163301, 14163309, 14163900, 14163967, 14164571, 14165063, 14165098, 14165182, 14165193, 14165728, 14165832, - 14166064, 14166499, 14166555, 14166559, 14166586, 14167320, 14167457, 14167507, 14167584, 14167707, 14167751, 14167792, 14167806, - 14167809, 14167830, 14167859, 14167868, 14167877, 14167979, 14167980, 14171368, 14171777, 14171890, 14171953, 14172042, 14172047, - 14172089, 14172170, 14172332, 14172456, 14172572, 14172639, 14173001, 14174547, 14174910, 14175087, 14175109, 14175111, 14175869, - 14175907, 14176246, 14176253, 14176343, 14176607, 14177124, 14177447, 14177503, 14177734, 14178614, 14178630, 14178820, 14178821, - 14178839, 14179074, 14179192, 14179237, 14179326, 14180592, 14180796, 14180851, 14181128, 14181137, 14181693, 14181698, 14181762, - 14181792, 14182209, 14182468, 14182581, 14183420, 14183543, 14183809, 14183872, 14184752, 14184842, 14185023, 14185412, 14185453, - 14185501, 14185653, 14185710, 14185798, 14186682, 14186733, 14187745, 14187752, 14187757, 14187821, 14188264, 14188460, 14188465, - 14188729, 14188778, 14189095, 14189171, 14191103, 14191217, 14191927, 14192000, 14192052, 14192242, 14192398, 14192827, 14192854, - 14193065, 14193073, 14193103, 14193143, 14193158, 14193482, 14193580, 14194305, 14194319, 14194412, 14194419, 14194484, 14194546, - 14194595, 14199795, 14199935, 14199983, 14199986, 14200044, 14200084, 14200111, 14200139, 14200182, 14200190, 14204347, 14204418, - 14204510, 14204511, 14204779, 14204797, 14204839, 14205356, 14205469, 14205477, 14205495, 14206818, 14206853, 14207065, 14207638, - 14207651, 14207666, 14207674, 14207769, 14208925, 14208929, 14208933, 14209218, 14209304, 14209336, 14209575, 14209637, 14209654, - 14209658, 14209756, 14209776, 14209798, 14209927, 14210583, 14210845, 14211495, 14211541, 14211907, 14211929, 14212341, 14212472, - 14212477, 14212690, 14213033, 14213418, 14213497, 14213514, 14213530, 14213652, 14213946, 14213953, 14213972, 14214116, 14214142, - 14214143, 14214366, 14214977, 14214987, 14215167, 14215207, 14215399, 14215416, 14215450, 14215516, 14217199, 14217219, 14217260, - 14217509, 14218325, 14218896, 14218935, 14219106, 14219113, 14219114, 14219119, 14219130, 14219957, 14219958, 14220038, 14220087, - 14220173, 14220219, 14220804, 14221341, 14222488, 14222500, 14222878, 14222894, 14222935, 14223004, 14223669, 14223764, 14227432, - 14227444, 14227445, 14227450, 14227692, 14227697, 14228042, 14228163, 14228181, 14228408, 14228421, 14228485, 14228486, 14228491, - 14228508, 14228587, 14228717, 14228762, 14228769, 14228773, 14228791, 14228792, 14228804, 14228903, 14229010, 14229018, 14229159, - 14231125, 14231300, 14231443, 14231448, 14232109, 14232208, 14232209, 14232381, 14232406, 14232802, 14232810, 14232864, 14232909, - 14233312, 14233318, 14233470, 14233715, 14233727, 14233759, 14235991, 14236061, 14236156, 14236267, 14236301, 14236377, 14236429, - 14236512, 14236650, 14236713, 14236756, 14236769, 14236824, 14236825, 14237021, 14237138, 14237249, 14237357, 14237367, 14237368, - 14237405, 14237422, 14237465, 14237979, 14238006, 14238047, 14238053, 14238054, 14238064, 14238210, 14241229, 14242371, 14242374, - 14242376, 14242495, 14242761, 14242796, 14242807, 14242848, 14242857, 14242860, 14242895, 14242902, 14242903, 14243742, 14243745, - 14243747, 14243828, 14243830, 14243898, 14243995, 14244554, 14244572, 14244661, 14244663, 14245554, 14245560, 14245614, 14245629, - 14245794, 14246045, 14246318, 14246687, 14246846, 14247108, 14247338, 14247826, 14247928, 14247954, 14247963, 14247985, 14248202, - 14248403, 14248732, 14249055, 14249278, 14249875, 14250216, 14250927, 14250928, 14251116, 14251143, 14251320, 14251343, 14251406, - 14251457, 14251569, 14251635, 14251874, 14251884, 14251898, 14252039, 14252092, 14252144, 14252246, 14252318, 14252972, 14253022, - 14255299, 14255310, 14255475, 14255516, 14255543, 14255556, 14255822, 14255995, 14256057, 14256504, 14256561, 14256571, 14256620, - 14258923, 14258985, 14259150, 14259607, 14259661, 14260250, 14260264, 14261054, 14261145, 14261150, 14261244, 14261398, 14261838, - 14261932, 14261969, 14262054, 14262427, 14262460, 14262621, 14263627, 14263682, 14267276, 14267288, 14267519, 14267528, 14267529, - 14267548, 14267622, 14267663, 14268607, 14268629, 14268630, 14268672, 14268685, 14268744, 14268750, 14268751, 14268755, 14269086, - 14269140, 14269168, 14269178, 14269347, 14269356, 14269543, 14269547, 14269776, 14269820, 14270276, 14270280, 14270283, 14270286, - 14270294, 14270310, 14270354, 14270419, 14270466, 14270486, 14270530, 14270550, 14270654, 14270738, 14270744, 14270751, 14270757, - 14270778, 14270784, 14270811, 14270841, 14270889, 14270897, 14270940, 14270943, 14270967, 14270972, 14271360, 14271401, 14271992, - 14271999, 14272079, 14272130, 14272289, 14272325, 14272717, 14272750, 14274773, 14274777, 14274997, 14275001, 14275127, 14275130, - 14275146, 14275323, 14275353, 14275424, 14275668, 14276086, 14276123, 14276168, 14276309, 14276370, 14276458, 14276520, 14277427, - 14277434, 14277438, 14277439, 14277514, 14277581, 14277637, 14278054, 14278075, 14278093, 14278096, 14278100, 14278142, 14278209, - 14278267, 14278302, 14278331, 14278429, 14278440, 14278687, 14278756, 14278811, 14279537, 14279693, 14279798, 14280053, 14280185, - 14280204, 14280267, 14280452, 14280583, 14280616, 14280703, 14281278, 14281362, 14281532, 14281603, 14281860, 14281911, 14282559, - 14283530, 14283550, 14283560, 14283564, 14283579, 14283595, 14283598, 14283613, 14283697, 14283746, 14284070, 14284218, 14284578, - 14284847, 14286487, 14286490, 14286613, 14286765, 14287334, 14287353, 14287608, 14287664, 14287752, 14287787, 14287796, 14287799, - 14287800, 14287802, 14287945, 14288161, 14288307, 14288451, 14288502, 14288846, 14288983, 14289001, 14289005, 14289016, 14289060, - 14289723, 14290173, 14290424, 14290457, 14290459, 14290506, 14290571, 14290766, 14290801, 14290962, 14291669, 14291708, 14291718, - 14291815, 14292939, 14292956, 14293247, 14293268, 14293297, 14293393, 14293441, 14293602, 14293740, 14293803, 14294518, 14294563, - 14294601, 14294625, 14295118, 14295131, 14295183, 14295205, 14295233, 14295243, 14295256, 14295279, 14295325, 14295328, 14295332, - 14295394, 14295420, 14295683, 14295688, 14295809, 14296174, 14296471, 14296495, 14296520, 14296596, 14296598, 14296727, 14296803, - 14296887, 14296913, 14296925, 14297069, 14297070, 14297260, 14297371, 14297452, 14297529, 14297538, 14297676, 14297759, 14297807, - 14297822, 14298409, 14298639, 14298896, 14298903, 14298932, 14299363, 14299554, 14300286, 14300298, 14300301, 14300495, 14300640, - 14300659, 14301074, 14301263, 14301438, 14301472, 14301639, 14301663, 14301665, 14301705, 14301827, 14302166, 14302216, 14302438, - 14302631, 14302782, 14302982, 14303337, 14303485, 14303928, 14304191, 14304195, 14304374, 14304577, 14304591, 14304640, 14305416, - 14305568, 14305668, 14305702, 14305917, 14305920, 14306074, 14306134, 14306454, 14307152, 14307386, 14307402, 14307413, 14307462, - 14307466, 14307547, 14307632, 14307804, 14307929, 14308045, 14308232, 14308345, 14308437, 14308448, 14309558, 14309627, 14309634, - 14309679, 14309714, 14309805, 14309832, 14309939, 14310154, 14310541, 14310658, 14310887, 14310987, 14311341, 14312039, 14312218, - 14312227, 14312251, 14312317, 14312327, 14312447, 14312532, 14313179, 14313565, 14313860, 14313880, 14313896, 14313985, 14314069, - 14314262, 14314503, 14314504, 14315064, 14315149, 14315158, 14315195, 14315406, 14315429, 14315534, 14315796, 14316030, 14316190, - 14316259, 14316600, 14316647, 14316861, 14317147, 14317635, 14317647, 14317657, 14317734, 14317812, 14317833, 14317844, 14317921, - 14317930, 14317937, 14317942, 14317945, 14317982, 14317988, 14318921, 14318922, 14319270, 14319315, 14319942, 14320162, 14320227, - 14320284, 14320753, 14320763, 14322722, 14322745, 14322786, 14322880, 14322990, 14323725, 14323744, 14324520, 14324584, 14324706, - 14324707, 14328007, 14328024, 14331549, 14331550, 14331679, 14332651, 14332653, 14332760, 14332764, 14332800, 14332809, 14333294, - 14333328, 14333336, 14333346, 14333551, 14333562, 14334351, 14334509, 14334540, 14334564, 14337693, 14340622, 14342084, 14342092, - 14342313, 14342321, 14342457, 14342462, 14343083, 14343087, 14343141, 14343154, 14343161, 14343551, 14343566, 14343577, 14343609, - 14343647, 14343803, 14343938, 14343962, 14344087, 14344928, 14344933, 14345088, 14345153, 14345161, 14345601, 14345744, 14345777, - 14346561, 14346614, 14346765, 14346782, 14346783, 14347126, 14347150, 14347420, 14347452, 14347570, 14347598, 14347626, 14347635, - 14347637, 14347725, 14347781, 14348725, 14348905, 14349352, 14349447, 14351917, 14352564, 14352616, 14352773, 14352923, 14353039, - 14354130, 14354236, 14354276, 14354277, 14354290, 14354327, 14354329, 14354337, 14354362, 14354420, 14354429, 14354456, 14354679, - 14354688, 14354691, 14354801, 14354829, 14354874, 14354902, 14354918, 14355487, 14355501, 14355611, 14355907, 14356212, 14356334, - 14356358, 14356391, 14356876, 14357035, 14357313, 14357658, 14357681, 14357718, 14357730, 14357799, 14357850, 14357987, 14358091, - 14358190, 14358267, 14358722, 14359057, 14359213, 14359358, 14359371, 14359465, 14359589, 14359597, 14359648, 14359654, 14360676, - 14360709, 14360796, 14361052, 14361484, 14361538, 14361631, 14361731, 14362244, 14362395, 14362428, 14362460, 14362496, 14362567, - 14362798, 14362805, 14362808, 14363004, 14363041, 14363050, 14363058, 14363068, 14363172, 14363510, 14363570, 14363734, 14364469, - 14364510, 14364518, 14365738, 14365742, 14365752, 14365867, 14365890, 14366055, 14366116, 14366211, 14366224, 14366233, 14366246, - 14366288, 14366309, 14366329, 14366429, 14366430, 14366443, 14366448, 14366472, 14366539, 14366589, 14366750, 14366765, 14366794, - 14366934, 14367112, 14367251, 14367272, 14367282, 14367466, 14367467, 14367468, 14367469, 14367477, 14367496, 14367530, 14367687, - 14367800, 14367833, 14367960, 14368004, 14368015, 14368024, 14368061, 14368069, 14368160, 14368167, 14368170, 14368194, 14368302, - 14368786, 14368797, 14368798, 14368810, 14368823, 14370205, 14370209, 14370844, 14370852, 14371635, 14371854, 14372502, 14372811, - 14375059, 14375196, 14375337, 14375353, 14376850, 14377162, 14377188, 14378134, 14378139, 14378142, 14378262, 14378276, 14378281, - 14378284, 14378300, 14378310, 14378366, 14378380, 14378433, 14380203, 14380358, 14380376, 14380432, 14380454, 14380479, 14380500, - 14380502, 14380511, 14380523, 14380526, 14380576, 14381101, 14381108, 14381116, 14381149, 14381187, 14381336, 14381643, 14381650, - 14384971, 14385017, 14385299, 14385327, 14385345, 14385346, 14385398, 14385409, 14386643, 14386717, 14387783, 14387792, 14387814, - 14387938, 14388060, 14388082, 14388164, 14388173, 14388184, 14388185, 14388190, 14388205, 14388211, 14388234, 14388244, 14388337, - 14388466, 14389756, 14389760, 14391505, 14391529, 14392389, 14392425, 14392444, 14392452, 14392466, 14392654, 14393420, 14393502, - 14393594, 14393595, 14393599, 14393671, 14394385, 14395110, 14395112, 14395122, 14395139, 14395232, 14395237, 14395341, 14395364, - 14395414, 14395416, 14397686, 14397758, 14397792, 14397865, 14398937, 14398955, 14398982, 14399110, 14399114, 14399131, 14399141, - 14399198, 14399200, 14399218, 14399248, 14399251, 14399276, 14399914, 14399919, 14399960, 14399989, 14399992, 14400040, 14400043, - 14400048, 14400097, 14400128, 14400131, 14402470, 14402526, 14402741, 14402794, 14402800, 14402805, 14402891, 14402926, 14404738, - 14404762, 14404988, 14405199, 14405204, 14405237, 14405348, 14406107, 14406164, 14406177, 14406665, 14406666, 14406887, 14406900, - 14406901, 14406982, 14406984, 14407108, 14407204, 14407309, 14407326, 14408372, 14408387, 14408522, 14408523, 14408534, 14408798, - 14408824, 14408858, 14410649, 14410860, 14410915, 14410986, 14411113, 14411190, 14411745, 14411764, 14412210, 14412275, 14412297, - 14412428, 14412434, 14412741, 14412857, 14412866, 14412869, 14413198, 14413199, 14413906, 14413934, 14414045, 14414168, 14414430, - 14414443, 14414710, 14415221, 14415252, 14415388, 14415429, 14415469, 14415513, 14415554, 14415608, 14415656, 14415660, 14415666, - 14415927, 14415975, 14416165, 14417518, 14418203, 14418277, 14418301, 14418317, 14418392, 14418533, 14418543, 14418546, 14419038, - 14419373, 14419466, 14419469, 14419481, 14419488, 14419499, 14419512, 14419521, 14419616, 14419697, 14419698, 14419805, 14419900, - 14419928, 14419929, 14419941, 14419942, 14419962, 14420023, 14420069, 14420082, 14420084, 14420086, 14420091, 14420094, 14420112, - 14420116, 14420129, 14420131, 14420180, 14420183, 14420193, 14420247, 14420253, 14420256, 14420275, 14420293, 14420303, 14420341, - 14420348, 14420480, 14420699, 14420814, 14420849, 14420851, 14420971, 14421014, 14421036, 14421045, 14421046, 14421169, 14421176, - 14421440, 14421858, 14421886, 14421920, 14422148, 14422321, 14422453, 14422593, 14422767, 14422856, 14423018, 14423133, 14423196, - 14423206, 14423268, 14423271, 14423515, 14423532, 14423583, 14423860, 14423881, 14423932, 14424014, 14424043, 14424067, 14424296, - 14424429, 14424452, 14424558, 14424562, 14424571, 14424585, 14424586, 14424589, 14424636, 14424685, 14424736, 14424750, 14424769, - 14425463, 14425546, 14425574, 14425575, 14425633, 14425767, 14425781, 14425849, 14425993, 14426028, 14426072, 14426221, 14426583, - 14427051, 14427197, 14427202, 14427208, 14427399, 14427441, 14427452, 14427473, 14427870, 14428817, 14428898, 14428920, 14429168, - 14429174, 14429180, 14429324, 14430071, 14430108, 14430138, 14430143, 14430231, 14430255, 14430816, 14430855, 14430886, 14430899, - 14430901, 14430902, 14430905, 14430924, 14430965, 14431006, 14431063, 14431282, 14431502, 14431545, 14431559, 14431720, 14431721, - 14432038, 14432172, 14432192, 14432201, 14432626, 14432636, 14432638, 14433023, 14433345, 14433362, 14433891, 14433944, 14434390, - 14434409, 14434414, 14434471, 14434649, 14436439, 14436511, 14436521, 14436616, 14436975, 14437026, 14437134, 14437167, 14437191, - 14437201, 14437204, 14437205, 14437268, 14437527, 14437534, 14437547, 14437565, 14437613, 14437807, 14437820, 14438118, 14438156, - 14438160, 14438162, 14438168, 14438215, 14438333, 14438365, 14438531, 14438538, 14438956, 14439014, 14439085, 14439105, 14439107, - 14439173, 14439501, 14439515, 14439776, 14439868, 14440295, 14440312, 14440363, 14440392, 14440418, 14440420, 14440431, 14440986, - 14440993, 14441010, 14441090, 14441114, 14441175, 14441182, 14441421, 14441424, 14441436, 14441455, 14442331, 14442410, 14442412, - 14442499, 14442590, 14443032, 14443124, 14443702, 14443783, 14443785, 14443880, 14443986, 14443987, 14443996, 14444016, 14444291, - 14444335, 14444348, 14444958, 14445106, 14445730, 14445744, 14445796, 14445857, 14445956, 14445960, 14449012, 14449107, 14449279, - 14449287, 14450086, 14450107, 14450169, 14450196, 14451369, 14451491, 14451664, 14451679, 14452080, 14452088, 14452158, 14452281, - 14452377, 14452464, 14454060, 14454100, 14454259, 14454284, 14455932, 14455937, 14456161, 14456169, 14456173, 14456215, 14456220, - 14456251, 14456262, 14456272, 14456374, 14456386, 14456389, 14456408, 14456422, 14456596, 14456654, 14456697, 14456714, 14457226, - 14457236, 14457251, 14457272, 14457294, 14457295, 14457323, 14457332, 14457341, 14457872, 14457925, 14458268, 14458361, 14462180, - 14462204, 14462241, 14462308, 14464172, 14464255, 14466306, 14466331, 14466411, 14466425, 14466470, 14466488, 14466497, 14466523, - 14466972, 14466984, 14467004, 14467023, 14468341, 14468496, 14469581, 14469604, 14469619, 14469675, 14470339, 14470341, 14470456, - 14470514, 14470520, 14470622, 14470887, 14470888, 14471412, 14471417, 14471591, 14471594, 14473086, 14473092, 14473096, 14473097, - 14473637, 14473642, 14475479, 14475496, 14475695, 14475733, 14476630, 14476676, 14476712, 14476812, 14477122, 14477145, 14477588, - 14477589, 14477594, 14477605, 14477607, 14477633, 14477742, 14477772, 14477777, 14478030, 14478043, 14478624, 14478666, 14479141, - 14479784, 14479865, 14479943, 14479950, 14479961, 14481636, 14481637, 14481722, 14481726, 14481758, 14481986, 14481997, 14482096, - 14482102, 14482118, 14482138, 14482420, 14482427, 14482457, 14482487, 14482508, 14482687, 14482693, 14482834, 14482845, 14483435, - 14483438, 14483442, 14483453, 14483471, 14483605, 14483834, 14483839, 14484322, 14484339, 14484341, 14484392, 14484412, 14484498, - 14484698, 14484752, 14484755, 14488867, 14488878, 14488894, 14488896, 14489287, 14489291, 14489510, 14489549, 14490029, 14490073, - 14490084, 14490085, 14490086, 14490088, 14490123, 14490128, 14490190, 14490213, 14490644, 14490652, 14490708, 14490728, 14490903, - 14490908, 14491415, 14491754, 14491757, 14491758, 14491805, 14492838, 14493628, 14494367, 14494372, 14494373, 14494376, 14494379, - 14494381, 14494646, 14494656, 14494661, 14494752, 14494868, 14494907, 14494921, 14494941, 14494953, 14494954, 14495034, 14495065, - 14495075, 14495076, 14495135, 14495154, 14495165, 14495173, 14495188, 14495192, 14495488, 14495493, 14495495, 14495501, 14495644, - 14495687, 14495688, 14495840, 14495967, 14495968, 14496394, 14496406, 14496408, 14496432, 14496500, 14496551, 14496604, 14496966, - 14497034, 14497038, 14497550, 14497568, 14497570, 14497668, 14497702, 14497706, 14497708, 14497820, 14497848, 14497895, 14497913, - 14497935, 14497937, 14498323, 14498354, 14498355, 14501002, 14501005, 14501526, 14502186, 14502208, 14502215, 14502229, 14502284, - 14502295, 14502315, 14502353, 14502605, 14502627, 14502635, 14502663, 14502758, 14502769, 14503020, 14503058, 14503061, 14503068, - 14503086, 14503134, 14503288, 14503395, 14503429, 14503435, 14503522, 14503525, 14504153, 14504162, 14504169, 14504173, 14504371, - 14504422, 14504432, 14504442, 14507145, 14507147, 14507476, 14507486, 14507489, 14507515, 14507520, 14507570, 14507702, 14507732, - 14508208, 14508212, 14509089, 14509103, 14509612, 14509623, 14511370, 14511373, 14511378, 14511379, 14511768, 14511773, 14512246, - 14512248, 14514087, 14514094, 14514100, 14514117, 14514130, 14514133, 14514156, 14514162, 14514508, 14514588, 14514908, 14514918, - 14514964, 14514971, 14514989, 14515007, 14515063, 14515165, 14515419, 14515421, 14515591, 14515593, 14515714, 14515716, 14515719, - 14515720, 14515748, 14515749, 14515854, 14515860, 14515903, 14515904, 14515951, 14515955, 14515993, 14515997, 14516253, 14516270, - 14516372, 14516412, 14516497, 14516503, 14517397, 14517439, 14519618, 14519619, 14519694, 14519701, 14519702, 14519714, 14519776, - 14519782, 14519803, 14519804, 14519955, 14519996, 14520020, 14520024, 14520043, 14520060, 14520061, 14520062, 14520115, 14520126, - 14520159, 14520172, 14520186, 14520190, 14520198, 14520212, 14520222, 14520227, 14520235, 14520497, 14520498, 14520746, 14520774, - 14520977, 14520982, 14520986, 14521011, 14521066, 14521069, 14522110, 14522112, 14522118, 14522165, 14522218, 14522219, 14522733, - 14522797, 14523118, 14523126, 14523830, 14523835, 14524242, 14524243, 14524259, 14524266, 14526070, 14526077, 14526083, 14526086, - 14526087, 14526099, 14526120, 14526126, 14526141, 14526211, 14526215, 14526221, 14526244, 14526255, 14526300, 14526321, 14526332, - 14526340, 14526344, 14526346, 14526356, 14526363, 14526380, 14526442, 14526463, 14527065, 14527080, 14527084, 14527176, 14527178, - 14527369, 14527370, 14527424, 14527431, 14527447, 14527451, 14527599, 14527626, 14527627, 14527633, 14527696, 14527715, 14527723, - 14527735, 14527839, 14528084, 14528085, 14528093, 14528124, 14528171, 14528614, 14528712, 14528723, 14528757, 14528758, 14528864, - 14528925, 14528961, 14528969, 14528986, 14528993, 14528997, 14529009, 14529012, 14529017, 14529021, 14529024, 14529026, 14529029, - 14529033, 14529037, 14529046, 14529100, 14529124, 14529557, 14530096, 14530149, 14531104, 14531141, 14531213, 14531235, 14531744, - 14531775, 14531956, 14531968, 14531999, 14532026, 14532066, 14532097, 14532696, 14532706, 14532729, 14532730, 14532739, 14532749, - 14532758, 14532838, 14532843, 14533032, 14533035, 14533049, 14533066, 14533070, 14533079, 14533136, 14533141, 14533267, 14533299, - 14533319, 14533321, 14533346, 14533372, 14533410, 14533430, 14533442, 14533526, 14533548, 14533722, 14533805, 14533836, 14533847, - 14533860, 14533861, 14533873, 14533878, 14533920, 14534184, 14534185, 14534191, 14534193, 14534233, 14534256, 14534343, 14534366, - 14534397, 14534426, 14535016, 14535017, 14535020, 14535028, 14535045, 14535083, 14535119, 14535180, 14535199, 14535394, 14535426, - 14535428, 14535456, 14535475, 14535634, 14535662, 14535688, 14535691, 14535692, 14535702, 14536479, 14536480, 14536489, 14536490, - 14536492, 14536493, 14538931, 14538950, 14539037, 14539038, 14539216, 14539309, 14539334, 14539344, 14539390, 14539420, 14539473, - 14539534, 14539537, 14539564, 14540149, 14540166, 14540656, 14540667, 14540769, 14540796, 14541039, 14541063, 14541069, 14541071, - 14541159, 14541165, 14541181, 14541201, 14541315, 14541323, 14541325, 14541328, 14541535, 14542840, 14542888, 14542906, 14542907, - 14543190, 14543248, 14543853, 14543908, 14544590, 14544596, 14544603, 14544616, 14544670, 14544671, 14544700, 14544710, 14544746, - 14544754, 14544827, 14544828, 14544837, 14544856, 14544877, 14544962, 14545025, 14545172, 14545204, 14545224, 14545226, 14545234, - 14545464, 14545483, 14545723, 14545743, 14545958, 14545994, 14546116, 14546131, 14546151, 14546163, 14546371, 14546380, 14546408, - 14546419, 14546448, 14546450, 14546509, 14546553, 14546560, 14546608, 14546630, 14546636, 14546678, 14546684, 14546867, 14546869, - 14547247, 14547249, 14547565, 14547577, 14547724, 14547850, 14547854, 14547861, 14547962, 14548000, 14550132, 14550221, 14552498, - 14552506, 14552667, 14552671, 14552813, 14552828, 14553470, 14553472, 14553476, 14554183, 14554188, 14554192, 14554225, 14554740, - 14554785, 14555988, 14556013, 14556021, 14556022, 14556083, 14556084, 14556089, 14556092, 14556100, 14556103, 14556108, 14556140, - 14556651, 14558534, 14559061, 14559072, 14559085, 14559733, 14559791, 14560016, 14560026, 14560028, 14560038, 14560040, 14560076, - 14560273, 14560275, 14560303, 14560306, 14560310, 14560322, 14560576, 14560577, 14560582, 14560595, 14560608, 14560622, 14560728, - 14560734, 14561795, 14561825, 14561840, 14562587, 14562623, 14562630, 14562645, 14563527, 14563541, 14563542, 14563549, 14563729, - 14563739, 14563740, 14563748, 14563749, 14563755, 14563766, 14563768, 14563774, 14563775, 14563894, 14563959, 14563963, 14563967, - 14564050, 14564054, 14564058, 14564075, 14564164, 14564730, 14564733, 14565457, 14565462, 14565943, 14566817, 14566822, 14588081, - 15278993, 15298860, 15299275, 15299420, 15299520, 15299715, 15299731, 15299757, 15301708, 15301850, 15301875, 15302455, 15302967, - 15304019, 15305121, 15305561, 15307407, 15307490, 15307868, 15308032, 15311107, 15311210, 15311599, 15316343, 15316528, 15316535, - 15317411, 15318069, 15318235, 15318288, 15318437, 15318758, 15319019, 15319366, 15319403, 15320313, 15321005, 15321511, 15321634, - 15321707, 15321890, 15322055, 15322136, 15323088, 15323182, 15323543, 15324636, 15327600, 15328789, 15328903, 15328961, 15329151, - 15330358, 15330441, 15330468, 15331215, 15331280, 15333764, 15333830, 15335397, 15336059, 15337247, 15337395, 15337630, 15339099, - 15340038, 15340971, 15341319, 15341479, 15341544, 15342783, 15343155, 15343302, 15343551, 15343809, 15344150, 15344169, 15344370, - 15344584, 15346218, 15346421, 15346604, 15346684, 15346714, 15346716, 15350123, 15350143, 15350966, 15351041, 15351346, 15351348, - 15352316, 15352341, 15353576, 15353802, 15354436, 15354503, 15354708, 15354744, 15355751, 15355938, 15356263, 15356464, 15357773, - 15357806, 15357836, 15357870, 15359242, 15359261, 15359409, 15359557, 15359701, 15359731, 15359846, 15359932, 15360348, 15360351, - 15360966, 15360968, 15360998, 15361018, 15363267, 15363312, 15363413, 15363420, 15363920, 15364070, 15364136, 15364150, 15364663, - 15364715, 15367310, 15367326, 15368095, 15368104, 15368537, 15368541, 15368874, 15368881, 15369797, 15369898, 15370883, 15370885, - 15371463, 15371516, 15372941, 15373029, 15373035, 15373039, 15373489, 15373548, 15374297, 15374326, 15374448, 15374596, 15375231, - 15375318, 15375776, 15375803, 15376049, 15376057, 15377278, 15377371, 15378036, 15378043, 15378052, 15378059, 15378164, 15378166, - 15379378, 15379430, 15379848, 15379863, 15379880, 15379890, 15381333, 15381472, 15381587, 15381594, 15382319, 15382335, 15382622, - 15382689, 15384884, 15384889, 15386453, 15386482, 15386506, 15386762, 15386943, 15387036, 15387461, 15387465, 15387752, 15387804, - 15388394, 15388486, 15388606, 15388617, 15389904, 15390109, 15390434, 15390437, 15390816, 15390866, 15393023, 15393050, 15393079, - 15393299, 15393785, 15393789, 15394171, 15394184, 15394223, 15394363, 15397304, 15397311, 15397367, 15397572, 15398540, 15398542, - 15398966, 15398984, 15400273, 15400276, 15400610, 15400638, 15401565, 15401650, 15404521, 15404620, 15406007, 15406017, 15406624, - 15406687, 15407958, 15407964, 15408278, 15408287, 15410615, 15410769, 15411104, 15411119, 15411326, 15411591, 15411833, 15411836, - 15413038, 15413046, 15413111, 15413148, 15413371, 15413374, 15413483, 15413499, 15415282, 15415416, 15417725, 15417802, 15417896, - 15417906, 15419558, 15419604, 15419797, 15419800, 15419980, 15420000, 15420016, 15420019, 15421514, 15421544, 15423424, 15423558, - 15423661, 15423673, 15424869, 15424873, 15425240, 15425382, 15425895, 15425897, 15426289, 15426372, 15427195, 15427225, 15427230, - 15427233, 15427289, 15427298, 15427993, 15427999, 15428176, 15428217, 15428227, 15428516, 15428529, 15428567, 15428784, 15429008, - 15429020, 15429026, 15429032, 15429281, 15430344, 15430346, 15430706, 15430735, 15430879, 15430885, 15431260, 15431365, 15432397, - 15432422, 15432649, 15432654, 15432804, 15432819, 15433923, 15433932, 15435272, 15435298, 15437041, 15437050, 15438105, 15438114, - 15440121, 15440253, 15441104, 15441282, 15442199, 15442584, 15443871, 15444142, 15444188, 15444408, 15444685, 15444690, 15445733, - 15445736, 15445863, 15445878, 15447031, 15447065, 15448796, 15448816, 15449403, 15449413, 15449587, 15449609, 15449711, 15449878, - 15449962, 15449964, 15450263, 15450405, 15450446, 15450450, 15451400, 15451408, 15451819, 15451857, 15452179, 15452192, 15452979, - 15453020, 15453357, 15453514, 15455431, 15455434, 15455761, 15455880, 15456762, 15456784, 15457983, 15459043, 15459439, 15459567, - 15459814, 15459822, 15460508, 15460591, 15461069, 15461082, 15462424, 15462426, 15462594, 15462656, 15462690, 15462696, 15463436, - 15463936, 15464266, 15465784, 15465839, 15465937, 15466610, 15466631, 15467021, 15467085, 15467103, 15467109, 15467756, 15467851, - 15468430, 15468503, 15468511, 15468652, 15469184, 15469200, 15469285, 15469458, 15469754, 15469759, 15470276, 15470283, 15470370, - 15470392, 15471545, 15471785, 15473261, 15473269, 15473454, 15473460, 15474422, 15474425, 15474922, 15475151, 15475640, 15475643, - 15476163, 15476405, 15476427, 15476439, 15477009, 15477179, 15477640, 15477649, 15479093, 15479107, 15480142, 15480151, 15480580, - 15480814, 15481022, 15481026, 15481035, 15481037, 15481562, 15481565, 15481590, 15481591, 15481741, 15481744, 15482067, 15482078, - 15482616, 15482683, 15486561, 15486564, 15486616, 15486617, 15486666, 15486668, 15486678, 15486680, 15487459, 15487500, 15488119, - 15488127, 15488401, 15488409, 15488440, 15488442, 15488965, 15488970, 15489694, 15489700, 15490595, 15490615, 15491720, 15491760, - 15492016, 15492020, 15492072, 15492087, 15492855, 15492857, 15493002, 15493004, 15493071, 15493074, 15493106, 15493108, 15493360, - 15493365, 15494319, 15494332, 15496258, 15496263, 15497235, 15497254, 15497321, 15497338, 15498352, 15498354, 15499365, 15499369, - 15501348, 15501354, 15502470, 15502478, 15503665, 15503673, 15504523, 15504537, 15504621, 15504628, 15504938, 15505080, 15506069, - 15506072, 15506112, 15506113, 15506426, 15506436, 15507433, 15507435, 15508130, 15508192, 15508250, 15508358, 15510418, 15510430, - 15510706, 15510712, 15511523, 15511526, 15511628, 15511629, 15512065, 15512071, 15512120, 15512121, 15513126, 15513199, 15513214, - 15513441, 15514260, 15514460, 15515518, 15515520, 15515699, 15515701, 15516480, 15516482, 15517627, 15517654, 15518075, 15518102, - 15519576, 15519578, 15520859, 15520864, 15521342, 15521351, 15521537, 15521553, 15521701, 15521707, 15522808, 15523015, 15523483, - 15523488, 15524388, 15524397, 15524703, 15524713, 15525341, 15525343, 15525349, 15525353, 15526412, 15526559, 15527127, 15527133, - 15527672, 15527675, 15528231, 15528248, 15528274, 15528307, 15529512, 15529522, 15529961, 15530071, 15530915, 15530926, 15531367, - 15531370, 15533472, 15533487, 15534560, 15534786, 15535306, 15535318, 15535392, 15535522, 15538116, 15539371, 15540337, 15540602, - 15541064, 15541071, 15541659, 15541666, 15541681, 15541719, 15541771, 15541777, 15542276, 15542282, 15542576, 15542585, 15542589, - 15542594, 15542886, 15542896, 15543880, 15543976, 15544196, 15546926, 15547006, 15547018, 15547117, 15547119, 15547436, 15547520, - 15547554, 15547587, 15547642, 15547644, 15549036, 15549039, 15549429, 15549448, 15550823, 15550828, 15551147, 15551381, 15551716, - 15551720, 15552150, 15552267, 15554087, 15554090, 15554449, 15554456, 15555207, 15555210, 15556032, 15556037, 15556177, 15556184, - 15557755, 15557761, 15558433, 15558443, 15559082, 15559107, 15560806, 15560890, 15561941, 15562075, 15562258, 15562260, 15563500, - 15563507, 15563620, 15563624, 15565974, 15565985, 15566159, 15566161, 15566675, 15567720, 15567772, 15697646, 15698252, 15699048, - 15699049, 15699308, 15699355, 15701033, 15701037, 15701139, 15701868, 15722361, 15723839, 15725644, 15726602, 15726621, 15726727, - 15726730, 15728420, 15728425, 15729973, 15729986, 15731110, 15731125, 15732349, 15732819, 15733345, 15733382, 15736966, 15741478, - 15742747, 15743712, 15744541, 15746902, 15748357, 15751438, 15751801, 15754322, 15755697, 15768595, 15768635, 15768636, 15771170, - 15771235, 15771418, 15771566, 15772511, 15772514, 15773217, 15773287, 15773693, 15775062, 15775162, 15775170, 15775628, 15775748, - 15777966, 15778518, 15780571, 15780590, 15781334, 15781414, 15783805, 15784103, 15784218, 15784222, 15784336, 15786288, 15786350, - 15786412, 15786880, 15787424, 15791418, 15791577, 15791945, 15792759, 15792904, 15792905, 15793375, 15799982, 15800147, 15800148, - 15800738, 15800739, 15801497, 15801498, 15803568, 15803571, 15805641, 15808771, 15809000, 15815539, 15815540, 15815571, 15816365, - 15816366, 15820482, 15820483, 15820930, 15820933, 15822783, 15822784, 15823306, 15823308, 15823485, 15823486, 15827101, 15827102, - 15830019, 15830020, 15830105, 15830106, 15835137, 15835138, 15838243, 15839723, 15840576, 15841503, 15841688, 15841690, 15847048, - 15847050, 15847745, 15848829, 15850375, 15855827, 15859288, 15859289, 15860023, 15860373, 15860606, 15860607, 15860828, 15860829, - 15861647, 15861648, 15861982, 15861983, 15863539, 15865475, 15865811, 15865812, 15865814, 15865819, 15865939, 15865940, 15866722, - 15866723, 15867794, 15869548, 15870297, 15870823, 15870956, 15870957, 15871190, 15871197, 15871254, 15871766, 15872132, 15873270, - 15875334, 15875634, 15875797, 15876025, 15876802, 15876803, 15876808, 15876810, 15876831, 15876833, 15876844, 15876845, 15876858, - 15876859, 15876865, 15876866, 15876996, 15877054, 15877147, 15878253, 15878396, 15878397, 15878409, 15878410, 15880251, 15880252, - 15880976, 15883223, 15883257, 15883258, 15883267, 15883268, 15883338, 15883366, 15883572, 15883573, 15883704, 15883705, 15883815, - 15883866, 15884708, 15885134, 15886585, 15886948, 15889015, 15889135, 15889263, 15889264, 15889297, 15890107, 15890836, 15890856, - 15891258, 15891259, 15891595, 15891596, 15898995, 15899413, 15900484, 15900485, 15900856, 15900857, 15900999, 15901784, 15902052, - 15902074, 15903287, 15904479, 15904560, 15904561, 15904756, 15904948, 15905428, 15905429, 15908728, 15908729, 15908732, 15908733, - 15908737, 15908739, 15911168, 15911169, 15911465, 15911466, 15912295, 15912378, 15912429, 15912435, 15912645, 15913367, 15915228, - 15915229, 15915232, 15915233, 15915473, 15915474, 15915509, 15915510, 15915885, 15915886, 15916207, 15916208, 15916906, 15916907, - 15917200, 15917202, 15917206, 15917207, 15921490, 15921491, 15921519, 15922789, 15923115, 15923117, 15924339, 15924525, 15924533, - 15926434, 15927196, 15928263, 15929673, 15929674, 15929698, 15929766, 15930272, 15941143, 15941944, 15941945, 15941949, 15941950, - 15941954, 15941955, 15941966, 15941967, 15942041, 15942242, 15943918, 15944225, 15944958, 15948423, 15948742, 15948893, 15948934, - 15948935, 15948952, 15948953, 15948974, 15948975, 15948980, 15948981, 15948984, 15948985, 15948995, 15948996, 15949061, 15949062, - 15950050, 15950051, 15950637, 15950638, 15950642, 15950643, 15950646, 15950647, 15950650, 15950651, 15950666, 15950667, 15950686, - 15950687, 15951694, 15951695, 15951941, 15951942, 15951970, 15951971, 15951974, 15951975, 15951978, 15951979, 15952040, 15954672, - 15956700, 15956815, 15957170, 15957963, 15965549, 15968309, 15969082, 15969120, 15970110, 15970111, 15970828, 15970854, 15971891, - 15971916, 15971980, 15972006, 15973526, 15973527, 15973835, 15974371, 15976265, 15977379, 15978362, 15978948, 15979197, 15980087, - 15980290, 15980299, 15981105, 15981106, 15981914, 15981915, 15982995, 15985005, 15985847, 15986020, 15986468, 15990277, 15990962, - 15991688, 15992374, 15992627, 15992966, 15994933, 15995140, 15995217, 15998964, 16006307, 16010481, 16011214, 16012893, 16013844, - 16015906, 17636688, 17637873, 17638275, 17638348, 17638487, 17638892, 17664726, 17667175, 17673330, 17673544, 17673816, 17681905, - 17685084, 17685085, 17687705, 17691885, 17692405, 17693311, 17694199, 17698519, 17699421, 17699575, 17699776, 17704976, 17705868, - 17707335, 17707490, 17710949, 17711356, 17711906, 17712444, 17720306, 17720567, 17723439, 17723538, 17729149, 17729172, 17730669, - 17735353, 17738506, 17739593, 17742978, 17746144, 17752865, 17759547, 17770240, 17774229, 17774250, 17778606, 17779105, 17782179, - 17783310, 17783420, 17784087, 17791119, 17792330, 17793195, 17795208, 17796208, 17798702, 17803925, 17806758, 17808553, 17811929, - 17815836, 17818217, 17853647, 17855162, 17855180, 17874661, 17881967, 17886031, 17886472, 17886499, 17892400, 17892586, 17893593, - 17918105, 17920208, 17923983, 17932312, 17940478, 17949572, 17950256, 17978577, 17978638, 17979243, 17981913, 17981914, 17986345, - 17995612, 17998455, 18001936, 18018601, 18019359, 18020832, 18020852, 18020857, 18021161, 18024791, 18028665, 18028982, 18029024, - 18029065, 18029402, 18029410, 18029412, 18029430, 18029461, 18029535, 18029709, 18029941, 18030109, 18030158, 18030174, 18030618, - 18030897, 18031010, 18031050, 18031102, 18031119, 18033407, 18033471, 18033519, 18034800, 18035522, 18035524, 18035558, 18035587, - 18035592, 18035611, 18035718, 18036283, 18037159, 18037177, 18037518, 18037756, 18037831, 18038107, 18038314, 18040137, 18040830, - 18042044, 18042107, 18042113, 18042989, 18044136, 18044214, 18045284, 18046457, 18046504, 18046619, 18046757, 18047186, 18047597, - 18047661, 18047776, 18047878, 18047880, 18048688, 18049264, 18050153, 18050586, 18050926, 18051022, 18052532, 18052575, 18052827, - 18053165, 18053676, 18053753, 18054135, 18055170, 18056994, 18057401, 18057693, 18057697, 18058403, 18058457, 18058779, 18058896, - 18059950, 18059951, 18061046, 18061130, 18061163, 18061330, 18062045, 18062047, 18062332, 18063045, 18063475, 18063531, 18063738, - 18064294, 18065075, 18065242, 18065980, 18066212, 18066443, 18066962, 18067060, 18067533, 18067720, 18067880, 18067908, 18067926, - 18069030, 18069287, 18069478, 18069486, 18070682, 18070696, 18070945, 18070960, 18071100, 18071247, 18071778, 18071877, 18071965, - 18072000, 18072080, 18072170, 18072197, 18072238, 18072391, 18072987, 18073243, 18074765, 18075302, 18075625, 18075780, 18075781, - 18075911, 18075915, 18075944, 18075961, 18078850, 18079649, 18082360, 18084867, 18084911, 18085324, 18085709, 18087962, 18087963, - 18088191, 18088242, 18088250, 18088280, 18088356, 18088559, 18088585, 18088685, 18088801, 18089141, 18089688, 18089823, 18090573, - 18092942, 18093321, 18093525, 18093792, 18094278, 18094280, 18094353, 18094818, 18095086, 18096830, 18096870, 18096945, 18099264, - 18099563, 18103567, 18105534, 18105712, 18105730, 18106676, 18106758, 18107898, 18108072, 18108109, 18108251, 18108364, 18108366, - 18108385, 18108608, 18109192, 18109630, 18109736, 18109886, 18110216, 18111914, 18117472, 18120015, 18121451, 18121461, 18123475, - 18126178, 18127068, 18127313, 18128050, 18128330, 18128335, 18128741, 18129173, 18129186, 18129274, 18129299, 18129598, 18129647, - 18130999, 18131052, 18132357, 18132384, 18132993, 18133129, 18133459, 18134121, 18134494, 18134563, 18134668, 18134725, 18135378, - 18135538, 18135637, 18136098, 18136421, 18136723, 18136850, 18138655, 18138798, 18139149, 18139266, 18139885, 18144618, 18145061, - 18145076, 18145167, 18145171, 18145489, 18145498, 18151530, 18154233, 18157193, 18157230, 18157352, 18157653, 18158227, 18159887, - 18160433, 18160599, 18163130, 18167158, 18167584, 18167696, 18168147, 18168194, 18169252, 18169257, 18169269, 18171907, 18171970, - 18173270, 18173746, 18173941, 18173950, 18174259, 18174963, 18176304, 18176339, 18176342, 18177237, 18177283, 18177395, 18177473, - 18177557, 18177648, 18178048, 18178068, 18179144, 18179923, 18180023, 18180031, 18182471, 18182554, 18183350, 18185302, 18186630, - 18189759, 18191550, 18191572, 18191690, 18191760, 18209428, 18209658, 18210069, 18210134, 18211447, 18211680, 18213658, 18214305, - 18226915, 18227231, 18233695, 18234036, 18234679, 18237160, 18237345, 18237354, 18237447, 18238159, 18238169, 18238305, 18238306, - 18238341, 18239452, 18239552, 18239591, 18242107, 18243775, 18247187, 18248062, 18248090, 18248152, 18248702, 18248948, 18251287, - 18253159, 18253172, 18253256, 18253494, 18253674, 18253702, 18253731, 18253737, 18254465, 18254579, 18254961, 18255157, 18255423, - 18255953, 18255964, 18255975, 18256059, 18256119, 18256175, 18256361, 18258481, 18258531, 18258617, 18258894, 18258898, 18258975, - 18259049, 18259278, 18259287, 18259310, 18260016, 18261458, 18261488, 18261623, 18262488, 18262528, 18262642, 18262749, 18262798, - 18262808, 18262813, 18262819, 18262827, 18262860, 18263274, 18265073, 18265373, 18274127, 18274713, 18274727, 18275088, 18275112, - 18275130, 18278505, 18278955, 18279067, 18279081, 18282620, 18282661, 18283406, 18283563, 18283848, 18284148, 18284248, 18284447, - 18284548, 18285101, 18285102, 18285296, 18285465, 18285587, 18286538, 18286732, 18286922, 18287028, 18287423, 18287435, 18288316, - 18288614, 18288684, 18289315, 18289388, 18289811, 18290157, 18291493, 18291622, 18291700, 18291765, 18292103, 18292104, 18292192, - 18292266, 18293383, 18293550, 18293680, 18293751, 18293811, 18294213, 18294759, 18299826, 18299990, 18300398, 18301246, 18301327, - 18303702, 18303813, 18304121, 18306402, 18306490, 18306738, 18307134, 18307258, 18307380, 18307382, 18307680, 18308694, 18308707, - 18308744, 18308789, 18308936, 18309470, 18309756, 18310124, 18310324, 18310679, 18313272, 18313276, 18313936, 18313942, 18314463, - 18314471, 18314489, 18314786, 18314944, 18314957, 18315430, 18315905, 18315975, 18316319, 18316622, 18316913, 18317424, 18317507, - 18317562, 18317614, 18318101, 18318833, 18319890, 18320642, 18320688, 18322258, 18322526, 18322711, 18323528, 18323546, 18324258, - 18326071, 18328517, 18329261, 18333428, 18334440, 18334468, 18340005, 18340701, 18341515, 18342104, 18343985, 18344306, 18344387, - 18344445, 18349782, 18354524, 18354532, 18354567, 18354647, 18355784, 18355800, 18355890, 18356093, 18356174, 18357105, 18358907, - 18359179, 18360540, 18360761, 18361109, 18362474, 18362701, 18363071, 18363333, 18363353, 18363359, 18363669, 18363849, 18364852, - 18365537, 18365642, 18370037, 18374101, 18374518, 18374703, 18378858, 18378979, 18379121, 18388650, 18392831, 18392906, 18393035, - 18393498, 18395705, 18396655, 18396696, 18399717, 18399721, 18399791, 18399885, 18400237, 18400318, 18401555, 18403896, 18403898, - 18403948, 18403950, 18404071, 18404074, 18404115, 18404117, 18404169, 18404170, 18404177, 18404214, 18408893, 18409021, 18409026, - 18409046, 18409296, 18409304, 18409332, 18409338, 18409342, 18409356, 18409383, 18409396, 18409511, 18409551, 18409567, 18409579, - 18409581, 18409638, 18409642, 18409660, 18409669, 18409705, 18409710, 18409737, 18410309, 18410336, 18410366, 18410382, 18410392, - 18410418, 18410426, 18410429, 18410929, 18410976, 18411158, 18414923, 18414966, 18414967, 18414971, 18414973, 18414996, 18415012, - 18415335, 18415343, 18415344, 18415372, 18415383, 18415401, 18415404, 18415409, 18415410, 18415439, 18415463, 18415730, 18415734, - 18415751, 18415752, 18415755, 18415762, 18415770, 18415789, 18415907, 18415911, 18415914, 18415915, 18415918, 18415919, 18415924, - 18415934, 18415935, 18415948, 18415951, 18415960, 18415962, 18415969, 18415974, 18415988, 18415996, 18416003, 18416007, 18416096, - 18416097, 18416098, 18416099, 18416110, 18416111, 18416121, 18417000, 18417004, 18417110, 18417111, 18417153, 18417223, 18417250, - 18417254, 18417255, 18417271, 18417276, 18417298, 18417306, 18418074, 18418081, 18419778, 18419803, 18419847, 18419867, 18419982, - 18420104, 18420138, 18420139, 18420149, 18420289, 18420295, 18421340, 18421341, 18421351, 18421354, 18421396, 18422027, 18422036, - 18422039, 18422146, 18422232, 18422238, 18422335, 18422473, 18422479, 18422569, 18422577, 18422932, 18423232, 18423233, 18423380, - 18423386, 18423801, 18423803, 18424005, 18424006, 18424106, 18424119, 18427918, 18428063, 18428188, 18428190, 18428341, 18428344, - 18428376, 18428378, 18428415, 18429089, 18429190, 18429191, 18429295, 18429301, 18429401, 18429408, 18429419, 18429425, 18429515, - 18429526, 18429763, 18430201, 18430203, 18430403, 18431180, 18431188, 18431554, 18431563, 18431586, 18431622, 18431858, 18431859, - 18432040, 18432050, 18432832, 18433010, 18433079, 18433119, 18459655, 18461356, 18461857, 18462173, 18463453, 18463531, 18479349, - 18479433, 18479437, 18479545, 18479547, 18479583, 18479584, 18479595, 18479615, 18479616, 18479622, 18481099, 18481103, 18481144, - 18481145, 18481150, 18481262, 18481457, 18481554, 18481769, 18485920, 18501825, 18501901, 18501914, 18503176, 18503321, 18503324, - 18503327, 18503748, 18503861, 18505085, 18505121, 18505795, 18505826, 18505827, 18505942, 18507352, 18507393, 18507395, 18507485, - 18507493, 18513155, 18513195, 18513450, 18513477, 18513488, 18513513, 18513532, 18513740, 18535188, 18535211, 18535223, 18535504, - 18535506, 18535511, 18535523, 18535526, 18535693, 18535863, 18535867, 18535950, 18535960, 18536171, 18536855, 18536862, 18536866, - 18536868, 18536869, 18537563, 18537686, 18537828, 18537830, 18539322, 18539428, 18539449, 18539565, 18539569, 18542957, 18549853, - 18549867, 18614667, 18614674, 18614685, 18614689, 18629129, 18629130, 18629263, 18629369, 18629370, 18629490, 18629492, 18630041, - 18630174, 18630284, 18640752, 18640754, 18640811, 18640900, 18640907, 18640943, 18640945, 18641080, 18641081, 18641157, 18641158, - 18641209, 18641401, 18642300, 18642313, 18642314, 18642405, 18642455, 18642533, 18642534, 18642593, 18642798, 18642799, 18644754, - 18690658, 18690699, 18692929, 18692939, 18698953, 18698954, 18699153, 18699427, 18699430, 18700378, 18700541, 18700543, 18700746, - 18700748, 18700766, 18700833, 18700834, 18700841, 18700842, 18701022, 18701473, 18701507, 18701522, 18701524, 18701573, 18701579, - 18701583, 18701911, 18702014, 18702025, 18702055, 18702094, 18702904, 18703319, 18703328, 18703920, 18704157, 18704427, 18704428, - 18705700, 18706080, 18707114, 18707117, 18707253, 18707486, 18707577, 18707592, 18707596, 18707946, 18707947, 18707956, 18707959, - 18707960, 18708017, 18708020, 18708754, 18708755, 18708938, 18709230, 18709237, 18709605, 18709606, 18709614, 18709621, 18709666, - 18709675, 18709742, 18709754, 18709760, 18709875, 18709881, 18709972, 18709987, 18710107, 18710153, 18710156, 18710159, 18710194, - 18710203, 18710456, 18710530, 18710672, 18722404, 18722407, 18722441, 18722444, 18722474, 18722476, 18722661, 18722684, 18722853, - 18722855, 18722857, 18722860, 18722964, 18722965, 18722991, 18723370, 18723413, 18723704, 18723707, 18723764, 18723766, 18723857, - 18723860, 18723916, 18723941, 18723981, 18735304, 18735677, 18737090, 18737199, 18737256, 18737264, 18737394, 18737400, 18738534, - 18738537, 18738632, 18738633, 18738690, 18738691, 18738755, 18739002, 18739014, 18739017, 18739026, 18739095, 18739204, 18739715, - 18739719, 18739774, 18739780, 18741326, 18741377, 18742319, 18742321, 18742401, 18743044, 18743049, 18743102, 18743109, 18743127, - 18743150, 18743153, 18744034, 18744038, 18744047, 18744053, 18744099, 18744100, 18744161, 18744178, 18744272, 18744440, 18744448, - 18744503, 18744507, 18744957, 18744963, 18745309, 18746182, 18746720, 18746766, 18746769, 18747055, 18747115, 18747509, 18748208, - 18748215, 18748216, 18748616, 18748632, 18748881, 18748930, 18749143, 18749153, 18749347, 18749597, 18749859, 18749862, 18749865, - 18750557, 18750566, 18750749, 18751180, 18751334, 18751358, 18751444, 18751733, 18751772, 18751777, 18751784, 18751800, 18751962, - 18751964, 18751967, 18751970, 18751974, 18751975, 18751977, 18752073, 18752085, 18752241, 18752245, 18752369, 18752782, 18752796, - 18753020, 18753025, 18753230, 18753299, 18753321, 18753444, 18754157, 18754468, 18754629, 18754632, 18755348, 18755580, 18755647, - 18756137, 18756196, 18757143, 18757175, 18757227, 18757294, 18757300, 18757544, 18757547, 18757917, 18757930, 18758219, 18758228, - 18758428, 18783923, 18784255, 18784257, 18784278, 18784506, 18784512, 18785925, 18785928, 18786059, 18787397, 18787805, 18787842, - 18840505, 18840540, 18842111, 18842255, 18842546, 18842613, 18843081, 18843086, 18843202, 18877846, 18877886, 18877938, 18877995, - 18878286, 18878288, 18878602, 18878604, 18878910, 18879022, 18879087, 18879201, 18879299, 18879376, 18879694, 18879819, 18879825, - 18879959, 18879963, 18880086, 18880208, 18880209, 18880253, 18880256, 18880438, 18880477, 18880478, 18880579, 18880588, 18880589, - 18880590, 18880674, 18880675, 18880688, 18880690, 18880698, 18880703, 18880710, 18880723, 18880777, 18880778, 18880818, 18880829, - 18880956, 18880957, 18880961, 18880971, 18881047, 18881049, 18881057, 18881059, 18881244, 18881250, 18881271, 18881309, 18881313, - 18881413, 18881417, 18881470, 18881473, 18881573, 18881588, 18881603, 18881665, 18881667, 18881833, 18881834, 18881875, 18881876, - 18881945, 18881946, 18882110, 18882201, 18882333, 18882334, 18882600, 18882620, 18882747, 18882795, 18882797, 18882825, 18882827, - 18882864, 18882874, 18883468, 18883469, 18883511, 18883515, 18883910, 18884107, 18884303, 18884455, 18884839, 18884840, 18884853, - 18885134, 18885240, 18885713, 18885715, 18885719, 18885720, 18890921, 18890923, 18890924, 18891002, 18891007, 18891013, 18891073, - 18891226, 18891230, 18891902, 18892071, 18916117, 18916500, 18917173, 18917229, 18917481, 18917487, 18917714, 18918454, 18918700, - 18919243, 18919244, 18919304, 18919307, 18919365, 18919372, 18919534, 18919859, 18919932, 18920320, 18934396, 18934399, 18934421, - 18934700, 18935088, 18935417, 18935420, 18935494, 18935501, 18936000, 18936103, 18936391, 18936459, 18936570, 18936578, 18936587, - 18936614, 18936649, 18936673, 18962602, 18962613, 18962625, 18962645, 18962662, 18962676, 18963370, 18963420, 18963833, 18963836, - 18963887, 18963911, 18964240, 18964303, 18964451, 18964454, 18964458, 18964500, 18964761, 18965395, 18965426, 18965875, 18965880, - 18965881, 18965931, 18965958, 18965959, 18965984, 18965985, 18967428, 18967463, 18967632, 18968583, 18968607, 18972151, 18972181, - 18972195, 18972196, 18972221, 18972231, 18972471, 18972549, 18972554, 18972611, 18972613, 18972651, 18972928, 18972929, 18972973, - 18972974, 18972992, 18972993, 18973042, 18973044, 18973048, 18973096, 18973098, 18973116, 18973218, 18973912, 18973952, 18973955, - 18974076, 18974093, 18974104, 18974117, 18974129, 18974206, 18974209, 18974419, 18974465, 18974797, 18974894, 18975162, 18975166, - 18975316, 18975374, 18975576, 18975578, 18976376, 18976386, 18976399, 18976405, 18977338, 18977345, 18977358, 18977728, 18977730, - 18977734, 18977736, 18978127, 18978129, 18978246, 18978494, 18978496, 18978826, 18978859, 18978866, 18978868, 18978873, 18978921, - 18978923, 18978933, 18978935, 18979157, 18979213, 18979247, 18979362, 18979627, 18979629, 18979659, 18979665, 18979666, 18979668, - 18979670, 18979746, 18979760, 18979767, 18979772, 18979782, 18979798, 18979820, 18979833, 18979855, 18979857, 18979955, 18979956, - 18980169, 18980439, 18980547, 18980548, 18980554, 18980591, 18980595, 18980691, 18980698, 18980831, 18980853, 18981626, 18981703, - 18981830, 18981937, 18981943, 18982171, 18982176, 18982186, 18982188, 18982196, 18982429, 18982431, 18982437, 18982740, 18982825, - 18982829, 18982867, 18982883, 18982926, 18983055, 18983244, 18983397, 18983401, 18983612, 18983619, 18983620, 18983932, 18983935, - 18983996, 18984329, 18984386, 18984405, 18984407, 18984413, 18984431, 18984501, 18984511, 18984763, 18984769, 18984913, 18984991, - 18985047, 18985161, 18985246, 18985248, 18985301, 18985304, 18985312, 18985520, 18985521, 18985726, 18985822, 18985850, 18986106, - 18986173, 18986174, 18986252, 18986266, 18986267, 18987017, 18987031, 18987048, 18987053, 18987081, 18987680, 18988159, 18988166, - 18988194, 18988205, 18988573, 18988712, 18988715, 18988857, 18988982, 18988984, 18988985, 18989012, 18989013, 18989018, 18989086, - 18989099, 18989125, 18989132, 18989165, 18989462, 18989464, 18989759, 18989899, 18989954, 18989955, 18990839, 18990846, 18990863, - 18990866, 18991105, 18991433, 18991452, 18991456, 18991462, 18991467, 18991469, 18991662, 18992464, 18992650, 18992774, 18992801, - 18992856, 18992860, 18992906, 18999657, 18999676, 18999686, 18999697, 18999881, 18999886, 19000091, 19000224, 19000241, 19000489, - 19000503, 19001195, 19001201, 19001347, 19001359, 19007968, 19007971, 19008121, 19011401, 19011569, 19011588, 19011656, 19011677, - 19011754, 19011759, 19012403, 19012416, 19012603, 19012613, 19012746, 19012747, 19014099, 19014206, 19020339, 19020428, 19020735, - 19020954, 19020959, 19021745, 19021748, 19021802, 19021803, 19022518, 19022523, 19157469, 19157470, 19157562, 19157597, 19157681, - 19157693, 19157727, 19157735, 19177628, 19177631, 19179127, 19180014, 19180478, 19180496, 19180576, 19180594, 19180601, 19180609, - 19182388, 19182390, 19182566, 19182598, 19183939, 19184062, 19184172, 19184613, 19187655, 19187674, 19187949, 19187959, 19189135, - 19190233, 19190353, 19190502, 19190504, 19190594, 19191003, 19191043, 19191046, 19191091, 19191098, 19191118, 19191122, 19191234, - 19191237, 19191305, 19191307, 19191407, 19191408, 19191453, 19191858, 19192015, 19192485, 19192487, 19192606, 19192607, 19192611, - 19192615, 19192896, 19192903, 19193680, 19193768, 19193789, 19193876, 19193879, 19194492, 19195385, 19200168, 19200172, 19200274, - 19200290, 19200578, 19200583, 19202205, 19202286, 19202388, 19202392, 19202403, 19202424, 19202450, 19202506, 19202509, 19203134, - 19203366, 19203572, 19203746, 19203752, 19204197, 19206989, 19207000, 19207077, 19207171, 19207271, 19207272, 19208337, 19208345, - 19208730, 19212689, 19212690, 19212744, 19212946, 19212947, 19213039, 19213045, 19213048, 19213301, 19213303, 19213574, 19213575, - 19213942, 19214581, 19214583, 19214681, 19214684, 19214905, 19215052, 19215418, 19216089, 19216095, 19218331, 19218601, 19218604, - 19218875, 19219205, 19220095, 19220100, 19221680, 19221683, 19221894, 19222484, 19222586, 19222590, 19224624, 19224626, 19225180, - 19226142, 19226145, 19226595, 19226609, 19226890, 19226896, 19226910, 19226911, 19226927, 19227005, 19227837, 19227907, 19227909, - 19228054, 19228056, 19228106, 19228107, 19228121, 19228123, 19228259, 19228261, 19228302, 19228304, 19229883, 19229890, 19230123, - 19233910, 19234320, 19234345, 19234424, 19234537, 19234956, 19235288, 19235308, 19237190, 19237199, 19237208, 19237233, 19239254, - 19239258, 19239376, 19239377, 19239389, 19239407, 19240001, 19240024, 19240499, 19240901, 19250124, 19250127, 19250230, 19250239, - 19252820, 19252824, 19252856, 19252859, 19253253, 19253258, 19253341, 19253648, 19253658, 19254248, 19254257, 19254261, 19254273, - 19255415, 19255483, 19255486, 19256056, 19256595, 19256596, 19257023, 19257421, 19257656, 19257794, 19257795, 19257825, 19257827, - 19257973, 19258287, 19258305, 19259424, 19259426, 19260016, 19260028, 19260034, 19260047, 19260053, 19260136, 19260185, 19260252, - 19260535, 19260539, 19263045, 19263046, 19263072, 19263297, 19263547, 19264542, 19264897, 19268898, 19268900, 19268986, 19268990, - 19269163, 19269421, 19269423, 19271598, 19271984, 19272062, 19272201, 19272203, 19272401, 19272409, 19272445, 19272449, 19281870, - 19281883, 19282504, 19285192, 19285575, 19285576, 19285624, 19301651, 19301652, 19301719, 19301721, 19302758, 19302769, 19302830, - 19302832, 19302846, 19304733, 19304737, 19304857, 19304863, 19304956, 19304961, 19305572, 19306684, 19306759, 19306763, 19306795, - 19306821, 19306844, 19306849, 19307117, 19307412, 19307778, 19307893, 19308083, 19308148, 19308304, 19314020, 19314021, 19314052, - 19314238, 19314253, 19315712, 19316333, 19317997, 19317999, 19318269, 19318271, 19318527, 19318529, 19318536, 19318578, 19318582, - 19318880, 19318881, 19319054, 19319328, 19319330, 19319376, 19324587, 19324593, 19324769, 19324771, 19324874, 19324883, 19324952, - 19324954, 19325006, 19325007, 19325008, 19325103, 19325184, 19325185, 19325391, 19325392, 19325399, 19325401, 19325570, 19325804, - 19326308, 19326329, 19326348, 19326618, 19326756, 19326757, 19326935, 19326944, 19326947, 19327176, 19327529, 19329583, 19329702, - 19329703, 19329745, 19329746, 19329754, 19329758, 19330909, 19330912, 19331006, 19331009, 19331094, 19331095, 19331200, 19331224, - 19331676, 19331678, 19331729, 19331732, 19332246, 19332827, 19332934, 19332935, 19333061, 19358286, 19358287, 19358310, 19360688, - 19360690, 19360794, 19360932, 19361096, 19362472, 19362473, 19362976, 19362979, 19363289, 19363291, 19363391, 19363719, 19364350, - 19364366, 19364392, 19364402, 19364936, 19364944, 19365015, 19365017, 19365059, 19365710, 19365714, 19365844, 19366349, 19366686, - 19366920, 19366924, 19367057, 19367062, 19367152, 19367158, 19367216, 19367219, 19367501, 19367504, 19368429, 19368434, 19368444, - 19368449, 19368461, 19368484, 19368500, 19368501, 19368676, 19368680, 19368783, 19368797, 19368801, 19368942, 19368948, 19368949, - 19368955, 19368966, 19369066, 19369075, 19369217, 19369229, 19369302, 19369310, 19369314, 19369341, 19369343, 19369598, 19369600, - 19369688, 19369690, 19369879, 19369904, 19369907, 19369914, 19369919, 19369924, 19370031, 19373906, 19373910, 19373914, 19373996, - 19374015, 19374165, 19374181, 19374182, 19374198, 19374266, 19374299, 19374800, 19375006, 19375010, 19375171, 19375174, 19375178, - 19375183, 19375189, 19375203, 19375209, 19375252, 19375259, 19375260, 19375719, 19375788, 19375789, 19376019, 19376020, 19376061, - 19385710, 19385787, 19389326, 19389328, 19389440, 19389442, 19389987, 19390185, 19390188, 19390245, 19390250, 19390286, 19390313, - 19390322, 19390345, 19390352, 19390586, 19390710, 19392042, 19392044, 19410405, 19410437, 19410449, 19410488, 19410489, 19410496, - 19410497, 19410510, 19410916, 19411000, 19411002, 19411204, 19411937, 19411939, 19411997, 19512944, 19513029, 19513189, 19513202, - 19513396, 19513538, 19513695, 19513945, 19513992, 19516059, 19516062, 19516075, 19516084, 19516968, 19517224, 19554953, 19558472, - 19609701, 19609719, 19609892, 19609947, 19610025, 19610494, 19610647, 19610652, 19610959, 19611209, 19611291, 19612269, 19612444, - 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285, 19613989, 19614239, 19614595, 19614600, - 19614607, 19615112, 19615114, 19615248, 19726042, 19726057, 19748242, 19748244, 19748269, 19748278, 19748377, 19750672, 19750695, - 19750702, 19750822, 19750833, 19751058, 19751064, 19751102, 19751108, 19751169, 19751172, 19751269, 19751854, 19751865, 19751878, - 19751936, 19752030, 19752349, 19755044, 19755063, 19755440, 19755881, 19756813, 19761538, 19761592, 19761593, 19761680, 19761685, - 19761995, 19762162, 19762167, 19763218, 19763430, 19763945, 19764280, 19764311, 19764333, 19764676, 19764744, 19765216, 19765374, - 19765479, 19767631, 19792072, 19792136, 19792139, 19793277, 19793318, 19793322, 19793528, 19793536, 19796241, 19796405, 19796407, - 19802815, 19802816, 19802881, 19804775, 19805218, 19805360, 19805515, 19807739, 19807796, 19808997, 19809396, 19809725, 19809990, - 19913194, 19913195, 19914726, 19914727, 19914735, 19914741, 19914769, 19914811, 19914876, 19914877, 19916067, 19917537, 19917540, - 19917991, 19918159, 19918171, 19918197, 19918202, 19918295, 19918302, 19918429, 19918432, 19918524, 19918639, 19918716, 19918797, - 19918799, 19918991, 19918992, 19919153, 19919287, 19919383, 19919514, 19919971, 19919995, 19920374, 19920778, 19920779, 19921528, - 19921531, 19921674, 19921675, 19921724, 19923306, 19923308, 19923480, 19923532, 19923534, 19923692, 19923702, 19923790, 19923814, - 19923818, 19923880, 19923884, 19924275, 19924279, 19924358, 19924367, 19924384, 19925554, 19925869, 19926582, 19926586, 19926619, - 19926620, 19926687, 19926859, 19926884, 19926887, 19926891, 19926959, 19927302, 19927422, 19928859, 19929054, 19932992, 19933015, - 19933313, 19933316, 19933328, 19933410, 19933760, 19933818, 19933876, 19934184, 19934490, 19934606, 19934621, 19934741, 19959354, - 19959578, 19960026, 19960122, 19962154, 19962536 -]; -export const PEG_CROSS_BLOCKS_LAST: u32 = 19962536; diff --git a/projects/subgraph-bean/cache-builder/results/PegCrossBlocks_eth.ts b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks_eth.ts new file mode 100644 index 0000000000..4a5663d38a --- /dev/null +++ b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks_eth.ts @@ -0,0 +1,624 @@ +export const PEG_CROSS_BLOCKS: u32[] = [ + 12974091, 12975421, 12978538, 12978615, 12978680, 12978911, 12979148, 12979149, 12979167, 12979171, 12979228, 12979230, 12979607, + 12983847, 12983871, 12983895, 12983897, 12983926, 12984038, 12984104, 12984170, 12984257, 12984310, 12984929, 12986590, 12986603, + 12986901, 12987603, 12990064, 12991358, 12991399, 12992193, 12992519, 12993217, 12993281, 12998537, 12998539, 12998546, 12998550, + 12998551, 12998553, 12999530, 12999585, 12999767, 12999776, 12999777, 12999779, 12999817, 12999840, 13000158, 13000196, 13000305, + 13000309, 13000334, 13000347, 13000356, 13000377, 13000577, 13000587, 13001082, 13001089, 13001396, 13001414, 13001894, 13001913, + 13001956, 13002009, 13002735, 13002738, 13003196, 13003198, 13004037, 13004045, 13004360, 13004364, 13004638, 13004646, 13004655, + 13004657, 13004817, 13004839, 13004843, 13004883, 13005075, 13005103, 13005107, 13005109, 13005372, 13005380, 13005673, 13005715, + 13005730, 13005733, 13005944, 13005946, 13006200, 13006202, 13006203, 13006321, 13006487, 13006488, 13006499, 13006546, 13006708, + 13006709, 13006980, 13007010, 13007245, 13007246, 13007274, 13007275, 13007509, 13007525, 13007574, 13007607, 13007780, 13007798, + 13007859, 13007898, 13008063, 13008065, 13008117, 13008191, 13008375, 13008387, 13008617, 13008671, 13008712, 13008736, 13008895, + 13008901, 13008906, 13008912, 13009163, 13009169, 13009190, 13009193, 13009199, 13009203, 13009381, 13009423, 13009669, 13009671, + 13009676, 13009679, 13009681, 13009687, 13009958, 13009972, 13009973, 13010009, 13010222, 13010231, 13010492, 13010556, 13010779, + 13014211, 13016266, 13018933, 13019023, 13019754, 13020690, 13020782, 13022699, 13022701, 13022825, 13023185, 13023247, 13023922, + 13025396, 13025666, 13026184, 13026256, 13026638, 13026640, 13027512, 13029384, 13030010, 13030107, 13030123, 13030393, 13030528, + 13031004, 13031259, 13032695, 13032731, 13032942, 13033010, 13033033, 13033210, 13034517, 13034543, 13035839, 13035922, 13035929, + 13036165, 13036689, 13036884, 13036897, 13036926, 13037135, 13037615, 13037642, 13038069, 13038108, 13038138, 13038145, 13038184, + 13039743, 13043682, 13043699, 13044756, 13044762, 13044770, 13044955, 13045801, 13046502, 13051141, 13051348, 13056233, 13056234, + 13057499, 13057501, 13057527, 13057595, 13058927, 13059717, 13059983, 13060079, 13060086, 13060118, 13060119, 13060121, 13060123, + 13060132, 13060160, 13060198, 13060449, 13060450, 13060479, 13060489, 13060492, 13060680, 13060716, 13060796, 13060802, 13060842, + 13060960, 13062059, 13062295, 13062299, 13062306, 13062319, 13062333, 13062352, 13062366, 13063788, 13063838, 13063861, 13063878, + 13075770, 13075888, 13076058, 13076195, 13076316, 13076435, 13076636, 13076662, 13076679, 13076703, 13076890, 13076891, 13076899, + 13076947, 13076964, 13076972, 13077164, 13077246, 13077426, 13077429, 13077495, 13077503, 13077730, 13077736, 13078272, 13078287, + 13078449, 13078457, 13078466, 13078470, 13078482, 13078487, 13078488, 13078519, 13078541, 13078561, 13078796, 13078810, 13078813, + 13078834, 13079299, 13079303, 13079572, 13079587, 13079588, 13079596, 13079620, 13079642, 13079648, 13079683, 13079724, 13079755, + 13079814, 13079885, 13079887, 13079895, 13079899, 13079919, 13079920, 13079941, 13080074, 13080179, 13080198, 13080229, 13080352, + 13080375, 13080400, 13080408, 13080634, 13080637, 13080648, 13080660, 13080672, 13080677, 13080678, 13080680, 13080768, 13080770, + 13080887, 13080888, 13080932, 13080934, 13080937, 13080958, 13080977, 13080990, 13080996, 13080999, 13081011, 13081057, 13081145, + 13081209, 13081632, 13081635, 13081700, 13081721, 13081750, 13081754, 13081766, 13081895, 13081963, 13081977, 13081992, 13081994, + 13082000, 13082006, 13082094, 13082163, 13082230, 13082282, 13082300, 13082301, 13082504, 13082507, 13082510, 13082555, 13082863, + 13082876, 13082878, 13082888, 13082969, 13083844, 13084930, 13084956, 13084984, 13085212, 13085233, 13085236, 13085311, 13085508, + 13085645, 13085877, 13086288, 13086337, 13086338, 13086356, 13086362, 13086369, 13086376, 13086400, 13086422, 13086440, 13086459, + 13086461, 13087211, 13087217, 13087221, 13087225, 13087231, 13087377, 13087393, 13087405, 13087410, 13087411, 13087527, 13088104, + 13088272, 13093705, 13093899, 13093903, 13093921, 13093932, 13093971, 13093975, 13099188, 13099189, 13099353, 13099362, 13099414, + 13099461, 13099465, 13099710, 13099714, 13099747, 13100289, 13100319, 13100358, 13100371, 13100898, 13100923, 13102868, 13102939, + 13107071, 13107096, 13110581, 13110588, 13110634, 13110706, 13110819, 13110844, 13111074, 13113042, 13113109, 13113110, 13113423, + 13113442, 13113448, 13113452, 13113453, 13113553, 13114481, 13114574, 13115940, 13115946, 13115955, 13115972, 13115989, 13115990, + 13117862, 13118077, 13118145, 13118291, 13118320, 13118321, 13118355, 13118356, 13118402, 13118413, 13118423, 13118428, 13118436, + 13118467, 13121070, 13121089, 13121099, 13121128, 13121178, 13121244, 13121307, 13121310, 13122225, 13122395, 13122407, 13122455, + 13122874, 13122951, 13122985, 13124397, 13124895, 13129783, 13129786, 13129854, 13129981, 13129991, 13130001, 13130094, 13130178, + 13131625, 13131662, 13131722, 13131929, 13137125, 13137568, 13138520, 13138647, 13138700, 13138778, 13138782, 13138813, 13138856, + 13138858, 13139212, 13139273, 13139367, 13139407, 13139408, 13139410, 13139609, 13140003, 13140015, 13140024, 13140027, 13140327, + 13140447, 13140687, 13141148, 13141156, 13141160, 13141165, 13141195, 13141863, 13141869, 13141870, 13141940, 13142135, 13143729, + 13143754, 13143760, 13143762, 13143763, 13143816, 13144293, 13144300, 13144362, 13144364, 13144774, 13144823, 13145005, 13145190, + 13145194, 13145195, 13145198, 13145206, 13145220, 13145747, 13146082, 13146089, 13147016, 13147028, 13147044, 13147045, 13148291, + 13148316, 13149112, 13150275, 13150279, 13150280, 13151314, 13151333, 13151356, 13151443, 13151450, 13151451, 13151460, 13151462, + 13151595, 13151598, 13151696, 13151700, 13151863, 13151867, 13152103, 13152260, 13152269, 13153306, 13153325, 13155620, 13156284, + 13156748, 13156781, 13157326, 13158957, 13159234, 13159235, 13159247, 13159248, 13159486, 13159495, 13161064, 13161086, 13161299, + 13161376, 13161392, 13161406, 13161416, 13161423, 13161487, 13161550, 13161611, 13161634, 13161636, 13162200, 13162208, 13162329, + 13162331, 13163395, 13163536, 13163565, 13163567, 13163596, 13163597, 13163604, 13163670, 13163995, 13164187, 13164189, 13164192, + 13164658, 13164746, 13165237, 13165391, 13165408, 13165727, 13165897, 13165996, 13166015, 13166072, 13166219, 13166222, 13166242, + 13166250, 13166251, 13166258, 13166259, 13166283, 13166287, 13166319, 13166381, 13166437, 13167205, 13167549, 13167575, 13167591, + 13167742, 13167972, 13168519, 13168524, 13169110, 13171988, 13175038, 13175053, 13175058, 13175064, 13175069, 13175146, 13175397, + 13175452, 13175497, 13175514, 13175520, 13175609, 13177587, 13177589, 13177597, 13177615, 13177647, 13177659, 13177660, 13177714, + 13177758, 13178360, 13178584, 13178652, 13179149, 13179177, 13179251, 13179252, 13179253, 13179274, 13179308, 13179337, 13179353, + 13179400, 13180079, 13180083, 13180101, 13180102, 13180117, 13180145, 13180189, 13180216, 13180664, 13180692, 13180713, 13180715, + 13180730, 13180758, 13180833, 13180888, 13180897, 13180909, 13181023, 13181155, 13181755, 13181777, 13181802, 13181820, 13182646, + 13182655, 13183890, 13183894, 13183955, 13183956, 13183957, 13184012, 13184973, 13184974, 13185191, 13185260, 13185321, 13185384, + 13185495, 13185703, 13185732, 13185850, 13187086, 13187116, 13187178, 13187233, 13188042, 13189001, 13189010, 13189082, 13191072, + 13191091, 13191099, 13191106, 13191522, 13191635, 13191637, 13191644, 13192232, 13192596, 13192599, 13192604, 13193031, 13193802, + 13194379, 13194410, 13194615, 13194717, 13194719, 13194824, 13196049, 13196067, 13196141, 13196190, 13196445, 13196459, 13196460, + 13198164, 13198273, 13198316, 13198557, 13198899, 13198902, 13198907, 13198909, 13198925, 13199052, 13199074, 13199086, 13199099, + 13199116, 13199129, 13199131, 13199260, 13199361, 13199363, 13200193, 13200194, 13200216, 13200219, 13200224, 13201208, 13201289, + 13201290, 13201321, 13201322, 13206138, 13206229, 13206338, 13206947, 13207266, 13207395, 13207435, 13207444, 13207445, 13207578, + 13207663, 13208184, 13211822, 13211897, 13211967, 13213641, 13214042, 13214163, 13214206, 13215008, 13215982, 13217044, 13217061, + 13217222, 13217341, 13217478, 13217783, 13217784, 13217810, 13217953, 13217970, 13217973, 13218020, 13218050, 13218279, 13218810, + 13218815, 13218816, 13218909, 13218949, 13218953, 13218954, 13225077, 13225299, 13226246, 13226559, 13226732, 13226957, 13227000, + 13229110, 13229499, 13229747, 13232674, 13232699, 13232717, 13233025, 13234172, 13234178, 13234264, 13234554, 13236246, 13236247, + 13236250, 13236319, 13237109, 13237552, 13244459, 13244462, 13245028, 13245032, 13245040, 13245162, 13245172, 13245175, 13245180, + 13245275, 13245545, 13245546, 13246387, 13246388, 13246647, 13246651, 13246920, 13246926, 13246980, 13246983, 13247415, 13247416, + 13247678, 13247695, 13247947, 13247952, 13248208, 13248209, 13248470, 13248473, 13249273, 13249276, 13249292, 13249294, 13249543, + 13249561, 13249800, 13249818, 13249822, 13250039, 13250057, 13250059, 13256813, 13256815, 13257386, 13257389, 13258210, 13258214, + 13259590, 13259594, 13259863, 13259865, 13260039, 13260056, 13260062, 13260063, 13260114, 13260126, 13260381, 13260386, 13260388, + 13260389, 13260884, 13260886, 13261140, 13261142, 13261145, 13261155, 13261156, 13261186, 13261206, 13261363, 13261373, 13261399, + 13262381, 13262382, 13262425, 13262428, 13262440, 13262442, 13262455, 13262462, 13262465, 13262469, 13262553, 13262554, 13262569, + 13262592, 13262593, 13262713, 13262719, 13262729, 13262748, 13262896, 13262899, 13262913, 13263080, 13263772, 13263871, 13264127, + 13264135, 13264139, 13264149, 13272546, 13272560, 13272905, 13272934, 13273058, 13273061, 13273064, 13273373, 13273436, 13273458, + 13273503, 13273513, 13273717, 13273719, 13274023, 13274030, 13274057, 13274064, 13274105, 13274148, 13274189, 13274198, 13274217, + 13274220, 13274242, 13274248, 13335750, 13335755, 13335869, 13336244, 13336323, 13336461, 13336505, 13336560, 13336618, 13336695, + 13336714, 13336777, 13336959, 13337532, 13337559, 13337935, 13337937, 13337959, 13340698, 13340781, 13340820, 13340947, 13341028, + 13341076, 13341108, 13341147, 13341156, 13341366, 13341373, 13342047, 13342121, 13342224, 13342548, 13376585, 13376710, 13376778, + 13378143, 13378793, 13378816, 13378829, 13379464, 13434006, 13434877, 13435565, 13435971, 13436006, 13436018, 13436025, 13436035, + 13436049, 13436107, 13437998, 13438644, 13438667, 13440517, 13442086, 13442913, 13443210, 13443231, 13443232, 13443239, 13443256, + 13443258, 13443270, 13443271, 13444653, 13444660, 13444712, 13446459, 13448008, 13449065, 13449128, 13449167, 13449303, 13449313, + 13449493, 13449495, 13449505, 13449506, 13449551, 13449634, 13449650, 13449705, 13449790, 13449821, 13449841, 13449855, 13449875, + 13449913, 13450052, 13450154, 13450187, 13450472, 13450507, 13450522, 13451061, 13451131, 13451155, 13451468, 13451543, 13451544, + 13451550, 13451555, 13451564, 13451596, 13451598, 13451649, 13451671, 13451675, 13455280, 13455282, 13455557, 13455600, 13455618, + 13455860, 13455891, 13455896, 13455911, 13461738, 13462027, 13462049, 13462066, 13462165, 13463379, 13463381, 13464408, 13466451, + 13467419, 13467691, 13468508, 13468675, 13468784, 13469000, 13469007, 13469012, 13469034, 13470634, 13470770, 13471747, 13474744, + 13474934, 13475341, 13475377, 13475394, 13475519, 13475523, 13475746, 13476174, 13476209, 13476325, 13476418, 13476419, 13479133, + 13479136, 13479138, 13479152, 13479196, 13479242, 13479941, 13480370, 13480372, 13480449, 13480647, 13480648, 13480717, 13481304, + 13481717, 13481988, 13482011, 13482102, 13483897, 13483977, 13483982, 13483998, 13484811, 13484846, 13484847, 13486887, 13486969, + 13488473, 13488482, 13489574, 13489977, 13490465, 13490505, 13490507, 13490517, 13490518, 13491374, 13494424, 13494752, 13494754, + 13495520, 13495854, 13497794, 13497797, 13497803, 13497820, 13497844, 13497868, 13498035, 13503686, 13503690, 13503704, 13503709, + 13503751, 13503763, 13503770, 13503813, 13503910, 13508461, 13508666, 13508680, 13508728, 13508759, 13508780, 13510297, 13510507, + 13510508, 13510514, 13510516, 13510518, 13510520, 13510556, 13510590, 13510603, 13510605, 13510610, 13510727, 13511700, 13511890, + 13511907, 13512045, 13512048, 13512304, 13512305, 13512359, 13512365, 13514281, 13514282, 13514705, 13514719, 13514721, 13514734, + 13515060, 13516318, 13516526, 13516569, 13517036, 13517567, 13518970, 13519495, 13519497, 13519756, 13521882, 13522133, 13523828, + 13523847, 13523862, 13523885, 13523912, 13523967, 13523969, 13524379, 13524397, 13525787, 13525872, 13525873, 13528534, 13528544, + 13528546, 13528558, 13528574, 13528579, 13528967, 13529028, 13531631, 13531875, 13531910, 13531954, 13531961, 13531990, 13532016, + 13532023, 13532081, 13532126, 13532137, 13532138, 13532143, 13532151, 13532161, 13532176, 13532179, 13532198, 13532239, 13532920, + 13532929, 13532946, 13533454, 13533933, 13535490, 13535493, 13535494, 13535499, 13538211, 13538232, 13538866, 13538895, 13539218, + 13539249, 13539673, 13539923, 13539946, 13539951, 13540826, 13540841, 13541140, 13541325, 13541849, 13541933, 13541958, 13541980, + 13541997, 13542002, 13542077, 13542086, 13542175, 13542179, 13542232, 13542254, 13543917, 13544624, 13545832, 13545837, 13545858, + 13546411, 13547018, 13547059, 13547095, 13547595, 13547630, 13548233, 13548387, 13550252, 13550987, 13551029, 13551119, 13551280, + 13551291, 13552190, 13552241, 13552260, 13552307, 13552675, 13552678, 13552681, 13552684, 13552688, 13552701, 13552704, 13552750, + 13552752, 13552754, 13552943, 13553661, 13553662, 13553676, 13553677, 13553853, 13554976, 13555095, 13555457, 13557196, 13557954, + 13558105, 13558112, 13558113, 13558114, 13558116, 13558121, 13558735, 13558752, 13558776, 13559078, 13559084, 13559255, 13559291, + 13559303, 13559410, 13559415, 13559416, 13559425, 13559561, 13559568, 13559602, 13559647, 13559656, 13559658, 13559791, 13559882, + 13560317, 13560318, 13560937, 13564634, 13564681, 13564697, 13564713, 13564837, 13564852, 13564859, 13564871, 13564879, 13564889, + 13564891, 13566648, 13568113, 13568302, 13568342, 13568345, 13568357, 13568484, 13568492, 13568495, 13568667, 13570256, 13570277, + 13570284, 13570300, 13570316, 13570318, 13570944, 13570952, 13571175, 13572652, 13572673, 13572674, 13572854, 13572856, 13572884, + 13572895, 13572918, 13572923, 13572958, 13572969, 13573024, 13573028, 13573096, 13573097, 13573405, 13573522, 13573523, 13573686, + 13573687, 13573693, 13573695, 13574201, 13574213, 13574289, 13574294, 13575376, 13575377, 13576614, 13576620, 13576635, 13576661, + 13576663, 13577153, 13577969, 13578897, 13578901, 13578940, 13578947, 13579158, 13579160, 13579235, 13579351, 13579385, 13579447, + 13579490, 13579530, 13579565, 13579572, 13579588, 13579894, 13579900, 13579911, 13579912, 13579914, 13579918, 13579942, 13580072, + 13580087, 13580260, 13580280, 13581920, 13582005, 13582060, 13582068, 13582069, 13582090, 13582096, 13582336, 13582467, 13582468, + 13582749, 13583449, 13583933, 13584045, 13584069, 13584076, 13584080, 13584082, 13584102, 13584104, 13584107, 13584126, 13584153, + 13584183, 13584184, 13584192, 13584195, 13584208, 13584209, 13584211, 13584243, 13584286, 13584294, 13584296, 13584485, 13584486, + 13585001, 13585594, 13585602, 13585607, 13585610, 13585641, 13585748, 13585775, 13585976, 13585992, 13586067, 13587038, 13587054, + 13587160, 13589367, 13589405, 13589454, 13589471, 13589485, 13589486, 13589512, 13589515, 13589527, 13589532, 13589574, 13589656, + 13589661, 13589867, 13590103, 13592391, 13594358, 13595502, 13595599, 13595883, 13596659, 13596666, 13596668, 13596671, 13598662, + 13599510, 13599974, 13600003, 13600116, 13600221, 13600229, 13600230, 13600343, 13600344, 13600519, 13602309, 13602377, 13602479, + 13602483, 13602486, 13602488, 13602489, 13602490, 13602493, 13602978, 13603574, 13603586, 13603652, 13603887, 13604255, 13605773, + 13605779, 13606896, 13607198, 13607202, 13607203, 13608420, 13608519, 13608665, 13608681, 13608968, 13610066, 13611161, 13614876, + 13614927, 13614991, 13614998, 13615404, 13617630, 13618342, 13621035, 13622147, 13623486, 13623495, 13623499, 13623577, 13623590, + 13623764, 13624270, 13624355, 13624363, 13624366, 13624383, 13624517, 13625958, 13625960, 13625982, 13626112, 13626125, 13626166, + 13626170, 13626212, 13628785, 13628854, 13628864, 13628865, 13629661, 13629662, 13629784, 13629785, 13629852, 13630011, 13630129, + 13630230, 13630429, 13630583, 13630683, 13630775, 13630780, 13630796, 13631292, 13631331, 13640082, 13640087, 13640104, 13640132, + 13640218, 13640556, 13640587, 13640615, 13641928, 13641929, 13642057, 13642071, 13642137, 13642155, 13642160, 13642167, 13642168, + 13642207, 13642212, 13642215, 13642216, 13642265, 13642911, 13644410, 13646116, 13646163, 13647476, 13647732, 13647733, 13647905, + 13657931, 13657936, 13658078, 13658083, 13658088, 13658106, 13666892, 13666908, 13667064, 13667842, 13671879, 13672266, 13685409, + 13685501, 13687313, 13687327, 13688700, 13688718, 13688728, 13688770, 13688773, 13689077, 13693941, 13693995, 13694143, 13694177, + 13703288, 13703407, 13704796, 13704804, 13704850, 13704871, 13710244, 13710333, 13710534, 13710568, 13717643, 13717686, 13720847, + 13720981, 13721138, 13721150, 13721209, 13721255, 13721263, 13721265, 13721279, 13721280, 13722372, 13722456, 13722731, 13722854, + 13722860, 13722861, 13722883, 13722884, 13722898, 13722924, 13723078, 13723597, 13723611, 13723617, 13724121, 13724580, 13724940, + 13724949, 13724958, 13725168, 13725481, 13725714, 13725715, 13725761, 13726532, 13728022, 13728049, 13729075, 13729079, 13729488, + 13729572, 13729622, 13729660, 13729666, 13729719, 13729765, 13729836, 13731361, 13731396, 13731754, 13731765, 13731769, 13731770, + 13731798, 13731966, 13732954, 13732957, 13732964, 13734204, 13734565, 13734582, 13734613, 13734671, 13735055, 13735059, 13735060, + 13735378, 13740278, 13740773, 13740781, 13740808, 13740821, 13740879, 13741264, 13742045, 13742386, 13742413, 13742433, 13742461, + 13742522, 13743142, 13743432, 13743636, 13743643, 13743676, 13744107, 13744604, 13800996, 13800999, 13801241, 13801243, 13804633, + 13804667, 13804672, 13804727, 13812443, 13812884, 13812892, 13812903, 13813249, 13813688, 13829732, 13829784, 13844956, 13844964, + 13845655, 13845657, 13845739, 13845745, 13845757, 13845780, 13848953, 13851591, 13851617, 13852217, 13852286, 13852519, 13853027, + 13854735, 13854789, 13854927, 13854932, 13854936, 13854950, 13854954, 13856012, 13856028, 13856077, 13856953, 13856955, 13857267, + 13857323, 13857365, 13857466, 13857469, 13857483, 13857490, 13857624, 13857918, 13858695, 13858898, 13858902, 13858904, 13858923, + 13858924, 13859670, 13859826, 13859936, 13860025, 13860899, 13861827, 13861932, 13861937, 13862044, 13862064, 13862197, 13862355, + 13862374, 13863113, 13864512, 13864522, 13864530, 13864926, 13864941, 13864946, 13864969, 13865001, 13865043, 13865070, 13865081, + 13865342, 13865516, 13865553, 13865581, 13865604, 13865623, 13865647, 13865678, 13866062, 13869401, 13869405, 13869422, 13869451, + 13869457, 13869834, 13870311, 13870632, 13871204, 13871210, 13871302, 13871334, 13871339, 13871363, 13871424, 13871435, 13871497, + 13871551, 13871568, 13871570, 13871583, 13871761, 13872175, 13872207, 13872240, 13872304, 13872378, 13872402, 13872443, 13872834, + 13872889, 13872979, 13873525, 13873669, 13874108, 13874137, 13874154, 13874198, 13874244, 13874484, 13875063, 13875708, 13875709, + 13876095, 13876631, 13876822, 13876828, 13876980, 13877074, 13877075, 13877496, 13877517, 13877520, 13877638, 13877848, 13878148, + 13882302, 13882360, 13882365, 13882591, 13882592, 13882597, 13882599, 13882806, 13882807, 13883051, 13883360, 13883433, 13884709, + 13885349, 13885866, 13885918, 13886883, 13887001, 13887338, 13887344, 13887380, 13887548, 13887611, 13888142, 13888577, 13888593, + 13888668, 13888746, 13889461, 13889503, 13889510, 13889524, 13889539, 13889649, 13890458, 13891050, 13891076, 13891081, 13891130, + 13891135, 13891138, 13902888, 13902992, 13906563, 13906944, 13908405, 13908630, 13912128, 13912739, 13913099, 13913121, 13913454, + 13913585, 13913596, 13914008, 13926989, 13926996, 13927003, 13927014, 13927024, 13927479, 13927483, 13927492, 13938606, 13938669, + 13939585, 13939590, 13939599, 13939708, 13939849, 13939850, 13942560, 13942563, 13942611, 13954079, 13954146, 13954148, 13954178, + 13985645, 13985651, 13992100, 14005135, 14005139, 14005140, 14005142, 14005185, 14009388, 14009390, 14038443, 14043167, 14043168, + 14098158, 14098190, 14098343, 14098347, 14098363, 14098372, 14098448, 14098510, 14099411, 14099421, 14111704, 14111988, 14112175, + 14112178, 14112222, 14112272, 14112281, 14112322, 14112332, 14112523, 14112534, 14112721, 14112870, 14113018, 14113027, 14113380, + 14113524, 14113544, 14113990, 14114153, 14114184, 14114266, 14114286, 14114342, 14114380, 14114399, 14114404, 14114436, 14114512, + 14114628, 14114673, 14114833, 14114886, 14114898, 14115278, 14115362, 14115372, 14115446, 14115500, 14115574, 14116384, 14116406, + 14116506, 14116797, 14116986, 14117002, 14117059, 14117070, 14117097, 14117135, 14117265, 14117322, 14117503, 14117521, 14117550, + 14118001, 14118142, 14118146, 14118158, 14118197, 14118368, 14118496, 14118533, 14118647, 14118701, 14118714, 14118937, 14119187, + 14119295, 14119413, 14119877, 14119901, 14119970, 14120278, 14120281, 14120282, 14120389, 14120437, 14120542, 14120552, 14120595, + 14121317, 14121366, 14121432, 14121455, 14121577, 14121580, 14121596, 14121601, 14121630, 14121638, 14121679, 14121684, 14121722, + 14121856, 14122382, 14122403, 14122483, 14122757, 14122763, 14122767, 14122824, 14122827, 14122833, 14122844, 14122853, 14122877, + 14123193, 14123200, 14123302, 14123407, 14124143, 14124163, 14124204, 14124296, 14124337, 14124352, 14124366, 14124368, 14124374, + 14124391, 14124991, 14125047, 14126549, 14126762, 14126770, 14126771, 14126782, 14126791, 14126823, 14126841, 14128740, 14128817, + 14128883, 14128944, 14129293, 14129452, 14129553, 14129573, 14129597, 14129617, 14129837, 14129898, 14129913, 14129915, 14129939, + 14130007, 14130296, 14130298, 14130316, 14130334, 14130355, 14130372, 14130378, 14130387, 14130388, 14130423, 14130440, 14130465, + 14130641, 14131066, 14131081, 14131115, 14131324, 14131407, 14131588, 14132136, 14132310, 14133768, 14133783, 14133786, 14133815, + 14133830, 14133981, 14134041, 14135528, 14135807, 14135812, 14135828, 14137560, 14137824, 14137853, 14138293, 14138307, 14138600, + 14138669, 14138825, 14138845, 14138888, 14139112, 14139816, 14140071, 14140079, 14140134, 14140318, 14140343, 14140597, 14140903, + 14140910, 14141386, 14141418, 14141461, 14141473, 14141478, 14141480, 14141489, 14141517, 14141541, 14141549, 14141628, 14141732, + 14141733, 14141780, 14141786, 14141800, 14142398, 14142742, 14142749, 14143111, 14143196, 14143745, 14143763, 14143828, 14143864, + 14144282, 14144473, 14145076, 14145285, 14145784, 14145908, 14145935, 14145988, 14146061, 14146091, 14146109, 14146166, 14146173, + 14146182, 14146184, 14146190, 14146207, 14146234, 14146754, 14146771, 14146832, 14147019, 14147204, 14147423, 14147483, 14147519, + 14147526, 14147554, 14147587, 14147607, 14147732, 14148521, 14148714, 14149592, 14149619, 14149789, 14149804, 14149812, 14149940, + 14149961, 14149966, 14149992, 14151350, 14151353, 14153570, 14154639, 14154760, 14154939, 14155463, 14155476, 14155742, 14155762, + 14155771, 14155906, 14155935, 14156644, 14156695, 14156824, 14157718, 14158023, 14158178, 14158179, 14158192, 14158225, 14158234, + 14160434, 14160448, 14160484, 14160591, 14160631, 14160678, 14161007, 14161029, 14161053, 14161067, 14161227, 14161241, 14161396, + 14161541, 14161546, 14161548, 14161549, 14161604, 14161618, 14161833, 14161976, 14161996, 14162133, 14162387, 14162615, 14162897, + 14163117, 14163286, 14163301, 14163309, 14163900, 14163967, 14164571, 14165063, 14165098, 14165182, 14165193, 14165728, 14165832, + 14166064, 14166499, 14166555, 14166559, 14166586, 14167320, 14167457, 14167507, 14167584, 14167707, 14167751, 14167792, 14167806, + 14167809, 14167830, 14167859, 14167868, 14167877, 14167979, 14167980, 14171368, 14171777, 14171890, 14171953, 14172042, 14172047, + 14172089, 14172170, 14172332, 14172456, 14172572, 14172639, 14173001, 14174547, 14174910, 14175087, 14175109, 14175111, 14175869, + 14175907, 14176246, 14176253, 14176343, 14176607, 14177124, 14177447, 14177503, 14177734, 14178614, 14178630, 14178820, 14178821, + 14178839, 14179074, 14179192, 14179237, 14179326, 14180592, 14180796, 14180851, 14181128, 14181137, 14181693, 14181698, 14181762, + 14181792, 14182209, 14182468, 14182581, 14183420, 14183543, 14183809, 14183872, 14184752, 14184842, 14185023, 14185412, 14185453, + 14185501, 14185653, 14185710, 14185798, 14186682, 14186733, 14187745, 14187752, 14187757, 14187821, 14188264, 14188460, 14188465, + 14188729, 14188778, 14189095, 14189171, 14191103, 14191217, 14191927, 14192000, 14192052, 14192242, 14192398, 14192827, 14192854, + 14193065, 14193073, 14193103, 14193143, 14193158, 14193482, 14193580, 14194305, 14194319, 14194412, 14194419, 14194484, 14194546, + 14194595, 14199795, 14199935, 14199983, 14199986, 14200044, 14200084, 14200111, 14200139, 14200182, 14200190, 14204347, 14204418, + 14204510, 14204511, 14204779, 14204797, 14204839, 14205356, 14205469, 14205477, 14205495, 14206818, 14206853, 14207065, 14207638, + 14207651, 14207666, 14207674, 14207769, 14208925, 14208929, 14208933, 14209218, 14209304, 14209336, 14209575, 14209637, 14209654, + 14209658, 14209756, 14209776, 14209798, 14209927, 14210583, 14210845, 14211495, 14211541, 14211907, 14211929, 14212341, 14212472, + 14212477, 14212690, 14213033, 14213418, 14213497, 14213514, 14213530, 14213652, 14213946, 14213953, 14213972, 14214116, 14214142, + 14214143, 14214366, 14214977, 14214987, 14215167, 14215207, 14215399, 14215416, 14215450, 14215516, 14217199, 14217219, 14217260, + 14217509, 14218325, 14218896, 14218935, 14219106, 14219113, 14219114, 14219119, 14219130, 14219957, 14219958, 14220038, 14220087, + 14220173, 14220219, 14220804, 14221341, 14222488, 14222500, 14222878, 14222894, 14222935, 14223004, 14223669, 14223764, 14227432, + 14227444, 14227445, 14227450, 14227692, 14227697, 14228042, 14228163, 14228181, 14228408, 14228421, 14228485, 14228486, 14228491, + 14228508, 14228587, 14228717, 14228762, 14228769, 14228773, 14228791, 14228792, 14228804, 14228903, 14229010, 14229018, 14229159, + 14231125, 14231300, 14231443, 14231448, 14232109, 14232208, 14232209, 14232381, 14232406, 14232802, 14232810, 14232864, 14232909, + 14233312, 14233318, 14233470, 14233715, 14233727, 14233759, 14235991, 14236061, 14236156, 14236267, 14236301, 14236377, 14236429, + 14236512, 14236650, 14236713, 14236756, 14236769, 14236824, 14236825, 14237021, 14237138, 14237249, 14237357, 14237367, 14237368, + 14237405, 14237422, 14237465, 14237979, 14238006, 14238047, 14238053, 14238054, 14238064, 14238210, 14241229, 14242371, 14242374, + 14242376, 14242495, 14242761, 14242796, 14242807, 14242848, 14242857, 14242860, 14242895, 14242902, 14242903, 14243742, 14243745, + 14243747, 14243828, 14243830, 14243898, 14243995, 14244554, 14244572, 14244661, 14244663, 14245554, 14245560, 14245614, 14245629, + 14245794, 14246045, 14246318, 14246687, 14246846, 14247108, 14247338, 14247826, 14247928, 14247954, 14247963, 14247985, 14248202, + 14248403, 14248732, 14249055, 14249278, 14249875, 14250216, 14250927, 14250928, 14251116, 14251143, 14251320, 14251343, 14251406, + 14251457, 14251569, 14251635, 14251874, 14251884, 14251898, 14252039, 14252092, 14252144, 14252246, 14252318, 14252972, 14253022, + 14255299, 14255310, 14255475, 14255516, 14255543, 14255556, 14255822, 14255995, 14256057, 14256504, 14256561, 14256571, 14256620, + 14258923, 14258985, 14259150, 14259607, 14259661, 14260250, 14260264, 14261054, 14261145, 14261150, 14261244, 14261398, 14261838, + 14261932, 14261969, 14262054, 14262427, 14262460, 14262621, 14263627, 14263682, 14267276, 14267288, 14267519, 14267528, 14267529, + 14267548, 14267622, 14267663, 14268607, 14268629, 14268630, 14268672, 14268685, 14268744, 14268750, 14268751, 14268755, 14269086, + 14269140, 14269168, 14269178, 14269347, 14269356, 14269543, 14269547, 14269776, 14269820, 14270276, 14270280, 14270283, 14270286, + 14270294, 14270310, 14270354, 14270419, 14270466, 14270486, 14270530, 14270550, 14270654, 14270738, 14270744, 14270751, 14270757, + 14270778, 14270784, 14270811, 14270841, 14270889, 14270897, 14270940, 14270943, 14270967, 14270972, 14271360, 14271401, 14271992, + 14271999, 14272079, 14272130, 14272289, 14272325, 14272717, 14272750, 14274773, 14274777, 14274997, 14275001, 14275127, 14275130, + 14275146, 14275323, 14275353, 14275424, 14275668, 14276086, 14276123, 14276168, 14276309, 14276370, 14276458, 14276520, 14277427, + 14277434, 14277438, 14277439, 14277514, 14277581, 14277637, 14278054, 14278075, 14278093, 14278096, 14278100, 14278142, 14278209, + 14278267, 14278302, 14278331, 14278429, 14278440, 14278687, 14278756, 14278811, 14279537, 14279693, 14279798, 14280053, 14280185, + 14280204, 14280267, 14280452, 14280583, 14280616, 14280703, 14281278, 14281362, 14281532, 14281603, 14281860, 14281911, 14282559, + 14283530, 14283550, 14283560, 14283564, 14283579, 14283595, 14283598, 14283613, 14283697, 14283746, 14284070, 14284218, 14284578, + 14284847, 14286487, 14286490, 14286613, 14286765, 14287334, 14287353, 14287608, 14287664, 14287752, 14287787, 14287796, 14287799, + 14287800, 14287802, 14287945, 14288161, 14288307, 14288451, 14288502, 14288846, 14288983, 14289001, 14289005, 14289016, 14289060, + 14289723, 14290173, 14290424, 14290457, 14290459, 14290506, 14290571, 14290766, 14290801, 14290962, 14291669, 14291708, 14291718, + 14291815, 14292939, 14292956, 14293247, 14293268, 14293297, 14293393, 14293441, 14293602, 14293740, 14293803, 14294518, 14294563, + 14294601, 14294625, 14295118, 14295131, 14295183, 14295205, 14295233, 14295243, 14295256, 14295279, 14295325, 14295328, 14295332, + 14295394, 14295420, 14295683, 14295688, 14295809, 14296174, 14296471, 14296495, 14296520, 14296596, 14296598, 14296727, 14296803, + 14296887, 14296913, 14296925, 14297069, 14297070, 14297260, 14297371, 14297452, 14297529, 14297538, 14297676, 14297759, 14297807, + 14297822, 14298409, 14298639, 14298896, 14298903, 14298932, 14299363, 14299554, 14300286, 14300298, 14300301, 14300495, 14300640, + 14300659, 14301074, 14301263, 14301438, 14301472, 14301639, 14301663, 14301665, 14301705, 14301827, 14302166, 14302216, 14302438, + 14302631, 14302782, 14302982, 14303337, 14303485, 14303928, 14304191, 14304195, 14304374, 14304577, 14304591, 14304640, 14305416, + 14305568, 14305668, 14305702, 14305917, 14305920, 14306074, 14306134, 14306454, 14307152, 14307386, 14307402, 14307413, 14307462, + 14307466, 14307547, 14307632, 14307804, 14307929, 14308045, 14308232, 14308345, 14308437, 14308448, 14309558, 14309627, 14309634, + 14309679, 14309714, 14309805, 14309832, 14309939, 14310154, 14310541, 14310658, 14310887, 14310987, 14311341, 14312039, 14312218, + 14312227, 14312251, 14312317, 14312327, 14312447, 14312532, 14313179, 14313565, 14313860, 14313880, 14313896, 14313985, 14314069, + 14314262, 14314503, 14314504, 14315064, 14315149, 14315158, 14315195, 14315406, 14315429, 14315534, 14315796, 14316030, 14316190, + 14316259, 14316600, 14316647, 14316861, 14317147, 14317635, 14317647, 14317657, 14317734, 14317812, 14317833, 14317844, 14317921, + 14317930, 14317937, 14317942, 14317945, 14317982, 14317988, 14318921, 14318922, 14319270, 14319315, 14319942, 14320162, 14320227, + 14320284, 14320753, 14320763, 14322722, 14322745, 14322786, 14322880, 14322990, 14323725, 14323744, 14324520, 14324584, 14324706, + 14324707, 14328007, 14328024, 14331549, 14331550, 14331679, 14332651, 14332653, 14332760, 14332764, 14332800, 14332809, 14333294, + 14333328, 14333336, 14333346, 14333551, 14333562, 14334351, 14334509, 14334540, 14334564, 14337693, 14340622, 14342084, 14342092, + 14342313, 14342321, 14342457, 14342462, 14343083, 14343087, 14343141, 14343154, 14343161, 14343551, 14343566, 14343577, 14343609, + 14343647, 14343803, 14343938, 14343962, 14344087, 14344928, 14344933, 14345088, 14345153, 14345161, 14345601, 14345744, 14345777, + 14346561, 14346614, 14346765, 14346782, 14346783, 14347126, 14347150, 14347420, 14347452, 14347570, 14347598, 14347626, 14347635, + 14347637, 14347725, 14347781, 14348725, 14348905, 14349352, 14349447, 14351917, 14352564, 14352616, 14352773, 14352923, 14353039, + 14354130, 14354236, 14354276, 14354277, 14354290, 14354327, 14354329, 14354337, 14354362, 14354420, 14354429, 14354456, 14354679, + 14354688, 14354691, 14354801, 14354829, 14354874, 14354902, 14354918, 14355487, 14355501, 14355611, 14355907, 14356212, 14356334, + 14356358, 14356391, 14356876, 14357035, 14357313, 14357658, 14357681, 14357718, 14357730, 14357799, 14357850, 14357987, 14358091, + 14358190, 14358267, 14358722, 14359057, 14359213, 14359358, 14359371, 14359465, 14359589, 14359597, 14359648, 14359654, 14360676, + 14360709, 14360796, 14361052, 14361484, 14361538, 14361631, 14361731, 14362244, 14362395, 14362428, 14362460, 14362496, 14362567, + 14362798, 14362805, 14362808, 14363004, 14363041, 14363050, 14363058, 14363068, 14363172, 14363510, 14363570, 14363734, 14364469, + 14364510, 14364518, 14365738, 14365742, 14365752, 14365867, 14365890, 14366055, 14366116, 14366211, 14366224, 14366233, 14366246, + 14366288, 14366309, 14366329, 14366429, 14366430, 14366443, 14366448, 14366472, 14366539, 14366589, 14366750, 14366765, 14366794, + 14366934, 14367112, 14367251, 14367272, 14367282, 14367466, 14367467, 14367468, 14367469, 14367477, 14367496, 14367530, 14367687, + 14367800, 14367833, 14367960, 14368004, 14368015, 14368024, 14368061, 14368069, 14368160, 14368167, 14368170, 14368194, 14368302, + 14368786, 14368797, 14368798, 14368810, 14368823, 14370205, 14370209, 14370844, 14370852, 14371635, 14371854, 14372502, 14372811, + 14375059, 14375196, 14375337, 14375353, 14376850, 14377162, 14377188, 14378134, 14378139, 14378142, 14378262, 14378276, 14378281, + 14378284, 14378300, 14378310, 14378366, 14378380, 14378433, 14380203, 14380358, 14380376, 14380432, 14380454, 14380479, 14380500, + 14380502, 14380511, 14380523, 14380526, 14380576, 14381101, 14381108, 14381116, 14381149, 14381187, 14381336, 14381643, 14381650, + 14384971, 14385017, 14385299, 14385327, 14385345, 14385346, 14385398, 14385409, 14386643, 14386717, 14387783, 14387792, 14387814, + 14387938, 14388060, 14388082, 14388164, 14388173, 14388184, 14388185, 14388190, 14388205, 14388211, 14388234, 14388244, 14388337, + 14388466, 14389756, 14389760, 14391505, 14391529, 14392389, 14392425, 14392444, 14392452, 14392466, 14392654, 14393420, 14393502, + 14393594, 14393595, 14393599, 14393671, 14394385, 14395110, 14395112, 14395122, 14395139, 14395232, 14395237, 14395341, 14395364, + 14395414, 14395416, 14397686, 14397758, 14397792, 14397865, 14398937, 14398955, 14398982, 14399110, 14399114, 14399131, 14399141, + 14399198, 14399200, 14399218, 14399248, 14399251, 14399276, 14399914, 14399919, 14399960, 14399989, 14399992, 14400040, 14400043, + 14400048, 14400097, 14400128, 14400131, 14402470, 14402526, 14402741, 14402794, 14402800, 14402805, 14402891, 14402926, 14404738, + 14404762, 14404988, 14405199, 14405204, 14405237, 14405348, 14406107, 14406164, 14406177, 14406665, 14406666, 14406887, 14406900, + 14406901, 14406982, 14406984, 14407108, 14407204, 14407309, 14407326, 14408372, 14408387, 14408522, 14408523, 14408534, 14408798, + 14408824, 14408858, 14410649, 14410860, 14410915, 14410986, 14411113, 14411190, 14411745, 14411764, 14412210, 14412275, 14412297, + 14412428, 14412434, 14412741, 14412857, 14412866, 14412869, 14413198, 14413199, 14413906, 14413934, 14414045, 14414168, 14414430, + 14414443, 14414710, 14415221, 14415252, 14415388, 14415429, 14415469, 14415513, 14415554, 14415608, 14415656, 14415660, 14415666, + 14415927, 14415975, 14416165, 14417518, 14418203, 14418277, 14418301, 14418317, 14418392, 14418533, 14418543, 14418546, 14419038, + 14419373, 14419466, 14419469, 14419481, 14419488, 14419499, 14419512, 14419521, 14419616, 14419697, 14419698, 14419805, 14419900, + 14419928, 14419929, 14419941, 14419942, 14419962, 14420023, 14420069, 14420082, 14420084, 14420086, 14420091, 14420094, 14420112, + 14420116, 14420129, 14420131, 14420180, 14420183, 14420193, 14420247, 14420253, 14420256, 14420275, 14420293, 14420303, 14420341, + 14420348, 14420480, 14420699, 14420814, 14420849, 14420851, 14420971, 14421014, 14421036, 14421045, 14421046, 14421169, 14421176, + 14421440, 14421858, 14421886, 14421920, 14422148, 14422321, 14422453, 14422593, 14422767, 14422856, 14423018, 14423133, 14423196, + 14423206, 14423268, 14423271, 14423515, 14423532, 14423583, 14423860, 14423881, 14423932, 14424014, 14424043, 14424067, 14424296, + 14424429, 14424452, 14424558, 14424562, 14424571, 14424585, 14424586, 14424589, 14424636, 14424685, 14424736, 14424750, 14424769, + 14425463, 14425546, 14425574, 14425575, 14425633, 14425767, 14425781, 14425849, 14425993, 14426028, 14426072, 14426221, 14426583, + 14427051, 14427197, 14427202, 14427208, 14427399, 14427441, 14427452, 14427473, 14427870, 14428817, 14428898, 14428920, 14429168, + 14429174, 14429180, 14429324, 14430071, 14430108, 14430138, 14430143, 14430231, 14430255, 14430816, 14430855, 14430886, 14430899, + 14430901, 14430902, 14430905, 14430924, 14430965, 14431006, 14431063, 14431282, 14431502, 14431545, 14431559, 14431720, 14431721, + 14432038, 14432172, 14432192, 14432201, 14432626, 14432636, 14432638, 14433023, 14433345, 14433362, 14433891, 14433944, 14434390, + 14434409, 14434414, 14434471, 14434649, 14436439, 14436511, 14436521, 14436616, 14436975, 14437026, 14437134, 14437167, 14437191, + 14437201, 14437204, 14437205, 14437268, 14437527, 14437534, 14437547, 14437565, 14437613, 14437807, 14437820, 14438118, 14438156, + 14438160, 14438162, 14438168, 14438215, 14438333, 14438365, 14438531, 14438538, 14438956, 14439014, 14439085, 14439105, 14439107, + 14439173, 14439501, 14439515, 14439776, 14439868, 14440295, 14440312, 14440363, 14440392, 14440418, 14440420, 14440431, 14440986, + 14440993, 14441010, 14441090, 14441114, 14441175, 14441182, 14441421, 14441424, 14441436, 14441455, 14442331, 14442410, 14442412, + 14442499, 14442590, 14443032, 14443124, 14443702, 14443783, 14443785, 14443880, 14443986, 14443987, 14443996, 14444016, 14444291, + 14444335, 14444348, 14444958, 14445106, 14445730, 14445744, 14445796, 14445857, 14445956, 14445960, 14449012, 14449107, 14449279, + 14449287, 14450086, 14450107, 14450169, 14450196, 14451369, 14451491, 14451664, 14451679, 14452080, 14452088, 14452158, 14452281, + 14452377, 14452464, 14454060, 14454100, 14454259, 14454284, 14455932, 14455937, 14456161, 14456169, 14456173, 14456215, 14456220, + 14456251, 14456262, 14456272, 14456374, 14456386, 14456389, 14456408, 14456422, 14456596, 14456654, 14456697, 14456714, 14457226, + 14457236, 14457251, 14457272, 14457294, 14457295, 14457323, 14457332, 14457341, 14457872, 14457925, 14458268, 14458361, 14462180, + 14462204, 14462241, 14462308, 14464172, 14464255, 14466306, 14466331, 14466411, 14466425, 14466470, 14466488, 14466497, 14466523, + 14466972, 14466984, 14467004, 14467023, 14468341, 14468496, 14469581, 14469604, 14469619, 14469675, 14470339, 14470341, 14470456, + 14470514, 14470520, 14470622, 14470887, 14470888, 14471412, 14471417, 14471591, 14471594, 14473086, 14473092, 14473096, 14473097, + 14473637, 14473642, 14475479, 14475496, 14475695, 14475733, 14476630, 14476676, 14476712, 14476812, 14477122, 14477145, 14477588, + 14477589, 14477594, 14477605, 14477607, 14477633, 14477742, 14477772, 14477777, 14478030, 14478043, 14478624, 14478666, 14479141, + 14479784, 14479865, 14479943, 14479950, 14479961, 14481636, 14481637, 14481722, 14481726, 14481758, 14481986, 14481997, 14482096, + 14482102, 14482118, 14482138, 14482420, 14482427, 14482457, 14482487, 14482508, 14482687, 14482693, 14482834, 14482845, 14483435, + 14483438, 14483442, 14483453, 14483471, 14483605, 14483834, 14483839, 14484322, 14484339, 14484341, 14484392, 14484412, 14484498, + 14484698, 14484752, 14484755, 14488867, 14488878, 14488894, 14488896, 14489287, 14489291, 14489510, 14489549, 14490029, 14490073, + 14490084, 14490085, 14490086, 14490088, 14490123, 14490128, 14490190, 14490213, 14490644, 14490652, 14490708, 14490728, 14490903, + 14490908, 14491415, 14491754, 14491757, 14491758, 14491805, 14492838, 14493628, 14494367, 14494372, 14494373, 14494376, 14494379, + 14494381, 14494646, 14494656, 14494661, 14494752, 14494868, 14494907, 14494921, 14494941, 14494953, 14494954, 14495034, 14495065, + 14495075, 14495076, 14495135, 14495154, 14495165, 14495173, 14495188, 14495192, 14495488, 14495493, 14495495, 14495501, 14495644, + 14495687, 14495688, 14495840, 14495967, 14495968, 14496394, 14496406, 14496408, 14496432, 14496500, 14496551, 14496604, 14496966, + 14497034, 14497038, 14497550, 14497568, 14497570, 14497668, 14497702, 14497706, 14497708, 14497820, 14497848, 14497895, 14497913, + 14497935, 14497937, 14498323, 14498354, 14498355, 14501002, 14501005, 14501526, 14502186, 14502208, 14502215, 14502229, 14502284, + 14502295, 14502315, 14502353, 14502605, 14502627, 14502635, 14502663, 14502758, 14502769, 14503020, 14503058, 14503061, 14503068, + 14503086, 14503134, 14503288, 14503395, 14503429, 14503435, 14503522, 14503525, 14504153, 14504162, 14504169, 14504173, 14504371, + 14504422, 14504432, 14504442, 14507145, 14507147, 14507476, 14507486, 14507489, 14507515, 14507520, 14507570, 14507702, 14507732, + 14508208, 14508212, 14509089, 14509103, 14509612, 14509623, 14511370, 14511373, 14511378, 14511379, 14511768, 14511773, 14512246, + 14512248, 14514087, 14514094, 14514100, 14514117, 14514130, 14514133, 14514156, 14514162, 14514508, 14514588, 14514908, 14514918, + 14514964, 14514971, 14514989, 14515007, 14515063, 14515165, 14515419, 14515421, 14515591, 14515593, 14515714, 14515716, 14515719, + 14515720, 14515748, 14515749, 14515854, 14515860, 14515903, 14515904, 14515951, 14515955, 14515993, 14515997, 14516253, 14516270, + 14516372, 14516412, 14516497, 14516503, 14517397, 14517439, 14519618, 14519619, 14519694, 14519701, 14519702, 14519714, 14519776, + 14519782, 14519803, 14519804, 14519955, 14519996, 14520020, 14520024, 14520043, 14520060, 14520061, 14520062, 14520115, 14520126, + 14520159, 14520172, 14520186, 14520190, 14520198, 14520212, 14520222, 14520227, 14520235, 14520497, 14520498, 14520746, 14520774, + 14520977, 14520982, 14520986, 14521011, 14521066, 14521069, 14522110, 14522112, 14522118, 14522165, 14522218, 14522219, 14522733, + 14522797, 14523118, 14523126, 14523830, 14523835, 14524242, 14524243, 14524259, 14524266, 14526070, 14526077, 14526083, 14526086, + 14526087, 14526099, 14526120, 14526126, 14526141, 14526211, 14526215, 14526221, 14526244, 14526255, 14526300, 14526321, 14526332, + 14526340, 14526344, 14526346, 14526356, 14526363, 14526380, 14526442, 14526463, 14527065, 14527080, 14527084, 14527176, 14527178, + 14527369, 14527370, 14527424, 14527431, 14527447, 14527451, 14527599, 14527626, 14527627, 14527633, 14527696, 14527715, 14527723, + 14527735, 14527839, 14528084, 14528085, 14528093, 14528124, 14528171, 14528614, 14528712, 14528723, 14528757, 14528758, 14528864, + 14528925, 14528961, 14528969, 14528986, 14528993, 14528997, 14529009, 14529012, 14529017, 14529021, 14529024, 14529026, 14529029, + 14529033, 14529037, 14529046, 14529100, 14529124, 14529557, 14530096, 14530149, 14531104, 14531141, 14531213, 14531235, 14531744, + 14531775, 14531956, 14531968, 14531999, 14532026, 14532066, 14532097, 14532696, 14532706, 14532729, 14532730, 14532739, 14532749, + 14532758, 14532838, 14532843, 14533032, 14533035, 14533049, 14533066, 14533070, 14533079, 14533136, 14533141, 14533267, 14533299, + 14533319, 14533321, 14533346, 14533372, 14533410, 14533430, 14533442, 14533526, 14533548, 14533722, 14533805, 14533836, 14533847, + 14533860, 14533861, 14533873, 14533878, 14533920, 14534184, 14534185, 14534191, 14534193, 14534233, 14534256, 14534343, 14534366, + 14534397, 14534426, 14535016, 14535017, 14535020, 14535028, 14535045, 14535083, 14535119, 14535180, 14535199, 14535394, 14535426, + 14535428, 14535456, 14535475, 14535634, 14535662, 14535688, 14535691, 14535692, 14535702, 14536479, 14536480, 14536489, 14536490, + 14536492, 14536493, 14538931, 14538950, 14539037, 14539038, 14539216, 14539309, 14539334, 14539344, 14539390, 14539420, 14539473, + 14539534, 14539537, 14539564, 14540149, 14540166, 14540656, 14540667, 14540769, 14540796, 14541039, 14541063, 14541069, 14541071, + 14541159, 14541165, 14541181, 14541201, 14541315, 14541323, 14541325, 14541328, 14541535, 14542840, 14542888, 14542906, 14542907, + 14543190, 14543248, 14543853, 14543908, 14544590, 14544596, 14544603, 14544616, 14544670, 14544671, 14544700, 14544710, 14544746, + 14544754, 14544827, 14544828, 14544837, 14544856, 14544877, 14544962, 14545025, 14545172, 14545204, 14545224, 14545226, 14545234, + 14545464, 14545483, 14545723, 14545743, 14545958, 14545994, 14546116, 14546131, 14546151, 14546163, 14546371, 14546380, 14546408, + 14546419, 14546448, 14546450, 14546509, 14546553, 14546560, 14546608, 14546630, 14546636, 14546678, 14546684, 14546867, 14546869, + 14547247, 14547249, 14547565, 14547577, 14547724, 14547850, 14547854, 14547861, 14547962, 14548000, 14550132, 14550221, 14552498, + 14552506, 14552667, 14552671, 14552813, 14552828, 14553470, 14553472, 14553476, 14554183, 14554188, 14554192, 14554225, 14554740, + 14554785, 14555988, 14556013, 14556021, 14556022, 14556083, 14556084, 14556089, 14556092, 14556100, 14556103, 14556108, 14556140, + 14556651, 14558534, 14559061, 14559072, 14559085, 14559733, 14559791, 14560016, 14560026, 14560028, 14560038, 14560040, 14560076, + 14560273, 14560275, 14560303, 14560306, 14560310, 14560322, 14560576, 14560577, 14560582, 14560595, 14560608, 14560622, 14560728, + 14560734, 14561795, 14561825, 14561840, 14562587, 14562623, 14562630, 14562645, 14563527, 14563541, 14563542, 14563549, 14563729, + 14563739, 14563740, 14563748, 14563749, 14563755, 14563766, 14563768, 14563774, 14563775, 14563894, 14563959, 14563963, 14563967, + 14564050, 14564054, 14564058, 14564075, 14564164, 14564730, 14564733, 14565457, 14565462, 14565943, 14566817, 14566822, 14588081, + 15278993, 15298860, 15299275, 15299420, 15299520, 15299715, 15299731, 15299757, 15301708, 15301850, 15301875, 15302455, 15302967, + 15304019, 15305121, 15305561, 15307407, 15307490, 15307868, 15308032, 15311107, 15311210, 15311599, 15316343, 15316528, 15316535, + 15317411, 15318069, 15318235, 15318288, 15318437, 15318758, 15319019, 15319366, 15319403, 15320313, 15321005, 15321511, 15321634, + 15321707, 15321890, 15322055, 15322136, 15323088, 15323182, 15323543, 15324636, 15327600, 15328789, 15328903, 15328961, 15329151, + 15330358, 15330441, 15330468, 15331215, 15331280, 15333764, 15333830, 15335397, 15336059, 15337247, 15337395, 15337630, 15339099, + 15340038, 15340971, 15341319, 15341479, 15341544, 15342783, 15343155, 15343302, 15343551, 15343809, 15344150, 15344169, 15344370, + 15344584, 15346218, 15346421, 15346604, 15346684, 15346714, 15346716, 15350123, 15350143, 15350966, 15351041, 15351346, 15351348, + 15352316, 15352341, 15353576, 15353802, 15354436, 15354503, 15354708, 15354744, 15355751, 15355938, 15356263, 15356464, 15357773, + 15357806, 15357836, 15357870, 15359242, 15359261, 15359409, 15359557, 15359701, 15359731, 15359846, 15359932, 15360348, 15360351, + 15360966, 15360968, 15360998, 15361018, 15363267, 15363312, 15363413, 15363420, 15363920, 15364070, 15364136, 15364150, 15364663, + 15364715, 15367310, 15367326, 15368095, 15368104, 15368537, 15368541, 15368874, 15368881, 15369797, 15369898, 15370883, 15370885, + 15371463, 15371516, 15372941, 15373029, 15373035, 15373039, 15373489, 15373548, 15374297, 15374326, 15374448, 15374596, 15375231, + 15375318, 15375776, 15375803, 15376049, 15376057, 15377278, 15377371, 15378036, 15378043, 15378052, 15378059, 15378164, 15378166, + 15379378, 15379430, 15379848, 15379863, 15379880, 15379890, 15381333, 15381472, 15381587, 15381594, 15382319, 15382335, 15382622, + 15382689, 15384884, 15384889, 15386453, 15386482, 15386506, 15386762, 15386943, 15387036, 15387461, 15387465, 15387752, 15387804, + 15388394, 15388486, 15388606, 15388617, 15389904, 15390109, 15390434, 15390437, 15390816, 15390866, 15393023, 15393050, 15393079, + 15393299, 15393785, 15393789, 15394171, 15394184, 15394223, 15394363, 15397304, 15397311, 15397367, 15397572, 15398540, 15398542, + 15398966, 15398984, 15400273, 15400276, 15400610, 15400638, 15401565, 15401650, 15404521, 15404620, 15406007, 15406017, 15406624, + 15406687, 15407958, 15407964, 15408278, 15408287, 15410615, 15410769, 15411104, 15411119, 15411326, 15411591, 15411833, 15411836, + 15413038, 15413046, 15413111, 15413148, 15413371, 15413374, 15413483, 15413499, 15415282, 15415416, 15417725, 15417802, 15417896, + 15417906, 15419558, 15419604, 15419797, 15419800, 15419980, 15420000, 15420016, 15420019, 15421514, 15421544, 15423424, 15423558, + 15423661, 15423673, 15424869, 15424873, 15425240, 15425382, 15425895, 15425897, 15426289, 15426372, 15427195, 15427225, 15427230, + 15427233, 15427289, 15427298, 15427993, 15427999, 15428176, 15428217, 15428227, 15428516, 15428529, 15428567, 15428784, 15429008, + 15429020, 15429026, 15429032, 15429281, 15430344, 15430346, 15430706, 15430735, 15430879, 15430885, 15431260, 15431365, 15432397, + 15432422, 15432649, 15432654, 15432804, 15432819, 15433923, 15433932, 15435272, 15435298, 15437041, 15437050, 15438105, 15438114, + 15440121, 15440253, 15441104, 15441282, 15442199, 15442584, 15443871, 15444142, 15444188, 15444408, 15444685, 15444690, 15445733, + 15445736, 15445863, 15445878, 15447031, 15447065, 15448796, 15448816, 15449403, 15449413, 15449587, 15449609, 15449711, 15449878, + 15449962, 15449964, 15450263, 15450405, 15450446, 15450450, 15451400, 15451408, 15451819, 15451857, 15452179, 15452192, 15452979, + 15453020, 15453357, 15453514, 15455431, 15455434, 15455761, 15455880, 15456762, 15456784, 15457983, 15459043, 15459439, 15459567, + 15459814, 15459822, 15460508, 15460591, 15461069, 15461082, 15462424, 15462426, 15462594, 15462656, 15462690, 15462696, 15463436, + 15463936, 15464266, 15465784, 15465839, 15465937, 15466610, 15466631, 15467021, 15467085, 15467103, 15467109, 15467756, 15467851, + 15468430, 15468503, 15468511, 15468652, 15469184, 15469200, 15469285, 15469458, 15469754, 15469759, 15470276, 15470283, 15470370, + 15470392, 15471545, 15471785, 15473261, 15473269, 15473454, 15473460, 15474422, 15474425, 15474922, 15475151, 15475640, 15475643, + 15476163, 15476405, 15476427, 15476439, 15477009, 15477179, 15477640, 15477649, 15479093, 15479107, 15480142, 15480151, 15480580, + 15480814, 15481022, 15481026, 15481035, 15481037, 15481562, 15481565, 15481590, 15481591, 15481741, 15481744, 15482067, 15482078, + 15482616, 15482683, 15486561, 15486564, 15486616, 15486617, 15486666, 15486668, 15486678, 15486680, 15487459, 15487500, 15488119, + 15488127, 15488401, 15488409, 15488440, 15488442, 15488965, 15488970, 15489694, 15489700, 15490595, 15490615, 15491720, 15491760, + 15492016, 15492020, 15492072, 15492087, 15492855, 15492857, 15493002, 15493004, 15493071, 15493074, 15493106, 15493108, 15493360, + 15493365, 15494319, 15494332, 15496258, 15496263, 15497235, 15497254, 15497321, 15497338, 15498352, 15498354, 15499365, 15499369, + 15501348, 15501354, 15502470, 15502478, 15503665, 15503673, 15504523, 15504537, 15504621, 15504628, 15504938, 15505080, 15506069, + 15506072, 15506112, 15506113, 15506426, 15506436, 15507433, 15507435, 15508130, 15508192, 15508250, 15508358, 15510418, 15510430, + 15510706, 15510712, 15511523, 15511526, 15511628, 15511629, 15512065, 15512071, 15512120, 15512121, 15513126, 15513199, 15513214, + 15513441, 15514260, 15514460, 15515518, 15515520, 15515699, 15515701, 15516480, 15516482, 15517627, 15517654, 15518075, 15518102, + 15519576, 15519578, 15520859, 15520864, 15521342, 15521351, 15521537, 15521553, 15521701, 15521707, 15522808, 15523015, 15523483, + 15523488, 15524388, 15524397, 15524703, 15524713, 15525341, 15525343, 15525349, 15525353, 15526412, 15526559, 15527127, 15527133, + 15527672, 15527675, 15528231, 15528248, 15528274, 15528307, 15529512, 15529522, 15529961, 15530071, 15530915, 15530926, 15531367, + 15531370, 15533472, 15533487, 15534560, 15534786, 15535306, 15535318, 15535392, 15535522, 15538116, 15539371, 15540337, 15540602, + 15541064, 15541071, 15541659, 15541666, 15541681, 15541719, 15541771, 15541777, 15542276, 15542282, 15542576, 15542585, 15542589, + 15542594, 15542886, 15542896, 15543880, 15543976, 15544196, 15546926, 15547006, 15547018, 15547117, 15547119, 15547436, 15547520, + 15547554, 15547587, 15547642, 15547644, 15549036, 15549039, 15549429, 15549448, 15550823, 15550828, 15551147, 15551381, 15551716, + 15551720, 15552150, 15552267, 15554087, 15554090, 15554449, 15554456, 15555207, 15555210, 15556032, 15556037, 15556177, 15556184, + 15557755, 15557761, 15558433, 15558443, 15559082, 15559107, 15560806, 15560890, 15561941, 15562075, 15562258, 15562260, 15563500, + 15563507, 15563620, 15563624, 15565974, 15565985, 15566159, 15566161, 15566675, 15567720, 15567772, 15697646, 15698252, 15699048, + 15699049, 15699308, 15699355, 15701033, 15701037, 15701139, 15701868, 15722361, 15723839, 15725644, 15726602, 15726621, 15726727, + 15726730, 15728420, 15728425, 15729973, 15729986, 15731110, 15731125, 15732349, 15732819, 15733345, 15733382, 15736966, 15741478, + 15742747, 15743712, 15744541, 15746902, 15748357, 15751438, 15751801, 15754322, 15755697, 15768595, 15768635, 15768636, 15771170, + 15771235, 15771418, 15771566, 15772511, 15772514, 15773217, 15773287, 15773693, 15775062, 15775162, 15775170, 15775628, 15775748, + 15777966, 15778518, 15780571, 15780590, 15781334, 15781414, 15783805, 15784103, 15784218, 15784222, 15784336, 15786288, 15786350, + 15786412, 15786880, 15787424, 15791418, 15791577, 15791945, 15792759, 15792904, 15792905, 15793375, 15799982, 15800147, 15800148, + 15800738, 15800739, 15801497, 15801498, 15803568, 15803571, 15805641, 15808771, 15809000, 15815539, 15815540, 15815571, 15816365, + 15816366, 15820482, 15820483, 15820930, 15820933, 15822783, 15822784, 15823306, 15823308, 15823485, 15823486, 15827101, 15827102, + 15830019, 15830020, 15830105, 15830106, 15835137, 15835138, 15838243, 15839723, 15840576, 15841503, 15841688, 15841690, 15847048, + 15847050, 15847745, 15848829, 15850375, 15855827, 15859288, 15859289, 15860023, 15860373, 15860606, 15860607, 15860828, 15860829, + 15861647, 15861648, 15861982, 15861983, 15863539, 15865475, 15865811, 15865812, 15865814, 15865819, 15865939, 15865940, 15866722, + 15866723, 15867794, 15869548, 15870297, 15870823, 15870956, 15870957, 15871190, 15871197, 15871254, 15871766, 15872132, 15873270, + 15875334, 15875634, 15875797, 15876025, 15876802, 15876803, 15876808, 15876810, 15876831, 15876833, 15876844, 15876845, 15876858, + 15876859, 15876865, 15876866, 15876996, 15877054, 15877147, 15878253, 15878396, 15878397, 15878409, 15878410, 15880251, 15880252, + 15880976, 15883223, 15883257, 15883258, 15883267, 15883268, 15883338, 15883366, 15883572, 15883573, 15883704, 15883705, 15883815, + 15883866, 15884708, 15885134, 15886585, 15886948, 15889015, 15889135, 15889263, 15889264, 15889297, 15890107, 15890836, 15890856, + 15891258, 15891259, 15891595, 15891596, 15898995, 15899413, 15900484, 15900485, 15900856, 15900857, 15900999, 15901784, 15902052, + 15902074, 15903287, 15904479, 15904560, 15904561, 15904756, 15904948, 15905428, 15905429, 15908728, 15908729, 15908732, 15908733, + 15908737, 15908739, 15911168, 15911169, 15911465, 15911466, 15912295, 15912378, 15912429, 15912435, 15912645, 15913367, 15915228, + 15915229, 15915232, 15915233, 15915473, 15915474, 15915509, 15915510, 15915885, 15915886, 15916207, 15916208, 15916906, 15916907, + 15917200, 15917202, 15917206, 15917207, 15921490, 15921491, 15921519, 15922789, 15923115, 15923117, 15924339, 15924525, 15924533, + 15926434, 15927196, 15928263, 15929673, 15929674, 15929698, 15929766, 15930272, 15941143, 15941944, 15941945, 15941949, 15941950, + 15941954, 15941955, 15941966, 15941967, 15942041, 15942242, 15943918, 15944225, 15944958, 15948423, 15948742, 15948893, 15948934, + 15948935, 15948952, 15948953, 15948974, 15948975, 15948980, 15948981, 15948984, 15948985, 15948995, 15948996, 15949061, 15949062, + 15950050, 15950051, 15950637, 15950638, 15950642, 15950643, 15950646, 15950647, 15950650, 15950651, 15950666, 15950667, 15950686, + 15950687, 15951694, 15951695, 15951941, 15951942, 15951970, 15951971, 15951974, 15951975, 15951978, 15951979, 15952040, 15954672, + 15956700, 15956815, 15957170, 15957963, 15965549, 15968309, 15969082, 15969120, 15970110, 15970111, 15970828, 15970854, 15971891, + 15971916, 15971980, 15972006, 15973526, 15973527, 15973835, 15974371, 15976265, 15977379, 15978362, 15978948, 15979197, 15980087, + 15980290, 15980299, 15981105, 15981106, 15981914, 15981915, 15982995, 15985005, 15985847, 15986020, 15986468, 15990277, 15990962, + 15991688, 15992374, 15992627, 15992966, 15994933, 15995140, 15995217, 15998964, 16006307, 16010481, 16011214, 16012893, 16013844, + 16015906, 17636688, 17637873, 17638275, 17638348, 17638487, 17638892, 17664726, 17667175, 17673330, 17673544, 17673816, 17681905, + 17685084, 17685085, 17687705, 17691885, 17692405, 17693311, 17694199, 17698519, 17699421, 17699575, 17699776, 17704976, 17705868, + 17707335, 17707490, 17710949, 17711356, 17711906, 17712444, 17720306, 17720567, 17723439, 17723538, 17729149, 17729172, 17730669, + 17735353, 17738506, 17739593, 17742978, 17746144, 17752865, 17759547, 17770240, 17774229, 17774250, 17778606, 17779105, 17782179, + 17783310, 17783420, 17784087, 17791119, 17792330, 17793195, 17795208, 17796208, 17798702, 17803925, 17806758, 17808553, 17811929, + 17815836, 17818217, 17853647, 17855162, 17855180, 17874661, 17881967, 17886031, 17886472, 17886499, 17892400, 17892586, 17893593, + 17918105, 17920208, 17923983, 17932312, 17940478, 17949572, 17950256, 17978577, 17978638, 17979243, 17981913, 17981914, 17986345, + 17995612, 17998455, 18001936, 18018601, 18019359, 18020832, 18020852, 18020857, 18021161, 18024791, 18028665, 18028982, 18029024, + 18029065, 18029402, 18029410, 18029412, 18029430, 18029461, 18029535, 18029709, 18029941, 18030109, 18030158, 18030174, 18030618, + 18030897, 18031010, 18031050, 18031102, 18031119, 18033407, 18033471, 18033519, 18034800, 18035522, 18035524, 18035558, 18035587, + 18035592, 18035611, 18035718, 18036283, 18037159, 18037177, 18037518, 18037756, 18037831, 18038107, 18038314, 18040137, 18040830, + 18042044, 18042107, 18042113, 18042989, 18044136, 18044214, 18045284, 18046457, 18046504, 18046619, 18046757, 18047186, 18047597, + 18047661, 18047776, 18047878, 18047880, 18048688, 18049264, 18050153, 18050586, 18050926, 18051022, 18052532, 18052575, 18052827, + 18053165, 18053676, 18053753, 18054135, 18055170, 18056994, 18057401, 18057693, 18057697, 18058403, 18058457, 18058779, 18058896, + 18059950, 18059951, 18061046, 18061130, 18061163, 18061330, 18062045, 18062047, 18062332, 18063045, 18063475, 18063531, 18063738, + 18064294, 18065075, 18065242, 18065980, 18066212, 18066443, 18066962, 18067060, 18067533, 18067720, 18067880, 18067908, 18067926, + 18069030, 18069287, 18069478, 18069486, 18070682, 18070696, 18070945, 18070960, 18071100, 18071247, 18071778, 18071877, 18071965, + 18072000, 18072080, 18072170, 18072197, 18072238, 18072391, 18072987, 18073243, 18074765, 18075302, 18075625, 18075780, 18075781, + 18075911, 18075915, 18075944, 18075961, 18078850, 18079649, 18082360, 18084867, 18084911, 18085324, 18085709, 18087962, 18087963, + 18088191, 18088242, 18088250, 18088280, 18088356, 18088559, 18088585, 18088685, 18088801, 18089141, 18089688, 18089823, 18090573, + 18092942, 18093321, 18093525, 18093792, 18094278, 18094280, 18094353, 18094818, 18095086, 18096830, 18096870, 18096945, 18099264, + 18099563, 18103567, 18105534, 18105712, 18105730, 18106676, 18106758, 18107898, 18108072, 18108109, 18108251, 18108364, 18108366, + 18108385, 18108608, 18109192, 18109630, 18109736, 18109886, 18110216, 18111914, 18117472, 18120015, 18121451, 18121461, 18123475, + 18126178, 18127068, 18127313, 18128050, 18128330, 18128335, 18128741, 18129173, 18129186, 18129274, 18129299, 18129598, 18129647, + 18130999, 18131052, 18132357, 18132384, 18132993, 18133129, 18133459, 18134121, 18134494, 18134563, 18134668, 18134725, 18135378, + 18135538, 18135637, 18136098, 18136421, 18136723, 18136850, 18138655, 18138798, 18139149, 18139266, 18139885, 18144618, 18145061, + 18145076, 18145167, 18145171, 18145489, 18145498, 18151530, 18154233, 18157193, 18157230, 18157352, 18157653, 18158227, 18159887, + 18160433, 18160599, 18163130, 18167158, 18167584, 18167696, 18168147, 18168194, 18169252, 18169257, 18169269, 18171907, 18171970, + 18173270, 18173746, 18173941, 18173950, 18174259, 18174963, 18176304, 18176339, 18176342, 18177237, 18177283, 18177395, 18177473, + 18177557, 18177648, 18178048, 18178068, 18179144, 18179923, 18180023, 18180031, 18182471, 18182554, 18183350, 18185302, 18186630, + 18189759, 18191550, 18191572, 18191690, 18191760, 18209428, 18209658, 18210069, 18210134, 18211447, 18211680, 18213658, 18214305, + 18226915, 18227231, 18233695, 18234036, 18234679, 18237160, 18237345, 18237354, 18237447, 18238159, 18238169, 18238305, 18238306, + 18238341, 18239452, 18239552, 18239591, 18242107, 18243775, 18247187, 18248062, 18248090, 18248152, 18248702, 18248948, 18251287, + 18253159, 18253172, 18253256, 18253494, 18253674, 18253702, 18253731, 18253737, 18254465, 18254579, 18254961, 18255157, 18255423, + 18255953, 18255964, 18255975, 18256059, 18256119, 18256175, 18256361, 18258481, 18258531, 18258617, 18258894, 18258898, 18258975, + 18259049, 18259278, 18259287, 18259310, 18260016, 18261458, 18261488, 18261623, 18262488, 18262528, 18262642, 18262749, 18262798, + 18262808, 18262813, 18262819, 18262827, 18262860, 18263274, 18265073, 18265373, 18274127, 18274713, 18274727, 18275088, 18275112, + 18275130, 18278505, 18278955, 18279067, 18279081, 18282620, 18282661, 18283406, 18283563, 18283848, 18284148, 18284248, 18284447, + 18284548, 18285101, 18285102, 18285296, 18285465, 18285587, 18286538, 18286732, 18286922, 18287028, 18287423, 18287435, 18288316, + 18288614, 18288684, 18289315, 18289388, 18289811, 18290157, 18291493, 18291622, 18291700, 18291765, 18292103, 18292104, 18292192, + 18292266, 18293383, 18293550, 18293680, 18293751, 18293811, 18294213, 18294759, 18299826, 18299990, 18300398, 18301246, 18301327, + 18303702, 18303813, 18304121, 18306402, 18306490, 18306738, 18307134, 18307258, 18307380, 18307382, 18307680, 18308694, 18308707, + 18308744, 18308789, 18308936, 18309470, 18309756, 18310124, 18310324, 18310679, 18313272, 18313276, 18313936, 18313942, 18314463, + 18314471, 18314489, 18314786, 18314944, 18314957, 18315430, 18315905, 18315975, 18316319, 18316622, 18316913, 18317424, 18317507, + 18317562, 18317614, 18318101, 18318833, 18319890, 18320642, 18320688, 18322258, 18322526, 18322711, 18323528, 18323546, 18324258, + 18326071, 18328517, 18329261, 18333428, 18334440, 18334468, 18340005, 18340701, 18341515, 18342104, 18343985, 18344306, 18344387, + 18344445, 18349782, 18354524, 18354532, 18354567, 18354647, 18355784, 18355800, 18355890, 18356093, 18356174, 18357105, 18358907, + 18359179, 18360540, 18360761, 18361109, 18362474, 18362701, 18363071, 18363333, 18363353, 18363359, 18363669, 18363849, 18364852, + 18365537, 18365642, 18370037, 18374101, 18374518, 18374703, 18378858, 18378979, 18379121, 18388650, 18392831, 18392906, 18393035, + 18393498, 18395705, 18396655, 18396696, 18399717, 18399721, 18399791, 18399885, 18400237, 18400318, 18401555, 18403896, 18403898, + 18403948, 18403950, 18404071, 18404074, 18404115, 18404117, 18404169, 18404170, 18404177, 18404214, 18408893, 18409021, 18409026, + 18409046, 18409296, 18409304, 18409332, 18409338, 18409342, 18409356, 18409383, 18409396, 18409511, 18409551, 18409567, 18409579, + 18409581, 18409638, 18409642, 18409660, 18409669, 18409705, 18409710, 18409737, 18410309, 18410336, 18410366, 18410382, 18410392, + 18410418, 18410426, 18410429, 18410929, 18410976, 18411158, 18414923, 18414966, 18414967, 18414971, 18414973, 18414996, 18415012, + 18415335, 18415343, 18415344, 18415372, 18415383, 18415401, 18415404, 18415409, 18415410, 18415439, 18415463, 18415730, 18415734, + 18415751, 18415752, 18415755, 18415762, 18415770, 18415789, 18415907, 18415911, 18415914, 18415915, 18415918, 18415919, 18415924, + 18415934, 18415935, 18415948, 18415951, 18415960, 18415962, 18415969, 18415974, 18415988, 18415996, 18416003, 18416007, 18416096, + 18416097, 18416098, 18416099, 18416110, 18416111, 18416121, 18417000, 18417004, 18417110, 18417111, 18417153, 18417223, 18417250, + 18417254, 18417255, 18417271, 18417276, 18417298, 18417306, 18418074, 18418081, 18419778, 18419803, 18419847, 18419867, 18419982, + 18420104, 18420138, 18420139, 18420149, 18420289, 18420295, 18421340, 18421341, 18421351, 18421354, 18421396, 18422027, 18422036, + 18422039, 18422146, 18422232, 18422238, 18422335, 18422473, 18422479, 18422569, 18422577, 18422932, 18423232, 18423233, 18423380, + 18423386, 18423801, 18423803, 18424005, 18424006, 18424106, 18424119, 18427918, 18428063, 18428188, 18428190, 18428341, 18428344, + 18428376, 18428378, 18428415, 18429089, 18429190, 18429191, 18429295, 18429301, 18429401, 18429408, 18429419, 18429425, 18429515, + 18429526, 18429763, 18430201, 18430203, 18430403, 18431180, 18431188, 18431554, 18431563, 18431586, 18431622, 18431858, 18431859, + 18432040, 18432050, 18432832, 18433010, 18433079, 18433119, 18459655, 18461356, 18461857, 18462173, 18463453, 18463531, 18479349, + 18479433, 18479437, 18479545, 18479547, 18479583, 18479584, 18479595, 18479615, 18479616, 18479622, 18481099, 18481103, 18481144, + 18481145, 18481150, 18481262, 18481457, 18481554, 18481769, 18485920, 18501825, 18501901, 18501914, 18503176, 18503321, 18503324, + 18503327, 18503748, 18503861, 18505085, 18505121, 18505795, 18505826, 18505827, 18505942, 18507352, 18507393, 18507395, 18507485, + 18507493, 18513155, 18513195, 18513450, 18513477, 18513488, 18513513, 18513532, 18513740, 18535188, 18535211, 18535223, 18535504, + 18535506, 18535511, 18535523, 18535526, 18535693, 18535863, 18535867, 18535950, 18535960, 18536171, 18536855, 18536862, 18536866, + 18536868, 18536869, 18537563, 18537686, 18537828, 18537830, 18539322, 18539428, 18539449, 18539565, 18539569, 18542957, 18549853, + 18549867, 18614667, 18614674, 18614685, 18614689, 18629129, 18629130, 18629263, 18629369, 18629370, 18629490, 18629492, 18630041, + 18630174, 18630284, 18640752, 18640754, 18640811, 18640900, 18640907, 18640943, 18640945, 18641080, 18641081, 18641157, 18641158, + 18641209, 18641401, 18642300, 18642313, 18642314, 18642405, 18642455, 18642533, 18642534, 18642593, 18642798, 18642799, 18644754, + 18690658, 18690699, 18692929, 18692939, 18698953, 18698954, 18699153, 18699427, 18699430, 18700378, 18700541, 18700543, 18700746, + 18700748, 18700766, 18700833, 18700834, 18700841, 18700842, 18701022, 18701473, 18701507, 18701522, 18701524, 18701573, 18701579, + 18701583, 18701911, 18702014, 18702025, 18702055, 18702094, 18702904, 18703319, 18703328, 18703920, 18704157, 18704427, 18704428, + 18705700, 18706080, 18707114, 18707117, 18707253, 18707486, 18707577, 18707592, 18707596, 18707946, 18707947, 18707956, 18707959, + 18707960, 18708017, 18708020, 18708754, 18708755, 18708938, 18709230, 18709237, 18709605, 18709606, 18709614, 18709621, 18709666, + 18709675, 18709742, 18709754, 18709760, 18709875, 18709881, 18709972, 18709987, 18710107, 18710153, 18710156, 18710159, 18710194, + 18710203, 18710456, 18710530, 18710672, 18722404, 18722407, 18722441, 18722444, 18722474, 18722476, 18722661, 18722684, 18722853, + 18722855, 18722857, 18722860, 18722964, 18722965, 18722991, 18723370, 18723413, 18723704, 18723707, 18723764, 18723766, 18723857, + 18723860, 18723916, 18723941, 18723981, 18735304, 18735677, 18737090, 18737199, 18737256, 18737264, 18737394, 18737400, 18738534, + 18738537, 18738632, 18738633, 18738690, 18738691, 18738755, 18739002, 18739014, 18739017, 18739026, 18739095, 18739204, 18739715, + 18739719, 18739774, 18739780, 18741326, 18741377, 18742319, 18742321, 18742401, 18743044, 18743049, 18743102, 18743109, 18743127, + 18743150, 18743153, 18744034, 18744038, 18744047, 18744053, 18744099, 18744100, 18744161, 18744178, 18744272, 18744440, 18744448, + 18744503, 18744507, 18744957, 18744963, 18745309, 18746182, 18746720, 18746766, 18746769, 18747055, 18747115, 18747509, 18748208, + 18748215, 18748216, 18748616, 18748632, 18748881, 18748930, 18749143, 18749153, 18749347, 18749597, 18749859, 18749862, 18749865, + 18750557, 18750566, 18750749, 18751180, 18751334, 18751358, 18751444, 18751733, 18751772, 18751777, 18751784, 18751800, 18751962, + 18751964, 18751967, 18751970, 18751974, 18751975, 18751977, 18752073, 18752085, 18752241, 18752245, 18752369, 18752782, 18752796, + 18753020, 18753025, 18753230, 18753299, 18753321, 18753444, 18754157, 18754468, 18754629, 18754632, 18755348, 18755580, 18755647, + 18756137, 18756196, 18757143, 18757175, 18757227, 18757294, 18757300, 18757544, 18757547, 18757917, 18757930, 18758219, 18758228, + 18758428, 18783923, 18784255, 18784257, 18784278, 18784506, 18784512, 18785925, 18785928, 18786059, 18787397, 18787805, 18787842, + 18840505, 18840540, 18842111, 18842255, 18842546, 18842613, 18843081, 18843086, 18843202, 18877846, 18877886, 18877938, 18877995, + 18878286, 18878288, 18878602, 18878604, 18878910, 18879022, 18879087, 18879201, 18879299, 18879376, 18879694, 18879819, 18879825, + 18879959, 18879963, 18880086, 18880208, 18880209, 18880253, 18880256, 18880438, 18880477, 18880478, 18880579, 18880588, 18880589, + 18880590, 18880674, 18880675, 18880688, 18880690, 18880698, 18880703, 18880710, 18880723, 18880777, 18880778, 18880818, 18880829, + 18880956, 18880957, 18880961, 18880971, 18881047, 18881049, 18881057, 18881059, 18881244, 18881250, 18881271, 18881309, 18881313, + 18881413, 18881417, 18881470, 18881473, 18881573, 18881588, 18881603, 18881665, 18881667, 18881833, 18881834, 18881875, 18881876, + 18881945, 18881946, 18882110, 18882201, 18882333, 18882334, 18882600, 18882620, 18882747, 18882795, 18882797, 18882825, 18882827, + 18882864, 18882874, 18883468, 18883469, 18883511, 18883515, 18883910, 18884107, 18884303, 18884455, 18884839, 18884840, 18884853, + 18885134, 18885240, 18885713, 18885715, 18885719, 18885720, 18890921, 18890923, 18890924, 18891002, 18891007, 18891013, 18891073, + 18891226, 18891230, 18891902, 18892071, 18916117, 18916500, 18917173, 18917229, 18917481, 18917487, 18917714, 18918454, 18918700, + 18919243, 18919244, 18919304, 18919307, 18919365, 18919372, 18919534, 18919859, 18919932, 18920320, 18934396, 18934399, 18934421, + 18934700, 18935088, 18935417, 18935420, 18935494, 18935501, 18936000, 18936103, 18936391, 18936459, 18936570, 18936578, 18936587, + 18936614, 18936649, 18936673, 18962602, 18962613, 18962625, 18962645, 18962662, 18962676, 18963370, 18963420, 18963833, 18963836, + 18963887, 18963911, 18964240, 18964303, 18964451, 18964454, 18964458, 18964500, 18964761, 18965395, 18965426, 18965875, 18965880, + 18965881, 18965931, 18965958, 18965959, 18965984, 18965985, 18967428, 18967463, 18967632, 18968583, 18968607, 18972151, 18972181, + 18972195, 18972196, 18972221, 18972231, 18972471, 18972549, 18972554, 18972611, 18972613, 18972651, 18972928, 18972929, 18972973, + 18972974, 18972992, 18972993, 18973042, 18973044, 18973048, 18973096, 18973098, 18973116, 18973218, 18973912, 18973952, 18973955, + 18974076, 18974093, 18974104, 18974117, 18974129, 18974206, 18974209, 18974419, 18974465, 18974797, 18974894, 18975162, 18975166, + 18975316, 18975374, 18975576, 18975578, 18976376, 18976386, 18976399, 18976405, 18977338, 18977345, 18977358, 18977728, 18977730, + 18977734, 18977736, 18978127, 18978129, 18978246, 18978494, 18978496, 18978826, 18978859, 18978866, 18978868, 18978873, 18978921, + 18978923, 18978933, 18978935, 18979157, 18979213, 18979247, 18979362, 18979627, 18979629, 18979659, 18979665, 18979666, 18979668, + 18979670, 18979746, 18979760, 18979767, 18979772, 18979782, 18979798, 18979820, 18979833, 18979855, 18979857, 18979955, 18979956, + 18980169, 18980439, 18980547, 18980548, 18980554, 18980591, 18980595, 18980691, 18980698, 18980831, 18980853, 18981626, 18981703, + 18981830, 18981937, 18981943, 18982171, 18982176, 18982186, 18982188, 18982196, 18982429, 18982431, 18982437, 18982740, 18982825, + 18982829, 18982867, 18982883, 18982926, 18983055, 18983244, 18983397, 18983401, 18983612, 18983619, 18983620, 18983932, 18983935, + 18983996, 18984329, 18984386, 18984405, 18984407, 18984413, 18984431, 18984501, 18984511, 18984763, 18984769, 18984913, 18984991, + 18985047, 18985161, 18985246, 18985248, 18985301, 18985304, 18985312, 18985520, 18985521, 18985726, 18985822, 18985850, 18986106, + 18986173, 18986174, 18986252, 18986266, 18986267, 18987017, 18987031, 18987048, 18987053, 18987081, 18987680, 18988159, 18988166, + 18988194, 18988205, 18988573, 18988712, 18988715, 18988857, 18988982, 18988984, 18988985, 18989012, 18989013, 18989018, 18989086, + 18989099, 18989125, 18989132, 18989165, 18989462, 18989464, 18989759, 18989899, 18989954, 18989955, 18990839, 18990846, 18990863, + 18990866, 18991105, 18991433, 18991452, 18991456, 18991462, 18991467, 18991469, 18991662, 18992464, 18992650, 18992774, 18992801, + 18992856, 18992860, 18992906, 18999657, 18999676, 18999686, 18999697, 18999881, 18999886, 19000091, 19000224, 19000241, 19000489, + 19000503, 19001195, 19001201, 19001347, 19001359, 19007968, 19007971, 19008121, 19011401, 19011569, 19011588, 19011656, 19011677, + 19011754, 19011759, 19012403, 19012416, 19012603, 19012613, 19012746, 19012747, 19014099, 19014206, 19020339, 19020428, 19020735, + 19020954, 19020959, 19021745, 19021748, 19021802, 19021803, 19022518, 19022523, 19157469, 19157470, 19157562, 19157597, 19157681, + 19157693, 19157727, 19157735, 19177628, 19177631, 19179127, 19180014, 19180478, 19180496, 19180576, 19180594, 19180601, 19180609, + 19182388, 19182390, 19182566, 19182598, 19183939, 19184062, 19184172, 19184613, 19187655, 19187674, 19187949, 19187959, 19189135, + 19190233, 19190353, 19190502, 19190504, 19190594, 19191003, 19191043, 19191046, 19191091, 19191098, 19191118, 19191122, 19191234, + 19191237, 19191305, 19191307, 19191407, 19191408, 19191453, 19191858, 19192015, 19192485, 19192487, 19192606, 19192607, 19192611, + 19192615, 19192896, 19192903, 19193680, 19193768, 19193789, 19193876, 19193879, 19194492, 19195385, 19200168, 19200172, 19200274, + 19200290, 19200578, 19200583, 19202205, 19202286, 19202388, 19202392, 19202403, 19202424, 19202450, 19202506, 19202509, 19203134, + 19203366, 19203572, 19203746, 19203752, 19204197, 19206989, 19207000, 19207077, 19207171, 19207271, 19207272, 19208337, 19208345, + 19208730, 19212689, 19212690, 19212744, 19212946, 19212947, 19213039, 19213045, 19213048, 19213301, 19213303, 19213574, 19213575, + 19213942, 19214581, 19214583, 19214681, 19214684, 19214905, 19215052, 19215418, 19216089, 19216095, 19218331, 19218601, 19218604, + 19218875, 19219205, 19220095, 19220100, 19221680, 19221683, 19221894, 19222484, 19222586, 19222590, 19224624, 19224626, 19225180, + 19226142, 19226145, 19226595, 19226609, 19226890, 19226896, 19226910, 19226911, 19226927, 19227005, 19227837, 19227907, 19227909, + 19228054, 19228056, 19228106, 19228107, 19228121, 19228123, 19228259, 19228261, 19228302, 19228304, 19229883, 19229890, 19230123, + 19233910, 19234320, 19234345, 19234424, 19234537, 19234956, 19235288, 19235308, 19237190, 19237199, 19237208, 19237233, 19239254, + 19239258, 19239376, 19239377, 19239389, 19239407, 19240001, 19240024, 19240499, 19240901, 19250124, 19250127, 19250230, 19250239, + 19252820, 19252824, 19252856, 19252859, 19253253, 19253258, 19253341, 19253648, 19253658, 19254248, 19254257, 19254261, 19254273, + 19255415, 19255483, 19255486, 19256056, 19256595, 19256596, 19257023, 19257421, 19257656, 19257794, 19257795, 19257825, 19257827, + 19257973, 19258287, 19258305, 19259424, 19259426, 19260016, 19260028, 19260034, 19260047, 19260053, 19260136, 19260185, 19260252, + 19260535, 19260539, 19263045, 19263046, 19263072, 19263297, 19263547, 19264542, 19264897, 19268898, 19268900, 19268986, 19268990, + 19269163, 19269421, 19269423, 19271598, 19271984, 19272062, 19272201, 19272203, 19272401, 19272409, 19272445, 19272449, 19281870, + 19281883, 19282504, 19285192, 19285575, 19285576, 19285624, 19301651, 19301652, 19301719, 19301721, 19302758, 19302769, 19302830, + 19302832, 19302846, 19304733, 19304737, 19304857, 19304863, 19304956, 19304961, 19305572, 19306684, 19306759, 19306763, 19306795, + 19306821, 19306844, 19306849, 19307117, 19307412, 19307778, 19307893, 19308083, 19308148, 19308304, 19314020, 19314021, 19314052, + 19314238, 19314253, 19315712, 19316333, 19317997, 19317999, 19318269, 19318271, 19318527, 19318529, 19318536, 19318578, 19318582, + 19318880, 19318881, 19319054, 19319328, 19319330, 19319376, 19324587, 19324593, 19324769, 19324771, 19324874, 19324883, 19324952, + 19324954, 19325006, 19325007, 19325008, 19325103, 19325184, 19325185, 19325391, 19325392, 19325399, 19325401, 19325570, 19325804, + 19326308, 19326329, 19326348, 19326618, 19326756, 19326757, 19326935, 19326944, 19326947, 19327176, 19327529, 19329583, 19329702, + 19329703, 19329745, 19329746, 19329754, 19329758, 19330909, 19330912, 19331006, 19331009, 19331094, 19331095, 19331200, 19331224, + 19331676, 19331678, 19331729, 19331732, 19332246, 19332827, 19332934, 19332935, 19333061, 19358286, 19358287, 19358310, 19360688, + 19360690, 19360794, 19360932, 19361096, 19362472, 19362473, 19362976, 19362979, 19363289, 19363291, 19363391, 19363719, 19364350, + 19364366, 19364392, 19364402, 19364936, 19364944, 19365015, 19365017, 19365059, 19365710, 19365714, 19365844, 19366349, 19366686, + 19366920, 19366924, 19367057, 19367062, 19367152, 19367158, 19367216, 19367219, 19367501, 19367504, 19368429, 19368434, 19368444, + 19368449, 19368461, 19368484, 19368500, 19368501, 19368676, 19368680, 19368783, 19368797, 19368801, 19368942, 19368948, 19368949, + 19368955, 19368966, 19369066, 19369075, 19369217, 19369229, 19369302, 19369310, 19369314, 19369341, 19369343, 19369598, 19369600, + 19369688, 19369690, 19369879, 19369904, 19369907, 19369914, 19369919, 19369924, 19370031, 19373906, 19373910, 19373914, 19373996, + 19374015, 19374165, 19374181, 19374182, 19374198, 19374266, 19374299, 19374800, 19375006, 19375010, 19375171, 19375174, 19375178, + 19375183, 19375189, 19375203, 19375209, 19375252, 19375259, 19375260, 19375719, 19375788, 19375789, 19376019, 19376020, 19376061, + 19385710, 19385787, 19389326, 19389328, 19389440, 19389442, 19389987, 19390185, 19390188, 19390245, 19390250, 19390286, 19390313, + 19390322, 19390345, 19390352, 19390586, 19390710, 19392042, 19392044, 19410405, 19410437, 19410449, 19410488, 19410489, 19410496, + 19410497, 19410510, 19410916, 19411000, 19411002, 19411204, 19411937, 19411939, 19411997, 19512944, 19513029, 19513189, 19513202, + 19513396, 19513538, 19513695, 19513945, 19513992, 19516059, 19516062, 19516075, 19516084, 19516968, 19517224, 19554953, 19558472, + 19609701, 19609719, 19609892, 19609947, 19610025, 19610494, 19610647, 19610652, 19610959, 19611209, 19611291, 19612269, 19612444, + 19612566, 19612653, 19612655, 19612784, 19612795, 19612890, 19612895, 19613164, 19613285, 19613989, 19614239, 19614595, 19614600, + 19614607, 19615112, 19615114, 19615248, 19726042, 19726057, 19748242, 19748244, 19748269, 19748278, 19748377, 19750672, 19750695, + 19750702, 19750822, 19750833, 19751058, 19751064, 19751102, 19751108, 19751169, 19751172, 19751269, 19751854, 19751865, 19751878, + 19751936, 19752030, 19752349, 19755044, 19755063, 19755440, 19755881, 19756813, 19761538, 19761592, 19761593, 19761680, 19761685, + 19761995, 19762162, 19762167, 19763218, 19763430, 19763945, 19764280, 19764311, 19764333, 19764676, 19764744, 19765216, 19765374, + 19765479, 19767631, 19792072, 19792136, 19792139, 19793277, 19793318, 19793322, 19793528, 19793536, 19796241, 19796405, 19796407, + 19802815, 19802816, 19802881, 19804775, 19805218, 19805360, 19805515, 19807739, 19807796, 19808997, 19809396, 19809725, 19809990, + 19913194, 19913195, 19914726, 19914727, 19914735, 19914741, 19914769, 19914811, 19914876, 19914877, 19916067, 19917537, 19917540, + 19917991, 19918159, 19918171, 19918197, 19918202, 19918295, 19918302, 19918429, 19918432, 19918524, 19918639, 19918716, 19918797, + 19918799, 19918991, 19918992, 19919153, 19919287, 19919383, 19919514, 19919971, 19919995, 19920374, 19920778, 19920779, 19921528, + 19921531, 19921674, 19921675, 19921724, 19923306, 19923308, 19923480, 19923532, 19923534, 19923692, 19923702, 19923790, 19923814, + 19923818, 19923880, 19923884, 19924275, 19924279, 19924358, 19924367, 19924384, 19925554, 19925869, 19926582, 19926586, 19926619, + 19926620, 19926687, 19926859, 19926884, 19926887, 19926891, 19926959, 19927302, 19927422, 19928859, 19929054, 19932992, 19933015, + 19933313, 19933316, 19933328, 19933410, 19933760, 19933818, 19933876, 19934184, 19934490, 19934606, 19934621, 19934741, 19959354, + 19959578, 19960026, 19960122, 19962154, 19962536 +]; +export const PEG_CROSS_BLOCKS_LAST: u32 = 19962536; diff --git a/projects/subgraph-bean/src/BlockHandler.ts b/projects/subgraph-bean/src/BlockHandler.ts index 4a49335d42..349cc1c58a 100644 --- a/projects/subgraph-bean/src/BlockHandler.ts +++ b/projects/subgraph-bean/src/BlockHandler.ts @@ -6,7 +6,7 @@ import { toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals" import { checkBeanCross, checkPoolCross } from "./utils/Cross"; import { loadOrCreatePool, updatePoolPrice, updatePoolValues } from "./utils/Pool"; import { BeanstalkPrice_try_price } from "./utils/price/BeanstalkPrice"; -import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "../cache-builder/results/PegCrossBlocks"; +import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "../cache-builder/results/PegCrossBlocks_eth"; import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; // Processing as each new ethereum block is created diff --git a/projects/subgraph-bean/tests/Cross.test.ts b/projects/subgraph-bean/tests/Cross.test.ts index 21d6c924ef..728a65718a 100644 --- a/projects/subgraph-bean/tests/Cross.test.ts +++ b/projects/subgraph-bean/tests/Cross.test.ts @@ -15,7 +15,7 @@ import { getPreReplantPriceETH, constantProductPrice, uniswapV2Reserves } from " import { mockPoolPriceAndLiquidity, mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves } from "./entity-mocking/MockPool"; import { updatePricesAndCheckCrosses as crv_updatePricesAndCheckCrosses } from "../src/Bean3CRVHandler_V1"; import { setWhitelistedPools } from "./entity-mocking/MockBean"; -import { PEG_CROSS_BLOCKS } from "../cache-builder/results/PegCrossBlocks"; +import { PEG_CROSS_BLOCKS } from "../cache-builder/results/PegCrossBlocks_eth"; import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; const wellCrossId = (n: u32): string => { From 138b266d953e22302ece009505f60456e54c73be Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 4 Sep 2024 23:47:12 -0700 Subject: [PATCH 04/88] bean entity init handler with sample input --- .../subgraph-bean/cache-builder/beanstalk3.js | 6 +++- .../cache-builder/peg-crosses.js | 8 +++-- .../cache-builder/results/BeanInit_arb.ts | 19 ++++++++++++ .../results/PegCrossBlocks_eth.ts | 2 ++ .../src/utils/b3-migration/BeanInit.ts | 31 +++++++++++++++++++ projects/subgraph-bean/tests/Cross.test.ts | 1 - projects/subgraph-bean/tests/DeltaB.test.ts | 4 +-- .../subgraph-bean/tests/Migration.test.ts | 23 ++++++++++++++ 8 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts create mode 100644 projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts create mode 100644 projects/subgraph-bean/tests/Migration.test.ts diff --git a/projects/subgraph-bean/cache-builder/beanstalk3.js b/projects/subgraph-bean/cache-builder/beanstalk3.js index 790a809399..d84b9bdf3b 100644 --- a/projects/subgraph-bean/cache-builder/beanstalk3.js +++ b/projects/subgraph-bean/cache-builder/beanstalk3.js @@ -1 +1,5 @@ -const url = "graph.bean.money/bean"; +const { GraphQLClient, gql } = require("graphql-request"); +const fs = require("fs"); + +const url = "https://graph.bean.money/bean"; +const subgraph = new GraphQLClient(url); diff --git a/projects/subgraph-bean/cache-builder/peg-crosses.js b/projects/subgraph-bean/cache-builder/peg-crosses.js index adc6167215..517a2c6923 100644 --- a/projects/subgraph-bean/cache-builder/peg-crosses.js +++ b/projects/subgraph-bean/cache-builder/peg-crosses.js @@ -1,7 +1,7 @@ const { GraphQLClient, gql } = require("graphql-request"); const fs = require("fs"); -const url = "https://graph.bean.money/bean"; +const url = "https://graph.bean.money/bean_eth"; const subgraph = new GraphQLClient(url); // Gets all unique blocks in which there was either a pool or peg cross. @@ -40,9 +40,11 @@ async function getAllPegCrossBlocks() { allCrossBlocks.sort(); const outFile = `${__dirname}/results/PegCrossBlocks_eth.ts`; - await fs.promises.appendFile( + await fs.promises.writeFile( outFile, - `export const PEG_CROSS_BLOCKS: u32[] = [${allCrossBlocks.join(",")}]; + `/* This is a generated file */ + + export const PEG_CROSS_BLOCKS: u32[] = [${allCrossBlocks.join(",")}]; export const PEG_CROSS_BLOCKS_LAST: u32 = ${allCrossBlocks[allCrossBlocks.length - 1]}; ` ); diff --git a/projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts b/projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts new file mode 100644 index 0000000000..2b7b42cb08 --- /dev/null +++ b/projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts @@ -0,0 +1,19 @@ +/* This is a generated file */ + +import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; + +class BeanInitialValues { + volume: BigInt; + volumeUsd: BigDecimal; + crosses: i32; + lastCross: BigInt; + lastSeason: i32; +} + +export const BEAN_INITIAL_VALUES: BeanInitialValues = { + volume: BigInt.fromU64(1), + volumeUsd: BigDecimal.fromString("1.2"), + crosses: 1, + lastCross: BigInt.fromU64(1), + lastSeason: 3 +}; diff --git a/projects/subgraph-bean/cache-builder/results/PegCrossBlocks_eth.ts b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks_eth.ts index 4a5663d38a..7306c86c11 100644 --- a/projects/subgraph-bean/cache-builder/results/PegCrossBlocks_eth.ts +++ b/projects/subgraph-bean/cache-builder/results/PegCrossBlocks_eth.ts @@ -1,3 +1,5 @@ +/* This is a generated file */ + export const PEG_CROSS_BLOCKS: u32[] = [ 12974091, 12975421, 12978538, 12978615, 12978680, 12978911, 12979148, 12979149, 12979167, 12979171, 12979228, 12979230, 12979607, 12983847, 12983871, 12983895, 12983897, 12983926, 12984038, 12984104, 12984170, 12984257, 12984310, 12984929, 12986590, 12986603, diff --git a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts new file mode 100644 index 0000000000..e27e9961d8 --- /dev/null +++ b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts @@ -0,0 +1,31 @@ +import { ethereum } from "@graphprotocol/graph-ts"; +import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../Bean"; +import { BEAN_ERC20 } from "../../../../subgraph-core/utils/Constants"; +import { BEAN_INITIAL_VALUES } from "../../../cache-builder/results/BeanInit_arb"; + +export function handleInitBeanEntity(block: ethereum.Block): void { + // TODO: how to determine correct token address? this is wrong + const token = BEAN_ERC20.toHexString(); + const bean = loadBean(token); + + bean.volume = BEAN_INITIAL_VALUES.volume; + bean.volumeUSD = BEAN_INITIAL_VALUES.volumeUsd; + bean.crosses = BEAN_INITIAL_VALUES.crosses; + bean.lastCross = BEAN_INITIAL_VALUES.lastCross; + bean.lastSeason = BEAN_INITIAL_VALUES.lastSeason; + bean.save(); + // No need to initialize supply/price etc as those will be initialized when liquidity is added. + + // Direct assignment for snapshots is preferable as to avoid large deltas + const beanHourly = loadOrCreateBeanHourlySnapshot(token, block.timestamp, bean.lastSeason); + beanHourly.volume = bean.volume; + beanHourly.volumeUSD = bean.volumeUSD; + beanHourly.crosses = bean.crosses; + beanHourly.save(); + + const beanDaily = loadOrCreateBeanDailySnapshot(token, block.timestamp); + beanDaily.volume = bean.volume; + beanDaily.volumeUSD = bean.volumeUSD; + beanDaily.crosses = bean.crosses; + beanDaily.save(); +} diff --git a/projects/subgraph-bean/tests/Cross.test.ts b/projects/subgraph-bean/tests/Cross.test.ts index 728a65718a..7581367550 100644 --- a/projects/subgraph-bean/tests/Cross.test.ts +++ b/projects/subgraph-bean/tests/Cross.test.ts @@ -50,7 +50,6 @@ describe("Peg Crosses", () => { }); afterEach(() => { - log.debug("clearing the store", []); clearStore(); }); diff --git a/projects/subgraph-bean/tests/DeltaB.test.ts b/projects/subgraph-bean/tests/DeltaB.test.ts index 8bc11a3266..8f4be327ab 100644 --- a/projects/subgraph-bean/tests/DeltaB.test.ts +++ b/projects/subgraph-bean/tests/DeltaB.test.ts @@ -13,8 +13,7 @@ import { mock_virtual_price } from "./event-mocking/Curve"; import { loadOrCreatePool } from "../src/utils/Pool"; import { loadBean } from "../src/utils/Bean"; import { getD, getY, priceFromY } from "../src/utils/price/CurvePrice"; -import { Bytes_bigEndian } from "../../subgraph-core/utils/Bytes"; -import { ABDK_toUInt, pow2toX } from "../../subgraph-core/utils/ABDKMathQuad"; +import { pow2toX } from "../../subgraph-core/utils/ABDKMathQuad"; const timestamp1 = BigInt.fromU32(1712793374); const hour1 = hourFromTimestamp(timestamp1).toString(); @@ -30,7 +29,6 @@ describe("DeltaB", () => { }); afterEach(() => { - // log.debug("clearing the store", []); clearStore(); }); diff --git a/projects/subgraph-bean/tests/Migration.test.ts b/projects/subgraph-bean/tests/Migration.test.ts new file mode 100644 index 0000000000..5841543d30 --- /dev/null +++ b/projects/subgraph-bean/tests/Migration.test.ts @@ -0,0 +1,23 @@ +import { clearStore, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; +import { handleInitBeanEntity } from "../src/utils/b3-migration/BeanInit"; +import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; +import { BEAN_ERC20 } from "../../subgraph-core/utils/Constants"; +import { BEAN_INITIAL_VALUES } from "../cache-builder/results/BeanInit_arb"; + +describe("Beanstalk 3 Migration", () => { + afterEach(() => { + clearStore(); + }); + + test("Bean entity initialization", () => { + handleInitBeanEntity(mockBlock()); + assert.fieldEquals("Bean", BEAN_ERC20.toHexString(), "volume", BEAN_INITIAL_VALUES.volume.toString()); + assert.fieldEquals("Bean", BEAN_ERC20.toHexString(), "crosses", BEAN_INITIAL_VALUES.crosses.toString()); + assert.fieldEquals( + "BeanHourlySnapshot", + BEAN_ERC20.toHexString() + "-" + BEAN_INITIAL_VALUES.lastSeason.toString(), + "crosses", + BEAN_INITIAL_VALUES.crosses.toString() + ); + }); +}); From 5bcfb35437f48c5cd90075371afbe54ba18e6931 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:16:30 -0700 Subject: [PATCH 05/88] bean subgraph l2 generator script --- .../subgraph-bean/cache-builder/beanstalk3.js | 42 +++++- .../cache-builder/results/BeanInit_arb.ts | 10 +- yarn.lock | 129 +----------------- 3 files changed, 48 insertions(+), 133 deletions(-) diff --git a/projects/subgraph-bean/cache-builder/beanstalk3.js b/projects/subgraph-bean/cache-builder/beanstalk3.js index d84b9bdf3b..ba795f4b7e 100644 --- a/projects/subgraph-bean/cache-builder/beanstalk3.js +++ b/projects/subgraph-bean/cache-builder/beanstalk3.js @@ -1,5 +1,45 @@ const { GraphQLClient, gql } = require("graphql-request"); const fs = require("fs"); -const url = "https://graph.bean.money/bean"; +const url = "https://graph.bean.money/bean_eth"; const subgraph = new GraphQLClient(url); + +(async () => { + const l1Values = await subgraph.request(gql` + { + bean(id: "0xbea0000029ad1c77d3d5d23ba2d8893db9d1efab") { + volume + volumeUSD + crosses + lastCross + lastSeason + } + } + `); + + const outFile = `${__dirname}/results/BeanInit_arb.ts`; + await fs.promises.writeFile( + outFile, + `/* This is a generated file */ + + import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; + + class BeanInitialValues { + volume: BigInt; + volumeUsd: BigDecimal; + crosses: i32; + lastCross: BigInt; + lastSeason: i32; + } + + export const BEAN_INITIAL_VALUES: BeanInitialValues = { + volume: BigInt.fromString('${l1Values.bean.volume}'), + volumeUsd: BigDecimal.fromString('${l1Values.bean.volumeUSD}'), + crosses: ${l1Values.bean.crosses}, + lastCross: BigInt.fromString('${l1Values.bean.lastCross}'), + lastSeason: ${l1Values.bean.lastSeason} + }; + ` + ); + console.log(`Wrote beanstalk 3 initial values to ${outFile}`); +})(); diff --git a/projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts b/projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts index 2b7b42cb08..0ebae741fe 100644 --- a/projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts +++ b/projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts @@ -11,9 +11,9 @@ class BeanInitialValues { } export const BEAN_INITIAL_VALUES: BeanInitialValues = { - volume: BigInt.fromU64(1), - volumeUsd: BigDecimal.fromString("1.2"), - crosses: 1, - lastCross: BigInt.fromU64(1), - lastSeason: 3 + volume: BigInt.fromString("71805665964835"), + volumeUsd: BigDecimal.fromString("82309886.099993589468"), + crosses: 5675, + lastCross: BigInt.fromString("1716828947"), + lastSeason: 24344 }; diff --git a/yarn.lock b/yarn.lock index 5b9b9ee343..1655f32269 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8205,34 +8205,6 @@ __metadata: languageName: node linkType: hard -"@molt/command@npm:^0.9.0": - version: 0.9.0 - resolution: "@molt/command@npm:0.9.0" - dependencies: - "@molt/types": "npm:0.2.0" - alge: "npm:0.8.1" - chalk: "npm:^5.3.0" - lodash.camelcase: "npm:^4.3.0" - lodash.snakecase: "npm:^4.1.1" - readline-sync: "npm:^1.4.10" - string-length: "npm:^6.0.0" - strip-ansi: "npm:^7.1.0" - ts-toolbelt: "npm:^9.6.0" - type-fest: "npm:^4.3.1" - zod: "npm:^3.22.2" - checksum: 10/e6ec7c6c2c6a64a1b28e09074196e5aa891bdcbff4129e54c59b902e1b6f4151033fd92c8535666be32267163d04ce3ce454ca0df0a4d5669a8506817131984e - languageName: node - linkType: hard - -"@molt/types@npm:0.2.0": - version: 0.2.0 - resolution: "@molt/types@npm:0.2.0" - dependencies: - ts-toolbelt: "npm:^9.6.0" - checksum: 10/0c7eab1dda0d689fda7025b4e4b37ffc290a7e2f7bfb0463a8bffc5834c30af66ab92d63bc2f71dc515cdd0121fc3587596690353a7e1c40d530395135540063 - languageName: node - linkType: hard - "@motionone/animation@npm:^10.12.0": version: 10.17.0 resolution: "@motionone/animation@npm:10.17.0" @@ -17517,18 +17489,6 @@ __metadata: languageName: node linkType: hard -"alge@npm:0.8.1": - version: 0.8.1 - resolution: "alge@npm:0.8.1" - dependencies: - lodash.ismatch: "npm:^4.4.0" - remeda: "npm:^1.0.0" - ts-toolbelt: "npm:^9.6.0" - zod: "npm:^3.17.3" - checksum: 10/11483523289bc7750b6462698a2b61c816bf3c7eada2ade206bc02b964679b6bf4b298cc561ae267f382573668b68ff311a0aec60c5ae011aecde491932240e8 - languageName: node - linkType: hard - "all-node-versions@npm:^11.3.0": version: 11.3.0 resolution: "all-node-versions@npm:11.3.0" @@ -20146,7 +20106,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:5.3.0, chalk@npm:^5.3.0": +"chalk@npm:5.3.0": version: 5.3.0 resolution: "chalk@npm:5.3.0" checksum: 10/6373caaab21bd64c405bfc4bd9672b145647fc9482657b5ea1d549b3b2765054e9d3d928870cdf764fb4aad67555f5061538ff247b8310f110c5c888d92397ea @@ -27619,31 +27579,6 @@ __metadata: languageName: node linkType: hard -"graphql-request@npm:7.1.0": - version: 7.1.0 - resolution: "graphql-request@npm:7.1.0" - dependencies: - "@graphql-typed-document-node/core": "npm:^3.2.0" - "@molt/command": "npm:^0.9.0" - zod: "npm:^3.23.8" - peerDependencies: - "@dprint/formatter": ^0.3.0 - "@dprint/typescript": ^0.91.1 - dprint: ^0.46.2 - graphql: 14 - 16 - peerDependenciesMeta: - "@dprint/formatter": - optional: true - "@dprint/typescript": - optional: true - dprint: - optional: true - bin: - graffle: build/cli/generate.js - checksum: 10/6e61cd8200f9842569a657b0fdc0cb45a8433d8afa730ace911fa9a09318fb3cae3ccd9396a9ab2e1795bf9ccbce976fc90fb0bfac9dfe2fc821e74845be57d9 - languageName: node - linkType: hard - "graphql-request@npm:^4": version: 4.3.0 resolution: "graphql-request@npm:4.3.0" @@ -33058,13 +32993,6 @@ __metadata: languageName: node linkType: hard -"lodash.ismatch@npm:^4.4.0": - version: 4.4.0 - resolution: "lodash.ismatch@npm:4.4.0" - checksum: 10/946a7176cdf4048f7b624378defda00dc0d01a2dad9933c54dad11fbecc253716df4210fbbfcd7d042e6fdb7603463cfe48e0ef576e20bf60d43f7deb1a2fe04 - languageName: node - linkType: hard - "lodash.isnumber@npm:^3.0.3": version: 3.0.3 resolution: "lodash.isnumber@npm:3.0.3" @@ -38706,13 +38634,6 @@ __metadata: languageName: node linkType: hard -"readline-sync@npm:^1.4.10": - version: 1.4.10 - resolution: "readline-sync@npm:1.4.10" - checksum: 10/5eb6465f5c5391e32cb525022a307a910a565828cd53da87ac05fca291607df54099dd65bc9c7a513ac53a5eb4e11454d48f0dcf4ad54126d36dec5fcec4a8f0 - languageName: node - linkType: hard - "real-require@npm:^0.1.0": version: 0.1.0 resolution: "real-require@npm:0.1.0" @@ -39133,13 +39054,6 @@ __metadata: languageName: node linkType: hard -"remeda@npm:^1.0.0": - version: 1.61.0 - resolution: "remeda@npm:1.61.0" - checksum: 10/0b0ec8688e340c7525a8788e99701b174ddca2eaf230d47f9e087d9aaccd54c7181a1f58bf4f95cb9c12bc1d26f03b17e3d3d9046a59225074a7ac3fa1356da3 - languageName: node - linkType: hard - "remedial@npm:^1.0.7": version: 1.0.8 resolution: "remedial@npm:1.0.8" @@ -41407,15 +41321,6 @@ __metadata: languageName: node linkType: hard -"string-length@npm:^6.0.0": - version: 6.0.0 - resolution: "string-length@npm:6.0.0" - dependencies: - strip-ansi: "npm:^7.1.0" - checksum: 10/b171e9e193ec292ad71f8b2a36e20478bf1bac8cd5beec062fb126942d627dfd9311959e271e9ab7b0a383d16b85b9e25a183d15786e30f22104d152e7627f99 - languageName: node - linkType: hard - "string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.0.0, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.2, string-width@npm:^4.2.3": version: 4.2.3 resolution: "string-width@npm:4.2.3" @@ -41666,15 +41571,6 @@ __metadata: languageName: node linkType: hard -"strip-ansi@npm:^7.1.0": - version: 7.1.0 - resolution: "strip-ansi@npm:7.1.0" - dependencies: - ansi-regex: "npm:^6.0.1" - checksum: 10/475f53e9c44375d6e72807284024ac5d668ee1d06010740dec0b9744f2ddf47de8d7151f80e5f6190fc8f384e802fdf9504b76a7e9020c9faee7103623338be2 - languageName: node - linkType: hard - "strip-bom@npm:^2.0.0": version: 2.0.0 resolution: "strip-bom@npm:2.0.0" @@ -41883,7 +41779,7 @@ __metadata: dependencies: "@graphprotocol/graph-cli": "npm:0.79.2" "@graphprotocol/graph-ts": "npm:0.34.0" - graphql-request: "npm:7.1.0" + graphql-request: "npm:^6.1.0" matchstick-as: "npm:^0.6.0" languageName: unknown linkType: soft @@ -42929,13 +42825,6 @@ __metadata: languageName: node linkType: hard -"ts-toolbelt@npm:^9.6.0": - version: 9.6.0 - resolution: "ts-toolbelt@npm:9.6.0" - checksum: 10/2c2dea2631dbd7372a79cccc6d09a377a6ca2f319f767fd239d2e312cd1d9165a90f8c1777a047227bfdcda6aeba3addbadce88fdfc7f43caf4534d385a43c82 - languageName: node - linkType: hard - "tsc-alias@npm:1.8.8": version: 1.8.8 resolution: "tsc-alias@npm:1.8.8" @@ -43142,13 +43031,6 @@ __metadata: languageName: node linkType: hard -"type-fest@npm:^4.3.1": - version: 4.26.0 - resolution: "type-fest@npm:4.26.0" - checksum: 10/f5fe86d2c3db693f7154c8ab0d228a89394e4c446f2ed30ea3b61afaea9757c87c4e79475ef8d6f5fafbd7a4efd302e3b0237d9657dd425228f20a27feee3aef - languageName: node - linkType: hard - "type-is@npm:~1.6.18": version: 1.6.18 resolution: "type-is@npm:1.6.18" @@ -45949,13 +45831,6 @@ __metadata: languageName: node linkType: hard -"zod@npm:^3.17.3, zod@npm:^3.22.2, zod@npm:^3.23.8": - version: 3.23.8 - resolution: "zod@npm:3.23.8" - checksum: 10/846fd73e1af0def79c19d510ea9e4a795544a67d5b34b7e1c4d0425bf6bfd1c719446d94cdfa1721c1987d891321d61f779e8236fde517dc0e524aa851a6eff1 - languageName: node - linkType: hard - "zustand@npm:4.4.1": version: 4.4.1 resolution: "zustand@npm:4.4.1" From 8bb7f020c53945dbd92585613b374454aaa4835b Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:52:18 -0700 Subject: [PATCH 06/88] major refactor and file restructure --- projects/subgraph-bean/src/Bean3CRVHandler.ts | 147 ------------ .../subgraph-bean/src/Bean3CRVHandler_V1.ts | 218 ------------------ .../subgraph-bean/src/UniswapV2Handler.ts | 146 ------------ projects/subgraph-bean/src/entities/Bean.ts | 92 ++++++++ projects/subgraph-bean/src/entities/Cross.ts | 43 ++++ projects/subgraph-bean/src/entities/Pool.ts | 103 +++++++++ projects/subgraph-bean/src/entities/Token.ts | 16 ++ .../subgraph-bean/src/entities/TwaOracle.ts | 24 ++ .../src/handlers/Bean3CRVHandler.ts | 197 ++++++++++++++++ .../src/{ => handlers}/BeanHandler.ts | 7 +- .../src/{ => handlers}/BeanWellHandler.ts | 112 +++------ .../src/{ => handlers}/BeanstalkHandler.ts | 86 +++---- .../src/{ => handlers}/BlockHandler.ts | 47 ++-- .../handlers/legacy/LegacyUniswapV2Handler.ts | 120 ++++++++++ projects/subgraph-bean/src/utils/Bean.ts | 152 +++--------- projects/subgraph-bean/src/utils/Cross.ts | 96 +++----- .../subgraph-bean/src/utils/LockedBeans.ts | 6 +- projects/subgraph-bean/src/utils/Pool.ts | 173 +++----------- projects/subgraph-bean/src/utils/Token.ts | 17 +- .../src/utils/b3-migration/BeanInit.ts | 2 +- .../src/utils/{ => constants}/BeanWells.ts | 2 +- .../src/{ => utils}/constants/PooledTokens.ts | 2 +- .../src/utils/price/BeanstalkPrice.ts | 4 +- .../src/utils/price/CurvePrice.ts | 13 +- .../src/utils/price/TwaOracle.ts | 27 +-- .../src/utils/price/UniswapPrice.ts | 14 +- .../src/utils/price/WellPrice.ts | 13 +- .../tests/BeanstalkPrice.test.ts | 4 +- projects/subgraph-bean/tests/Cross.test.ts | 145 +----------- projects/subgraph-bean/tests/DeltaB.test.ts | 6 +- projects/subgraph-bean/tests/Pool.test.ts | 3 +- .../subgraph-bean/tests/Whitelist.test.ts | 34 +-- .../tests/entity-mocking/MockBean.ts | 3 +- .../tests/entity-mocking/MockPool.ts | 2 +- projects/subgraph-bean/tests/l2sr.test.ts | 8 +- 35 files changed, 834 insertions(+), 1250 deletions(-) delete mode 100644 projects/subgraph-bean/src/Bean3CRVHandler.ts delete mode 100644 projects/subgraph-bean/src/Bean3CRVHandler_V1.ts delete mode 100644 projects/subgraph-bean/src/UniswapV2Handler.ts create mode 100644 projects/subgraph-bean/src/entities/Bean.ts create mode 100644 projects/subgraph-bean/src/entities/Cross.ts create mode 100644 projects/subgraph-bean/src/entities/Pool.ts create mode 100644 projects/subgraph-bean/src/entities/Token.ts create mode 100644 projects/subgraph-bean/src/entities/TwaOracle.ts create mode 100644 projects/subgraph-bean/src/handlers/Bean3CRVHandler.ts rename projects/subgraph-bean/src/{ => handlers}/BeanHandler.ts (67%) rename projects/subgraph-bean/src/{ => handlers}/BeanWellHandler.ts (52%) rename projects/subgraph-bean/src/{ => handlers}/BeanstalkHandler.ts (54%) rename projects/subgraph-bean/src/{ => handlers}/BlockHandler.ts (62%) create mode 100644 projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts rename projects/subgraph-bean/src/utils/{ => constants}/BeanWells.ts (92%) rename projects/subgraph-bean/src/{ => utils}/constants/PooledTokens.ts (98%) diff --git a/projects/subgraph-bean/src/Bean3CRVHandler.ts b/projects/subgraph-bean/src/Bean3CRVHandler.ts deleted file mode 100644 index b5e9418750..0000000000 --- a/projects/subgraph-bean/src/Bean3CRVHandler.ts +++ /dev/null @@ -1,147 +0,0 @@ -import { BigInt, BigDecimal, Address } from "@graphprotocol/graph-ts"; -import { - AddLiquidity, - RemoveLiquidity, - RemoveLiquidityImbalance, - RemoveLiquidityOne, - TokenExchange, - TokenExchangeUnderlying -} from "../generated/Bean-ABIs/Bean3CRV"; -import { CurvePrice } from "../generated/Bean-ABIs/CurvePrice"; -import { updateBeanAfterPoolSwap } from "./utils/Bean"; -import { CURVE_PRICE } from "../../subgraph-core/utils/Constants"; -import { toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues } from "./utils/Pool"; - -export function handleTokenExchange(event: TokenExchange): void { - handleSwap( - event.address.toHexString(), - event.params.sold_id, - event.params.tokens_sold, - event.params.bought_id, - event.params.tokens_bought, - event.block.timestamp, - event.block.number - ); -} - -export function handleTokenExchangeUnderlying(event: TokenExchangeUnderlying): void { - handleSwap( - event.address.toHexString(), - event.params.sold_id, - event.params.tokens_sold, - event.params.bought_id, - event.params.tokens_bought, - event.block.timestamp, - event.block.number - ); -} - -export function handleAddLiquidity(event: AddLiquidity): void { - handleLiquidityChange( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - event.params.token_amounts[0], - event.params.token_amounts[1] - ); -} - -export function handleRemoveLiquidity(event: RemoveLiquidity): void { - handleLiquidityChange( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - event.params.token_amounts[0], - event.params.token_amounts[1] - ); -} - -export function handleRemoveLiquidityImbalance(event: RemoveLiquidityImbalance): void { - handleLiquidityChange( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - event.params.token_amounts[0], - event.params.token_amounts[1] - ); -} - -export function handleRemoveLiquidityOne(event: RemoveLiquidityOne): void { - handleLiquidityChange(event.address.toHexString(), event.block.timestamp, event.block.number, event.params.coin_amount, ZERO_BI); -} - -function handleLiquidityChange( - poolAddress: string, - timestamp: BigInt, - blockNumber: BigInt, - token0Amount: BigInt, - token1Amount: BigInt -): void { - // Get Curve Price Details - let curvePrice = CurvePrice.bind(CURVE_PRICE); - let curve = curvePrice.try_getCurve(); - - if (curve.reverted) { - return; - } - - let startingLiquidity = getPoolLiquidityUSD(poolAddress, blockNumber); - - let newPrice = toDecimal(curve.value.price); - let deltaLiquidityUSD = toDecimal(curve.value.liquidity).minus(startingLiquidity); - - let volumeUSD = - deltaLiquidityUSD < ZERO_BD - ? deltaLiquidityUSD.div(BigDecimal.fromString("2")).times(BigDecimal.fromString("-1")) - : deltaLiquidityUSD.div(BigDecimal.fromString("2")); - let volumeBean = BigInt.fromString(volumeUSD.div(newPrice).times(BigDecimal.fromString("1000000")).truncate(0).toString()); - - if (token0Amount !== ZERO_BI && token1Amount !== ZERO_BI) { - volumeUSD = ZERO_BD; - volumeBean = ZERO_BI; - } - - setPoolReserves(poolAddress, curve.value.balances, timestamp, blockNumber); - updatePoolValues(poolAddress, timestamp, blockNumber, volumeBean, volumeUSD, deltaLiquidityUSD, curve.value.deltaB); - updatePoolPrice(poolAddress, timestamp, blockNumber, newPrice); - - updateBeanAfterPoolSwap(poolAddress, toDecimal(curve.value.price), volumeBean, volumeUSD, deltaLiquidityUSD, timestamp, blockNumber); -} - -function handleSwap( - poolAddress: string, - sold_id: BigInt, - tokens_sold: BigInt, - bought_id: BigInt, - tokens_bought: BigInt, - timestamp: BigInt, - blockNumber: BigInt -): void { - // Get Curve Price Details - let curvePrice = CurvePrice.bind(CURVE_PRICE); - let curve = curvePrice.try_getCurve(); - - if (curve.reverted) { - return; - } - - let startingLiquidity = getPoolLiquidityUSD(poolAddress, blockNumber); - - let newPrice = toDecimal(curve.value.price); - let volumeBean = ZERO_BI; - - if (sold_id == ZERO_BI) { - volumeBean = tokens_sold; - } else if (bought_id == ZERO_BI) { - volumeBean = tokens_bought; - } - let volumeUSD = toDecimal(volumeBean).times(newPrice); - let deltaLiquidityUSD = toDecimal(curve.value.liquidity).minus(startingLiquidity); - - setPoolReserves(poolAddress, curve.value.balances, timestamp, blockNumber); - updatePoolValues(poolAddress, timestamp, blockNumber, volumeBean, volumeUSD, deltaLiquidityUSD, curve.value.deltaB); - updatePoolPrice(poolAddress, timestamp, blockNumber, newPrice); - - updateBeanAfterPoolSwap(poolAddress, toDecimal(curve.value.price), volumeBean, volumeUSD, deltaLiquidityUSD, timestamp, blockNumber); -} diff --git a/projects/subgraph-bean/src/Bean3CRVHandler_V1.ts b/projects/subgraph-bean/src/Bean3CRVHandler_V1.ts deleted file mode 100644 index d13fe81df0..0000000000 --- a/projects/subgraph-bean/src/Bean3CRVHandler_V1.ts +++ /dev/null @@ -1,218 +0,0 @@ -import { BigInt, BigDecimal, Address } from "@graphprotocol/graph-ts"; -import { - AddLiquidity, - RemoveLiquidity, - RemoveLiquidityImbalance, - RemoveLiquidityOne, - TokenExchange, - TokenExchangeUnderlying -} from "../generated/Bean-ABIs/Bean3CRV"; -import { calcLiquidityWeightedBeanPrice, getLastBeanPrice, loadBean, updateBeanSupplyPegPercent, updateBeanValues } from "./utils/Bean"; -import { BEAN_ERC20_V1, BEAN_LUSD_V1, BEAN_WETH_V1 } from "../../subgraph-core/utils/Constants"; -import { toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { loadOrCreatePool, setPoolReserves, updatePoolPrice, updatePoolValues } from "./utils/Pool"; -import { Bean3CRV } from "../generated/Bean-ABIs/Bean3CRV"; -import { ERC20 } from "../generated/Bean-ABIs/ERC20"; -import { checkBeanCross } from "./utils/Cross"; -import { curveDeltaBUsingVPrice, curvePriceAndLp } from "./utils/price/CurvePrice"; -import { manualTwa } from "./utils/price/TwaOracle"; -import { externalUpdatePoolPrice as univ2_externalUpdatePoolPrice } from "./UniswapV2Handler"; - -export function handleTokenExchange(event: TokenExchange): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - handleSwap( - event.address.toHexString(), - event.params.sold_id, - event.params.tokens_sold, - event.params.bought_id, - event.params.tokens_bought, - event.block.timestamp, - event.block.number - ); -} - -export function handleTokenExchangeUnderlying(event: TokenExchangeUnderlying): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - handleSwap( - event.address.toHexString(), - event.params.sold_id, - event.params.tokens_sold, - event.params.bought_id, - event.params.tokens_bought, - event.block.timestamp, - event.block.number - ); -} - -export function handleAddLiquidity(event: AddLiquidity): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - handleLiquidityChange( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - event.params.token_amounts[0], - event.params.token_amounts[1] - ); -} - -export function handleRemoveLiquidity(event: RemoveLiquidity): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - handleLiquidityChange( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - ZERO_BI.minus(event.params.token_amounts[0]), - ZERO_BI.minus(event.params.token_amounts[1]) - ); -} - -export function handleRemoveLiquidityImbalance(event: RemoveLiquidityImbalance): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - handleLiquidityChange( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - ZERO_BI.minus(event.params.token_amounts[0]), - ZERO_BI.minus(event.params.token_amounts[1]) - ); -} - -export function handleRemoveLiquidityOne(event: RemoveLiquidityOne): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - if (event.params.provider == BEAN_ERC20_V1) { - handleLiquidityChange(event.address.toHexString(), event.block.timestamp, event.block.number, event.params.token_amount, ZERO_BI); - } else { - handleLiquidityChange(event.address.toHexString(), event.block.timestamp, event.block.number, ZERO_BI, event.params.token_amount); - } -} - -function handleLiquidityChange( - poolAddress: string, - timestamp: BigInt, - blockNumber: BigInt, - token0Amount: BigInt, - token1Amount: BigInt -): void { - let pool = loadOrCreatePool(poolAddress, blockNumber); - - let lpContract = Bean3CRV.bind(Address.fromString(poolAddress)); - - let priceAndLp = curvePriceAndLp(Address.fromString(poolAddress)); - let newPoolPrice = priceAndLp[0]; - let lpValue = priceAndLp[1]; - - let beanContract = ERC20.bind(BEAN_ERC20_V1); - let beanHolding = toDecimal(beanContract.balanceOf(Address.fromString(poolAddress))); - let beanValue = beanHolding.times(newPoolPrice); - - let liquidityUSD = beanValue.plus(lpValue); - let deltaLiquidityUSD = liquidityUSD.minus(pool.liquidityUSD); - - let volumeUSD = - deltaLiquidityUSD < ZERO_BD - ? deltaLiquidityUSD.div(BigDecimal.fromString("2")).times(BigDecimal.fromString("-1")) - : deltaLiquidityUSD.div(BigDecimal.fromString("2")); - let volumeBean = BigInt.fromString(volumeUSD.div(newPoolPrice).times(BigDecimal.fromString("1000000")).truncate(0).toString()); - - if (token0Amount !== ZERO_BI && token1Amount !== ZERO_BI) { - volumeUSD = ZERO_BD; - volumeBean = ZERO_BI; - } - - let reserveBalances = lpContract.try_get_balances(); - if (!reserveBalances.reverted) { - setPoolReserves(poolAddress, reserveBalances.value, timestamp, blockNumber); - if (poolAddress == BEAN_LUSD_V1.toHexString()) { - manualTwa(poolAddress, reserveBalances.value, timestamp); - } - } - - updateBeanSupplyPegPercent(blockNumber); - - let deltaB = curveDeltaBUsingVPrice(Address.fromString(poolAddress), reserveBalances.value[0]); - - updatePricesAndCheckCrosses(poolAddress, newPoolPrice, volumeBean, volumeUSD, deltaLiquidityUSD, deltaB, timestamp, blockNumber); -} - -function handleSwap( - poolAddress: string, - sold_id: BigInt, - tokens_sold: BigInt, - bought_id: BigInt, - tokens_bought: BigInt, - timestamp: BigInt, - blockNumber: BigInt -): void { - let pool = loadOrCreatePool(poolAddress, blockNumber); - - let lpContract = Bean3CRV.bind(Address.fromString(poolAddress)); - - let priceAndLp = curvePriceAndLp(Address.fromString(poolAddress)); - let newPoolPrice = priceAndLp[0]; - let lpValue = priceAndLp[1]; - - let beanContract = ERC20.bind(BEAN_ERC20_V1); - let beanHolding = toDecimal(beanContract.balanceOf(Address.fromString(poolAddress))); - let beanValue = beanHolding.times(newPoolPrice); - - let liquidityUSD = beanValue.plus(lpValue); - let deltaLiquidityUSD = liquidityUSD.minus(pool.liquidityUSD); - - let volumeBean = ZERO_BI; - if (sold_id == ZERO_BI) { - volumeBean = tokens_sold; - } else if (bought_id == ZERO_BI) { - volumeBean = tokens_bought; - } - - let reserveBalances = lpContract.try_get_balances(); - if (!reserveBalances.reverted) { - setPoolReserves(poolAddress, reserveBalances.value, timestamp, blockNumber); - if (poolAddress == BEAN_LUSD_V1.toHexString()) { - manualTwa(poolAddress, reserveBalances.value, timestamp); - } - } - - let deltaB = curveDeltaBUsingVPrice(Address.fromString(poolAddress), reserveBalances.value[0]); - - updateBeanSupplyPegPercent(blockNumber); - - let volumeUSD = toDecimal(volumeBean).times(newPoolPrice); - - updatePricesAndCheckCrosses(poolAddress, newPoolPrice, volumeBean, volumeUSD, deltaLiquidityUSD, deltaB, timestamp, blockNumber); -} - -export function updatePricesAndCheckCrosses( - poolAddress: string, - newPoolPrice: BigDecimal, - volumeBean: BigInt, - volumeUSD: BigDecimal, - deltaLiquidityUSD: BigDecimal, - deltaB: BigInt, - timestamp: BigInt, - blockNumber: BigInt -): void { - updatePoolValues(poolAddress, timestamp, blockNumber, volumeBean, volumeUSD, deltaLiquidityUSD, deltaB); - updatePoolPrice(poolAddress, timestamp, blockNumber, newPoolPrice); - - // Update volatile pools (in practice, for pre-replant its beaneth only) - univ2_externalUpdatePoolPrice(BEAN_WETH_V1, timestamp, blockNumber); - - // Check for bean peg cross - let oldBeanPrice = getLastBeanPrice(BEAN_ERC20_V1.toHexString()); - const newBeanPrice = calcLiquidityWeightedBeanPrice(BEAN_ERC20_V1.toHexString()); - updateBeanValues(BEAN_ERC20_V1.toHexString(), timestamp, newBeanPrice, ZERO_BI, volumeBean, volumeUSD, deltaLiquidityUSD); - checkBeanCross(BEAN_ERC20_V1.toHexString(), timestamp, blockNumber, oldBeanPrice, newBeanPrice); -} diff --git a/projects/subgraph-bean/src/UniswapV2Handler.ts b/projects/subgraph-bean/src/UniswapV2Handler.ts deleted file mode 100644 index 272895ec6f..0000000000 --- a/projects/subgraph-bean/src/UniswapV2Handler.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { BigDecimal, BigInt, ethereum, Address, log } from "@graphprotocol/graph-ts"; -import { Swap, Sync } from "../generated/Bean-ABIs/UniswapV2Pair"; -import { getLastBeanPrice, calcLiquidityWeightedBeanPrice, loadBean, updateBeanSupplyPegPercent, updateBeanValues } from "./utils/Bean"; -import { BEAN_ERC20_V1, BEAN_WETH_V1, WETH } from "../../subgraph-core/utils/Constants"; -import { toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { loadOrCreatePool, setPoolReserves, updatePoolPrice, updatePoolValues } from "./utils/Pool"; -import { loadOrCreateToken, updateTokenPrice } from "./utils/Token"; -import { checkBeanCross, checkPoolCross } from "./utils/Cross"; -import { getPreReplantPriceETH, updatePreReplantPriceETH, calcUniswapV2Inst_2 } from "./utils/price/UniswapPrice"; - -// export function handleMint(event: Mint): void { -// updatePoolReserves(event.address.toHexString(), event.params.amount0, event.params.amount1, event.block.number); - -// updateBeanSupplyPegPercent(event.block.number); -// } - -// export function handleBurn(event: Burn): void { -// updatePoolReserves( -// event.address.toHexString(), -// ZERO_BI.minus(event.params.amount0), -// ZERO_BI.minus(event.params.amount1), -// event.block.number -// ); - -// updateBeanSupplyPegPercent(event.block.number); -// } - -// Reserves/price already updated by Sync event. Sync event is always emitted prior to a swap. -// Just update the volume for usd/bean -export function handleSwap(event: Swap): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - let weth = loadOrCreateToken(WETH.toHexString()); - let usdVolume = toDecimal(event.params.amount0In.plus(event.params.amount0Out), 18).times(weth.lastPriceUSD); - - let pool = loadOrCreatePool(event.address.toHexString(), event.block.number); - updatePoolValues( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - event.params.amount1In.plus(event.params.amount1Out), - usdVolume, - ZERO_BD, - pool.deltaBeans - ); - - updateBeanValues(BEAN_ERC20_V1.toHexString(), event.block.timestamp, null, ZERO_BI, ZERO_BI, usdVolume, ZERO_BD); -} - -// Sync is called in UniswapV2 on any liquidity or swap transaction. -// It updates the `reserves` value on the contract. - -export function handleSync(event: Sync): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - const oldBeanPrice = getLastBeanPrice(BEAN_ERC20_V1.toHexString()); - - // Token 0 is WETH and Token 1 is BEAN - let reserves = [event.params.reserve0, event.params.reserve1]; - - let wethPrice = updatePreReplantPriceETH(); - - const newPoolPrices = calcUniswapV2Inst_2(toDecimal(reserves[1]), toDecimal(reserves[0], 18), wethPrice); - - let pool = loadOrCreatePool(event.address.toHexString(), event.block.number); - let deltaLiquidityUSD = newPoolPrices.liquidity.minus(pool.liquidityUSD); - - setPoolReserves(event.address.toHexString(), reserves, event.block.timestamp, event.block.number); - updatePoolValues( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - ZERO_BI, - ZERO_BD, - deltaLiquidityUSD, - newPoolPrices.deltaB - ); - updatePoolPrice(event.address.toHexString(), event.block.timestamp, event.block.number, newPoolPrices.price); - - updateBeanSupplyPegPercent(event.block.number); - - const newBeanPrice = calcLiquidityWeightedBeanPrice(BEAN_ERC20_V1.toHexString()); - checkBeanCross(BEAN_ERC20_V1.toHexString(), event.block.timestamp, event.block.number, oldBeanPrice, newBeanPrice); - updateBeanValues(BEAN_ERC20_V1.toHexString(), event.block.timestamp, newBeanPrice, ZERO_BI, ZERO_BI, ZERO_BD, deltaLiquidityUSD); -} - -// Update pool price/liquidity/deltaB. This is for updating the price when a swap occurs in another pool. -// The caller is expected to update overall bean prices after this function completes. -export function externalUpdatePoolPrice(poolAddr: Address, timestamp: BigInt, blockNumber: BigInt): void { - const pool = loadOrCreatePool(poolAddr.toHexString(), blockNumber); - - const ethPrice = updatePreReplantPriceETH(); - const newPoolPrices = calcUniswapV2Inst_2(toDecimal(pool.reserves[1]), toDecimal(pool.reserves[0], 18), ethPrice); - const deltaLiquidityUSD = newPoolPrices.liquidity.minus(pool.liquidityUSD); - - updatePoolValues(BEAN_WETH_V1.toHexString(), timestamp, blockNumber, ZERO_BI, ZERO_BD, deltaLiquidityUSD, newPoolPrices.deltaB); - updatePoolPrice(BEAN_WETH_V1.toHexString(), timestamp, blockNumber, newPoolPrices.price); -} - -export function checkPegCrossEth(block: ethereum.Block): void { - const pool = loadOrCreatePool(BEAN_WETH_V1.toHexString(), block.number); - const prevPoolPrice = pool.lastPrice; - - const reserves = pool.reserves; - if (reserves[0] == ZERO_BI || reserves[1] == ZERO_BI) { - return; - } - const ethPrice = getPreReplantPriceETH(); - const newPoolPrices = calcUniswapV2Inst_2(toDecimal(reserves[1]), toDecimal(reserves[0], 18), ethPrice); - - // log.debug("Prev/New bean price {} / {}", [prevPrice.toString(), newPrice.toString()]); - - // Check for pool peg cross - const poolCrossed = checkPoolCross(BEAN_WETH_V1.toHexString(), block.timestamp, block.number, prevPoolPrice, newPoolPrices.price); - - let deltaLiquidityUSD = ZERO_BD; - if (poolCrossed) { - // Update price for the pool - deltaLiquidityUSD = newPoolPrices.liquidity.minus(pool.liquidityUSD); - updatePoolValues(BEAN_WETH_V1.toHexString(), block.timestamp, block.number, ZERO_BI, ZERO_BD, deltaLiquidityUSD, newPoolPrices.deltaB); - updatePoolPrice(BEAN_WETH_V1.toHexString(), block.timestamp, block.number, newPoolPrices.price, false); - } - - // Check for overall Bean cross - const oldBeanPrice = getLastBeanPrice(BEAN_ERC20_V1.toHexString()); - const newBeanPrice = calcLiquidityWeightedBeanPrice(BEAN_ERC20_V1.toHexString()); - // log.info("old {} new bp {}", [oldBeanPrice.toString(), newBeanPrice.toString()]); - const beanCrossed = checkBeanCross(BEAN_ERC20_V1.toHexString(), block.timestamp, block.number, oldBeanPrice, newBeanPrice); - if (beanCrossed) { - updateBeanValues( - BEAN_ERC20_V1.toHexString(), - block.timestamp, - newBeanPrice, - ZERO_BI, - ZERO_BI, - ZERO_BD, - deltaLiquidityUSD // Assumption is that 3crv/lusd prices are constant - ); - } - - if (poolCrossed || beanCrossed) { - updateTokenPrice(WETH.toHexString(), ethPrice); - } -} diff --git a/projects/subgraph-bean/src/entities/Bean.ts b/projects/subgraph-bean/src/entities/Bean.ts new file mode 100644 index 0000000000..f16e171d92 --- /dev/null +++ b/projects/subgraph-bean/src/entities/Bean.ts @@ -0,0 +1,92 @@ +import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; +import { BEAN_ERC20, BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { dayFromTimestamp } from "../../../subgraph-core/utils/Dates"; +import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { Bean, BeanDailySnapshot, BeanHourlySnapshot } from "../../generated/schema"; +import { getV1Crosses } from "../utils/Cross"; + +export function loadBean(token: string): Bean { + let bean = Bean.load(token); + if (bean == null) { + bean = new Bean(token); + bean.chain = "ethereum"; + bean.beanstalk = BEANSTALK.toHexString(); + bean.supply = ZERO_BI; + bean.marketCap = ZERO_BD; + bean.lockedBeans = ZERO_BI; + bean.supplyInPegLP = ZERO_BD; + bean.volume = ZERO_BI; + bean.volumeUSD = ZERO_BD; + bean.liquidityUSD = ZERO_BD; + bean.price = BigDecimal.fromString("1.072"); + bean.crosses = token == BEAN_ERC20.toHexString() ? getV1Crosses() : 0; // starting point for v2 is where v1 left off + bean.lastCross = ZERO_BI; + bean.lastSeason = token == BEAN_ERC20.toHexString() ? 6074 : 0; + bean.pools = []; + bean.dewhitelistedPools = []; + bean.save(); + } + return bean as Bean; +} + +export function loadOrCreateBeanHourlySnapshot(token: string, timestamp: BigInt, season: i32): BeanHourlySnapshot { + let id = token + "-" + season.toString(); + let snapshot = BeanHourlySnapshot.load(id); + if (snapshot == null) { + let bean = loadBean(token); + snapshot = new BeanHourlySnapshot(id); + snapshot.bean = bean.id; + snapshot.supply = bean.supply; + snapshot.marketCap = bean.marketCap; + snapshot.lockedBeans = bean.lockedBeans; + snapshot.supplyInPegLP = bean.supplyInPegLP; + snapshot.instantaneousDeltaB = ZERO_BI; + snapshot.twaDeltaB = ZERO_BI; + snapshot.volume = bean.volume; + snapshot.volumeUSD = bean.volumeUSD; + snapshot.liquidityUSD = bean.liquidityUSD; + snapshot.price = bean.price; + snapshot.twaPrice = ZERO_BD; + snapshot.crosses = bean.crosses; + snapshot.deltaVolume = ZERO_BI; + snapshot.deltaVolumeUSD = ZERO_BD; + snapshot.deltaLiquidityUSD = ZERO_BD; + snapshot.deltaCrosses = 0; + snapshot.season = bean.lastSeason; + snapshot.timestamp = timestamp; + snapshot.blockNumber = ZERO_BI; + snapshot.save(); + } + return snapshot as BeanHourlySnapshot; +} + +export function loadOrCreateBeanDailySnapshot(token: string, timestamp: BigInt): BeanDailySnapshot { + let day = dayFromTimestamp(timestamp).toString(); + let snapshot = BeanDailySnapshot.load(day); + if (snapshot == null) { + let bean = loadBean(token); + snapshot = new BeanDailySnapshot(day); + snapshot.bean = bean.id; + snapshot.supply = bean.supply; + snapshot.marketCap = bean.marketCap; + snapshot.lockedBeans = bean.lockedBeans; + snapshot.supplyInPegLP = bean.supplyInPegLP; + snapshot.instantaneousDeltaB = ZERO_BI; + snapshot.twaDeltaB = ZERO_BI; + snapshot.volume = bean.volume; + snapshot.volumeUSD = bean.volumeUSD; + snapshot.liquidityUSD = bean.liquidityUSD; + snapshot.price = bean.price; + snapshot.twaPrice = ZERO_BD; + snapshot.crosses = bean.crosses; + snapshot.deltaVolume = ZERO_BI; + snapshot.deltaVolumeUSD = ZERO_BD; + snapshot.deltaLiquidityUSD = ZERO_BD; + snapshot.deltaCrosses = 0; + snapshot.season = bean.lastSeason; + snapshot.timestamp = timestamp; + snapshot.blockNumber = ZERO_BI; + snapshot.save(); + } + return snapshot as BeanDailySnapshot; +} diff --git a/projects/subgraph-bean/src/entities/Cross.ts b/projects/subgraph-bean/src/entities/Cross.ts new file mode 100644 index 0000000000..f106f6afe9 --- /dev/null +++ b/projects/subgraph-bean/src/entities/Cross.ts @@ -0,0 +1,43 @@ +import { ethereum } from "@graphprotocol/graph-ts"; +import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; +import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { BeanCross, PoolCross } from "../../generated/schema"; + +export function loadOrCreateBeanCross(id: i32, bean: string, block: ethereum.Block): BeanCross { + let cross = BeanCross.load(id.toString()); + if (cross == null) { + let hour = hourFromTimestamp(block.timestamp).toString(); + let day = dayFromTimestamp(block.timestamp).toString(); + cross = new BeanCross(id.toString()); + cross.bean = bean; + cross.price = ZERO_BD; + cross.blockNumber = block.number; + cross.timestamp = block.timestamp; + cross.timeSinceLastCross = ZERO_BI; + cross.above = false; + cross.hourlySnapshot = hour; + cross.dailySnapshot = day; + cross.save(); + } + return cross as BeanCross; +} + +export function loadOrCreatePoolCross(id: i32, pool: string, block: ethereum.Block): PoolCross { + let crossID = pool + "-" + id.toString(); + let cross = PoolCross.load(crossID); + if (cross == null) { + let hour = hourFromTimestamp(block.timestamp).toString(); + let day = dayFromTimestamp(block.timestamp).toString(); + cross = new PoolCross(crossID); + cross.pool = pool; + cross.price = ZERO_BD; + cross.blockNumber = block.number; + cross.timestamp = block.timestamp; + cross.timeSinceLastCross = ZERO_BI; + cross.above = false; + cross.hourlySnapshot = hour; + cross.dailySnapshot = day; + cross.save(); + } + return cross as PoolCross; +} diff --git a/projects/subgraph-bean/src/entities/Pool.ts b/projects/subgraph-bean/src/entities/Pool.ts new file mode 100644 index 0000000000..b56542e599 --- /dev/null +++ b/projects/subgraph-bean/src/entities/Pool.ts @@ -0,0 +1,103 @@ +import { BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { getBeanTokenAddress } from "../utils/Bean"; +import { loadBean } from "./Bean"; +import { getTokensForPool } from "../utils/constants/PooledTokens"; +import { Pool, PoolDailySnapshot, PoolHourlySnapshot } from "../../generated/schema"; +import { loadOrCreateToken } from "./Token"; +import { emptyBigIntArray, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; + +export function loadOrCreatePool(poolAddress: string, blockNumber: BigInt): Pool { + let pool = Pool.load(poolAddress); + if (pool == null) { + let beanAddress = getBeanTokenAddress(blockNumber); + let bean = loadBean(beanAddress); + + pool = new Pool(poolAddress); + pool.tokens = getTokensForPool(poolAddress); + for (let i = 0; i < pool.tokens.length; ++i) { + loadOrCreateToken(pool.tokens[i]); + } + pool.bean = beanAddress; + pool.reserves = emptyBigIntArray(2); + pool.lastSeason = bean.lastSeason; + pool.lastPrice = ZERO_BD; + pool.volume = ZERO_BI; + pool.volumeUSD = ZERO_BD; + pool.liquidityUSD = ZERO_BD; + pool.crosses = 0; + pool.lastCross = ZERO_BI; + pool.deltaBeans = ZERO_BI; + pool.save(); + + // Add new pool to the Bean entity + let pools = bean.pools; + pools.push(poolAddress); + bean.pools = pools; + bean.save(); + } + return pool as Pool; +} + +export function loadOrCreatePoolHourlySnapshot(pool: string, block: ethereum.Block): PoolHourlySnapshot { + let hour = hourFromTimestamp(block.timestamp).toString(); + let id = pool + "-" + hour; + let snapshot = PoolHourlySnapshot.load(id); + if (snapshot == null) { + let currentPool = loadOrCreatePool(pool, block.number); + snapshot = new PoolHourlySnapshot(id); + snapshot.pool = pool; + snapshot.reserves = currentPool.reserves; + snapshot.lastPrice = currentPool.lastPrice; + snapshot.twaPrice = ZERO_BD; + snapshot.volume = currentPool.volume; + snapshot.volumeUSD = currentPool.volumeUSD; + snapshot.liquidityUSD = currentPool.liquidityUSD; + snapshot.crosses = currentPool.crosses; + snapshot.utilization = ZERO_BD; + snapshot.deltaBeans = ZERO_BI; + snapshot.twaDeltaBeans = ZERO_BI; + snapshot.deltaReserves = emptyBigIntArray(2); + snapshot.deltaVolume = ZERO_BI; + snapshot.deltaVolumeUSD = ZERO_BD; + snapshot.deltaLiquidityUSD = ZERO_BD; + snapshot.deltaCrosses = 0; + snapshot.season = currentPool.lastSeason; + snapshot.createdAt = block.timestamp; + snapshot.updatedAt = block.timestamp; + snapshot.save(); + } + return snapshot as PoolHourlySnapshot; +} + +export function loadOrCreatePoolDailySnapshot(pool: string, block: ethereum.Block): PoolDailySnapshot { + let day = dayFromTimestamp(block.timestamp).toString(); + + let id = pool + "-" + day; + let snapshot = PoolDailySnapshot.load(id); + if (snapshot == null) { + let currentPool = loadOrCreatePool(pool, block.number); + snapshot = new PoolDailySnapshot(id); + snapshot.pool = pool; + snapshot.reserves = currentPool.reserves; + snapshot.lastPrice = currentPool.lastPrice; + snapshot.twaPrice = ZERO_BD; + snapshot.volume = currentPool.volume; + snapshot.volumeUSD = currentPool.volumeUSD; + snapshot.liquidityUSD = currentPool.liquidityUSD; + snapshot.crosses = currentPool.crosses; + snapshot.utilization = ZERO_BD; + snapshot.deltaBeans = ZERO_BI; + snapshot.twaDeltaBeans = ZERO_BI; + snapshot.deltaReserves = emptyBigIntArray(2); + snapshot.deltaVolume = ZERO_BI; + snapshot.deltaVolumeUSD = ZERO_BD; + snapshot.deltaLiquidityUSD = ZERO_BD; + snapshot.deltaCrosses = 0; + snapshot.season = currentPool.lastSeason; + snapshot.createdAt = block.timestamp; + snapshot.updatedAt = block.timestamp; + snapshot.save(); + } + return snapshot as PoolDailySnapshot; +} diff --git a/projects/subgraph-bean/src/entities/Token.ts b/projects/subgraph-bean/src/entities/Token.ts new file mode 100644 index 0000000000..2536c77945 --- /dev/null +++ b/projects/subgraph-bean/src/entities/Token.ts @@ -0,0 +1,16 @@ +import { getTokenInfo } from "../utils/constants/PooledTokens"; +import { ZERO_BD } from "../../../subgraph-core/utils/Decimals"; +import { Token } from "../../generated/schema"; + +export function loadOrCreateToken(address: string): Token { + let token = Token.load(address); + if (token == null) { + const tokenInfo = getTokenInfo(address); + token = new Token(address); + token.name = tokenInfo.name; + token.decimals = tokenInfo.decimals; + token.lastPriceUSD = ZERO_BD; + token.save(); + } + return token as Token; +} diff --git a/projects/subgraph-bean/src/entities/TwaOracle.ts b/projects/subgraph-bean/src/entities/TwaOracle.ts new file mode 100644 index 0000000000..ab6f94cdbe --- /dev/null +++ b/projects/subgraph-bean/src/entities/TwaOracle.ts @@ -0,0 +1,24 @@ +import { Bytes } from "@graphprotocol/graph-ts"; +import { emptyBigIntArray, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { TwaOracle } from "../../generated/schema"; + +export function loadOrCreateTwaOracle(poolAddress: string): TwaOracle { + let twaOracle = TwaOracle.load(poolAddress); + if (twaOracle == null) { + twaOracle = new TwaOracle(poolAddress); + twaOracle.pool = poolAddress; + twaOracle.priceCumulativeSun = emptyBigIntArray(2); + twaOracle.lastSun = ZERO_BI; + twaOracle.priceCumulativeLast = emptyBigIntArray(2); + twaOracle.lastBalances = emptyBigIntArray(2); + twaOracle.lastUpdated = ZERO_BI; + twaOracle.cumulativeWellReserves = Bytes.empty(); + twaOracle.cumulativeWellReservesTime = ZERO_BI; + twaOracle.cumulativeWellReservesBlock = ZERO_BI; + twaOracle.cumulativeWellReservesPrev = Bytes.empty(); + twaOracle.cumulativeWellReservesPrevTime = ZERO_BI; + twaOracle.cumulativeWellReservesPrevBlock = ZERO_BI; + twaOracle.save(); + } + return twaOracle as TwaOracle; +} diff --git a/projects/subgraph-bean/src/handlers/Bean3CRVHandler.ts b/projects/subgraph-bean/src/handlers/Bean3CRVHandler.ts new file mode 100644 index 0000000000..a0cc8ff575 --- /dev/null +++ b/projects/subgraph-bean/src/handlers/Bean3CRVHandler.ts @@ -0,0 +1,197 @@ +import { BigInt, BigDecimal, ethereum, Address } from "@graphprotocol/graph-ts"; +import { + AddLiquidity, + Bean3CRV, + RemoveLiquidity, + RemoveLiquidityImbalance, + RemoveLiquidityOne, + TokenExchange, + TokenExchangeUnderlying +} from "../../generated/Bean-ABIs/Bean3CRV"; +import { updateBeanAfterPoolSwap } from "../utils/Bean"; +import { BEAN_3CRV_V1, BEAN_ERC20_V1, BEAN_LUSD_V1, CURVE_PRICE } from "../../../subgraph-core/utils/Constants"; +import { curveDeltaBUsingVPrice, curvePriceAndLp } from "../utils/price/CurvePrice"; +import { loadOrCreatePool } from "../entities/Pool"; +import { ERC20 } from "../../generated/Bean-ABIs/ERC20"; +import { manualTwa } from "../utils/price/TwaOracle"; +import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues } from "../utils/Pool"; +import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { CurvePrice } from "../../generated/Bean-ABIs/CurvePrice"; + +export function handleTokenExchange(event: TokenExchange): void { + handleSwap( + event.address.toHexString(), + event.params.sold_id, + event.params.tokens_sold, + event.params.bought_id, + event.params.tokens_bought, + event.block + ); +} + +export function handleTokenExchangeUnderlying(event: TokenExchangeUnderlying): void { + handleSwap( + event.address.toHexString(), + event.params.sold_id, + event.params.tokens_sold, + event.params.bought_id, + event.params.tokens_bought, + event.block + ); +} + +export function handleAddLiquidity(event: AddLiquidity): void { + handleLiquidityChange( + event.address.toHexString(), + event.params.token_amounts[0] !== ZERO_BI && event.params.token_amounts[1] !== ZERO_BI, + event.block + ); +} + +export function handleRemoveLiquidity(event: RemoveLiquidity): void { + handleLiquidityChange( + event.address.toHexString(), + event.params.token_amounts[0] !== ZERO_BI && event.params.token_amounts[1] !== ZERO_BI, + event.block + ); +} + +export function handleRemoveLiquidityImbalance(event: RemoveLiquidityImbalance): void { + handleLiquidityChange( + event.address.toHexString(), + event.params.token_amounts[0] !== ZERO_BI && event.params.token_amounts[1] !== ZERO_BI, + event.block + ); +} + +export function handleRemoveLiquidityOne(event: RemoveLiquidityOne): void { + handleLiquidityChange(event.address.toHexString(), false, event.block); +} + +function handleLiquidityChange(poolAddress: string, isBoth: boolean, block: ethereum.Block): void { + // TODO: refactor this part out from liquidity and swap + let deltaB; + let newPoolPrice; + let reserveBalances; + let deltaLiquidityUSD; + if (poolAddress === BEAN_3CRV_V1.toHexString()) { + let pool = loadOrCreatePool(poolAddress, block.number); + + let priceAndLp = curvePriceAndLp(Address.fromString(poolAddress)); + let newPoolPrice = priceAndLp[0]; + let lpValue = priceAndLp[1]; + + let beanContract = ERC20.bind(BEAN_ERC20_V1); + let beanHolding = toDecimal(beanContract.balanceOf(Address.fromString(poolAddress))); + let beanValue = beanHolding.times(newPoolPrice); + + let liquidityUSD = beanValue.plus(lpValue); + deltaLiquidityUSD = liquidityUSD.minus(pool.liquidityUSD); + + let lpContract = Bean3CRV.bind(Address.fromString(poolAddress)); + reserveBalances = lpContract.get_balances(); + deltaB = curveDeltaBUsingVPrice(Address.fromString(poolAddress), reserveBalances[0]); + + if (poolAddress == BEAN_LUSD_V1.toHexString()) { + manualTwa(poolAddress, reserveBalances, block.timestamp); + } + } else { + // Use curve price contract + let curvePrice = CurvePrice.bind(CURVE_PRICE); + let curve = curvePrice.try_getCurve(); + + if (curve.reverted) { + return; + } + + let startingLiquidity = getPoolLiquidityUSD(poolAddress, block); + + deltaB = curve.value.deltaB; + newPoolPrice = toDecimal(curve.value.price); + reserveBalances = curve.value.balances; + deltaLiquidityUSD = toDecimal(curve.value.liquidity).minus(startingLiquidity); + } + + let volumeUSD = + deltaLiquidityUSD < ZERO_BD + ? deltaLiquidityUSD.div(BigDecimal.fromString("2")).times(BigDecimal.fromString("-1")) + : deltaLiquidityUSD.div(BigDecimal.fromString("2")); + let volumeBean = BigInt.fromString(volumeUSD.div(newPoolPrice!).times(BigDecimal.fromString("1000000")).truncate(0).toString()); + + // Ideally this would constitute volume if both tokens are involved, but not in equal proportion. + if (isBoth) { + volumeUSD = ZERO_BD; + volumeBean = ZERO_BI; + } + + setPoolReserves(poolAddress, reserveBalances, block); + updatePoolValues(poolAddress, volumeBean, volumeUSD, deltaLiquidityUSD, deltaB, block); + updatePoolPrice(poolAddress, newPoolPrice!, block); + + updateBeanAfterPoolSwap(poolAddress, newPoolPrice!, volumeBean, volumeUSD, deltaLiquidityUSD, block); +} + +function handleSwap( + poolAddress: string, + sold_id: BigInt, + tokens_sold: BigInt, + bought_id: BigInt, + tokens_bought: BigInt, + block: ethereum.Block +): void { + let deltaB; + let newPoolPrice; + let reserveBalances; + let deltaLiquidityUSD; + if (poolAddress === BEAN_3CRV_V1.toHexString()) { + let pool = loadOrCreatePool(poolAddress, block.number); + + let priceAndLp = curvePriceAndLp(Address.fromString(poolAddress)); + let newPoolPrice = priceAndLp[0]; + let lpValue = priceAndLp[1]; + + let beanContract = ERC20.bind(BEAN_ERC20_V1); + let beanHolding = toDecimal(beanContract.balanceOf(Address.fromString(poolAddress))); + let beanValue = beanHolding.times(newPoolPrice); + + let liquidityUSD = beanValue.plus(lpValue); + deltaLiquidityUSD = liquidityUSD.minus(pool.liquidityUSD); + + let lpContract = Bean3CRV.bind(Address.fromString(poolAddress)); + reserveBalances = lpContract.get_balances(); + deltaB = curveDeltaBUsingVPrice(Address.fromString(poolAddress), reserveBalances[0]); + + if (poolAddress == BEAN_LUSD_V1.toHexString()) { + manualTwa(poolAddress, reserveBalances, block.timestamp); + } + } else { + // Use curve price contract + let curvePrice = CurvePrice.bind(CURVE_PRICE); + let curve = curvePrice.try_getCurve(); + + if (curve.reverted) { + return; + } + + let startingLiquidity = getPoolLiquidityUSD(poolAddress, block); + + deltaB = curve.value.deltaB; + newPoolPrice = toDecimal(curve.value.price); + reserveBalances = curve.value.balances; + deltaLiquidityUSD = toDecimal(curve.value.liquidity).minus(startingLiquidity); + } + + let volumeBean = ZERO_BI; + if (sold_id == ZERO_BI) { + volumeBean = tokens_sold; + } else if (bought_id == ZERO_BI) { + volumeBean = tokens_bought; + } + let volumeUSD = toDecimal(volumeBean).times(newPoolPrice!); + + setPoolReserves(poolAddress, reserveBalances, block); + updatePoolValues(poolAddress, volumeBean, volumeUSD, deltaLiquidityUSD, deltaB, block); + updatePoolPrice(poolAddress, newPoolPrice!, block); + + updateBeanAfterPoolSwap(poolAddress, newPoolPrice!, volumeBean, volumeUSD, deltaLiquidityUSD, block); +} diff --git a/projects/subgraph-bean/src/BeanHandler.ts b/projects/subgraph-bean/src/handlers/BeanHandler.ts similarity index 67% rename from projects/subgraph-bean/src/BeanHandler.ts rename to projects/subgraph-bean/src/handlers/BeanHandler.ts index 02c0cddb25..15ec6cfb72 100644 --- a/projects/subgraph-bean/src/BeanHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanHandler.ts @@ -1,6 +1,7 @@ -import { Transfer } from "../generated/Bean-ABIs/ERC20"; -import { loadBean, updateBeanSupplyPegPercent } from "./utils/Bean"; -import { ADDRESS_ZERO, BEAN_ERC20_V1 } from "../../subgraph-core/utils/Constants"; +import { ADDRESS_ZERO, BEAN_ERC20_V1 } from "../../../subgraph-core/utils/Constants"; +import { Transfer } from "../../generated/Bean-ABIs/ERC20"; +import { loadBean } from "../entities/Bean"; +import { updateBeanSupplyPegPercent } from "../utils/Bean"; export function handleTransfer(event: Transfer): void { if (event.params.from == ADDRESS_ZERO || event.params.to == ADDRESS_ZERO) { diff --git a/projects/subgraph-bean/src/BeanWellHandler.ts b/projects/subgraph-bean/src/handlers/BeanWellHandler.ts similarity index 52% rename from projects/subgraph-bean/src/BeanWellHandler.ts rename to projects/subgraph-bean/src/handlers/BeanWellHandler.ts index d67a1a7262..276aaeb6fc 100644 --- a/projects/subgraph-bean/src/BeanWellHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanWellHandler.ts @@ -1,41 +1,27 @@ -import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20 } from "../../subgraph-core/utils/Constants"; -import { ZERO_BD, ZERO_BI, deltaBigIntArray, toDecimal } from "../../subgraph-core/utils/Decimals"; -import { AddLiquidity, RemoveLiquidity, RemoveLiquidityOneToken, Shift, Swap, Sync } from "../generated/Bean-ABIs/Well"; -import { updateBeanAfterPoolSwap } from "./utils/Bean"; -import { getPoolLiquidityUSD, loadOrCreatePool, setPoolReserves, updatePoolPrice, updatePoolValues } from "./utils/Pool"; -import { BeanstalkPrice_try_price, getPoolPrice } from "./utils/price/BeanstalkPrice"; +import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { AddLiquidity, RemoveLiquidity, RemoveLiquidityOneToken, Shift, Swap, Sync } from "../../generated/Bean-ABIs/Well"; +import { deltaBigIntArray, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { BEAN_ERC20 } from "../../../subgraph-core/utils/Constants"; +import { loadOrCreatePool } from "../entities/Pool"; +import { BeanstalkPrice_try_price, getPoolPrice } from "../utils/price/BeanstalkPrice"; +import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues } from "../utils/Pool"; +import { updateBeanAfterPoolSwap } from "../utils/Bean"; export function handleAddLiquidity(event: AddLiquidity): void { - handleLiquidityChange( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - event.params.tokenAmountsIn[0], - event.params.tokenAmountsIn[1], - false - ); + handleLiquidityChange(event.address.toHexString(), event.params.tokenAmountsIn[0], event.params.tokenAmountsIn[1], false, event.block); } export function handleRemoveLiquidity(event: RemoveLiquidity): void { - handleLiquidityChange( - event.address.toHexString(), - event.block.timestamp, - event.block.number, - event.params.tokenAmountsOut[0], - event.params.tokenAmountsOut[1], - true - ); + handleLiquidityChange(event.address.toHexString(), event.params.tokenAmountsOut[0], event.params.tokenAmountsOut[1], true, event.block); } export function handleRemoveLiquidityOneToken(event: RemoveLiquidityOneToken): void { handleLiquidityChange( event.address.toHexString(), - event.block.timestamp, - event.block.number, event.params.tokenOut == BEAN_ERC20 ? event.params.tokenAmountOut : ZERO_BI, event.params.tokenOut != BEAN_ERC20 ? event.params.tokenAmountOut : ZERO_BI, - true + true, + event.block ); } @@ -44,18 +30,11 @@ export function handleSync(event: Sync): void { let deltaReserves = deltaBigIntArray(event.params.reserves, pool.reserves); - handleLiquidityChange(event.address.toHexString(), event.block.timestamp, event.block.number, deltaReserves[0], deltaReserves[1], false); + handleLiquidityChange(event.address.toHexString(), deltaReserves[0], deltaReserves[1], false, event.block); } export function handleSwap(event: Swap): void { - handleSwapEvent( - event.address.toHexString(), - event.params.toToken, - event.params.amountIn, - event.params.amountOut, - event.block.timestamp, - event.block.number - ); + handleSwapEvent(event.address.toHexString(), event.params.toToken, event.params.amountIn, event.params.amountOut, event.block); } export function handleShift(event: Shift): void { @@ -68,21 +47,19 @@ export function handleShift(event: Shift): void { event.params.toToken, event.params.toToken == BEAN_ERC20 ? deltaReserves[1] : deltaReserves[0], event.params.amountOut, - event.block.timestamp, - event.block.number + event.block ); } function handleLiquidityChange( poolAddress: string, - timestamp: BigInt, - blockNumber: BigInt, token0Amount: BigInt, token1Amount: BigInt, - removal: boolean + removal: boolean, + block: ethereum.Block ): void { // Get Price Details via Price contract - let beanPrice = BeanstalkPrice_try_price(BEAN_ERC20, blockNumber); + let beanPrice = BeanstalkPrice_try_price(BEAN_ERC20, block.number); if (beanPrice.reverted) { return; } @@ -91,7 +68,7 @@ function handleLiquidityChange( return; } - let startingLiquidity = getPoolLiquidityUSD(poolAddress, blockNumber); + let startingLiquidity = getPoolLiquidityUSD(poolAddress, block); let newPrice = toDecimal(wellPrice.price); let deltaLiquidityUSD = toDecimal(wellPrice.liquidity).minus(startingLiquidity); @@ -116,32 +93,16 @@ function handleLiquidityChange( } } - setPoolReserves(poolAddress, wellPrice.balances, timestamp, blockNumber); - updatePoolValues(poolAddress, timestamp, blockNumber, volumeBean, volumeUSD, deltaLiquidityUSD, wellPrice.deltaB); - updatePoolPrice(poolAddress, timestamp, blockNumber, newPrice); - - updateBeanAfterPoolSwap( - poolAddress, - toDecimal(wellPrice.price), - volumeBean, - volumeUSD, - deltaLiquidityUSD, - timestamp, - blockNumber, - beanPrice - ); + setPoolReserves(poolAddress, wellPrice.balances, block); + updatePoolValues(poolAddress, volumeBean, volumeUSD, deltaLiquidityUSD, wellPrice.deltaB, block); + updatePoolPrice(poolAddress, newPrice, block); + + updateBeanAfterPoolSwap(poolAddress, toDecimal(wellPrice.price), volumeBean, volumeUSD, deltaLiquidityUSD, block, beanPrice); } -function handleSwapEvent( - poolAddress: string, - toToken: Address, - amountIn: BigInt, - amountOut: BigInt, - timestamp: BigInt, - blockNumber: BigInt -): void { +function handleSwapEvent(poolAddress: string, toToken: Address, amountIn: BigInt, amountOut: BigInt, block: ethereum.Block): void { // Get Price Details via Price contract - let beanPrice = BeanstalkPrice_try_price(BEAN_ERC20, blockNumber); + let beanPrice = BeanstalkPrice_try_price(BEAN_ERC20, block.number); if (beanPrice.reverted) { return; } @@ -150,7 +111,7 @@ function handleSwapEvent( return; } - let startingLiquidity = getPoolLiquidityUSD(poolAddress, blockNumber); + let startingLiquidity = getPoolLiquidityUSD(poolAddress, block); let newPrice = toDecimal(wellPrice.price); let volumeBean = toToken == BEAN_ERC20 ? amountOut : amountIn; @@ -158,18 +119,9 @@ function handleSwapEvent( let volumeUSD = toDecimal(volumeBean).times(newPrice); let deltaLiquidityUSD = toDecimal(wellPrice.liquidity).minus(startingLiquidity); - setPoolReserves(poolAddress, wellPrice.balances, timestamp, blockNumber); - updatePoolValues(poolAddress, timestamp, blockNumber, volumeBean, volumeUSD, deltaLiquidityUSD, wellPrice.deltaB); - updatePoolPrice(poolAddress, timestamp, blockNumber, newPrice); - - updateBeanAfterPoolSwap( - poolAddress, - toDecimal(wellPrice.price), - volumeBean, - volumeUSD, - deltaLiquidityUSD, - timestamp, - blockNumber, - beanPrice - ); + setPoolReserves(poolAddress, wellPrice.balances, block); + updatePoolValues(poolAddress, volumeBean, volumeUSD, deltaLiquidityUSD, wellPrice.deltaB, block); + updatePoolPrice(poolAddress, newPrice, block); + + updateBeanAfterPoolSwap(poolAddress, toDecimal(wellPrice.price), volumeBean, volumeUSD, deltaLiquidityUSD, block, beanPrice); } diff --git a/projects/subgraph-bean/src/BeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts similarity index 54% rename from projects/subgraph-bean/src/BeanstalkHandler.ts rename to projects/subgraph-bean/src/handlers/BeanstalkHandler.ts index 665ae61618..d95de667cc 100644 --- a/projects/subgraph-bean/src/BeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts @@ -1,18 +1,20 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; -import { Chop, DewhitelistToken, Reward, Sunrise } from "../generated/Bean-ABIs/Beanstalk"; -import { getBeanTokenAddress, loadBean, updateBeanSeason, updateBeanSupplyPegPercent, updateBeanTwa, updateBeanValues } from "./utils/Bean"; -import { loadOrCreatePool, updatePoolPrice, updatePoolSeason, updatePoolValues } from "./utils/Pool"; -import { BEAN_3CRV, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_V1, CURVE_PRICE } from "../../subgraph-core/utils/Constants"; -import { ZERO_BD, ZERO_BI, toDecimal } from "../../subgraph-core/utils/Decimals"; -import { CurvePrice } from "../generated/Bean-ABIs/CurvePrice"; -import { checkBeanCross } from "./utils/Cross"; -import { calcUniswapV2Inst, setUniswapV2Twa } from "./utils/price/UniswapPrice"; -import { calcCurveInst, setCurveTwa } from "./utils/price/CurvePrice"; -import { MetapoolOracle, WellOracle } from "../generated/Bean-ABIs/BIP37"; -import { DeltaBPriceLiquidity } from "./utils/price/Types"; -import { setRawWellReserves, setTwaLast } from "./utils/price/TwaOracle"; -import { decodeCumulativeWellReserves, setWellTwa } from "./utils/price/WellPrice"; +import { BigInt } from "@graphprotocol/graph-ts"; import { beanstalkPrice_updatePoolPrices } from "./BlockHandler"; +import { getBeanTokenAddress, updateBeanSeason, updateBeanSupplyPegPercent, updateBeanTwa, updateBeanValues } from "../utils/Bean"; +import { Chop, DewhitelistToken, Reward, Sunrise } from "../../generated/Bean-ABIs/Beanstalk"; +import { CurvePrice } from "../../generated/Bean-ABIs/CurvePrice"; +import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../subgraph-core/utils/Constants"; +import { loadOrCreatePool } from "../entities/Pool"; +import { updatePoolPrice, updatePoolSeason, updatePoolValues } from "../utils/Pool"; +import { loadBean } from "../entities/Bean"; +import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { checkBeanCross } from "../utils/Cross"; +import { DeltaBPriceLiquidity } from "../utils/price/Types"; +import { calcUniswapV2Inst, setUniswapV2Twa } from "../utils/price/UniswapPrice"; +import { calcCurveInst, setCurveTwa } from "../utils/price/CurvePrice"; +import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BIP37"; +import { setRawWellReserves, setTwaLast } from "../utils/price/TwaOracle"; +import { decodeCumulativeWellReserves, setWellTwa } from "../utils/price/WellPrice"; export function handleSunrise(event: Sunrise): void { // Update the season for hourly and daily liquidity metrics @@ -24,11 +26,11 @@ export function handleSunrise(event: Sunrise): void { let bean = loadBean(beanToken); let oldBeanPrice = bean.price; for (let i = 0; i < bean.pools.length; i++) { - updatePoolSeason(bean.pools[i], event.block.timestamp, event.block.number, event.params.season.toI32()); + updatePoolSeason(bean.pools[i], event.params.season.toI32(), event.block); } for (let i = 0; i < bean.dewhitelistedPools.length; i++) { - updatePoolSeason(bean.dewhitelistedPools[i], event.block.timestamp, event.block.number, event.params.season.toI32()); + updatePoolSeason(bean.dewhitelistedPools[i], event.params.season.toI32(), event.block); } // Fetch price from price contract to capture any non-bean token price movevements @@ -44,23 +46,22 @@ export function handleSunrise(event: Sunrise): void { let beanCurve = loadOrCreatePool(BEAN_3CRV.toHexString(), event.block.number); if (!curve.reverted) { - updateBeanValues(BEAN_ERC20.toHexString(), event.block.timestamp, toDecimal(curve.value.price), ZERO_BI, ZERO_BI, ZERO_BD, ZERO_BD); + updateBeanValues(beanToken, toDecimal(curve.value.price), ZERO_BI, ZERO_BI, ZERO_BD, ZERO_BD, event.block); updatePoolValues( BEAN_3CRV.toHexString(), - event.block.timestamp, - event.block.number, ZERO_BI, ZERO_BD, toDecimal(curve.value.liquidity).minus(beanCurve.liquidityUSD), - curve.value.deltaB + curve.value.deltaB, + event.block ); - updatePoolPrice(BEAN_3CRV.toHexString(), event.block.timestamp, event.block.number, toDecimal(curve.value.price)); - checkBeanCross(BEAN_ERC20.toHexString(), event.block.timestamp, event.block.number, oldBeanPrice, toDecimal(curve.value.price)); + updatePoolPrice(BEAN_3CRV.toHexString(), toDecimal(curve.value.price), event.block); + checkBeanCross(beanToken, oldBeanPrice, toDecimal(curve.value.price), event.block); } } } else { // Pre-Replant - let bean = loadBean(BEAN_ERC20_V1.toHexString()); + let bean = loadBean(beanToken); let weightedPrice = ZERO_BD; let totalLiquidity = ZERO_BD; for (let i = 0; i < bean.pools.length; i++) { @@ -68,40 +69,24 @@ export function handleSunrise(event: Sunrise): void { let inst: DeltaBPriceLiquidity; if (bean.pools[i] == BEAN_WETH_V1.toHexString()) { inst = calcUniswapV2Inst(pool); - setUniswapV2Twa(bean.pools[i], event.block.timestamp, event.block.number); + setUniswapV2Twa(bean.pools[i], event.block); } else { inst = calcCurveInst(pool); - setCurveTwa(bean.pools[i], event.block.timestamp, event.block.number); + setCurveTwa(bean.pools[i], event.block); } // Update price, liquidity, and deltaB in the pool - updatePoolValues( - bean.pools[i], - event.block.timestamp, - event.block.number, - ZERO_BI, - ZERO_BD, - inst.liquidity.minus(pool.liquidityUSD), - inst.deltaB - ); - updatePoolPrice(bean.pools[i], event.block.timestamp, event.block.number, inst.price); + updatePoolValues(bean.pools[i], ZERO_BI, ZERO_BD, inst.liquidity.minus(pool.liquidityUSD), inst.deltaB, event.block); + updatePoolPrice(bean.pools[i], inst.price, event.block); weightedPrice = weightedPrice.plus(inst.price.times(inst.liquidity)); totalLiquidity = totalLiquidity.plus(inst.liquidity); } const totalPrice = weightedPrice.div(totalLiquidity); - updateBeanValues( - BEAN_ERC20_V1.toHexString(), - event.block.timestamp, - totalPrice, - ZERO_BI, - ZERO_BI, - ZERO_BD, - totalLiquidity.minus(bean.liquidityUSD) - ); - checkBeanCross(BEAN_ERC20_V1.toHexString(), event.block.timestamp, event.block.number, bean.price, totalPrice); - updateBeanTwa(event.block.timestamp, event.block.number); + updateBeanValues(beanToken, totalPrice, ZERO_BI, ZERO_BI, ZERO_BD, totalLiquidity.minus(bean.liquidityUSD), event.block); + checkBeanCross(beanToken, bean.price, totalPrice, event.block); + updateBeanTwa(event.block); } } @@ -123,15 +108,15 @@ export function handleDewhitelistToken(event: DewhitelistToken): void { export function handleMetapoolOracle(event: MetapoolOracle): void { setTwaLast(BEAN_3CRV.toHexString(), event.params.balances, event.block.timestamp); - setCurveTwa(BEAN_3CRV.toHexString(), event.block.timestamp, event.block.number); - updateBeanTwa(event.block.timestamp, event.block.number); + setCurveTwa(BEAN_3CRV.toHexString(), event.block); + updateBeanTwa(event.block); } export function handleWellOracle(event: WellOracle): void { setRawWellReserves(event); setTwaLast(event.params.well.toHexString(), decodeCumulativeWellReserves(event.params.cumulativeReserves), event.block.timestamp); - setWellTwa(event.params.well.toHexString(), event.params.deltaB, event.block.timestamp, event.block.number); - updateBeanTwa(event.block.timestamp, event.block.number); + setWellTwa(event.params.well.toHexString(), event.params.deltaB, event.block); + updateBeanTwa(event.block); } // LOCKED BEANS // @@ -143,6 +128,7 @@ export function handleWellOracle(event: WellOracle): void { export function handleChop(event: Chop): void { updateBeanSupplyPegPercent(event.block.number); } +// TODO: add handler for convert-chops here as well. export function handleRewardMint(event: Reward): void { updateBeanSupplyPegPercent(event.block.number); diff --git a/projects/subgraph-bean/src/BlockHandler.ts b/projects/subgraph-bean/src/handlers/BlockHandler.ts similarity index 62% rename from projects/subgraph-bean/src/BlockHandler.ts rename to projects/subgraph-bean/src/handlers/BlockHandler.ts index 349cc1c58a..c7260306eb 100644 --- a/projects/subgraph-bean/src/BlockHandler.ts +++ b/projects/subgraph-bean/src/handlers/BlockHandler.ts @@ -1,13 +1,15 @@ import { ethereum } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20, BEAN_WETH_CP2_WELL_BLOCK, EXPLOIT_BLOCK } from "../../subgraph-core/utils/Constants"; -import { checkPegCrossEth as univ2_checkPegCrossEth } from "./UniswapV2Handler"; -import { loadBean, updateBeanValues } from "./utils/Bean"; -import { toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { checkBeanCross, checkPoolCross } from "./utils/Cross"; -import { loadOrCreatePool, updatePoolPrice, updatePoolValues } from "./utils/Pool"; -import { BeanstalkPrice_try_price } from "./utils/price/BeanstalkPrice"; -import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "../cache-builder/results/PegCrossBlocks_eth"; -import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; +import { checkPegCrossEth as univ2_checkPegCrossEth } from "./legacy/LegacyUniswapV2Handler"; +import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "../../cache-builder/results/PegCrossBlocks_eth"; +import { BEAN_ERC20, BEAN_WETH_CP2_WELL_BLOCK, EXPLOIT_BLOCK } from "../../../subgraph-core/utils/Constants"; +import { u32_binarySearchIndex } from "../../../subgraph-core/utils/Math"; +import { BeanstalkPrice_try_price } from "../utils/price/BeanstalkPrice"; +import { loadBean } from "../entities/Bean"; +import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { checkBeanCross, checkPoolCross } from "../utils/Cross"; +import { loadOrCreatePool } from "../entities/Pool"; +import { updatePoolPrice, updatePoolValues } from "../utils/Pool"; +import { updateBeanValues } from "../utils/Bean"; // Processing as each new ethereum block is created export function handleBlock(block: ethereum.Block): void { @@ -39,7 +41,7 @@ export function beanstalkPrice_updatePoolPrices(priceOnlyOnCross: boolean, block const newPrice = toDecimal(priceResult.value.price); // Check for overall peg cross - const beanCrossed = checkBeanCross(BEAN_ERC20.toHexString(), block.timestamp, block.number, prevPrice, newPrice); + const beanCrossed = checkBeanCross(BEAN_ERC20.toHexString(), prevPrice, newPrice, block); // Update pool price for each pool - necessary for checking pool cross let totalLiquidity = ZERO_BD; @@ -47,40 +49,25 @@ export function beanstalkPrice_updatePoolPrices(priceOnlyOnCross: boolean, block const poolPriceInfo = priceResult.value.ps[i]; const pool = loadOrCreatePool(poolPriceInfo.pool.toHexString(), block.number); - const poolCrossed = checkPoolCross( - poolPriceInfo.pool.toHexString(), - block.timestamp, - block.number, - pool.lastPrice, - toDecimal(poolPriceInfo.price) - ); + const poolCrossed = checkPoolCross(poolPriceInfo.pool.toHexString(), pool.lastPrice, toDecimal(poolPriceInfo.price), block); if (!priceOnlyOnCross || poolCrossed || beanCrossed) { totalLiquidity = totalLiquidity.plus(toDecimal(poolPriceInfo.liquidity)); updatePoolValues( poolPriceInfo.pool.toHexString(), - block.timestamp, - block.number, ZERO_BI, ZERO_BD, toDecimal(poolPriceInfo.liquidity).minus(pool.liquidityUSD), - poolPriceInfo.deltaB + poolPriceInfo.deltaB, + block ); - updatePoolPrice(poolPriceInfo.pool.toHexString(), block.timestamp, block.number, toDecimal(poolPriceInfo.price), false); + updatePoolPrice(poolPriceInfo.pool.toHexString(), toDecimal(poolPriceInfo.price), block, false); } } // Update bean values at the end now that the summation of pool liquidity is known if (!priceOnlyOnCross || beanCrossed) { - updateBeanValues( - BEAN_ERC20.toHexString(), - block.timestamp, - newPrice, - ZERO_BI, - ZERO_BI, - ZERO_BD, - totalLiquidity.minus(bean.liquidityUSD) - ); + updateBeanValues(BEAN_ERC20.toHexString(), newPrice, ZERO_BI, ZERO_BI, ZERO_BD, totalLiquidity.minus(bean.liquidityUSD), block); } return true; } diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts new file mode 100644 index 0000000000..a203def44f --- /dev/null +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts @@ -0,0 +1,120 @@ +import { BigInt, ethereum, Address, log } from "@graphprotocol/graph-ts"; +import { getLastBeanPrice, calcLiquidityWeightedBeanPrice, updateBeanSupplyPegPercent, updateBeanValues } from "../../utils/Bean"; +import { Swap, Sync } from "../../../generated/Bean-ABIs/UniswapV2Pair"; +import { loadOrCreateToken } from "../../entities/Token"; +import { BEAN_ERC20_V1, BEAN_WETH_V1, WETH } from "../../../../subgraph-core/utils/Constants"; +import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { loadOrCreatePool } from "../../entities/Pool"; +import { setPoolReserves, updatePoolPrice, updatePoolValues } from "../../utils/Pool"; +import { calcUniswapV2Inst_2, getPreReplantPriceETH, updatePreReplantPriceETH } from "../../utils/price/UniswapPrice"; +import { checkBeanCross, checkPoolCross } from "../../utils/Cross"; +import { updateTokenPrice } from "../../utils/Token"; + +// Reserves/price already updated by Sync event. Sync event is always emitted prior to a swap. +// Just update the volume for usd/bean +export function handleSwap(event: Swap): void { + // Do not index post-exploit data + if (event.block.number >= BigInt.fromI32(14602790)) return; + + let weth = loadOrCreateToken(WETH.toHexString()); + let usdVolume = toDecimal(event.params.amount0In.plus(event.params.amount0Out), 18).times(weth.lastPriceUSD); + + let pool = loadOrCreatePool(event.address.toHexString(), event.block.number); + updatePoolValues( + event.address.toHexString(), + event.params.amount1In.plus(event.params.amount1Out), + usdVolume, + ZERO_BD, + pool.deltaBeans, + event.block + ); + + updateBeanValues(pool.bean, null, ZERO_BI, ZERO_BI, usdVolume, ZERO_BD, event.block); +} + +// Sync is called in UniswapV2 on any liquidity or swap transaction. +// It updates the `reserves` value on the contract. + +export function handleSync(event: Sync): void { + // Do not index post-exploit data + if (event.block.number >= BigInt.fromI32(14602790)) return; + + let pool = loadOrCreatePool(event.address.toHexString(), event.block.number); + const oldBeanPrice = getLastBeanPrice(pool.bean); + + // Token 0 is WETH and Token 1 is BEAN + let reserves = [event.params.reserve0, event.params.reserve1]; + + let wethPrice = updatePreReplantPriceETH(); + + const newPoolPrices = calcUniswapV2Inst_2(toDecimal(reserves[1]), toDecimal(reserves[0], 18), wethPrice); + + let deltaLiquidityUSD = newPoolPrices.liquidity.minus(pool.liquidityUSD); + + setPoolReserves(event.address.toHexString(), reserves, event.block); + updatePoolValues(event.address.toHexString(), ZERO_BI, ZERO_BD, deltaLiquidityUSD, newPoolPrices.deltaB, event.block); + updatePoolPrice(event.address.toHexString(), newPoolPrices.price, event.block); + + updateBeanSupplyPegPercent(event.block.number); + + const newBeanPrice = calcLiquidityWeightedBeanPrice(pool.bean); + checkBeanCross(pool.bean, oldBeanPrice, newBeanPrice, event.block); + updateBeanValues(pool.bean, newBeanPrice, ZERO_BI, ZERO_BI, ZERO_BD, deltaLiquidityUSD, event.block); +} + +// Update pool price/liquidity/deltaB. This is for updating the price when a swap occurs in another pool. +// The caller is expected to update overall bean prices after this function completes. +export function externalUpdatePoolPrice(poolAddr: Address, block: ethereum.Block): void { + const pool = loadOrCreatePool(poolAddr.toHexString(), block.number); + + const ethPrice = updatePreReplantPriceETH(); + const newPoolPrices = calcUniswapV2Inst_2(toDecimal(pool.reserves[1]), toDecimal(pool.reserves[0], 18), ethPrice); + const deltaLiquidityUSD = newPoolPrices.liquidity.minus(pool.liquidityUSD); + + updatePoolValues(poolAddr.toHexString(), ZERO_BI, ZERO_BD, deltaLiquidityUSD, newPoolPrices.deltaB, block); + updatePoolPrice(poolAddr.toHexString(), newPoolPrices.price, block); +} + +export function checkPegCrossEth(block: ethereum.Block): void { + const poolAddrString = BEAN_WETH_V1.toHexString(); + const pool = loadOrCreatePool(poolAddrString, block.number); + const prevPoolPrice = pool.lastPrice; + + const reserves = pool.reserves; + if (reserves[0] == ZERO_BI || reserves[1] == ZERO_BI) { + return; + } + const ethPrice = getPreReplantPriceETH(); + const newPoolPrices = calcUniswapV2Inst_2(toDecimal(reserves[1]), toDecimal(reserves[0], 18), ethPrice); + + // Check for pool peg cross + const poolCrossed = checkPoolCross(poolAddrString, prevPoolPrice, newPoolPrices.price, block); + + let deltaLiquidityUSD = ZERO_BD; + if (poolCrossed) { + // Update price for the pool + deltaLiquidityUSD = newPoolPrices.liquidity.minus(pool.liquidityUSD); + updatePoolValues(poolAddrString, ZERO_BI, ZERO_BD, deltaLiquidityUSD, newPoolPrices.deltaB, block); + updatePoolPrice(poolAddrString, newPoolPrices.price, block, false); + } + + // Check for overall Bean cross + const oldBeanPrice = getLastBeanPrice(BEAN_ERC20_V1.toHexString()); + const newBeanPrice = calcLiquidityWeightedBeanPrice(BEAN_ERC20_V1.toHexString()); + const beanCrossed = checkBeanCross(BEAN_ERC20_V1.toHexString(), oldBeanPrice, newBeanPrice, block); + if (beanCrossed) { + updateBeanValues( + pool.bean, + newBeanPrice, + ZERO_BI, + ZERO_BI, + ZERO_BD, + deltaLiquidityUSD, // Assumption is that 3crv/lusd prices are constant + block + ); + } + + if (poolCrossed || beanCrossed) { + updateTokenPrice(WETH.toHexString(), ethPrice); + } +} diff --git a/projects/subgraph-bean/src/utils/Bean.ts b/projects/subgraph-bean/src/utils/Bean.ts index 17b5220e53..c45875c26f 100644 --- a/projects/subgraph-bean/src/utils/Bean.ts +++ b/projects/subgraph-bean/src/utils/Bean.ts @@ -1,115 +1,29 @@ -import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; -import { Bean, BeanDailySnapshot, BeanHourlySnapshot, Pool } from "../../generated/schema"; +import { BigDecimal, BigInt, ethereum, Address } from "@graphprotocol/graph-ts"; +import { Pool } from "../../generated/schema"; import { BEAN_ERC20_V1, BEAN_ERC20, BEAN_WETH_V1, BEAN_3CRV_V1, BEAN_LUSD_V1, - BEANSTALK, NEW_BEAN_TOKEN_BLOCK } from "../../../subgraph-core/utils/Constants"; -import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { checkBeanCross, getV1Crosses } from "./Cross"; -import { loadOrCreatePool, loadOrCreatePoolHourlySnapshot } from "./Pool"; +import { checkBeanCross } from "./Cross"; import { BeanstalkPrice_try_price, BeanstalkPriceResult } from "./price/BeanstalkPrice"; import { calcLockedBeans } from "./LockedBeans"; - -export function loadBean(token: string): Bean { - let bean = Bean.load(token); - if (bean == null) { - bean = new Bean(token); - bean.chain = "ethereum"; - bean.beanstalk = BEANSTALK.toHexString(); - bean.supply = ZERO_BI; - bean.marketCap = ZERO_BD; - bean.lockedBeans = ZERO_BI; - bean.supplyInPegLP = ZERO_BD; - bean.volume = ZERO_BI; - bean.volumeUSD = ZERO_BD; - bean.liquidityUSD = ZERO_BD; - bean.price = BigDecimal.fromString("1.072"); - bean.crosses = token == BEAN_ERC20.toHexString() ? getV1Crosses() : 0; // starting point for v2 is where v1 left off - bean.lastCross = ZERO_BI; - bean.lastSeason = token == BEAN_ERC20.toHexString() ? 6074 : 0; - bean.pools = []; - bean.dewhitelistedPools = []; - bean.save(); - } - return bean as Bean; -} - -export function loadOrCreateBeanHourlySnapshot(token: string, timestamp: BigInt, season: i32): BeanHourlySnapshot { - let id = token + "-" + season.toString(); - let snapshot = BeanHourlySnapshot.load(id); - if (snapshot == null) { - let bean = loadBean(token); - snapshot = new BeanHourlySnapshot(id); - snapshot.bean = bean.id; - snapshot.supply = bean.supply; - snapshot.marketCap = bean.marketCap; - snapshot.lockedBeans = bean.lockedBeans; - snapshot.supplyInPegLP = bean.supplyInPegLP; - snapshot.instantaneousDeltaB = ZERO_BI; - snapshot.twaDeltaB = ZERO_BI; - snapshot.volume = bean.volume; - snapshot.volumeUSD = bean.volumeUSD; - snapshot.liquidityUSD = bean.liquidityUSD; - snapshot.price = bean.price; - snapshot.twaPrice = ZERO_BD; - snapshot.crosses = bean.crosses; - snapshot.deltaVolume = ZERO_BI; - snapshot.deltaVolumeUSD = ZERO_BD; - snapshot.deltaLiquidityUSD = ZERO_BD; - snapshot.deltaCrosses = 0; - snapshot.season = bean.lastSeason; - snapshot.timestamp = timestamp; - snapshot.blockNumber = ZERO_BI; - snapshot.save(); - } - return snapshot as BeanHourlySnapshot; -} - -export function loadOrCreateBeanDailySnapshot(token: string, timestamp: BigInt): BeanDailySnapshot { - let day = dayFromTimestamp(timestamp).toString(); - let snapshot = BeanDailySnapshot.load(day); - if (snapshot == null) { - let bean = loadBean(token); - snapshot = new BeanDailySnapshot(day); - snapshot.bean = bean.id; - snapshot.supply = bean.supply; - snapshot.marketCap = bean.marketCap; - snapshot.lockedBeans = bean.lockedBeans; - snapshot.supplyInPegLP = bean.supplyInPegLP; - snapshot.instantaneousDeltaB = ZERO_BI; - snapshot.twaDeltaB = ZERO_BI; - snapshot.volume = bean.volume; - snapshot.volumeUSD = bean.volumeUSD; - snapshot.liquidityUSD = bean.liquidityUSD; - snapshot.price = bean.price; - snapshot.twaPrice = ZERO_BD; - snapshot.crosses = bean.crosses; - snapshot.deltaVolume = ZERO_BI; - snapshot.deltaVolumeUSD = ZERO_BD; - snapshot.deltaLiquidityUSD = ZERO_BD; - snapshot.deltaCrosses = 0; - snapshot.season = bean.lastSeason; - snapshot.timestamp = timestamp; - snapshot.blockNumber = ZERO_BI; - snapshot.save(); - } - return snapshot as BeanDailySnapshot; -} +import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../entities/Bean"; +import { loadOrCreatePool, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; +import { externalUpdatePoolPrice as univ2_externalUpdatePoolPrice } from "../handlers/legacy/LegacyUniswapV2Handler"; export function updateBeanValues( token: string, - timestamp: BigInt, newPrice: BigDecimal | null, deltaSupply: BigInt, deltaVolume: BigInt, deltaVolumeUSD: BigDecimal, - deltaLiquidityUSD: BigDecimal + deltaLiquidityUSD: BigDecimal, + block: ethereum.Block ): void { let bean = loadBean(token); if (newPrice !== null) { @@ -122,8 +36,8 @@ export function updateBeanValues( bean.liquidityUSD = bean.liquidityUSD.plus(deltaLiquidityUSD); bean.save(); - let beanHourly = loadOrCreateBeanHourlySnapshot(token, timestamp, bean.lastSeason); - let beanDaily = loadOrCreateBeanDailySnapshot(token, timestamp); + let beanHourly = loadOrCreateBeanHourlySnapshot(token, block.timestamp, bean.lastSeason); + let beanDaily = loadOrCreateBeanDailySnapshot(token, block.timestamp); beanHourly.volume = bean.volume; beanHourly.volumeUSD = bean.volumeUSD; @@ -232,37 +146,43 @@ export function updateBeanAfterPoolSwap( volumeBean: BigInt, volumeUSD: BigDecimal, deltaLiquidityUSD: BigDecimal, - timestamp: BigInt, - blockNumber: BigInt, + block: ethereum.Block, priceContractResult: BeanstalkPriceResult | null = null ): void { - let bean = loadBean(BEAN_ERC20.toHexString()); + let pool = loadOrCreatePool(poolAddress, block.number); + let bean = loadBean(pool.bean); + // Verify the pool is still whitelisted if (bean.pools.indexOf(poolAddress) >= 0) { let oldBeanPrice = bean.price; let beanPrice = poolPrice; // Get overall price from price contract if a result was not already provided - if (priceContractResult === null) { - priceContractResult = BeanstalkPrice_try_price(BEAN_ERC20, blockNumber); - } - if (!priceContractResult.reverted) { - beanPrice = toDecimal(priceContractResult.value.price); + if (bean.id == BEAN_ERC20_V1.toHexString()) { + univ2_externalUpdatePoolPrice(BEAN_WETH_V1, block); + beanPrice = calcLiquidityWeightedBeanPrice(bean.id); + } else { + if (priceContractResult === null) { + priceContractResult = BeanstalkPrice_try_price(Address.fromString(bean.id), block.number); + } + if (!priceContractResult.reverted) { + beanPrice = toDecimal(priceContractResult.value.price); + } } - updateBeanSupplyPegPercent(blockNumber); - updateBeanValues(BEAN_ERC20.toHexString(), timestamp, beanPrice, ZERO_BI, volumeBean, volumeUSD, deltaLiquidityUSD); - checkBeanCross(BEAN_ERC20.toHexString(), timestamp, blockNumber, oldBeanPrice, beanPrice); + updateBeanSupplyPegPercent(block.number); + updateBeanValues(bean.id, beanPrice, ZERO_BI, volumeBean, volumeUSD, deltaLiquidityUSD, block); + checkBeanCross(bean.id, oldBeanPrice, beanPrice, block); } } -export function updateInstDeltaB(token: string, blockNumber: BigInt, timestamp: BigInt): void { +export function updateInstDeltaB(token: string, block: ethereum.Block): void { let bean = loadBean(token); - let beanHourly = loadOrCreateBeanHourlySnapshot(token, timestamp, bean.lastSeason); - let beanDaily = loadOrCreateBeanDailySnapshot(token, timestamp); + let beanHourly = loadOrCreateBeanHourlySnapshot(token, block.timestamp, bean.lastSeason); + let beanDaily = loadOrCreateBeanDailySnapshot(token, block.timestamp); let cumulativeDeltaB = ZERO_BI; for (let i = 0; i < bean.pools.length; i++) { - let pool = loadOrCreatePool(bean.pools[i], blockNumber); + let pool = loadOrCreatePool(bean.pools[i], block.number); cumulativeDeltaB = cumulativeDeltaB.plus(pool.deltaBeans); } @@ -273,16 +193,16 @@ export function updateInstDeltaB(token: string, blockNumber: BigInt, timestamp: } // Update Bean's TWA deltaB and price. Individual pools' values must be computed prior to calling this method. -export function updateBeanTwa(timestamp: BigInt, blockNumber: BigInt): void { - let beanAddress = getBeanTokenAddress(blockNumber); +export function updateBeanTwa(block: ethereum.Block): void { + let beanAddress = getBeanTokenAddress(block.number); let bean = loadBean(beanAddress); - let beanHourly = loadOrCreateBeanHourlySnapshot(beanAddress, timestamp, bean.lastSeason); - let beanDaily = loadOrCreateBeanDailySnapshot(beanAddress, timestamp); + let beanHourly = loadOrCreateBeanHourlySnapshot(beanAddress, block.timestamp, bean.lastSeason); + let beanDaily = loadOrCreateBeanDailySnapshot(beanAddress, block.timestamp); let twaDeltaB = ZERO_BI; let weightedTwaPrice = ZERO_BD; for (let i = 0; i < bean.pools.length; i++) { - let poolHourly = loadOrCreatePoolHourlySnapshot(bean.pools[i], timestamp, blockNumber); + let poolHourly = loadOrCreatePoolHourlySnapshot(bean.pools[i], block); twaDeltaB = twaDeltaB.plus(poolHourly.twaDeltaBeans); weightedTwaPrice = weightedTwaPrice.plus(poolHourly.twaPrice.times(poolHourly.liquidityUSD)); } diff --git a/projects/subgraph-bean/src/utils/Cross.ts b/projects/subgraph-bean/src/utils/Cross.ts index 37ccc43368..8509b2142c 100644 --- a/projects/subgraph-bean/src/utils/Cross.ts +++ b/projects/subgraph-bean/src/utils/Cross.ts @@ -1,71 +1,31 @@ -import { BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; -import { BeanCross, PoolCross } from "../../generated/schema"; -import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "./Bean"; -import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; -import { ONE_BD, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { loadOrCreatePool, loadOrCreatePoolDailySnapshot, loadOrCreatePoolHourlySnapshot } from "./Pool"; +import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; +import { ONE_BD } from "../../../subgraph-core/utils/Decimals"; import { BEAN_ERC20_V1 } from "../../../subgraph-core/utils/Constants"; +import { loadOrCreatePool, loadOrCreatePoolDailySnapshot, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; +import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../entities/Bean"; +import { loadOrCreateBeanCross, loadOrCreatePoolCross } from "../entities/Cross"; -export function loadOrCreateBeanCross(id: i32, bean: string, blockNumber: BigInt, timestamp: BigInt): BeanCross { - let cross = BeanCross.load(id.toString()); - if (cross == null) { - let hour = hourFromTimestamp(timestamp).toString(); - let day = dayFromTimestamp(timestamp).toString(); - cross = new BeanCross(id.toString()); - cross.bean = bean; - cross.price = ZERO_BD; - cross.blockNumber = blockNumber; - cross.timestamp = timestamp; - cross.timeSinceLastCross = ZERO_BI; - cross.above = false; - cross.hourlySnapshot = hour; - cross.dailySnapshot = day; - cross.save(); - } - return cross as BeanCross; -} - -export function loadOrCreatePoolCross(id: i32, pool: string, blockNumber: BigInt, timestamp: BigInt): PoolCross { - let crossID = pool + "-" + id.toString(); - let cross = PoolCross.load(crossID); - if (cross == null) { - let hour = hourFromTimestamp(timestamp).toString(); - let day = dayFromTimestamp(timestamp).toString(); - cross = new PoolCross(crossID); - cross.pool = pool; - cross.price = ZERO_BD; - cross.blockNumber = blockNumber; - cross.timestamp = timestamp; - cross.timeSinceLastCross = ZERO_BI; - cross.above = false; - cross.hourlySnapshot = hour; - cross.dailySnapshot = day; - cross.save(); - } - return cross as PoolCross; -} - -export function checkPoolCross(pool: string, timestamp: BigInt, blockNumber: BigInt, oldPrice: BigDecimal, newPrice: BigDecimal): boolean { - let poolInfo = loadOrCreatePool(pool, blockNumber); +export function checkPoolCross(pool: string, oldPrice: BigDecimal, newPrice: BigDecimal, block: ethereum.Block): boolean { + let poolInfo = loadOrCreatePool(pool, block.number); let token = poolInfo.bean; let bean = loadBean(token); // log.debug("Prev/New well price {} / {}", [oldPrice.toString(), newPrice.toString()]); if (oldPrice >= ONE_BD && newPrice < ONE_BD) { - let cross = loadOrCreatePoolCross(poolInfo.crosses, pool, blockNumber, timestamp); + let cross = loadOrCreatePoolCross(poolInfo.crosses, pool, block); cross.price = newPrice; - cross.timeSinceLastCross = timestamp.minus(poolInfo.lastCross); + cross.timeSinceLastCross = block.timestamp.minus(poolInfo.lastCross); cross.above = false; cross.save(); - poolInfo.lastCross = timestamp; + poolInfo.lastCross = block.timestamp; poolInfo.crosses += 1; poolInfo.save(); - let poolHourly = loadOrCreatePoolHourlySnapshot(pool, timestamp, BigInt.fromI32(bean.lastSeason)); - let poolDaily = loadOrCreatePoolDailySnapshot(pool, timestamp, blockNumber); + let poolHourly = loadOrCreatePoolHourlySnapshot(pool, block); + let poolDaily = loadOrCreatePoolDailySnapshot(pool, block); poolHourly.crosses += 1; poolHourly.deltaCrosses += 1; @@ -76,19 +36,19 @@ export function checkPoolCross(pool: string, timestamp: BigInt, blockNumber: Big poolDaily.save(); return true; } else if (oldPrice < ONE_BD && newPrice >= ONE_BD) { - let cross = loadOrCreatePoolCross(poolInfo.crosses, pool, blockNumber, timestamp); + let cross = loadOrCreatePoolCross(poolInfo.crosses, pool, block); cross.price = newPrice; - cross.timeSinceLastCross = timestamp.minus(poolInfo.lastCross); + cross.timeSinceLastCross = block.timestamp.minus(poolInfo.lastCross); cross.above = true; cross.save(); - poolInfo.lastCross = timestamp; + poolInfo.lastCross = block.timestamp; poolInfo.crosses += 1; poolInfo.save(); - let poolHourly = loadOrCreatePoolHourlySnapshot(pool, timestamp, BigInt.fromI32(bean.lastSeason)); - let poolDaily = loadOrCreatePoolDailySnapshot(pool, timestamp, blockNumber); + let poolHourly = loadOrCreatePoolHourlySnapshot(pool, block); + let poolDaily = loadOrCreatePoolDailySnapshot(pool, block); poolHourly.crosses += 1; poolHourly.deltaCrosses += 1; @@ -102,23 +62,23 @@ export function checkPoolCross(pool: string, timestamp: BigInt, blockNumber: Big return false; } -export function checkBeanCross(token: string, timestamp: BigInt, blockNumber: BigInt, oldPrice: BigDecimal, newPrice: BigDecimal): boolean { +export function checkBeanCross(token: string, oldPrice: BigDecimal, newPrice: BigDecimal, block: ethereum.Block): boolean { let bean = loadBean(token); if (oldPrice >= ONE_BD && newPrice < ONE_BD) { - let cross = loadOrCreateBeanCross(bean.crosses, token, blockNumber, timestamp); + let cross = loadOrCreateBeanCross(bean.crosses, token, block); cross.price = newPrice; - cross.timeSinceLastCross = timestamp.minus(bean.lastCross); + cross.timeSinceLastCross = block.timestamp.minus(bean.lastCross); cross.above = false; cross.save(); - bean.lastCross = timestamp; + bean.lastCross = block.timestamp; bean.crosses += 1; bean.save(); - let beanHourly = loadOrCreateBeanHourlySnapshot(token, timestamp, bean.lastSeason); - let beanDaily = loadOrCreateBeanDailySnapshot(token, timestamp); + let beanHourly = loadOrCreateBeanHourlySnapshot(token, block.timestamp, bean.lastSeason); + let beanDaily = loadOrCreateBeanDailySnapshot(token, block.timestamp); beanHourly.crosses += 1; beanHourly.deltaCrosses += 1; @@ -129,19 +89,19 @@ export function checkBeanCross(token: string, timestamp: BigInt, blockNumber: Bi beanDaily.save(); return true; } else if (oldPrice < ONE_BD && newPrice >= ONE_BD) { - let cross = loadOrCreateBeanCross(bean.crosses, token, blockNumber, timestamp); + let cross = loadOrCreateBeanCross(bean.crosses, token, block); cross.price = newPrice; - cross.timeSinceLastCross = timestamp.minus(bean.lastCross); + cross.timeSinceLastCross = block.timestamp.minus(bean.lastCross); cross.above = true; cross.save(); - bean.lastCross = timestamp; + bean.lastCross = block.timestamp; bean.crosses += 1; bean.save(); - let beanHourly = loadOrCreateBeanHourlySnapshot(token, timestamp, bean.lastSeason); - let beanDaily = loadOrCreateBeanDailySnapshot(token, timestamp); + let beanHourly = loadOrCreateBeanHourlySnapshot(token, block.timestamp, bean.lastSeason); + let beanDaily = loadOrCreateBeanDailySnapshot(token, block.timestamp); beanHourly.crosses += 1; beanHourly.deltaCrosses += 1; diff --git a/projects/subgraph-bean/src/utils/LockedBeans.ts b/projects/subgraph-bean/src/utils/LockedBeans.ts index bd006d47fa..460b18c0dc 100644 --- a/projects/subgraph-bean/src/utils/LockedBeans.ts +++ b/projects/subgraph-bean/src/utils/LockedBeans.ts @@ -11,11 +11,11 @@ import { UNRIPE_LP } from "../../../subgraph-core/utils/Constants"; import { SeedGauge } from "../../generated/Bean-ABIs/SeedGauge"; -import { ONE_BI, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { ERC20 } from "../../generated/Bean-ABIs/ERC20"; import { Beanstalk } from "../../generated/Bean-ABIs/Beanstalk"; -import { loadOrCreatePool } from "./Pool"; -import { loadOrCreateTwaOracle } from "./price/TwaOracle"; +import { loadOrCreateTwaOracle } from "../entities/TwaOracle"; +import { loadOrCreatePool } from "../entities/Pool"; export function calcLockedBeans(blockNumber: BigInt): BigInt { // If BIP45 is deployed - return the result from the contract diff --git a/projects/subgraph-bean/src/utils/Pool.ts b/projects/subgraph-bean/src/utils/Pool.ts index 92beff98d1..1b3c6a2ba2 100644 --- a/projects/subgraph-bean/src/utils/Pool.ts +++ b/projects/subgraph-bean/src/utils/Pool.ts @@ -1,120 +1,21 @@ -import { BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; -import { Pool, PoolDailySnapshot, PoolHourlySnapshot } from "../../generated/schema"; -import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; -import { emptyBigIntArray, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { getBeanTokenAddress, loadBean, updateInstDeltaB } from "./Bean"; +import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; +import { ZERO_BD } from "../../../subgraph-core/utils/Decimals"; +import { updateInstDeltaB } from "./Bean"; import { checkPoolCross } from "./Cross"; import { DeltaBAndPrice } from "./price/Types"; -import { getTokensForPool } from "../constants/PooledTokens"; -import { loadOrCreateToken } from "./Token"; - -export function loadOrCreatePool(poolAddress: string, blockNumber: BigInt): Pool { - let pool = Pool.load(poolAddress); - if (pool == null) { - let beanAddress = getBeanTokenAddress(blockNumber); - let bean = loadBean(beanAddress); - - pool = new Pool(poolAddress); - pool.tokens = getTokensForPool(poolAddress); - for (let i = 0; i < pool.tokens.length; ++i) { - loadOrCreateToken(pool.tokens[i]); - } - pool.bean = beanAddress; - pool.reserves = emptyBigIntArray(2); - pool.lastSeason = bean.lastSeason; - pool.lastPrice = ZERO_BD; - pool.volume = ZERO_BI; - pool.volumeUSD = ZERO_BD; - pool.liquidityUSD = ZERO_BD; - pool.crosses = 0; - pool.lastCross = ZERO_BI; - pool.deltaBeans = ZERO_BI; - pool.save(); - - // Add new pool to the Bean entity - let pools = bean.pools; - pools.push(poolAddress); - bean.pools = pools; - bean.save(); - } - return pool as Pool; -} - -export function loadOrCreatePoolHourlySnapshot(pool: string, timestamp: BigInt, blockNumber: BigInt): PoolHourlySnapshot { - let hour = hourFromTimestamp(timestamp).toString(); - let id = pool + "-" + hour; - let snapshot = PoolHourlySnapshot.load(id); - if (snapshot == null) { - let currentPool = loadOrCreatePool(pool, blockNumber); - snapshot = new PoolHourlySnapshot(id); - snapshot.pool = pool; - snapshot.reserves = currentPool.reserves; - snapshot.lastPrice = currentPool.lastPrice; - snapshot.twaPrice = ZERO_BD; - snapshot.volume = currentPool.volume; - snapshot.volumeUSD = currentPool.volumeUSD; - snapshot.liquidityUSD = currentPool.liquidityUSD; - snapshot.crosses = currentPool.crosses; - snapshot.utilization = ZERO_BD; - snapshot.deltaBeans = ZERO_BI; - snapshot.twaDeltaBeans = ZERO_BI; - snapshot.deltaReserves = emptyBigIntArray(2); - snapshot.deltaVolume = ZERO_BI; - snapshot.deltaVolumeUSD = ZERO_BD; - snapshot.deltaLiquidityUSD = ZERO_BD; - snapshot.deltaCrosses = 0; - snapshot.season = currentPool.lastSeason; - snapshot.createdAt = timestamp; - snapshot.updatedAt = timestamp; - snapshot.save(); - } - return snapshot as PoolHourlySnapshot; -} - -export function loadOrCreatePoolDailySnapshot(pool: string, timestamp: BigInt, blockNumber: BigInt): PoolDailySnapshot { - let day = dayFromTimestamp(timestamp).toString(); - - let id = pool + "-" + day; - let snapshot = PoolDailySnapshot.load(id); - if (snapshot == null) { - let currentPool = loadOrCreatePool(pool, blockNumber); - snapshot = new PoolDailySnapshot(id); - snapshot.pool = pool; - snapshot.reserves = currentPool.reserves; - snapshot.lastPrice = currentPool.lastPrice; - snapshot.twaPrice = ZERO_BD; - snapshot.volume = currentPool.volume; - snapshot.volumeUSD = currentPool.volumeUSD; - snapshot.liquidityUSD = currentPool.liquidityUSD; - snapshot.crosses = currentPool.crosses; - snapshot.utilization = ZERO_BD; - snapshot.deltaBeans = ZERO_BI; - snapshot.twaDeltaBeans = ZERO_BI; - snapshot.deltaReserves = emptyBigIntArray(2); - snapshot.deltaVolume = ZERO_BI; - snapshot.deltaVolumeUSD = ZERO_BD; - snapshot.deltaLiquidityUSD = ZERO_BD; - snapshot.deltaCrosses = 0; - snapshot.season = currentPool.lastSeason; - snapshot.createdAt = timestamp; - snapshot.updatedAt = timestamp; - snapshot.save(); - } - return snapshot as PoolDailySnapshot; -} +import { loadOrCreatePool, loadOrCreatePoolDailySnapshot, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; export function updatePoolValues( poolAddress: string, - timestamp: BigInt, - blockNumber: BigInt, volumeBean: BigInt, volumeUSD: BigDecimal, deltaLiquidityUSD: BigDecimal, - deltaBeans: BigInt + deltaBeans: BigInt, + block: ethereum.Block ): void { - let pool = loadOrCreatePool(poolAddress, blockNumber); - let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, timestamp, blockNumber); - let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, timestamp, blockNumber); + let pool = loadOrCreatePool(poolAddress, block.number); + let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); + let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); pool.volume = pool.volume.plus(volumeBean); pool.volumeUSD = pool.volumeUSD.plus(volumeUSD); @@ -132,7 +33,7 @@ export function updatePoolValues( if (poolHourly.liquidityUSD.gt(ZERO_BD)) { poolHourly.utilization = poolHourly.deltaVolumeUSD.div(poolHourly.liquidityUSD); } - poolHourly.updatedAt = timestamp; + poolHourly.updatedAt = block.timestamp; poolHourly.save(); poolDaily.volume = pool.volume; @@ -145,16 +46,16 @@ export function updatePoolValues( if (poolDaily.liquidityUSD.gt(ZERO_BD)) { poolDaily.utilization = poolDaily.deltaVolumeUSD.div(poolDaily.liquidityUSD); } - poolDaily.updatedAt = timestamp; + poolDaily.updatedAt = block.timestamp; poolDaily.save(); - updateInstDeltaB(pool.bean, blockNumber, timestamp); + updateInstDeltaB(pool.bean, block); } -export function incrementPoolCross(poolAddress: string, timestamp: BigInt, blockNumber: BigInt): void { - let pool = loadOrCreatePool(poolAddress, blockNumber); - let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, timestamp, blockNumber); - let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, timestamp, blockNumber); +export function incrementPoolCross(poolAddress: string, block: ethereum.Block): void { + let pool = loadOrCreatePool(poolAddress, block.number); + let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); + let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); pool.crosses += 1; pool.save(); @@ -168,10 +69,10 @@ export function incrementPoolCross(poolAddress: string, timestamp: BigInt, block poolDaily.save(); } -export function updatePoolSeason(poolAddress: string, timestamp: BigInt, blockNumber: BigInt, season: i32): void { - let pool = loadOrCreatePool(poolAddress, blockNumber); - let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, timestamp, blockNumber); - let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, timestamp, blockNumber); +export function updatePoolSeason(poolAddress: string, season: i32, block: ethereum.Block): void { + let pool = loadOrCreatePool(poolAddress, block.number); + let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); + let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); pool.lastSeason = season; poolHourly.season = season; @@ -182,16 +83,10 @@ export function updatePoolSeason(poolAddress: string, timestamp: BigInt, blockNu poolDaily.save(); } -export function updatePoolPrice( - poolAddress: string, - timestamp: BigInt, - blockNumber: BigInt, - price: BigDecimal, - checkCross: boolean = true -): void { - let pool = loadOrCreatePool(poolAddress, blockNumber); - let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, timestamp, blockNumber); - let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, timestamp, blockNumber); +export function updatePoolPrice(poolAddress: string, price: BigDecimal, block: ethereum.Block, checkCross: boolean = true): void { + let pool = loadOrCreatePool(poolAddress, block.number); + let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); + let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); let oldPrice = pool.lastPrice; @@ -205,14 +100,14 @@ export function updatePoolPrice( poolDaily.save(); if (checkCross) { - checkPoolCross(poolAddress, timestamp, blockNumber, oldPrice, price); + checkPoolCross(poolAddress, oldPrice, price, block); } } -export function setPoolReserves(poolAddress: string, reserves: BigInt[], timestamp: BigInt, blockNumber: BigInt): void { - let pool = loadOrCreatePool(poolAddress, blockNumber); - let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, timestamp, blockNumber); - let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, timestamp, blockNumber); +export function setPoolReserves(poolAddress: string, reserves: BigInt[], block: ethereum.Block): void { + let pool = loadOrCreatePool(poolAddress, block.number); + let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); + let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); let deltaReserves: BigInt[] = []; for (let i = 0; i < reserves.length; ++i) { @@ -238,14 +133,14 @@ export function setPoolReserves(poolAddress: string, reserves: BigInt[], timesta poolDaily.save(); } -export function getPoolLiquidityUSD(poolAddress: string, blockNumber: BigInt): BigDecimal { - let pool = loadOrCreatePool(poolAddress, blockNumber); +export function getPoolLiquidityUSD(poolAddress: string, block: ethereum.Block): BigDecimal { + let pool = loadOrCreatePool(poolAddress, block.number); return pool.liquidityUSD; } -export function setPoolTwa(poolAddress: string, twaValues: DeltaBAndPrice, timestamp: BigInt, blockNumber: BigInt): void { - let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, timestamp, blockNumber); - let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, timestamp, blockNumber); +export function setPoolTwa(poolAddress: string, twaValues: DeltaBAndPrice, block: ethereum.Block): void { + let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); + let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); poolHourly.twaDeltaBeans = twaValues.deltaB; poolHourly.twaPrice = twaValues.price; poolHourly.twaToken2Price = twaValues.token2Price; diff --git a/projects/subgraph-bean/src/utils/Token.ts b/projects/subgraph-bean/src/utils/Token.ts index a371df1909..c94019dec7 100644 --- a/projects/subgraph-bean/src/utils/Token.ts +++ b/projects/subgraph-bean/src/utils/Token.ts @@ -1,20 +1,5 @@ import { BigDecimal } from "@graphprotocol/graph-ts"; -import { Token } from "../../generated/schema"; -import { ZERO_BD } from "../../../subgraph-core/utils/Decimals"; -import { getTokenInfo } from "../constants/PooledTokens"; - -export function loadOrCreateToken(address: string): Token { - let token = Token.load(address); - if (token == null) { - const tokenInfo = getTokenInfo(address); - token = new Token(address); - token.name = tokenInfo.name; - token.decimals = tokenInfo.decimals; - token.lastPriceUSD = ZERO_BD; - token.save(); - } - return token as Token; -} +import { loadOrCreateToken } from "../entities/Token"; export function updateTokenPrice(address: string, price: BigDecimal): void { let token = loadOrCreateToken(address); diff --git a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts index e27e9961d8..02b63cfdf2 100644 --- a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts +++ b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts @@ -1,7 +1,7 @@ import { ethereum } from "@graphprotocol/graph-ts"; -import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../Bean"; import { BEAN_ERC20 } from "../../../../subgraph-core/utils/Constants"; import { BEAN_INITIAL_VALUES } from "../../../cache-builder/results/BeanInit_arb"; +import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../../entities/Bean"; export function handleInitBeanEntity(block: ethereum.Block): void { // TODO: how to determine correct token address? this is wrong diff --git a/projects/subgraph-bean/src/utils/BeanWells.ts b/projects/subgraph-bean/src/utils/constants/BeanWells.ts similarity index 92% rename from projects/subgraph-bean/src/utils/BeanWells.ts rename to projects/subgraph-bean/src/utils/constants/BeanWells.ts index 5cc72a0121..c2c5bb6cda 100644 --- a/projects/subgraph-bean/src/utils/BeanWells.ts +++ b/projects/subgraph-bean/src/utils/constants/BeanWells.ts @@ -4,7 +4,7 @@ import { BEAN_WETH_CP2_WELL_BLOCK, BEAN_WSTETH_CP2_WELL, BEAN_WSTETH_CP2_WELL_BLOCK -} from "../../../subgraph-core/utils/Constants"; +} from "../../../../subgraph-core/utils/Constants"; export enum WellFunction { ConstantProduct diff --git a/projects/subgraph-bean/src/constants/PooledTokens.ts b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts similarity index 98% rename from projects/subgraph-bean/src/constants/PooledTokens.ts rename to projects/subgraph-bean/src/utils/constants/PooledTokens.ts index 5ef138c463..90a29abcd9 100644 --- a/projects/subgraph-bean/src/constants/PooledTokens.ts +++ b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts @@ -12,7 +12,7 @@ import { BEAN_WETH_CP2_WELL, BEAN_WSTETH_CP2_WELL, WSTETH -} from "../../../subgraph-core/utils/Constants"; +} from "../../../../subgraph-core/utils/Constants"; // Use this mapping to determine which tokens are in each pool. Pools may each follow a distinct interface, // so a view function shouldn't be used, and a new subgraph build is already required to track a newly whitelisted asset. diff --git a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts index f0d92d8b12..42b3421cd1 100644 --- a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts +++ b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts @@ -5,9 +5,9 @@ import { BeanstalkPrice__priceResultPPsStruct, BeanstalkPrice__priceResultPStruct } from "../../../generated/Bean-ABIs/BeanstalkPrice"; -import { loadBean } from "../Bean"; -import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_1_BLOCK, PRICE_2_BLOCK } from "../../../../subgraph-core/utils/Constants"; +import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../../subgraph-core/utils/Constants"; import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { loadBean } from "../../entities/Bean"; // Can't use the autogenerated one because the fields need to be updateable class PriceOverallStruct { diff --git a/projects/subgraph-bean/src/utils/price/CurvePrice.ts b/projects/subgraph-bean/src/utils/price/CurvePrice.ts index 9cb5fb0d75..11d50eac1b 100644 --- a/projects/subgraph-bean/src/utils/price/CurvePrice.ts +++ b/projects/subgraph-bean/src/utils/price/CurvePrice.ts @@ -1,6 +1,6 @@ -import { Address, BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; +import { Address, BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Bean3CRV } from "../../../generated/Bean-ABIs/Bean3CRV"; -import { BD_10, BI_10, ONE_BI, toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { BI_10, ONE_BI, toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { BEAN_3CRV_V1, BEAN_LUSD_V1, @@ -14,8 +14,9 @@ import { CalculationsCurve } from "../../../generated/Bean-ABIs/CalculationsCurv import { ERC20 } from "../../../generated/Bean-ABIs/ERC20"; import { DeltaBAndPrice, DeltaBPriceLiquidity, TWAType } from "./Types"; import { Pool } from "../../../generated/schema"; -import { getTWAPrices, loadOrCreateTwaOracle } from "./TwaOracle"; import { setPoolTwa } from "../Pool"; +import { getTWAPrices } from "./TwaOracle"; +import { loadOrCreateTwaOracle } from "../../entities/TwaOracle"; // Note that the Bean3CRV type applies to any curve pool (including lusd) @@ -79,13 +80,13 @@ export function curveDeltaBUsingVPrice(pool: Address, beanReserves: BigInt): Big } // Calculates and sets the TWA on the pool hourly/daily snapshots -export function setCurveTwa(poolAddress: string, timestamp: BigInt, blockNumber: BigInt): void { - const twaBalances = getTWAPrices(poolAddress, TWAType.CURVE, timestamp); +export function setCurveTwa(poolAddress: string, block: ethereum.Block): void { + const twaBalances = getTWAPrices(poolAddress, TWAType.CURVE, block.timestamp); const beanPool = Address.fromString(poolAddress); const otherPool = beanPool == BEAN_LUSD_V1 ? LUSD_3POOL : CRV3_POOL; const twaResult = curveTwaDeltaBAndPrice(twaBalances, beanPool, otherPool); - setPoolTwa(poolAddress, twaResult, timestamp, blockNumber); + setPoolTwa(poolAddress, twaResult, block); } export function curveCumulativePrices(pool: Address, timestamp: BigInt): BigInt[] { diff --git a/projects/subgraph-bean/src/utils/price/TwaOracle.ts b/projects/subgraph-bean/src/utils/price/TwaOracle.ts index d5729d7a20..99c65425b1 100644 --- a/projects/subgraph-bean/src/utils/price/TwaOracle.ts +++ b/projects/subgraph-bean/src/utils/price/TwaOracle.ts @@ -1,33 +1,12 @@ -import { BigInt, Address, BigDecimal, Bytes, log } from "@graphprotocol/graph-ts"; -import { TwaOracle } from "../../../generated/schema"; -import { BI_10, emptyBigIntArray, ONE_BI, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { BigInt, Address, BigDecimal } from "@graphprotocol/graph-ts"; +import { BI_10, ONE_BI, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { uniswapCumulativePrice } from "./UniswapPrice"; import { WETH_USDC_PAIR } from "../../../../subgraph-core/utils/Constants"; import { curveCumulativePrices } from "./CurvePrice"; import { TWAType } from "./Types"; import { wellCumulativePrices, wellTwaReserves } from "./WellPrice"; import { WellOracle } from "../../../generated/Bean-ABIs/BIP37"; - -export function loadOrCreateTwaOracle(poolAddress: string): TwaOracle { - let twaOracle = TwaOracle.load(poolAddress); - if (twaOracle == null) { - twaOracle = new TwaOracle(poolAddress); - twaOracle.pool = poolAddress; - twaOracle.priceCumulativeSun = emptyBigIntArray(2); - twaOracle.lastSun = ZERO_BI; - twaOracle.priceCumulativeLast = emptyBigIntArray(2); - twaOracle.lastBalances = emptyBigIntArray(2); - twaOracle.lastUpdated = ZERO_BI; - twaOracle.cumulativeWellReserves = Bytes.empty(); - twaOracle.cumulativeWellReservesTime = ZERO_BI; - twaOracle.cumulativeWellReservesBlock = ZERO_BI; - twaOracle.cumulativeWellReservesPrev = Bytes.empty(); - twaOracle.cumulativeWellReservesPrevTime = ZERO_BI; - twaOracle.cumulativeWellReservesPrevBlock = ZERO_BI; - twaOracle.save(); - } - return twaOracle as TwaOracle; -} +import { loadOrCreateTwaOracle } from "../../entities/TwaOracle"; export function manualTwa(poolAddress: string, newReserves: BigInt[], timestamp: BigInt): void { let twaOracle = loadOrCreateTwaOracle(poolAddress); diff --git a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts index f305396ff1..aad51803b5 100644 --- a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts +++ b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts @@ -1,13 +1,13 @@ -import { Address, BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; +import { Address, BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { BD_10, BI_10, ONE_BI, pow, sqrt, toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; -import { Pool, Token } from "../../../generated/schema"; -import { loadOrCreateToken } from "../Token"; +import { Pool } from "../../../generated/schema"; import { UniswapV2Pair } from "../../../generated/Bean-ABIs/UniswapV2Pair"; import { BEANSTALK, WETH, WETH_USDC_PAIR } from "../../../../subgraph-core/utils/Constants"; import { PreReplant } from "../../../generated/Bean-ABIs/PreReplant"; import { DeltaBAndPrice, DeltaBPriceLiquidity, TWAType } from "./Types"; import { setPoolTwa } from "../Pool"; import { getTWAPrices } from "./TwaOracle"; +import { loadOrCreateToken } from "../../entities/Token"; export function updatePreReplantPriceETH(): BigDecimal { let token = loadOrCreateToken(WETH.toHexString()); @@ -73,11 +73,11 @@ export function uniswapV2DeltaB(beanReserves: BigDecimal, token2Reserves: BigDec } // Calculates and sets the TWA on the pool hourly/daily snapshots -export function setUniswapV2Twa(poolAddress: string, timestamp: BigInt, blockNumber: BigInt): void { - const twaPrices = getTWAPrices(poolAddress, TWAType.UNISWAP, timestamp); - const twaResult = uniswapTwaDeltaBAndPrice(twaPrices, blockNumber); +export function setUniswapV2Twa(poolAddress: string, block: ethereum.Block): void { + const twaPrices = getTWAPrices(poolAddress, TWAType.UNISWAP, block.timestamp); + const twaResult = uniswapTwaDeltaBAndPrice(twaPrices, block.number); - setPoolTwa(poolAddress, twaResult, timestamp, blockNumber); + setPoolTwa(poolAddress, twaResult, block); } export function uniswapCumulativePrice(pool: Address, tokenIndex: u32, timestamp: BigInt): BigInt { diff --git a/projects/subgraph-bean/src/utils/price/WellPrice.ts b/projects/subgraph-bean/src/utils/price/WellPrice.ts index 5c9798b3bf..cc1ac9fa18 100644 --- a/projects/subgraph-bean/src/utils/price/WellPrice.ts +++ b/projects/subgraph-bean/src/utils/price/WellPrice.ts @@ -1,10 +1,11 @@ -import { Bytes, BigInt, Address, BigDecimal, log } from "@graphprotocol/graph-ts"; -import { getTWAPrices, loadOrCreateTwaOracle } from "./TwaOracle"; +import { Bytes, BigInt, Address, BigDecimal, ethereum, log } from "@graphprotocol/graph-ts"; +import { getTWAPrices } from "./TwaOracle"; import { ABDK_toUInt, pow2toX } from "../../../../subgraph-core/utils/ABDKMathQuad"; import { DeltaBAndPrice, TWAType } from "./Types"; import { setPoolTwa } from "../Pool"; import { constantProductPrice } from "./UniswapPrice"; -import { ONE_BI, pow, toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { ONE_BI, pow, toDecimal, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { loadOrCreateTwaOracle } from "../../entities/TwaOracle"; // Cumulative Well reserves are abi encoded as a bytes16[]. This decodes into BigInt[] in uint format export function decodeCumulativeWellReserves(data: Bytes): BigInt[] { @@ -46,11 +47,11 @@ export function wellTwaReserves(currentReserves: BigInt[], pastReserves: BigInt[ ]; } -export function setWellTwa(wellAddress: string, twaDeltaB: BigInt, timestamp: BigInt, blockNumber: BigInt): void { - const twaBalances = getTWAPrices(wellAddress, TWAType.WELL_PUMP, timestamp); +export function setWellTwa(wellAddress: string, twaDeltaB: BigInt, block: ethereum.Block): void { + const twaBalances = getTWAPrices(wellAddress, TWAType.WELL_PUMP, block.timestamp); const twaResult = wellTwaDeltaBAndPrice(twaBalances, twaDeltaB); - setPoolTwa(wellAddress, twaResult, timestamp, blockNumber); + setPoolTwa(wellAddress, twaResult, block); } function wellTwaDeltaBAndPrice(twaBalances: BigInt[], twaDeltaB: BigInt): DeltaBAndPrice { diff --git a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts index 69c6de0a98..ae465a151c 100644 --- a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts +++ b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts @@ -1,5 +1,4 @@ import { beforeEach, beforeAll, afterEach, assert, clearStore, describe, test, log } from "matchstick-as/assembly/index"; -import { loadBean } from "../src/utils/Bean"; import { BEAN_3CRV, BEAN_ERC20, @@ -10,12 +9,13 @@ import { PRICE_2_BLOCK, WETH } from "../../subgraph-core/utils/Constants"; -import { handleDewhitelistToken } from "../src/BeanstalkHandler"; import { createDewhitelistTokenEvent } from "./event-mocking/Beanstalk"; import { setMockBeanPrice } from "../../subgraph-core/tests/event-mocking/Price"; import { BigInt } from "@graphprotocol/graph-ts"; import { BI_10 } from "../../subgraph-core/utils/Decimals"; import { BeanstalkPrice_try_price, getPoolPrice } from "../src/utils/price/BeanstalkPrice"; +import { loadBean } from "../src/entities/Bean"; +import { handleDewhitelistToken } from "../src/handlers/BeanstalkHandler"; const curvePrice = BigInt.fromU32(1012000); const beanEthPrice = BigInt.fromU32(1025000); diff --git a/projects/subgraph-bean/tests/Cross.test.ts b/projects/subgraph-bean/tests/Cross.test.ts index 7581367550..063ca8e200 100644 --- a/projects/subgraph-bean/tests/Cross.test.ts +++ b/projects/subgraph-bean/tests/Cross.test.ts @@ -3,20 +3,19 @@ import { log } from "matchstick-as/assembly/log"; import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; -import { handleBlock } from "../src/BlockHandler"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { mockPreReplantETHPrice, simpleMockPrice } from "../../subgraph-core/tests/event-mocking/Price"; import { BEAN_3CRV_V1, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_CP2_WELL, BEAN_WETH_V1 } from "../../subgraph-core/utils/Constants"; import { BD_10, BigDecimal_round, ONE_BD, ONE_BI, toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { loadBean } from "../src/utils/Bean"; import { getPreReplantPriceETH, constantProductPrice, uniswapV2Reserves } from "../src/utils/price/UniswapPrice"; import { mockPoolPriceAndLiquidity, mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves } from "./entity-mocking/MockPool"; -import { updatePricesAndCheckCrosses as crv_updatePricesAndCheckCrosses } from "../src/Bean3CRVHandler_V1"; import { setWhitelistedPools } from "./entity-mocking/MockBean"; import { PEG_CROSS_BLOCKS } from "../cache-builder/results/PegCrossBlocks_eth"; import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; +import { handleBlock } from "../src/handlers/BlockHandler"; +import { loadBean } from "../src/entities/Bean"; const wellCrossId = (n: u32): string => { return BEAN_WETH_CP2_WELL.toHexString() + "-" + n.toString(); @@ -118,146 +117,6 @@ describe("Peg Crosses", () => { assert.fieldEquals("BeanCross", "1", "above", "false"); assert.fieldEquals("PoolCross", univ2CrossId(1), "above", "false"); }); - - test("UniswapV2/Bean cross above (separately)", () => { - const liquidity = BigDecimal.fromString("5000000"); - mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("0.95"), liquidity); - mockPoolPriceAndLiquidity(BEAN_3CRV_V1, BigDecimal.fromString("0.99"), liquidity, UNIV2_CROSS_BLOCK); - handleBlock(mockBlock(UNIV2_CROSS_BLOCK)); - - assert.notInStore("BeanCross", "0"); - assert.notInStore("PoolCross", univ2CrossId(0)); - assert.notInStore("PoolCross", crvV1CrossId(0)); - - mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("1.02"), liquidity); - mockPoolPriceAndLiquidity(BEAN_3CRV_V1, BigDecimal.fromString("0.9"), liquidity, UNIV2_CROSS_BLOCK); - handleBlock(mockBlock(UNIV2_CROSS_BLOCK)); - - assert.notInStore("BeanCross", "0"); - assert.fieldEquals("PoolCross", univ2CrossId(0), "above", "true"); - assert.notInStore("PoolCross", crvV1CrossId(0)); - - mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("1.06"), liquidity); - // Requires a curve swap to update since the uniswap pool already crossed. Swap content is irrelevant - // This doesnt perform the full swap logic but is sufficient - crv_updatePricesAndCheckCrosses( - BEAN_3CRV_V1.toHexString(), - BigDecimal.fromString("0.95"), - ONE_BI, - ONE_BD, - ONE_BD, - ZERO_BI, - ZERO_BI, - UNIV2_CROSS_BLOCK - ); - - assert.fieldEquals("BeanCross", "0", "above", "true"); - assert.notInStore("PoolCross", univ2CrossId(1)); - assert.notInStore("PoolCross", crvV1CrossId(0)); - assert.fieldEquals("Pool", BEAN_WETH_V1.toHexString(), "lastPrice", "1.06000000000033071999957610318464"); - }); - - test("UniswapV2/Bean cross below (separately)", () => { - const liquidity = BigDecimal.fromString("5000000"); - mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("1.05"), liquidity); - // mockPoolPriceAndLiquidity(BEAN_3CRV_V1, BigDecimal.fromString("1.01"), liquidity, UNIV2_CROSS_BLOCK); - handleBlock(mockBlock(UNIV2_CROSS_BLOCK)); - crv_updatePricesAndCheckCrosses( - BEAN_3CRV_V1.toHexString(), - BigDecimal.fromString("1.01"), - ONE_BI, - ONE_BD, - ONE_BD, - ZERO_BI, - ZERO_BI, - UNIV2_CROSS_BLOCK - ); - - assert.fieldEquals("BeanCross", "0", "above", "true"); - assert.fieldEquals("PoolCross", univ2CrossId(0), "above", "true"); - assert.fieldEquals("PoolCross", crvV1CrossId(0), "above", "true"); - - mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("0.97"), liquidity); - mockPoolPriceAndLiquidity(BEAN_3CRV_V1, BigDecimal.fromString("1.05"), liquidity, UNIV2_CROSS_BLOCK); - handleBlock(mockBlock(UNIV2_CROSS_BLOCK)); - - assert.notInStore("BeanCross", "1"); - assert.fieldEquals("PoolCross", univ2CrossId(1), "above", "false"); - assert.notInStore("PoolCross", crvV1CrossId(1)); - - mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("0.92"), liquidity); - // Requires a curve swap to update since the uniswap pool already crossed. Swap content is irrelevant - // This doesnt perform the full swap logic but is sufficient - crv_updatePricesAndCheckCrosses( - BEAN_3CRV_V1.toHexString(), - BigDecimal.fromString("1.04"), - ONE_BI, - ONE_BD, - ONE_BD, - ZERO_BI, - ZERO_BI, - UNIV2_CROSS_BLOCK - ); - - assert.fieldEquals("BeanCross", "1", "above", "false"); - assert.notInStore("PoolCross", univ2CrossId(2)); - assert.notInStore("PoolCross", crvV1CrossId(1)); - assert.fieldEquals("Pool", BEAN_WETH_V1.toHexString(), "lastPrice", "0.9200000000002796799996320850227199"); - }); - - test("Bean cross from Liquidity change", () => { - const liquidity = BigDecimal.fromString("5000000"); - const crvConstantPrice = BigDecimal.fromString("1.01"); - const crvLiquidity2 = liquidity.times(BD_10); - mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("0.95"), liquidity); - crv_updatePricesAndCheckCrosses( - BEAN_3CRV_V1.toHexString(), - crvConstantPrice, - ONE_BI, - ONE_BD, - ONE_BD, - ZERO_BI, - ZERO_BI, - UNIV2_CROSS_BLOCK - ); - handleBlock(mockBlock(UNIV2_CROSS_BLOCK)); - - assert.notInStore("BeanCross", "0"); - assert.notInStore("PoolCross", univ2CrossId(0)); - assert.fieldEquals("PoolCross", crvV1CrossId(0), "above", "true"); - - mockPoolPriceAndLiquidity(BEAN_3CRV_V1, crvConstantPrice, crvLiquidity2, UNIV2_CROSS_BLOCK); - crv_updatePricesAndCheckCrosses( - BEAN_3CRV_V1.toHexString(), - crvConstantPrice, - ONE_BI, - ONE_BD, - ONE_BD, - ZERO_BI, - ZERO_BI, - UNIV2_CROSS_BLOCK - ); - - assert.fieldEquals("BeanCross", "0", "above", "true"); - assert.notInStore("PoolCross", univ2CrossId(0)); - assert.notInStore("PoolCross", crvV1CrossId(1)); - - mockPoolPriceAndLiquidity(BEAN_3CRV_V1, crvConstantPrice, liquidity, UNIV2_CROSS_BLOCK); - crv_updatePricesAndCheckCrosses( - BEAN_3CRV_V1.toHexString(), - crvConstantPrice, - ONE_BI, - ONE_BD, - ONE_BD, - ZERO_BI, - ZERO_BI, - UNIV2_CROSS_BLOCK - ); - - assert.fieldEquals("BeanCross", "1", "above", "false"); - assert.notInStore("PoolCross", univ2CrossId(0)); - assert.notInStore("PoolCross", crvV1CrossId(1)); - }); }); describe("BEAN:ETH Well", () => { diff --git a/projects/subgraph-bean/tests/DeltaB.test.ts b/projects/subgraph-bean/tests/DeltaB.test.ts index 8f4be327ab..1e363cf504 100644 --- a/projects/subgraph-bean/tests/DeltaB.test.ts +++ b/projects/subgraph-bean/tests/DeltaB.test.ts @@ -1,7 +1,6 @@ import { beforeEach, beforeAll, afterEach, assert, clearStore, describe, test, createMockedFunction } from "matchstick-as/assembly/index"; import { BigInt, Bytes, BigDecimal, log } from "@graphprotocol/graph-ts"; // import { log } from "matchstick-as/assembly/log"; -import { handleMetapoolOracle, handleWellOracle } from "../src/BeanstalkHandler"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { createMetapoolOracleEvent, createWellOracleEvent } from "./event-mocking/Beanstalk"; import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, CRV3_POOL } from "../../subgraph-core/utils/Constants"; @@ -10,10 +9,11 @@ import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { uniswapV2DeltaB } from "../src/utils/price/UniswapPrice"; import { decodeCumulativeWellReserves } from "../src/utils/price/WellPrice"; import { mock_virtual_price } from "./event-mocking/Curve"; -import { loadOrCreatePool } from "../src/utils/Pool"; -import { loadBean } from "../src/utils/Bean"; import { getD, getY, priceFromY } from "../src/utils/price/CurvePrice"; import { pow2toX } from "../../subgraph-core/utils/ABDKMathQuad"; +import { handleMetapoolOracle, handleWellOracle } from "../src/handlers/BeanstalkHandler"; +import { loadBean } from "../src/entities/Bean"; +import { loadOrCreatePool } from "../src/entities/Pool"; const timestamp1 = BigInt.fromU32(1712793374); const hour1 = hourFromTimestamp(timestamp1).toString(); diff --git a/projects/subgraph-bean/tests/Pool.test.ts b/projects/subgraph-bean/tests/Pool.test.ts index 21e0a3684c..354bdd4e97 100644 --- a/projects/subgraph-bean/tests/Pool.test.ts +++ b/projects/subgraph-bean/tests/Pool.test.ts @@ -1,8 +1,7 @@ import { afterEach, clearStore, describe, assert, test } from "matchstick-as/assembly/index"; -import { loadOrCreateToken } from "../src/utils/Token"; import { BEAN_3CRV, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_V1, CRV3_TOKEN, WETH } from "../../subgraph-core/utils/Constants"; import { BigInt } from "@graphprotocol/graph-ts"; -import { loadOrCreatePool } from "../src/utils/Pool"; +import { loadOrCreatePool } from "../src/entities/Pool"; describe("Token", () => { afterEach(() => { diff --git a/projects/subgraph-bean/tests/Whitelist.test.ts b/projects/subgraph-bean/tests/Whitelist.test.ts index 141f2af384..c8d91a3059 100644 --- a/projects/subgraph-bean/tests/Whitelist.test.ts +++ b/projects/subgraph-bean/tests/Whitelist.test.ts @@ -1,22 +1,8 @@ -import { - beforeEach, - beforeAll, - afterEach, - assert, - clearStore, - describe, - test -} from "matchstick-as/assembly/index"; -import { loadBean } from "../src/utils/Bean"; -import { - BEAN_3CRV, - BEAN_ERC20, - BEAN_WETH_CP2_WELL, - BEAN_WETH_CP2_WELL_BLOCK -} from "../../subgraph-core/utils/Constants"; -import { handleDewhitelistToken } from "../src/BeanstalkHandler"; +import { beforeEach, beforeAll, afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; +import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, BEAN_WETH_CP2_WELL_BLOCK } from "../../subgraph-core/utils/Constants"; import { createDewhitelistTokenEvent } from "./event-mocking/Beanstalk"; import { setWhitelistedPools } from "./entity-mocking/MockBean"; +import { handleDewhitelistToken } from "../src/handlers/BeanstalkHandler"; describe("Whitelisting", () => { afterEach(() => { @@ -31,17 +17,7 @@ describe("Whitelisting", () => { event.block.number = BEAN_WETH_CP2_WELL_BLOCK; handleDewhitelistToken(event); - assert.fieldEquals( - "Bean", - BEAN_ERC20.toHexString(), - "pools", - "[" + BEAN_WETH_CP2_WELL.toHexString() + "]" - ); - assert.fieldEquals( - "Bean", - BEAN_ERC20.toHexString(), - "dewhitelistedPools", - "[" + BEAN_3CRV.toHexString() + "]" - ); + assert.fieldEquals("Bean", BEAN_ERC20.toHexString(), "pools", "[" + BEAN_WETH_CP2_WELL.toHexString() + "]"); + assert.fieldEquals("Bean", BEAN_ERC20.toHexString(), "dewhitelistedPools", "[" + BEAN_3CRV.toHexString() + "]"); }); }); diff --git a/projects/subgraph-bean/tests/entity-mocking/MockBean.ts b/projects/subgraph-bean/tests/entity-mocking/MockBean.ts index b24c0837b7..ad963d2a95 100644 --- a/projects/subgraph-bean/tests/entity-mocking/MockBean.ts +++ b/projects/subgraph-bean/tests/entity-mocking/MockBean.ts @@ -1,6 +1,5 @@ -import { BigInt, Address, BigDecimal } from "@graphprotocol/graph-ts"; import { BEAN_ERC20 } from "../../../subgraph-core/utils/Constants"; -import { loadBean } from "../../src/utils/Bean"; +import { loadBean } from "../../src/entities/Bean"; export function setWhitelistedPools(pools: string[]): void { let bean = loadBean(BEAN_ERC20.toHexString()); diff --git a/projects/subgraph-bean/tests/entity-mocking/MockPool.ts b/projects/subgraph-bean/tests/entity-mocking/MockPool.ts index 537b11280e..553e0a025a 100644 --- a/projects/subgraph-bean/tests/entity-mocking/MockPool.ts +++ b/projects/subgraph-bean/tests/entity-mocking/MockPool.ts @@ -1,7 +1,7 @@ import { BigInt, Address, BigDecimal } from "@graphprotocol/graph-ts"; -import { loadOrCreatePool } from "../../src/utils/Pool"; import { mockPreReplantBeanEthPriceAndLiquidity } from "../../../subgraph-core/tests/event-mocking/Price"; import { BEAN_WETH_V1, BEANSTALK_BLOCK } from "../../../subgraph-core/utils/Constants"; +import { loadOrCreatePool } from "../../src/entities/Pool"; export function mockPoolPriceAndLiquidity(poolAddr: Address, price: BigDecimal, liquidityUSD: BigDecimal, blockNumber: BigInt): void { let pool = loadOrCreatePool(poolAddr.toHexString(), blockNumber); diff --git a/projects/subgraph-bean/tests/l2sr.test.ts b/projects/subgraph-bean/tests/l2sr.test.ts index a31842cc21..db317eb92c 100644 --- a/projects/subgraph-bean/tests/l2sr.test.ts +++ b/projects/subgraph-bean/tests/l2sr.test.ts @@ -1,6 +1,5 @@ import { beforeEach, beforeAll, afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; import { BigInt, Bytes, BigDecimal, log } from "@graphprotocol/graph-ts"; -import { loadBean } from "../src/utils/Bean"; import { BEAN_ERC20, BEAN_WETH_CP2_WELL, @@ -17,14 +16,15 @@ import { mockSeedGaugeLockedBeans, mockSeedGaugeLockedBeansReverts } from "./call-mocking/Beanstalk"; -import { handleChop } from "../src/BeanstalkHandler"; import { mockBeanstalkEvent } from "../../subgraph-core/tests/event-mocking/Util"; import { Chop } from "../generated/Bean-ABIs/Beanstalk"; -import { loadOrCreatePool } from "../src/utils/Pool"; import { calcLockedBeans, LibLockedUnderlying_getPercentLockedUnderlying } from "../src/utils/LockedBeans"; import { mockERC20TokenSupply } from "../../subgraph-core/tests/event-mocking/Tokens"; -import { loadOrCreateTwaOracle } from "../src/utils/price/TwaOracle"; import { TwaOracle } from "../generated/schema"; +import { loadOrCreateTwaOracle } from "../src/entities/TwaOracle"; +import { loadOrCreatePool } from "../src/entities/Pool"; +import { loadBean } from "../src/entities/Bean"; +import { handleChop } from "../src/handlers/BeanstalkHandler"; const mockReserves = Bytes.fromHexString("0xabcdef"); const mockReservesTime = BigInt.fromString("123456"); From 8143641d26919942368457b46a93181b11efaf39 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 5 Sep 2024 19:04:34 -0700 Subject: [PATCH 07/88] chop converts and l2sr --- .../subgraph-bean/manifests/ethereum.yaml | 2 ++ .../src/handlers/BeanstalkHandler.ts | 10 ++++++-- .../src/utils/constants/Addresses.ts | 12 ++++++++++ .../tests/event-mocking/Beanstalk.ts | 21 ++++++++++++++++- projects/subgraph-bean/tests/l2sr.test.ts | 23 +++++++++++++++++-- 5 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 projects/subgraph-bean/src/utils/constants/Addresses.ts diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index f42e9afb87..4277071fa9 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -156,6 +156,8 @@ dataSources: handler: handleRewardMint - event: Chop(indexed address,indexed address,uint256,uint256) handler: handleChop + - event: Convert(indexed address,address,address,uint256,uint256) + handler: handleConvert file: ../src/BeanstalkHandler.ts - kind: ethereum/contract name: BeanUniswapV2Pair diff --git a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts index d95de667cc..41bee9e341 100644 --- a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts @@ -1,7 +1,7 @@ import { BigInt } from "@graphprotocol/graph-ts"; import { beanstalkPrice_updatePoolPrices } from "./BlockHandler"; import { getBeanTokenAddress, updateBeanSeason, updateBeanSupplyPegPercent, updateBeanTwa, updateBeanValues } from "../utils/Bean"; -import { Chop, DewhitelistToken, Reward, Sunrise } from "../../generated/Bean-ABIs/Beanstalk"; +import { Chop, Convert, DewhitelistToken, Reward, Sunrise } from "../../generated/Bean-ABIs/Beanstalk"; import { CurvePrice } from "../../generated/Bean-ABIs/CurvePrice"; import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../subgraph-core/utils/Constants"; import { loadOrCreatePool } from "../entities/Pool"; @@ -15,6 +15,7 @@ import { calcCurveInst, setCurveTwa } from "../utils/price/CurvePrice"; import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BIP37"; import { setRawWellReserves, setTwaLast } from "../utils/price/TwaOracle"; import { decodeCumulativeWellReserves, setWellTwa } from "../utils/price/WellPrice"; +import { isUnripe } from "../utils/constants/Addresses"; export function handleSunrise(event: Sunrise): void { // Update the season for hourly and daily liquidity metrics @@ -128,7 +129,12 @@ export function handleWellOracle(event: WellOracle): void { export function handleChop(event: Chop): void { updateBeanSupplyPegPercent(event.block.number); } -// TODO: add handler for convert-chops here as well. + +export function handleConvert(event: Convert): void { + if (isUnripe(event.params.fromToken) && !isUnripe(event.params.toToken)) { + updateBeanSupplyPegPercent(event.block.number); + } +} export function handleRewardMint(event: Reward): void { updateBeanSupplyPegPercent(event.block.number); diff --git a/projects/subgraph-bean/src/utils/constants/Addresses.ts b/projects/subgraph-bean/src/utils/constants/Addresses.ts new file mode 100644 index 0000000000..239999fdf3 --- /dev/null +++ b/projects/subgraph-bean/src/utils/constants/Addresses.ts @@ -0,0 +1,12 @@ +import { Address } from "@graphprotocol/graph-ts"; +import { UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/utils/Constants"; + +export function isUnripe(token: Address): boolean { + const unripeTokens = [UNRIPE_BEAN, UNRIPE_LP]; + for (let i = 0; i < unripeTokens.length; ++i) { + if (unripeTokens[i] == token) { + return true; + } + } + return false; +} diff --git a/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts b/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts index f4e1419ffb..73e9d306bc 100644 --- a/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts +++ b/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts @@ -1,7 +1,7 @@ import { BigInt, ethereum, Address, Bytes } from "@graphprotocol/graph-ts"; import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BIP37"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; -import { DewhitelistToken } from "../../generated/Bean-ABIs/Beanstalk"; +import { Convert, DewhitelistToken } from "../../generated/Bean-ABIs/Beanstalk"; export function createMetapoolOracleEvent( season: BigInt, @@ -61,3 +61,22 @@ export function createDewhitelistTokenEvent(token: string): DewhitelistToken { event.parameters.push(param1); return event as DewhitelistToken; } + +export function createConvertEvent(account: Address, fromToken: Address, toToken: Address, fromAmount: BigInt, toAmount: BigInt): Convert { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(account)); + let param2 = new ethereum.EventParam("fromToken", ethereum.Value.fromAddress(fromToken)); + let param3 = new ethereum.EventParam("toToken", ethereum.Value.fromAddress(toToken)); + let param4 = new ethereum.EventParam("fromAmount", ethereum.Value.fromUnsignedBigInt(fromAmount)); + let param5 = new ethereum.EventParam("toAmount", ethereum.Value.fromUnsignedBigInt(toAmount)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + + return event as Convert; +} diff --git a/projects/subgraph-bean/tests/l2sr.test.ts b/projects/subgraph-bean/tests/l2sr.test.ts index db317eb92c..193a11e624 100644 --- a/projects/subgraph-bean/tests/l2sr.test.ts +++ b/projects/subgraph-bean/tests/l2sr.test.ts @@ -1,6 +1,8 @@ import { beforeEach, beforeAll, afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; import { BigInt, Bytes, BigDecimal, log } from "@graphprotocol/graph-ts"; import { + ADDRESS_ZERO, + BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, BEAN_WETH_CP2_WELL_BLOCK, @@ -17,14 +19,15 @@ import { mockSeedGaugeLockedBeansReverts } from "./call-mocking/Beanstalk"; import { mockBeanstalkEvent } from "../../subgraph-core/tests/event-mocking/Util"; -import { Chop } from "../generated/Bean-ABIs/Beanstalk"; +import { Chop, Convert } from "../generated/Bean-ABIs/Beanstalk"; import { calcLockedBeans, LibLockedUnderlying_getPercentLockedUnderlying } from "../src/utils/LockedBeans"; import { mockERC20TokenSupply } from "../../subgraph-core/tests/event-mocking/Tokens"; import { TwaOracle } from "../generated/schema"; import { loadOrCreateTwaOracle } from "../src/entities/TwaOracle"; import { loadOrCreatePool } from "../src/entities/Pool"; import { loadBean } from "../src/entities/Bean"; -import { handleChop } from "../src/handlers/BeanstalkHandler"; +import { handleChop, handleConvert } from "../src/handlers/BeanstalkHandler"; +import { createConvertEvent } from "./event-mocking/Beanstalk"; const mockReserves = Bytes.fromHexString("0xabcdef"); const mockReservesTime = BigInt.fromString("123456"); @@ -105,6 +108,22 @@ describe("L2SR", () => { assert.fieldEquals("Bean", BEAN_ERC20.toHexString(), "supplyInPegLP", "0.5"); }); + test("Chop convert updates Locked Beans", () => { + const lockedBeans = BigInt.fromString("3000").times(BI_10.pow(6)); + let twaOracle = mockTwaOracle(); + mockSeedGaugeLockedBeans(twaOracle.cumulativeWellReserves, twaOracle.cumulativeWellReservesTime, lockedBeans); + + const event = createConvertEvent(ADDRESS_ZERO, BEAN_3CRV, BEAN_ERC20, ONE_BI, ONE_BI); + event.block.number = GAUGE_BIP45_BLOCK; + handleConvert(event); + assert.fieldEquals("Bean", BEAN_ERC20.toHexString(), "lockedBeans", "0"); + + const event2 = createConvertEvent(ADDRESS_ZERO, UNRIPE_BEAN, BEAN_ERC20, ONE_BI, ONE_BI); + event2.block.number = GAUGE_BIP45_BLOCK; + handleConvert(event2); + assert.fieldEquals("Bean", BEAN_ERC20.toHexString(), "lockedBeans", lockedBeans.toString()); + }); + // Its unclear how to mock a specific amount of locked beans. The Pre-gauge calculation is verified above // test("Locked Beans Pre-Gauge", () => { // const lockedBeans = BigInt.fromString("1000").times(BI_10.pow(6)); From e8df1f9f50fa1922f556b000dcc0d9de631ff559 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:51:33 -0700 Subject: [PATCH 08/88] entity bytes refactor and add protocol to version entity --- projects/subgraph-basin/schema.graphql | 29 ++- projects/subgraph-basin/src/utils/Init.ts | 11 +- .../subgraph-bean/manifests/codegen-abis.yaml | 2 +- .../subgraph-bean/manifests/ethereum.yaml | 190 +++++++++--------- projects/subgraph-bean/schema.graphql | 10 +- projects/subgraph-bean/src/entities/Bean.ts | 14 +- projects/subgraph-bean/src/entities/Cross.ts | 8 +- projects/subgraph-bean/src/entities/Pool.ts | 21 +- projects/subgraph-bean/src/entities/Token.ts | 3 +- .../subgraph-bean/src/entities/TwaOracle.ts | 4 +- .../subgraph-bean/src/handlers/BeanHandler.ts | 19 +- .../src/handlers/BeanWellHandler.ts | 24 +-- .../src/handlers/BeanstalkHandler.ts | 38 ++-- .../src/handlers/BlockHandler.ts | 14 +- .../LegacyBean3CRVHandler.ts} | 60 +++--- .../src/handlers/legacy/LegacyBeanHandler.ts | 9 + .../handlers/legacy/LegacyBeanstalkHandler.ts | 0 .../handlers/legacy/LegacyUniswapV2Handler.ts | 61 +++--- projects/subgraph-bean/src/utils/Bean.ts | 100 ++++----- projects/subgraph-bean/src/utils/Cross.ts | 12 +- .../subgraph-bean/src/utils/LockedBeans.ts | 9 +- projects/subgraph-bean/src/utils/Pool.ts | 19 +- projects/subgraph-bean/src/utils/Token.ts | 4 +- .../src/utils/b3-migration/BeanInit.ts | 2 +- .../src/utils/constants/Addresses.ts | 24 ++- .../src/utils/constants/PooledTokens.ts | 48 ++--- .../utils/{Init.ts => constants/Version.ts} | 17 +- .../subgraph-bean/src/utils/legacy/Bean.ts | 28 +++ .../src/utils/price/BeanstalkPrice.ts | 9 +- .../src/utils/price/CurvePrice.ts | 15 +- .../src/utils/price/TwaOracle.ts | 16 +- .../src/utils/price/UniswapPrice.ts | 2 +- .../src/utils/price/WellPrice.ts | 4 +- .../tests/BeanstalkPrice.test.ts | 9 +- projects/subgraph-bean/tests/Cross.test.ts | 13 +- projects/subgraph-bean/tests/DeltaB.test.ts | 9 +- .../subgraph-bean/tests/Migration.test.ts | 6 +- projects/subgraph-bean/tests/Pool.test.ts | 21 +- .../subgraph-bean/tests/Whitelist.test.ts | 8 +- .../tests/entity-mocking/MockBean.ts | 8 +- .../tests/entity-mocking/MockPool.ts | 4 +- .../tests/entity-mocking/MockVersion.ts | 7 + .../tests/event-mocking/Beanstalk.ts | 6 +- projects/subgraph-bean/tests/l2sr.test.ts | 12 +- projects/subgraph-beanft/schema.graphql | 2 + projects/subgraph-beanft/src/utils/Init.ts | 11 +- projects/subgraph-beanstalk/schema.graphql | 26 +-- .../src/handlers/MarketplaceHandler.ts | 15 +- projects/subgraph-beanstalk/src/utils/Init.ts | 11 +- projects/subgraph-core/utils/Bytes.ts | 22 +- 50 files changed, 550 insertions(+), 466 deletions(-) rename projects/subgraph-bean/src/handlers/{Bean3CRVHandler.ts => legacy/LegacyBean3CRVHandler.ts} (74%) create mode 100644 projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts create mode 100644 projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts rename projects/subgraph-bean/src/utils/{Init.ts => constants/Version.ts} (56%) create mode 100644 projects/subgraph-bean/src/utils/legacy/Bean.ts create mode 100644 projects/subgraph-bean/tests/entity-mocking/MockVersion.ts diff --git a/projects/subgraph-basin/schema.graphql b/projects/subgraph-basin/schema.graphql index 688f00497d..67a4123cb1 100644 --- a/projects/subgraph-basin/schema.graphql +++ b/projects/subgraph-basin/schema.graphql @@ -1,7 +1,16 @@ -# Custommized base schema from Messari -# Subgraph Schema: DEX AMM (Extended) -# Version: 3.0.3 -# See https://github.com/messari/subgraphs/blob/master/docs/Schema.md for details +# This same entity schema is intended for use across the subgraphs +type Version @entity { + "= 'subgraph'" + id: ID! + "= 'beanstalk'" + subgraphName: String! + "Verison number of the subgraph" + versionNumber: String! + "Address of Beanstalk protocol" + protocolAddress: Bytes! + "Which blockchain is being indexed, i.e. 'ethereum', 'arbitrum', etc." + chain: String! +} enum LiquidityEvent { # Additions @@ -17,18 +26,6 @@ enum SwapEvent { SHIFT } -# This same entity schema is intended for use across the subgraphs -type Version @entity { - "= 'subgraph'" - id: ID! - "= 'beanstalk'" - subgraphName: String! - "Verison number of the subgraph" - versionNumber: String! - "Which blockchain is being indexed, i.e. 'ethereum', 'arbitrum', etc." - chain: String! -} - type Token @entity { " Smart contract address of the token " id: Bytes! diff --git a/projects/subgraph-basin/src/utils/Init.ts b/projects/subgraph-basin/src/utils/Init.ts index 630642264e..87b76fa584 100644 --- a/projects/subgraph-basin/src/utils/Init.ts +++ b/projects/subgraph-basin/src/utils/Init.ts @@ -1,10 +1,12 @@ -import { BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../generated/schema"; +import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); versionEntity.versionNumber = "2.2.2"; versionEntity.subgraphName = subgraphNameForBlockNumber(block.number); + versionEntity.protocolAddress = protocolForBlockNumber(block.number); versionEntity.chain = chainForBlockNumber(block.number); versionEntity.save(); } @@ -16,6 +18,13 @@ function subgraphNameForBlockNumber(blockNumber: BigInt): string { throw new Error("Unable to initialize subgraph name for this block number"); } +function protocolForBlockNumber(blockNumber: BigInt): Address { + if (blockNumber == BigInt.fromU32(12974075)) { + return BEANSTALK; + } + throw new Error("Unable to initialize protocol address for this block number"); +} + function chainForBlockNumber(blockNumber: BigInt): string { if (blockNumber == BigInt.fromU32(17977922)) { return "ethereum"; diff --git a/projects/subgraph-bean/manifests/codegen-abis.yaml b/projects/subgraph-bean/manifests/codegen-abis.yaml index 1ab42fdf24..776757986f 100644 --- a/projects/subgraph-bean/manifests/codegen-abis.yaml +++ b/projects/subgraph-bean/manifests/codegen-abis.yaml @@ -33,7 +33,7 @@ dataSources: file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json - name: Beanstalk file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: BIP37 + - name: BasinBip file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP37.json - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 4277071fa9..8ed060c003 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -27,6 +27,9 @@ dataSources: filter: kind: once file: ../src/utils/Init.ts + ### + # BEAN TOKEN + ### - kind: ethereum/contract name: BeanV1 network: mainnet @@ -43,8 +46,6 @@ dataSources: abis: - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Beanstalk - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: @@ -67,54 +68,16 @@ dataSources: abis: - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Beanstalk - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: Transfer(indexed address,indexed address,uint256) handler: handleTransfer file: ../src/BeanHandler.ts - - kind: ethereum/contract - name: Bean3CRV - network: mainnet - source: - address: "0xc9C32cd16Bf7eFB85Ff14e0c8603cc90F6F2eE49" - abi: Bean3CRV - startBlock: 15278082 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - Bean3CRV - abis: - - name: Bean3CRV - file: ../../subgraph-core/abis/Bean3CRV.json - - name: BeanstalkPrice - file: ../../subgraph-core/abis/BeanstalkPrice.json - - name: CurvePrice - file: ../../subgraph-core/abis/CurvePrice.json - - name: ERC20 - file: ../../subgraph-core/abis/ERC20.json - - name: Beanstalk - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - eventHandlers: - - event: TokenExchange(indexed address,int128,uint256,int128,uint256) - handler: handleTokenExchange - - event: TokenExchangeUnderlying(indexed address,int128,uint256,int128,uint256) - handler: handleTokenExchangeUnderlying - - event: AddLiquidity(indexed address,uint256[2],uint256[2],uint256,uint256) - handler: handleAddLiquidity - - event: RemoveLiquidity(indexed address,uint256[2],uint256[2],uint256) - handler: handleRemoveLiquidity - - event: RemoveLiquidityImbalance(indexed address,uint256[2],uint256[2],uint256,uint256) - handler: handleRemoveLiquidityImbalance - - event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256) - handler: handleRemoveLiquidityOne - file: ../src/Bean3CRVHandler.ts + ### + # BEANSTALK PROTOCOL + ### + # TODO: refactor sunrise part to pre/post exploit - kind: ethereum/contract name: Beanstalk network: mainnet @@ -159,13 +122,45 @@ dataSources: - event: Convert(indexed address,address,address,uint256,uint256) handler: handleConvert file: ../src/BeanstalkHandler.ts + - kind: ethereum/contract + name: TWAPOracles + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: BasinBip + startBlock: 15277988 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Bean + abis: + # This abi is chosen because it contains both MetapoolOracle and WellOracle events. + # Indexing of this source should begin prior to BIP37 deployment. + - name: BasinBip + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP37.json + - name: Bean3CRV + file: ../../subgraph-core/abis/Bean3CRV.json + - name: Well + file: ../../subgraph-core/abis/Well.json + eventHandlers: + - event: MetapoolOracle(indexed uint32,int256,uint256[2]) + handler: handleMetapoolOracle + - event: WellOracle(indexed uint32,address,int256,bytes) + handler: handleWellOracle + file: ../src/handlers/BeanstalkHandler.ts + ### + # POOLS + ### - kind: ethereum/contract name: BeanUniswapV2Pair network: mainnet source: address: "0x87898263B6C5BABe34b4ec53F22d98430b91e371" - abi: UniswapV2Pair + abi: UniswapV2Pair-V1 startBlock: 12974077 + endBlock: 14602790 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -183,15 +178,11 @@ dataSources: - name: ERC20 file: ../../subgraph-core/abis/ERC20.json eventHandlers: - # - event: Burn(indexed address,uint256,uint256,indexed address) - # handler: handleBurn - # - event: Mint(indexed address,uint256,uint256) - # handler: handleMint - event: Swap(indexed address,uint256,uint256,uint256,uint256,indexed address) handler: handleSwap - event: Sync(uint112,uint112) handler: handleSync - file: ../src/UniswapV2Handler.ts + file: ../src/handlers/legacy/LegacyUniswapV2Handler.ts - kind: ethereum/contract name: Bean3CRV-V1 network: mainnet @@ -199,6 +190,7 @@ dataSources: address: "0x3a70DfA7d2262988064A2D051dd47521E43c9BdD" abi: Bean3CRV startBlock: 13954026 + endBlock: 14602790 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -227,7 +219,7 @@ dataSources: handler: handleRemoveLiquidityImbalance - event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256) handler: handleRemoveLiquidityOne - file: ../src/Bean3CRVHandler_V1.ts + file: ../src/handlers/legacy/LegacyBean3CRVHandler.ts - kind: ethereum/contract name: BeanLUSD-V1 network: mainnet @@ -235,6 +227,7 @@ dataSources: address: "0xD652c40fBb3f06d6B58Cb9aa9CFF063eE63d465D" abi: Bean3CRV startBlock: 14450075 + endBlock: 14602790 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -263,9 +256,49 @@ dataSources: handler: handleRemoveLiquidityImbalance - event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256) handler: handleRemoveLiquidityOne - file: ../src/Bean3CRVHandler_V1.ts + file: ../src/handlers/legacy/LegacyBean3CRVHandler.ts + - kind: ethereum/contract + name: Bean3CRV-V2 + network: mainnet + source: + address: "0xc9C32cd16Bf7eFB85Ff14e0c8603cc90F6F2eE49" + abi: Bean3CRV + startBlock: 15278082 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Bean3CRV + abis: + - name: Bean3CRV + file: ../../subgraph-core/abis/Bean3CRV.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: CurvePrice + file: ../../subgraph-core/abis/CurvePrice.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + - name: Beanstalk + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + eventHandlers: + - event: TokenExchange(indexed address,int128,uint256,int128,uint256) + handler: handleTokenExchange + - event: TokenExchangeUnderlying(indexed address,int128,uint256,int128,uint256) + handler: handleTokenExchangeUnderlying + - event: AddLiquidity(indexed address,uint256[2],uint256[2],uint256,uint256) + handler: handleAddLiquidity + - event: RemoveLiquidity(indexed address,uint256[2],uint256[2],uint256) + handler: handleRemoveLiquidity + - event: RemoveLiquidityImbalance(indexed address,uint256[2],uint256[2],uint256,uint256) + handler: handleRemoveLiquidityImbalance + - event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256) + handler: handleRemoveLiquidityOne + file: ../src/handlers/legacy/LegacyBean3CRVHandler.ts - kind: ethereum/contract - name: BeanWETHCP2w + name: BeanWETHCP2w-V2 network: mainnet source: address: "0xBEA0e11282e2bB5893bEcE110cF199501e872bAd" @@ -301,9 +334,9 @@ dataSources: handler: handleShift - event: Sync(uint256[],uint256,address) handler: handleSync - file: ../src/BeanWellHandler.ts + file: ../src/handlers/BeanWellHandler.ts - kind: ethereum/contract - name: BEANwstETHCP2w + name: BEANwstETHCP2w-V2 network: mainnet source: address: "0xBeA0000113B0d182f4064C86B71c315389E4715D" @@ -339,38 +372,11 @@ dataSources: handler: handleShift - event: Sync(uint256[],uint256,address) handler: handleSync - file: ../src/BeanWellHandler.ts - - kind: ethereum/contract - name: TWAPOracles - network: mainnet - source: - address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: BIP37 - startBlock: 15277988 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - BeanHourlySnapshot - - BeanDailySnapshot - - PoolHourlySnapshot - - PoolDailySnapshot - abis: - # This abi is chosen because it contains both MetapoolOracle and WellOracle events. - # Indexing of this source should begin prior to BIP37 deployment. - - name: BIP37 - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP37.json - - name: Bean3CRV - file: ../../subgraph-core/abis/Bean3CRV.json - - name: Well - file: ../../subgraph-core/abis/Well.json - eventHandlers: - - event: MetapoolOracle(indexed uint32,int256,uint256[2]) - handler: handleMetapoolOracle - - event: WellOracle(indexed uint32,address,int256,bytes) - handler: handleWellOracle - file: ../src/BeanstalkHandler.ts + file: ../src/handlers/BeanWellHandler.ts + ### + # PEG CROSS CHECK PER BLOCK + ### + # TODO: refactor this into multiple data sources - kind: ethereum/contract name: BlockHandler network: mainnet @@ -383,15 +389,7 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - Token - - Bean - - BeanHourlySnapshot - - BeanDailySnapshot - BeanCross - - PoolCross - - Pool - - PoolHourlySnapshot - - PoolDailySnapshot abis: - name: UniswapV2Pair file: ../../subgraph-core/abis/UniswapV2Pair.json @@ -399,7 +397,7 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json blockHandlers: - handler: handleBlock - file: ../src/BlockHandler.ts + file: ../src/handlers/BlockHandler.ts # features: # - grafting # graft: diff --git a/projects/subgraph-bean/schema.graphql b/projects/subgraph-bean/schema.graphql index 9392462efa..165ab638b3 100644 --- a/projects/subgraph-bean/schema.graphql +++ b/projects/subgraph-bean/schema.graphql @@ -6,13 +6,15 @@ type Version @entity { subgraphName: String! "Verison number of the subgraph" versionNumber: String! + "Address of Beanstalk protocol" + protocolAddress: Bytes! "Which blockchain is being indexed, i.e. 'ethereum', 'arbitrum', etc." chain: String! } type Token @entity { "Smart contract address of the token" - id: ID! + id: Bytes! "Name of the token, i.e. BEAN, WETH" name: String! @@ -26,7 +28,7 @@ type Token @entity { type Bean @entity { "Contract address of the Bean token" - id: ID! + id: Bytes! "Which chain this Bean is from" chain: String! @@ -207,7 +209,7 @@ type PoolCross @entity { } type Pool @entity { - id: ID! + id: Bytes! "The Bean token that is in this pool" bean: Bean! "All tokens in this pool" @@ -288,7 +290,7 @@ type PoolDailySnapshot @entity { # For tracking twa balances as the seasons progress type TwaOracle @entity { - id: ID! + id: Bytes! pool: Pool! # These two fields are used to determine twa over the previous season. # priceCumulativeSun is the value of priceCumulativeLast at the time of the previous sunrise (lastSun) diff --git a/projects/subgraph-bean/src/entities/Bean.ts b/projects/subgraph-bean/src/entities/Bean.ts index f16e171d92..9a99bfbb69 100644 --- a/projects/subgraph-bean/src/entities/Bean.ts +++ b/projects/subgraph-bean/src/entities/Bean.ts @@ -1,11 +1,11 @@ -import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; +import { BigInt, BigDecimal, Address } from "@graphprotocol/graph-ts"; import { BEAN_ERC20, BEANSTALK } from "../../../subgraph-core/utils/Constants"; import { dayFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { Bean, BeanDailySnapshot, BeanHourlySnapshot } from "../../generated/schema"; import { getV1Crosses } from "../utils/Cross"; -export function loadBean(token: string): Bean { +export function loadBean(token: Address): Bean { let bean = Bean.load(token); if (bean == null) { bean = new Bean(token); @@ -19,9 +19,9 @@ export function loadBean(token: string): Bean { bean.volumeUSD = ZERO_BD; bean.liquidityUSD = ZERO_BD; bean.price = BigDecimal.fromString("1.072"); - bean.crosses = token == BEAN_ERC20.toHexString() ? getV1Crosses() : 0; // starting point for v2 is where v1 left off + bean.crosses = token == BEAN_ERC20 ? getV1Crosses() : 0; // starting point for v2 is where v1 left off bean.lastCross = ZERO_BI; - bean.lastSeason = token == BEAN_ERC20.toHexString() ? 6074 : 0; + bean.lastSeason = token == BEAN_ERC20 ? 6074 : 0; bean.pools = []; bean.dewhitelistedPools = []; bean.save(); @@ -29,8 +29,8 @@ export function loadBean(token: string): Bean { return bean as Bean; } -export function loadOrCreateBeanHourlySnapshot(token: string, timestamp: BigInt, season: i32): BeanHourlySnapshot { - let id = token + "-" + season.toString(); +export function loadOrCreateBeanHourlySnapshot(token: Address, timestamp: BigInt, season: i32): BeanHourlySnapshot { + let id = token.toHexString() + "-" + season.toString(); let snapshot = BeanHourlySnapshot.load(id); if (snapshot == null) { let bean = loadBean(token); @@ -60,7 +60,7 @@ export function loadOrCreateBeanHourlySnapshot(token: string, timestamp: BigInt, return snapshot as BeanHourlySnapshot; } -export function loadOrCreateBeanDailySnapshot(token: string, timestamp: BigInt): BeanDailySnapshot { +export function loadOrCreateBeanDailySnapshot(token: Address, timestamp: BigInt): BeanDailySnapshot { let day = dayFromTimestamp(timestamp).toString(); let snapshot = BeanDailySnapshot.load(day); if (snapshot == null) { diff --git a/projects/subgraph-bean/src/entities/Cross.ts b/projects/subgraph-bean/src/entities/Cross.ts index f106f6afe9..7c6cfb8320 100644 --- a/projects/subgraph-bean/src/entities/Cross.ts +++ b/projects/subgraph-bean/src/entities/Cross.ts @@ -1,9 +1,9 @@ -import { ethereum } from "@graphprotocol/graph-ts"; +import { ethereum, Address } from "@graphprotocol/graph-ts"; import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { BeanCross, PoolCross } from "../../generated/schema"; -export function loadOrCreateBeanCross(id: i32, bean: string, block: ethereum.Block): BeanCross { +export function loadOrCreateBeanCross(id: i32, bean: Address, block: ethereum.Block): BeanCross { let cross = BeanCross.load(id.toString()); if (cross == null) { let hour = hourFromTimestamp(block.timestamp).toString(); @@ -22,8 +22,8 @@ export function loadOrCreateBeanCross(id: i32, bean: string, block: ethereum.Blo return cross as BeanCross; } -export function loadOrCreatePoolCross(id: i32, pool: string, block: ethereum.Block): PoolCross { - let crossID = pool + "-" + id.toString(); +export function loadOrCreatePoolCross(id: i32, pool: Address, block: ethereum.Block): PoolCross { + let crossID = pool.toHexString() + "-" + id.toString(); let cross = PoolCross.load(crossID); if (cross == null) { let hour = hourFromTimestamp(block.timestamp).toString(); diff --git a/projects/subgraph-bean/src/entities/Pool.ts b/projects/subgraph-bean/src/entities/Pool.ts index b56542e599..cbc3b57bb2 100644 --- a/projects/subgraph-bean/src/entities/Pool.ts +++ b/projects/subgraph-bean/src/entities/Pool.ts @@ -1,22 +1,23 @@ -import { BigInt, ethereum } from "@graphprotocol/graph-ts"; -import { getBeanTokenAddress } from "../utils/Bean"; +import { BigInt, Address, ethereum } from "@graphprotocol/graph-ts"; import { loadBean } from "./Bean"; import { getTokensForPool } from "../utils/constants/PooledTokens"; import { Pool, PoolDailySnapshot, PoolHourlySnapshot } from "../../generated/schema"; import { loadOrCreateToken } from "./Token"; import { emptyBigIntArray, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; +import { getProtocolToken } from "../utils/constants/Addresses"; +import { toAddress, toBytesArray } from "../../../subgraph-core/utils/Bytes"; -export function loadOrCreatePool(poolAddress: string, blockNumber: BigInt): Pool { +export function loadOrCreatePool(poolAddress: Address, blockNumber: BigInt): Pool { let pool = Pool.load(poolAddress); if (pool == null) { - let beanAddress = getBeanTokenAddress(blockNumber); + let beanAddress = getProtocolToken(blockNumber); let bean = loadBean(beanAddress); pool = new Pool(poolAddress); - pool.tokens = getTokensForPool(poolAddress); + pool.tokens = toBytesArray(getTokensForPool(poolAddress)); for (let i = 0; i < pool.tokens.length; ++i) { - loadOrCreateToken(pool.tokens[i]); + loadOrCreateToken(toAddress(pool.tokens[i])); } pool.bean = beanAddress; pool.reserves = emptyBigIntArray(2); @@ -39,9 +40,9 @@ export function loadOrCreatePool(poolAddress: string, blockNumber: BigInt): Pool return pool as Pool; } -export function loadOrCreatePoolHourlySnapshot(pool: string, block: ethereum.Block): PoolHourlySnapshot { +export function loadOrCreatePoolHourlySnapshot(pool: Address, block: ethereum.Block): PoolHourlySnapshot { let hour = hourFromTimestamp(block.timestamp).toString(); - let id = pool + "-" + hour; + let id = pool.toHexString() + "-" + hour; let snapshot = PoolHourlySnapshot.load(id); if (snapshot == null) { let currentPool = loadOrCreatePool(pool, block.number); @@ -70,10 +71,10 @@ export function loadOrCreatePoolHourlySnapshot(pool: string, block: ethereum.Blo return snapshot as PoolHourlySnapshot; } -export function loadOrCreatePoolDailySnapshot(pool: string, block: ethereum.Block): PoolDailySnapshot { +export function loadOrCreatePoolDailySnapshot(pool: Address, block: ethereum.Block): PoolDailySnapshot { let day = dayFromTimestamp(block.timestamp).toString(); - let id = pool + "-" + day; + let id = pool.toHexString() + "-" + day; let snapshot = PoolDailySnapshot.load(id); if (snapshot == null) { let currentPool = loadOrCreatePool(pool, block.number); diff --git a/projects/subgraph-bean/src/entities/Token.ts b/projects/subgraph-bean/src/entities/Token.ts index 2536c77945..05762c5e32 100644 --- a/projects/subgraph-bean/src/entities/Token.ts +++ b/projects/subgraph-bean/src/entities/Token.ts @@ -1,8 +1,9 @@ +import { Address } from "@graphprotocol/graph-ts"; import { getTokenInfo } from "../utils/constants/PooledTokens"; import { ZERO_BD } from "../../../subgraph-core/utils/Decimals"; import { Token } from "../../generated/schema"; -export function loadOrCreateToken(address: string): Token { +export function loadOrCreateToken(address: Address): Token { let token = Token.load(address); if (token == null) { const tokenInfo = getTokenInfo(address); diff --git a/projects/subgraph-bean/src/entities/TwaOracle.ts b/projects/subgraph-bean/src/entities/TwaOracle.ts index ab6f94cdbe..ffa1036599 100644 --- a/projects/subgraph-bean/src/entities/TwaOracle.ts +++ b/projects/subgraph-bean/src/entities/TwaOracle.ts @@ -1,8 +1,8 @@ -import { Bytes } from "@graphprotocol/graph-ts"; +import { Address, Bytes } from "@graphprotocol/graph-ts"; import { emptyBigIntArray, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { TwaOracle } from "../../generated/schema"; -export function loadOrCreateTwaOracle(poolAddress: string): TwaOracle { +export function loadOrCreateTwaOracle(poolAddress: Address): TwaOracle { let twaOracle = TwaOracle.load(poolAddress); if (twaOracle == null) { twaOracle = new TwaOracle(poolAddress); diff --git a/projects/subgraph-bean/src/handlers/BeanHandler.ts b/projects/subgraph-bean/src/handlers/BeanHandler.ts index 15ec6cfb72..eea762fb60 100644 --- a/projects/subgraph-bean/src/handlers/BeanHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanHandler.ts @@ -1,23 +1,10 @@ import { ADDRESS_ZERO, BEAN_ERC20_V1 } from "../../../subgraph-core/utils/Constants"; import { Transfer } from "../../generated/Bean-ABIs/ERC20"; -import { loadBean } from "../entities/Bean"; -import { updateBeanSupplyPegPercent } from "../utils/Bean"; +import { adjustSupply, updateBeanSupplyPegPercent } from "../utils/Bean"; export function handleTransfer(event: Transfer): void { if (event.params.from == ADDRESS_ZERO || event.params.to == ADDRESS_ZERO) { - let bean = loadBean(event.address.toHexString()); - - if (event.params.from == ADDRESS_ZERO) { - // Minted - bean.supply = bean.supply.plus(event.params.value); - } else { - // Burned - bean.supply = bean.supply.minus(event.params.value); - } - bean.save(); - - if (event.address != BEAN_ERC20_V1) { - updateBeanSupplyPegPercent(event.block.number); - } + adjustSupply(event.address, event.params.from == ADDRESS_ZERO ? event.params.value : event.params.value.neg()); + updateBeanSupplyPegPercent(event.address, event.block.number); } } diff --git a/projects/subgraph-bean/src/handlers/BeanWellHandler.ts b/projects/subgraph-bean/src/handlers/BeanWellHandler.ts index 276aaeb6fc..7901fcd6f8 100644 --- a/projects/subgraph-bean/src/handlers/BeanWellHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanWellHandler.ts @@ -8,16 +8,16 @@ import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues import { updateBeanAfterPoolSwap } from "../utils/Bean"; export function handleAddLiquidity(event: AddLiquidity): void { - handleLiquidityChange(event.address.toHexString(), event.params.tokenAmountsIn[0], event.params.tokenAmountsIn[1], false, event.block); + handleLiquidityChange(event.address, event.params.tokenAmountsIn[0], event.params.tokenAmountsIn[1], false, event.block); } export function handleRemoveLiquidity(event: RemoveLiquidity): void { - handleLiquidityChange(event.address.toHexString(), event.params.tokenAmountsOut[0], event.params.tokenAmountsOut[1], true, event.block); + handleLiquidityChange(event.address, event.params.tokenAmountsOut[0], event.params.tokenAmountsOut[1], true, event.block); } export function handleRemoveLiquidityOneToken(event: RemoveLiquidityOneToken): void { handleLiquidityChange( - event.address.toHexString(), + event.address, event.params.tokenOut == BEAN_ERC20 ? event.params.tokenAmountOut : ZERO_BI, event.params.tokenOut != BEAN_ERC20 ? event.params.tokenAmountOut : ZERO_BI, true, @@ -26,24 +26,24 @@ export function handleRemoveLiquidityOneToken(event: RemoveLiquidityOneToken): v } export function handleSync(event: Sync): void { - let pool = loadOrCreatePool(event.address.toHexString(), event.block.number); + let pool = loadOrCreatePool(event.address, event.block.number); let deltaReserves = deltaBigIntArray(event.params.reserves, pool.reserves); - handleLiquidityChange(event.address.toHexString(), deltaReserves[0], deltaReserves[1], false, event.block); + handleLiquidityChange(event.address, deltaReserves[0], deltaReserves[1], false, event.block); } export function handleSwap(event: Swap): void { - handleSwapEvent(event.address.toHexString(), event.params.toToken, event.params.amountIn, event.params.amountOut, event.block); + handleSwapEvent(event.address, event.params.toToken, event.params.amountIn, event.params.amountOut, event.block); } export function handleShift(event: Shift): void { - let pool = loadOrCreatePool(event.address.toHexString(), event.block.number); + let pool = loadOrCreatePool(event.address, event.block.number); let deltaReserves = deltaBigIntArray(event.params.reserves, pool.reserves); handleSwapEvent( - event.address.toHexString(), + event.address, event.params.toToken, event.params.toToken == BEAN_ERC20 ? deltaReserves[1] : deltaReserves[0], event.params.amountOut, @@ -52,7 +52,7 @@ export function handleShift(event: Shift): void { } function handleLiquidityChange( - poolAddress: string, + poolAddress: Address, token0Amount: BigInt, token1Amount: BigInt, removal: boolean, @@ -63,7 +63,7 @@ function handleLiquidityChange( if (beanPrice.reverted) { return; } - let wellPrice = getPoolPrice(beanPrice, Address.fromString(poolAddress)); + let wellPrice = getPoolPrice(beanPrice, poolAddress); if (wellPrice == null) { return; } @@ -100,13 +100,13 @@ function handleLiquidityChange( updateBeanAfterPoolSwap(poolAddress, toDecimal(wellPrice.price), volumeBean, volumeUSD, deltaLiquidityUSD, block, beanPrice); } -function handleSwapEvent(poolAddress: string, toToken: Address, amountIn: BigInt, amountOut: BigInt, block: ethereum.Block): void { +function handleSwapEvent(poolAddress: Address, toToken: Address, amountIn: BigInt, amountOut: BigInt, block: ethereum.Block): void { // Get Price Details via Price contract let beanPrice = BeanstalkPrice_try_price(BEAN_ERC20, block.number); if (beanPrice.reverted) { return; } - let wellPrice = getPoolPrice(beanPrice, Address.fromString(poolAddress)); + let wellPrice = getPoolPrice(beanPrice, poolAddress); if (wellPrice == null) { return; } diff --git a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts index 41bee9e341..0099b2c9e3 100644 --- a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts @@ -1,6 +1,6 @@ import { BigInt } from "@graphprotocol/graph-ts"; import { beanstalkPrice_updatePoolPrices } from "./BlockHandler"; -import { getBeanTokenAddress, updateBeanSeason, updateBeanSupplyPegPercent, updateBeanTwa, updateBeanValues } from "../utils/Bean"; +import { updateBeanSeason, updateBeanSupplyPegPercent, updateBeanTwa, updateBeanValues } from "../utils/Bean"; import { Chop, Convert, DewhitelistToken, Reward, Sunrise } from "../../generated/Bean-ABIs/Beanstalk"; import { CurvePrice } from "../../generated/Bean-ABIs/CurvePrice"; import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../subgraph-core/utils/Constants"; @@ -12,15 +12,15 @@ import { checkBeanCross } from "../utils/Cross"; import { DeltaBPriceLiquidity } from "../utils/price/Types"; import { calcUniswapV2Inst, setUniswapV2Twa } from "../utils/price/UniswapPrice"; import { calcCurveInst, setCurveTwa } from "../utils/price/CurvePrice"; -import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BIP37"; +import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BasinBip"; import { setRawWellReserves, setTwaLast } from "../utils/price/TwaOracle"; import { decodeCumulativeWellReserves, setWellTwa } from "../utils/price/WellPrice"; -import { isUnripe } from "../utils/constants/Addresses"; +import { getProtocolToken, isUnripe } from "../utils/constants/Addresses"; export function handleSunrise(event: Sunrise): void { // Update the season for hourly and daily liquidity metrics - let beanToken = getBeanTokenAddress(event.block.number); + let beanToken = getProtocolToken(event.block.number); updateBeanSeason(beanToken, event.block.timestamp, event.params.season.toI32()); @@ -44,19 +44,19 @@ export function handleSunrise(event: Sunrise): void { // Pre Basin deployment - Use original Curve price contract to update on each season. let curvePrice = CurvePrice.bind(CURVE_PRICE); let curve = curvePrice.try_getCurve(); - let beanCurve = loadOrCreatePool(BEAN_3CRV.toHexString(), event.block.number); + let beanCurve = loadOrCreatePool(BEAN_3CRV, event.block.number); if (!curve.reverted) { updateBeanValues(beanToken, toDecimal(curve.value.price), ZERO_BI, ZERO_BI, ZERO_BD, ZERO_BD, event.block); updatePoolValues( - BEAN_3CRV.toHexString(), + BEAN_3CRV, ZERO_BI, ZERO_BD, toDecimal(curve.value.liquidity).minus(beanCurve.liquidityUSD), curve.value.deltaB, event.block ); - updatePoolPrice(BEAN_3CRV.toHexString(), toDecimal(curve.value.price), event.block); + updatePoolPrice(BEAN_3CRV, toDecimal(curve.value.price), event.block); checkBeanCross(beanToken, oldBeanPrice, toDecimal(curve.value.price), event.block); } } @@ -68,7 +68,7 @@ export function handleSunrise(event: Sunrise): void { for (let i = 0; i < bean.pools.length; i++) { const pool = loadOrCreatePool(bean.pools[i], event.block.number); let inst: DeltaBPriceLiquidity; - if (bean.pools[i] == BEAN_WETH_V1.toHexString()) { + if (bean.pools[i] == BEAN_WETH_V1) { inst = calcUniswapV2Inst(pool); setUniswapV2Twa(bean.pools[i], event.block); } else { @@ -93,8 +93,9 @@ export function handleSunrise(event: Sunrise): void { // Assumption is that the whitelisted token corresponds to a pool lp. If not, this method will simply do nothing. export function handleDewhitelistToken(event: DewhitelistToken): void { - let bean = loadBean(getBeanTokenAddress(event.block.number)); - let index = bean.pools.indexOf(event.params.token.toHexString()); + let beanToken = getProtocolToken(event.block.number); + let bean = loadBean(beanToken); + let index = bean.pools.indexOf(event.params.token); if (index >= 0) { const newPools = bean.pools; const newDewhitelistedPools = bean.dewhitelistedPools; @@ -108,15 +109,15 @@ export function handleDewhitelistToken(event: DewhitelistToken): void { // POST REPLANT TWA DELTAB // export function handleMetapoolOracle(event: MetapoolOracle): void { - setTwaLast(BEAN_3CRV.toHexString(), event.params.balances, event.block.timestamp); - setCurveTwa(BEAN_3CRV.toHexString(), event.block); + setTwaLast(BEAN_3CRV, event.params.balances, event.block.timestamp); + setCurveTwa(BEAN_3CRV, event.block); updateBeanTwa(event.block); } export function handleWellOracle(event: WellOracle): void { setRawWellReserves(event); - setTwaLast(event.params.well.toHexString(), decodeCumulativeWellReserves(event.params.cumulativeReserves), event.block.timestamp); - setWellTwa(event.params.well.toHexString(), event.params.deltaB, event.block); + setTwaLast(event.params.well, decodeCumulativeWellReserves(event.params.cumulativeReserves), event.block.timestamp); + setWellTwa(event.params.well, event.params.deltaB, event.block); updateBeanTwa(event.block); } @@ -127,15 +128,18 @@ export function handleWellOracle(event: WellOracle): void { // The result of fertilizer purchases will be included by the AddLiquidity event export function handleChop(event: Chop): void { - updateBeanSupplyPegPercent(event.block.number); + let beanToken = getProtocolToken(event.block.number); + updateBeanSupplyPegPercent(beanToken, event.block.number); } export function handleConvert(event: Convert): void { if (isUnripe(event.params.fromToken) && !isUnripe(event.params.toToken)) { - updateBeanSupplyPegPercent(event.block.number); + let beanToken = getProtocolToken(event.block.number); + updateBeanSupplyPegPercent(beanToken, event.block.number); } } export function handleRewardMint(event: Reward): void { - updateBeanSupplyPegPercent(event.block.number); + let beanToken = getProtocolToken(event.block.number); + updateBeanSupplyPegPercent(beanToken, event.block.number); } diff --git a/projects/subgraph-bean/src/handlers/BlockHandler.ts b/projects/subgraph-bean/src/handlers/BlockHandler.ts index c7260306eb..8ff8dbb992 100644 --- a/projects/subgraph-bean/src/handlers/BlockHandler.ts +++ b/projects/subgraph-bean/src/handlers/BlockHandler.ts @@ -36,38 +36,38 @@ export function beanstalkPrice_updatePoolPrices(priceOnlyOnCross: boolean, block // Price contract was unavailable briefly after well deployment return false; } - const bean = loadBean(BEAN_ERC20.toHexString()); + const bean = loadBean(BEAN_ERC20); const prevPrice = bean.price; const newPrice = toDecimal(priceResult.value.price); // Check for overall peg cross - const beanCrossed = checkBeanCross(BEAN_ERC20.toHexString(), prevPrice, newPrice, block); + const beanCrossed = checkBeanCross(BEAN_ERC20, prevPrice, newPrice, block); // Update pool price for each pool - necessary for checking pool cross let totalLiquidity = ZERO_BD; for (let i = 0; i < priceResult.value.ps.length; ++i) { const poolPriceInfo = priceResult.value.ps[i]; - const pool = loadOrCreatePool(poolPriceInfo.pool.toHexString(), block.number); + const pool = loadOrCreatePool(poolPriceInfo.pool, block.number); - const poolCrossed = checkPoolCross(poolPriceInfo.pool.toHexString(), pool.lastPrice, toDecimal(poolPriceInfo.price), block); + const poolCrossed = checkPoolCross(poolPriceInfo.pool, pool.lastPrice, toDecimal(poolPriceInfo.price), block); if (!priceOnlyOnCross || poolCrossed || beanCrossed) { totalLiquidity = totalLiquidity.plus(toDecimal(poolPriceInfo.liquidity)); updatePoolValues( - poolPriceInfo.pool.toHexString(), + poolPriceInfo.pool, ZERO_BI, ZERO_BD, toDecimal(poolPriceInfo.liquidity).minus(pool.liquidityUSD), poolPriceInfo.deltaB, block ); - updatePoolPrice(poolPriceInfo.pool.toHexString(), toDecimal(poolPriceInfo.price), block, false); + updatePoolPrice(poolPriceInfo.pool, toDecimal(poolPriceInfo.price), block, false); } } // Update bean values at the end now that the summation of pool liquidity is known if (!priceOnlyOnCross || beanCrossed) { - updateBeanValues(BEAN_ERC20.toHexString(), newPrice, ZERO_BI, ZERO_BI, ZERO_BD, totalLiquidity.minus(bean.liquidityUSD), block); + updateBeanValues(BEAN_ERC20, newPrice, ZERO_BI, ZERO_BI, ZERO_BD, totalLiquidity.minus(bean.liquidityUSD), block); } return true; } diff --git a/projects/subgraph-bean/src/handlers/Bean3CRVHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts similarity index 74% rename from projects/subgraph-bean/src/handlers/Bean3CRVHandler.ts rename to projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts index a0cc8ff575..570dbe13d8 100644 --- a/projects/subgraph-bean/src/handlers/Bean3CRVHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts @@ -7,20 +7,20 @@ import { RemoveLiquidityOne, TokenExchange, TokenExchangeUnderlying -} from "../../generated/Bean-ABIs/Bean3CRV"; -import { updateBeanAfterPoolSwap } from "../utils/Bean"; -import { BEAN_3CRV_V1, BEAN_ERC20_V1, BEAN_LUSD_V1, CURVE_PRICE } from "../../../subgraph-core/utils/Constants"; -import { curveDeltaBUsingVPrice, curvePriceAndLp } from "../utils/price/CurvePrice"; -import { loadOrCreatePool } from "../entities/Pool"; -import { ERC20 } from "../../generated/Bean-ABIs/ERC20"; -import { manualTwa } from "../utils/price/TwaOracle"; -import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues } from "../utils/Pool"; -import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { CurvePrice } from "../../generated/Bean-ABIs/CurvePrice"; +} from "../../../generated/Bean-ABIs/Bean3CRV"; +import { updateBeanAfterPoolSwap } from "../../utils/Bean"; +import { BEAN_3CRV_V1, BEAN_ERC20_V1, BEAN_LUSD_V1, CURVE_PRICE } from "../../../../subgraph-core/utils/Constants"; +import { curveDeltaBUsingVPrice, curvePriceAndLp } from "../../utils/price/CurvePrice"; +import { loadOrCreatePool } from "../../entities/Pool"; +import { ERC20 } from "../../../generated/Bean-ABIs/ERC20"; +import { manualTwa } from "../../utils/price/TwaOracle"; +import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues } from "../../utils/Pool"; +import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { CurvePrice } from "../../../generated/Bean-ABIs/CurvePrice"; export function handleTokenExchange(event: TokenExchange): void { handleSwap( - event.address.toHexString(), + event.address, event.params.sold_id, event.params.tokens_sold, event.params.bought_id, @@ -31,7 +31,7 @@ export function handleTokenExchange(event: TokenExchange): void { export function handleTokenExchangeUnderlying(event: TokenExchangeUnderlying): void { handleSwap( - event.address.toHexString(), + event.address, event.params.sold_id, event.params.tokens_sold, event.params.bought_id, @@ -41,58 +41,46 @@ export function handleTokenExchangeUnderlying(event: TokenExchangeUnderlying): v } export function handleAddLiquidity(event: AddLiquidity): void { - handleLiquidityChange( - event.address.toHexString(), - event.params.token_amounts[0] !== ZERO_BI && event.params.token_amounts[1] !== ZERO_BI, - event.block - ); + handleLiquidityChange(event.address, event.params.token_amounts[0] !== ZERO_BI && event.params.token_amounts[1] !== ZERO_BI, event.block); } export function handleRemoveLiquidity(event: RemoveLiquidity): void { - handleLiquidityChange( - event.address.toHexString(), - event.params.token_amounts[0] !== ZERO_BI && event.params.token_amounts[1] !== ZERO_BI, - event.block - ); + handleLiquidityChange(event.address, event.params.token_amounts[0] !== ZERO_BI && event.params.token_amounts[1] !== ZERO_BI, event.block); } export function handleRemoveLiquidityImbalance(event: RemoveLiquidityImbalance): void { - handleLiquidityChange( - event.address.toHexString(), - event.params.token_amounts[0] !== ZERO_BI && event.params.token_amounts[1] !== ZERO_BI, - event.block - ); + handleLiquidityChange(event.address, event.params.token_amounts[0] !== ZERO_BI && event.params.token_amounts[1] !== ZERO_BI, event.block); } export function handleRemoveLiquidityOne(event: RemoveLiquidityOne): void { - handleLiquidityChange(event.address.toHexString(), false, event.block); + handleLiquidityChange(event.address, false, event.block); } -function handleLiquidityChange(poolAddress: string, isBoth: boolean, block: ethereum.Block): void { +function handleLiquidityChange(poolAddress: Address, isBoth: boolean, block: ethereum.Block): void { // TODO: refactor this part out from liquidity and swap let deltaB; let newPoolPrice; let reserveBalances; let deltaLiquidityUSD; - if (poolAddress === BEAN_3CRV_V1.toHexString()) { + if (poolAddress === BEAN_3CRV_V1) { let pool = loadOrCreatePool(poolAddress, block.number); - let priceAndLp = curvePriceAndLp(Address.fromString(poolAddress)); + let priceAndLp = curvePriceAndLp(poolAddress); let newPoolPrice = priceAndLp[0]; let lpValue = priceAndLp[1]; let beanContract = ERC20.bind(BEAN_ERC20_V1); - let beanHolding = toDecimal(beanContract.balanceOf(Address.fromString(poolAddress))); + let beanHolding = toDecimal(beanContract.balanceOf(poolAddress)); let beanValue = beanHolding.times(newPoolPrice); let liquidityUSD = beanValue.plus(lpValue); deltaLiquidityUSD = liquidityUSD.minus(pool.liquidityUSD); - let lpContract = Bean3CRV.bind(Address.fromString(poolAddress)); + let lpContract = Bean3CRV.bind(poolAddress); reserveBalances = lpContract.get_balances(); - deltaB = curveDeltaBUsingVPrice(Address.fromString(poolAddress), reserveBalances[0]); + deltaB = curveDeltaBUsingVPrice(poolAddress, reserveBalances[0]); - if (poolAddress == BEAN_LUSD_V1.toHexString()) { + if (poolAddress == BEAN_LUSD_V1) { manualTwa(poolAddress, reserveBalances, block.timestamp); } } else { @@ -132,7 +120,7 @@ function handleLiquidityChange(poolAddress: string, isBoth: boolean, block: ethe } function handleSwap( - poolAddress: string, + poolAddress: Address, sold_id: BigInt, tokens_sold: BigInt, bought_id: BigInt, diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts new file mode 100644 index 0000000000..b0485fd80e --- /dev/null +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts @@ -0,0 +1,9 @@ +import { ADDRESS_ZERO } from "../../../../subgraph-core/utils/Constants"; +import { Transfer } from "../../../generated/Bean-ABIs/ERC20"; +import { adjustSupply } from "../../utils/Bean"; + +export function handleTransfer_v1(event: Transfer): void { + if (event.params.from == ADDRESS_ZERO || event.params.to == ADDRESS_ZERO) { + adjustSupply(event.address, event.params.from == ADDRESS_ZERO ? event.params.value : event.params.value.neg()); + } +} diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts index a203def44f..cdba233bf3 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts @@ -9,38 +9,27 @@ import { setPoolReserves, updatePoolPrice, updatePoolValues } from "../../utils/ import { calcUniswapV2Inst_2, getPreReplantPriceETH, updatePreReplantPriceETH } from "../../utils/price/UniswapPrice"; import { checkBeanCross, checkPoolCross } from "../../utils/Cross"; import { updateTokenPrice } from "../../utils/Token"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; // Reserves/price already updated by Sync event. Sync event is always emitted prior to a swap. // Just update the volume for usd/bean export function handleSwap(event: Swap): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - let weth = loadOrCreateToken(WETH.toHexString()); + let weth = loadOrCreateToken(WETH); let usdVolume = toDecimal(event.params.amount0In.plus(event.params.amount0Out), 18).times(weth.lastPriceUSD); - let pool = loadOrCreatePool(event.address.toHexString(), event.block.number); - updatePoolValues( - event.address.toHexString(), - event.params.amount1In.plus(event.params.amount1Out), - usdVolume, - ZERO_BD, - pool.deltaBeans, - event.block - ); - - updateBeanValues(pool.bean, null, ZERO_BI, ZERO_BI, usdVolume, ZERO_BD, event.block); + let pool = loadOrCreatePool(event.address, event.block.number); + updatePoolValues(event.address, event.params.amount1In.plus(event.params.amount1Out), usdVolume, ZERO_BD, pool.deltaBeans, event.block); + + updateBeanValues(toAddress(pool.bean), null, ZERO_BI, ZERO_BI, usdVolume, ZERO_BD, event.block); } // Sync is called in UniswapV2 on any liquidity or swap transaction. // It updates the `reserves` value on the contract. export function handleSync(event: Sync): void { - // Do not index post-exploit data - if (event.block.number >= BigInt.fromI32(14602790)) return; - - let pool = loadOrCreatePool(event.address.toHexString(), event.block.number); - const oldBeanPrice = getLastBeanPrice(pool.bean); + let pool = loadOrCreatePool(event.address, event.block.number); + const beanAddress = toAddress(pool.bean); + const oldBeanPrice = getLastBeanPrice(beanAddress); // Token 0 is WETH and Token 1 is BEAN let reserves = [event.params.reserve0, event.params.reserve1]; @@ -51,32 +40,32 @@ export function handleSync(event: Sync): void { let deltaLiquidityUSD = newPoolPrices.liquidity.minus(pool.liquidityUSD); - setPoolReserves(event.address.toHexString(), reserves, event.block); - updatePoolValues(event.address.toHexString(), ZERO_BI, ZERO_BD, deltaLiquidityUSD, newPoolPrices.deltaB, event.block); - updatePoolPrice(event.address.toHexString(), newPoolPrices.price, event.block); + setPoolReserves(event.address, reserves, event.block); + updatePoolValues(event.address, ZERO_BI, ZERO_BD, deltaLiquidityUSD, newPoolPrices.deltaB, event.block); + updatePoolPrice(event.address, newPoolPrices.price, event.block); - updateBeanSupplyPegPercent(event.block.number); + updateBeanSupplyPegPercent(beanAddress, event.block.number); - const newBeanPrice = calcLiquidityWeightedBeanPrice(pool.bean); - checkBeanCross(pool.bean, oldBeanPrice, newBeanPrice, event.block); - updateBeanValues(pool.bean, newBeanPrice, ZERO_BI, ZERO_BI, ZERO_BD, deltaLiquidityUSD, event.block); + const newBeanPrice = calcLiquidityWeightedBeanPrice(beanAddress); + checkBeanCross(beanAddress, oldBeanPrice, newBeanPrice, event.block); + updateBeanValues(beanAddress, newBeanPrice, ZERO_BI, ZERO_BI, ZERO_BD, deltaLiquidityUSD, event.block); } // Update pool price/liquidity/deltaB. This is for updating the price when a swap occurs in another pool. // The caller is expected to update overall bean prices after this function completes. export function externalUpdatePoolPrice(poolAddr: Address, block: ethereum.Block): void { - const pool = loadOrCreatePool(poolAddr.toHexString(), block.number); + const pool = loadOrCreatePool(poolAddr, block.number); const ethPrice = updatePreReplantPriceETH(); const newPoolPrices = calcUniswapV2Inst_2(toDecimal(pool.reserves[1]), toDecimal(pool.reserves[0], 18), ethPrice); const deltaLiquidityUSD = newPoolPrices.liquidity.minus(pool.liquidityUSD); - updatePoolValues(poolAddr.toHexString(), ZERO_BI, ZERO_BD, deltaLiquidityUSD, newPoolPrices.deltaB, block); - updatePoolPrice(poolAddr.toHexString(), newPoolPrices.price, block); + updatePoolValues(poolAddr, ZERO_BI, ZERO_BD, deltaLiquidityUSD, newPoolPrices.deltaB, block); + updatePoolPrice(poolAddr, newPoolPrices.price, block); } export function checkPegCrossEth(block: ethereum.Block): void { - const poolAddrString = BEAN_WETH_V1.toHexString(); + const poolAddrString = BEAN_WETH_V1; const pool = loadOrCreatePool(poolAddrString, block.number); const prevPoolPrice = pool.lastPrice; @@ -99,12 +88,12 @@ export function checkPegCrossEth(block: ethereum.Block): void { } // Check for overall Bean cross - const oldBeanPrice = getLastBeanPrice(BEAN_ERC20_V1.toHexString()); - const newBeanPrice = calcLiquidityWeightedBeanPrice(BEAN_ERC20_V1.toHexString()); - const beanCrossed = checkBeanCross(BEAN_ERC20_V1.toHexString(), oldBeanPrice, newBeanPrice, block); + const oldBeanPrice = getLastBeanPrice(BEAN_ERC20_V1); + const newBeanPrice = calcLiquidityWeightedBeanPrice(BEAN_ERC20_V1); + const beanCrossed = checkBeanCross(BEAN_ERC20_V1, oldBeanPrice, newBeanPrice, block); if (beanCrossed) { updateBeanValues( - pool.bean, + toAddress(pool.bean), newBeanPrice, ZERO_BI, ZERO_BI, @@ -115,6 +104,6 @@ export function checkPegCrossEth(block: ethereum.Block): void { } if (poolCrossed || beanCrossed) { - updateTokenPrice(WETH.toHexString(), ethPrice); + updateTokenPrice(WETH, ethPrice); } } diff --git a/projects/subgraph-bean/src/utils/Bean.ts b/projects/subgraph-bean/src/utils/Bean.ts index c45875c26f..9f8abccff4 100644 --- a/projects/subgraph-bean/src/utils/Bean.ts +++ b/projects/subgraph-bean/src/utils/Bean.ts @@ -1,13 +1,6 @@ import { BigDecimal, BigInt, ethereum, Address } from "@graphprotocol/graph-ts"; import { Pool } from "../../generated/schema"; -import { - BEAN_ERC20_V1, - BEAN_ERC20, - BEAN_WETH_V1, - BEAN_3CRV_V1, - BEAN_LUSD_V1, - NEW_BEAN_TOKEN_BLOCK -} from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20_V1, BEAN_WETH_V1 } from "../../../subgraph-core/utils/Constants"; import { ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { checkBeanCross } from "./Cross"; import { BeanstalkPrice_try_price, BeanstalkPriceResult } from "./price/BeanstalkPrice"; @@ -15,9 +8,18 @@ import { calcLockedBeans } from "./LockedBeans"; import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../entities/Bean"; import { loadOrCreatePool, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; import { externalUpdatePoolPrice as univ2_externalUpdatePoolPrice } from "../handlers/legacy/LegacyUniswapV2Handler"; +import { updateBeanSupplyPegPercent_v1 } from "./legacy/Bean"; +import { getProtocolToken } from "./constants/Addresses"; +import { toAddress } from "../../../subgraph-core/utils/Bytes"; + +export function adjustSupply(beanToken: Address, amount: BigInt): void { + let bean = loadBean(beanToken); + bean.supply = bean.supply.plus(amount); + bean.save(); +} export function updateBeanValues( - token: string, + token: Address, newPrice: BigDecimal | null, deltaSupply: BigInt, deltaVolume: BigInt, @@ -64,7 +66,7 @@ export function updateBeanValues( beanDaily.save(); } -export function updateBeanSeason(token: string, timestamp: BigInt, season: i32): void { +export function updateBeanSeason(token: Address, timestamp: BigInt, season: i32): void { let bean = loadBean(token); bean.lastSeason = season; bean.save(); @@ -80,13 +82,13 @@ export function updateBeanSeason(token: string, timestamp: BigInt, season: i32): } // Returns the last stored bean price -export function getLastBeanPrice(token: string): BigDecimal { +export function getLastBeanPrice(token: Address): BigDecimal { let bean = loadBean(token); return bean.price; } // Returns the liquidity-weighted bean price across all of the whitelisted pools. -export function calcLiquidityWeightedBeanPrice(token: string): BigDecimal { +export function calcLiquidityWeightedBeanPrice(token: Address): BigDecimal { let bean = loadBean(token); let weightedPrice = ZERO_BD; let totalLiquidity = ZERO_BD; @@ -99,49 +101,26 @@ export function calcLiquidityWeightedBeanPrice(token: string): BigDecimal { return weightedPrice.div(totalLiquidity == ZERO_BD ? ONE_BD : totalLiquidity); } -export function getBeanTokenAddress(blockNumber: BigInt): string { - return blockNumber < NEW_BEAN_TOKEN_BLOCK ? BEAN_ERC20_V1.toHexString() : BEAN_ERC20.toHexString(); -} - -export function updateBeanSupplyPegPercent(blockNumber: BigInt): void { - if (blockNumber < NEW_BEAN_TOKEN_BLOCK) { - let bean = loadBean(BEAN_ERC20_V1.toHexString()); - let lpSupply = ZERO_BD; - - let pool = Pool.load(BEAN_WETH_V1.toHexString()); - if (pool != null) { - lpSupply = lpSupply.plus(toDecimal(pool.reserves[1])); - } - - pool = Pool.load(BEAN_3CRV_V1.toHexString()); - if (pool != null) { - lpSupply = lpSupply.plus(toDecimal(pool.reserves[0])); - } - - pool = Pool.load(BEAN_LUSD_V1.toHexString()); - if (pool != null) { - lpSupply = lpSupply.plus(toDecimal(pool.reserves[0])); - } - - bean.supplyInPegLP = lpSupply.div(toDecimal(bean.supply)); - bean.save(); - } else { - let bean = loadBean(BEAN_ERC20.toHexString()); - let pegSupply = ZERO_BI; - for (let i = 0; i < bean.pools.length; ++i) { - let pool = loadOrCreatePool(bean.pools[i], blockNumber); - // Assumption that beans is in the 0 index for all pools, this may need to be revisited. - pegSupply = pegSupply.plus(pool.reserves[0]); - } - bean.lockedBeans = calcLockedBeans(blockNumber); - bean.supplyInPegLP = toDecimal(pegSupply).div(toDecimal(bean.supply.minus(bean.lockedBeans))); - bean.save(); +export function updateBeanSupplyPegPercent(beanToken: Address, blockNumber: BigInt): void { + if (beanToken === BEAN_ERC20_V1) { + updateBeanSupplyPegPercent_v1(beanToken, blockNumber); + return; + } + let bean = loadBean(beanToken); + let pegSupply = ZERO_BI; + for (let i = 0; i < bean.pools.length; ++i) { + let pool = loadOrCreatePool(toAddress(bean.pools[i]), blockNumber); + // Assumption that beans is in the 0 index for all pools, this may need to be revisited. + pegSupply = pegSupply.plus(pool.reserves[0]); } + bean.lockedBeans = calcLockedBeans(blockNumber); + bean.supplyInPegLP = toDecimal(pegSupply).div(toDecimal(bean.supply.minus(bean.lockedBeans))); + bean.save(); } // Update bean information if the pool is still whitelisted export function updateBeanAfterPoolSwap( - poolAddress: string, + poolAddress: Address, poolPrice: BigDecimal, volumeBean: BigInt, volumeUSD: BigDecimal, @@ -151,38 +130,39 @@ export function updateBeanAfterPoolSwap( ): void { let pool = loadOrCreatePool(poolAddress, block.number); let bean = loadBean(pool.bean); + const beanToken = toAddress(bean.id); // Verify the pool is still whitelisted if (bean.pools.indexOf(poolAddress) >= 0) { let oldBeanPrice = bean.price; let beanPrice = poolPrice; // Get overall price from price contract if a result was not already provided - if (bean.id == BEAN_ERC20_V1.toHexString()) { + if (beanToken == BEAN_ERC20_V1) { univ2_externalUpdatePoolPrice(BEAN_WETH_V1, block); - beanPrice = calcLiquidityWeightedBeanPrice(bean.id); + beanPrice = calcLiquidityWeightedBeanPrice(beanToken); } else { if (priceContractResult === null) { - priceContractResult = BeanstalkPrice_try_price(Address.fromString(bean.id), block.number); + priceContractResult = BeanstalkPrice_try_price(beanToken, block.number); } if (!priceContractResult.reverted) { beanPrice = toDecimal(priceContractResult.value.price); } } - updateBeanSupplyPegPercent(block.number); - updateBeanValues(bean.id, beanPrice, ZERO_BI, volumeBean, volumeUSD, deltaLiquidityUSD, block); - checkBeanCross(bean.id, oldBeanPrice, beanPrice, block); + updateBeanSupplyPegPercent(pool.bean, block.number); + updateBeanValues(beanToken, beanPrice, ZERO_BI, volumeBean, volumeUSD, deltaLiquidityUSD, block); + checkBeanCross(beanToken, oldBeanPrice, beanPrice, block); } } -export function updateInstDeltaB(token: string, block: ethereum.Block): void { +export function updateInstDeltaB(token: Address, block: ethereum.Block): void { let bean = loadBean(token); let beanHourly = loadOrCreateBeanHourlySnapshot(token, block.timestamp, bean.lastSeason); let beanDaily = loadOrCreateBeanDailySnapshot(token, block.timestamp); let cumulativeDeltaB = ZERO_BI; for (let i = 0; i < bean.pools.length; i++) { - let pool = loadOrCreatePool(bean.pools[i], block.number); + let pool = loadOrCreatePool(toAddress(bean.pools[i]), block.number); cumulativeDeltaB = cumulativeDeltaB.plus(pool.deltaBeans); } @@ -194,7 +174,7 @@ export function updateInstDeltaB(token: string, block: ethereum.Block): void { // Update Bean's TWA deltaB and price. Individual pools' values must be computed prior to calling this method. export function updateBeanTwa(block: ethereum.Block): void { - let beanAddress = getBeanTokenAddress(block.number); + let beanAddress = getProtocolToken(block.number); let bean = loadBean(beanAddress); let beanHourly = loadOrCreateBeanHourlySnapshot(beanAddress, block.timestamp, bean.lastSeason); let beanDaily = loadOrCreateBeanDailySnapshot(beanAddress, block.timestamp); @@ -202,7 +182,7 @@ export function updateBeanTwa(block: ethereum.Block): void { let twaDeltaB = ZERO_BI; let weightedTwaPrice = ZERO_BD; for (let i = 0; i < bean.pools.length; i++) { - let poolHourly = loadOrCreatePoolHourlySnapshot(bean.pools[i], block); + let poolHourly = loadOrCreatePoolHourlySnapshot(toAddress(bean.pools[i]), block); twaDeltaB = twaDeltaB.plus(poolHourly.twaDeltaBeans); weightedTwaPrice = weightedTwaPrice.plus(poolHourly.twaPrice.times(poolHourly.liquidityUSD)); } diff --git a/projects/subgraph-bean/src/utils/Cross.ts b/projects/subgraph-bean/src/utils/Cross.ts index 8509b2142c..92b8329dda 100644 --- a/projects/subgraph-bean/src/utils/Cross.ts +++ b/projects/subgraph-bean/src/utils/Cross.ts @@ -1,16 +1,12 @@ -import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; +import { BigDecimal, Address, ethereum, log } from "@graphprotocol/graph-ts"; import { ONE_BD } from "../../../subgraph-core/utils/Decimals"; import { BEAN_ERC20_V1 } from "../../../subgraph-core/utils/Constants"; import { loadOrCreatePool, loadOrCreatePoolDailySnapshot, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../entities/Bean"; import { loadOrCreateBeanCross, loadOrCreatePoolCross } from "../entities/Cross"; -export function checkPoolCross(pool: string, oldPrice: BigDecimal, newPrice: BigDecimal, block: ethereum.Block): boolean { +export function checkPoolCross(pool: Address, oldPrice: BigDecimal, newPrice: BigDecimal, block: ethereum.Block): boolean { let poolInfo = loadOrCreatePool(pool, block.number); - let token = poolInfo.bean; - let bean = loadBean(token); - - // log.debug("Prev/New well price {} / {}", [oldPrice.toString(), newPrice.toString()]); if (oldPrice >= ONE_BD && newPrice < ONE_BD) { let cross = loadOrCreatePoolCross(poolInfo.crosses, pool, block); @@ -62,7 +58,7 @@ export function checkPoolCross(pool: string, oldPrice: BigDecimal, newPrice: Big return false; } -export function checkBeanCross(token: string, oldPrice: BigDecimal, newPrice: BigDecimal, block: ethereum.Block): boolean { +export function checkBeanCross(token: Address, oldPrice: BigDecimal, newPrice: BigDecimal, block: ethereum.Block): boolean { let bean = loadBean(token); if (oldPrice >= ONE_BD && newPrice < ONE_BD) { @@ -116,6 +112,6 @@ export function checkBeanCross(token: string, oldPrice: BigDecimal, newPrice: Bi } export function getV1Crosses(): i32 { - let bean = loadBean(BEAN_ERC20_V1.toHexString()); + let bean = loadBean(BEAN_ERC20_V1); return bean.crosses; } diff --git a/projects/subgraph-bean/src/utils/LockedBeans.ts b/projects/subgraph-bean/src/utils/LockedBeans.ts index 460b18c0dc..3c0960aa54 100644 --- a/projects/subgraph-bean/src/utils/LockedBeans.ts +++ b/projects/subgraph-bean/src/utils/LockedBeans.ts @@ -13,7 +13,6 @@ import { import { SeedGauge } from "../../generated/Bean-ABIs/SeedGauge"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { ERC20 } from "../../generated/Bean-ABIs/ERC20"; -import { Beanstalk } from "../../generated/Bean-ABIs/Beanstalk"; import { loadOrCreateTwaOracle } from "../entities/TwaOracle"; import { loadOrCreatePool } from "../entities/Pool"; @@ -21,7 +20,7 @@ export function calcLockedBeans(blockNumber: BigInt): BigInt { // If BIP45 is deployed - return the result from the contract if (blockNumber >= GAUGE_BIP45_BLOCK) { // If we are trying to calculate locked beans on the same block as the sunrise, use the values from the previous hour - const twaOracle = loadOrCreateTwaOracle(getUnderlyingUnripe(blockNumber).toHexString()); + const twaOracle = loadOrCreateTwaOracle(getUnderlyingUnripe(blockNumber)); const twaReserves = blockNumber == twaOracle.cumulativeWellReservesBlock ? twaOracle.cumulativeWellReservesPrev : twaOracle.cumulativeWellReserves; const twaTime = @@ -37,7 +36,7 @@ export function calcLockedBeans(blockNumber: BigInt): BigInt { } // Pre-gauge there was no lockedBeans contract function, instead we recreate the same calculation. - let beanstalk = Beanstalk.bind(BEANSTALK); + let beanstalk = SeedGauge.bind(BEANSTALK); const recapPercentResult = beanstalk.try_getRecapPaidPercent(); if (recapPercentResult.reverted) { // This function was made available later in the Replant process, for a few hundred blocks it is unavailable @@ -49,7 +48,7 @@ export function calcLockedBeans(blockNumber: BigInt): BigInt { const lockedUnripeLp = LibLockedUnderlying_getLockedUnderlying(UNRIPE_LP, recapPaidPercent); const underlyingLpPool = getUnderlyingUnripe(blockNumber); - const poolBeanReserves = loadOrCreatePool(underlyingLpPool.toHexString(), blockNumber).reserves[0]; + const poolBeanReserves = loadOrCreatePool(underlyingLpPool, blockNumber).reserves[0]; const totalLpTokens = ERC20.bind(getUnderlyingUnripe(blockNumber)).totalSupply(); // Simplification here: does not account for twa reserves nor twa lp tokens const lockedBeansUrLP = lockedUnripeLp.times(poolBeanReserves).div(totalLpTokens); @@ -68,7 +67,7 @@ function getUnderlyingUnripe(blockNumber: BigInt): Address { } export function LibLockedUnderlying_getLockedUnderlying(unripeToken: Address, recapPercentPaid: BigDecimal): BigInt { - const balanceOfUnderlying = Beanstalk.bind(BEANSTALK).getTotalUnderlying(unripeToken); + const balanceOfUnderlying = SeedGauge.bind(BEANSTALK).getTotalUnderlying(unripeToken); const percentLocked = LibLockedUnderlying_getPercentLockedUnderlying(unripeToken, recapPercentPaid); return BigInt.fromString(new BigDecimal(balanceOfUnderlying).times(percentLocked).truncate(0).toString()); } diff --git a/projects/subgraph-bean/src/utils/Pool.ts b/projects/subgraph-bean/src/utils/Pool.ts index 1b3c6a2ba2..3e18489c99 100644 --- a/projects/subgraph-bean/src/utils/Pool.ts +++ b/projects/subgraph-bean/src/utils/Pool.ts @@ -1,12 +1,13 @@ -import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; +import { BigDecimal, BigInt, ethereum, Address, log } from "@graphprotocol/graph-ts"; import { ZERO_BD } from "../../../subgraph-core/utils/Decimals"; import { updateInstDeltaB } from "./Bean"; import { checkPoolCross } from "./Cross"; import { DeltaBAndPrice } from "./price/Types"; import { loadOrCreatePool, loadOrCreatePoolDailySnapshot, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; +import { toAddress } from "../../../subgraph-core/utils/Bytes"; export function updatePoolValues( - poolAddress: string, + poolAddress: Address, volumeBean: BigInt, volumeUSD: BigDecimal, deltaLiquidityUSD: BigDecimal, @@ -49,10 +50,10 @@ export function updatePoolValues( poolDaily.updatedAt = block.timestamp; poolDaily.save(); - updateInstDeltaB(pool.bean, block); + updateInstDeltaB(toAddress(pool.bean), block); } -export function incrementPoolCross(poolAddress: string, block: ethereum.Block): void { +export function incrementPoolCross(poolAddress: Address, block: ethereum.Block): void { let pool = loadOrCreatePool(poolAddress, block.number); let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); @@ -69,7 +70,7 @@ export function incrementPoolCross(poolAddress: string, block: ethereum.Block): poolDaily.save(); } -export function updatePoolSeason(poolAddress: string, season: i32, block: ethereum.Block): void { +export function updatePoolSeason(poolAddress: Address, season: i32, block: ethereum.Block): void { let pool = loadOrCreatePool(poolAddress, block.number); let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); @@ -83,7 +84,7 @@ export function updatePoolSeason(poolAddress: string, season: i32, block: ethere poolDaily.save(); } -export function updatePoolPrice(poolAddress: string, price: BigDecimal, block: ethereum.Block, checkCross: boolean = true): void { +export function updatePoolPrice(poolAddress: Address, price: BigDecimal, block: ethereum.Block, checkCross: boolean = true): void { let pool = loadOrCreatePool(poolAddress, block.number); let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); @@ -104,7 +105,7 @@ export function updatePoolPrice(poolAddress: string, price: BigDecimal, block: e } } -export function setPoolReserves(poolAddress: string, reserves: BigInt[], block: ethereum.Block): void { +export function setPoolReserves(poolAddress: Address, reserves: BigInt[], block: ethereum.Block): void { let pool = loadOrCreatePool(poolAddress, block.number); let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); @@ -133,12 +134,12 @@ export function setPoolReserves(poolAddress: string, reserves: BigInt[], block: poolDaily.save(); } -export function getPoolLiquidityUSD(poolAddress: string, block: ethereum.Block): BigDecimal { +export function getPoolLiquidityUSD(poolAddress: Address, block: ethereum.Block): BigDecimal { let pool = loadOrCreatePool(poolAddress, block.number); return pool.liquidityUSD; } -export function setPoolTwa(poolAddress: string, twaValues: DeltaBAndPrice, block: ethereum.Block): void { +export function setPoolTwa(poolAddress: Address, twaValues: DeltaBAndPrice, block: ethereum.Block): void { let poolHourly = loadOrCreatePoolHourlySnapshot(poolAddress, block); let poolDaily = loadOrCreatePoolDailySnapshot(poolAddress, block); poolHourly.twaDeltaBeans = twaValues.deltaB; diff --git a/projects/subgraph-bean/src/utils/Token.ts b/projects/subgraph-bean/src/utils/Token.ts index c94019dec7..25d8f3749e 100644 --- a/projects/subgraph-bean/src/utils/Token.ts +++ b/projects/subgraph-bean/src/utils/Token.ts @@ -1,7 +1,7 @@ -import { BigDecimal } from "@graphprotocol/graph-ts"; +import { BigDecimal, Address } from "@graphprotocol/graph-ts"; import { loadOrCreateToken } from "../entities/Token"; -export function updateTokenPrice(address: string, price: BigDecimal): void { +export function updateTokenPrice(address: Address, price: BigDecimal): void { let token = loadOrCreateToken(address); token.lastPriceUSD = price; token.save(); diff --git a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts index 02b63cfdf2..6dc93eddc9 100644 --- a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts +++ b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts @@ -5,7 +5,7 @@ import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot export function handleInitBeanEntity(block: ethereum.Block): void { // TODO: how to determine correct token address? this is wrong - const token = BEAN_ERC20.toHexString(); + const token = BEAN_ERC20; const bean = loadBean(token); bean.volume = BEAN_INITIAL_VALUES.volume; diff --git a/projects/subgraph-bean/src/utils/constants/Addresses.ts b/projects/subgraph-bean/src/utils/constants/Addresses.ts index 239999fdf3..bc9efc0a45 100644 --- a/projects/subgraph-bean/src/utils/constants/Addresses.ts +++ b/projects/subgraph-bean/src/utils/constants/Addresses.ts @@ -1,5 +1,25 @@ -import { Address } from "@graphprotocol/graph-ts"; -import { UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/utils/Constants"; +import { BigInt, Address } from "@graphprotocol/graph-ts"; +import { + BEAN_ERC20, + BEAN_ERC20_V1, + BEANSTALK, + NEW_BEAN_TOKEN_BLOCK, + UNRIPE_BEAN, + UNRIPE_LP +} from "../../../../subgraph-core/utils/Constants"; +import { getVersionEntity } from "./Version"; + +export function getProtocolToken(blockNumber: BigInt): Address { + const protocol = getVersionEntity().protocolAddress; + if (protocol == BEANSTALK) { + if (blockNumber < NEW_BEAN_TOKEN_BLOCK) { + return BEAN_ERC20_V1; + } else { + return BEAN_ERC20; + } + } + throw new Error("Unsupported protocol"); +} export function isUnripe(token: Address): boolean { const unripeTokens = [UNRIPE_BEAN, UNRIPE_LP]; diff --git a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts index 90a29abcd9..c8d7fe5d57 100644 --- a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts +++ b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts @@ -1,4 +1,4 @@ -import { BigInt, log } from "@graphprotocol/graph-ts"; +import { BigInt, Address, log } from "@graphprotocol/graph-ts"; import { BEAN_ERC20, BEAN_ERC20_V1, @@ -16,7 +16,7 @@ import { // Use this mapping to determine which tokens are in each pool. Pools may each follow a distinct interface, // so a view function shouldn't be used, and a new subgraph build is already required to track a newly whitelisted asset. -export function getTokensForPool(pool: string): string[] { +export function getTokensForPool(pool: Address): Address[] { for (let i = 0; i < poolTokens.length; ++i) { if (poolTokens[i].pool == pool) { return poolTokens[i].tokens; @@ -26,7 +26,7 @@ export function getTokensForPool(pool: string): string[] { } // Name/Decimals are not guaranteed as part of the ERC20 interface, so predefined values are necessary -export function getTokenInfo(token: string): TokenInfo { +export function getTokenInfo(token: Address): TokenInfo { for (let i = 0; i < tokens.length; ++i) { if (tokens[i].address == token) { return tokens[i].info; @@ -36,39 +36,39 @@ export function getTokenInfo(token: string): TokenInfo { } class PoolTokens { - pool: string; - tokens: string[]; + pool: Address; + tokens: Address[]; } // WHITELIST: Add new pools here const poolTokens: PoolTokens[] = [ { - pool: BEAN_WETH_V1.toHexString(), - tokens: [BEAN_ERC20_V1.toHexString(), WETH.toHexString()] + pool: BEAN_WETH_V1, + tokens: [BEAN_ERC20_V1, WETH] }, { - pool: BEAN_3CRV_V1.toHexString(), - tokens: [BEAN_ERC20_V1.toHexString(), CRV3_TOKEN.toHexString()] + pool: BEAN_3CRV_V1, + tokens: [BEAN_ERC20_V1, CRV3_TOKEN] }, { - pool: BEAN_LUSD_V1.toHexString(), - tokens: [BEAN_ERC20_V1.toHexString(), LUSD.toHexString()] + pool: BEAN_LUSD_V1, + tokens: [BEAN_ERC20_V1, LUSD] }, { - pool: BEAN_3CRV.toHexString(), - tokens: [BEAN_ERC20.toHexString(), CRV3_TOKEN.toHexString()] + pool: BEAN_3CRV, + tokens: [BEAN_ERC20, CRV3_TOKEN] }, { - pool: BEAN_WETH_CP2_WELL.toHexString(), - tokens: [BEAN_ERC20.toHexString(), WETH.toHexString()] + pool: BEAN_WETH_CP2_WELL, + tokens: [BEAN_ERC20, WETH] }, { - pool: BEAN_WSTETH_CP2_WELL.toHexString(), - tokens: [BEAN_ERC20.toHexString(), WSTETH.toHexString()] + pool: BEAN_WSTETH_CP2_WELL, + tokens: [BEAN_ERC20, WSTETH] } ]; class Token { - address: string; + address: Address; info: TokenInfo; } @@ -80,27 +80,27 @@ class TokenInfo { // WHITELIST: Add new tokens here const tokens: Token[] = [ { - address: BEAN_ERC20_V1.toHexString(), + address: BEAN_ERC20_V1, info: { name: "BEAN", decimals: BigInt.fromU32(6) } }, { - address: BEAN_ERC20.toHexString(), + address: BEAN_ERC20, info: { name: "BEAN", decimals: BigInt.fromU32(6) } }, { - address: WETH.toHexString(), + address: WETH, info: { name: "WETH", decimals: BigInt.fromU32(18) } }, { - address: CRV3_TOKEN.toHexString(), + address: CRV3_TOKEN, info: { name: "3CRV", decimals: BigInt.fromU32(18) } }, { - address: LUSD.toHexString(), + address: LUSD, info: { name: "LUSD", decimals: BigInt.fromU32(18) } }, { - address: WSTETH.toHexString(), + address: WSTETH, info: { name: "wstETH", decimals: BigInt.fromU32(18) } } ]; diff --git a/projects/subgraph-bean/src/utils/Init.ts b/projects/subgraph-bean/src/utils/constants/Version.ts similarity index 56% rename from projects/subgraph-bean/src/utils/Init.ts rename to projects/subgraph-bean/src/utils/constants/Version.ts index 3ca88c6450..2f33371239 100644 --- a/projects/subgraph-bean/src/utils/Init.ts +++ b/projects/subgraph-bean/src/utils/constants/Version.ts @@ -1,14 +1,20 @@ -import { BigInt, ethereum } from "@graphprotocol/graph-ts"; -import { Version } from "../../generated/schema"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Version } from "../../../generated/schema"; +import { BEANSTALK } from "../../../../subgraph-core/utils/Constants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); versionEntity.versionNumber = "2.3.1"; versionEntity.subgraphName = subgraphNameForBlockNumber(block.number); + versionEntity.protocolAddress = protocolForBlockNumber(block.number); versionEntity.chain = chainForBlockNumber(block.number); versionEntity.save(); } +export function getVersionEntity(): Version { + return Version.load("subgraph")!; +} + function subgraphNameForBlockNumber(blockNumber: BigInt): string { if (blockNumber == BigInt.fromU32(12974075)) { return "bean"; @@ -16,6 +22,13 @@ function subgraphNameForBlockNumber(blockNumber: BigInt): string { throw new Error("Unable to initialize subgraph name for this block number"); } +function protocolForBlockNumber(blockNumber: BigInt): Address { + if (blockNumber == BigInt.fromU32(12974075)) { + return BEANSTALK; + } + throw new Error("Unable to initialize protocol address for this block number"); +} + function chainForBlockNumber(blockNumber: BigInt): string { if (blockNumber == BigInt.fromU32(12974075)) { return "ethereum"; diff --git a/projects/subgraph-bean/src/utils/legacy/Bean.ts b/projects/subgraph-bean/src/utils/legacy/Bean.ts new file mode 100644 index 0000000000..9f749b4497 --- /dev/null +++ b/projects/subgraph-bean/src/utils/legacy/Bean.ts @@ -0,0 +1,28 @@ +import { BigInt, Address } from "@graphprotocol/graph-ts"; +import { BEAN_3CRV_V1, BEAN_LUSD_V1, BEAN_WETH_V1 } from "../../../../subgraph-core/utils/Constants"; +import { toDecimal, ZERO_BD } from "../../../../subgraph-core/utils/Decimals"; +import { Pool } from "../../../generated/schema"; +import { loadBean } from "../../entities/Bean"; + +export function updateBeanSupplyPegPercent_v1(beanToken: Address, blockNumber: BigInt): void { + let bean = loadBean(beanToken); + let lpSupply = ZERO_BD; + + let pool = Pool.load(BEAN_WETH_V1); + if (pool != null) { + lpSupply = lpSupply.plus(toDecimal(pool.reserves[1])); + } + + pool = Pool.load(BEAN_3CRV_V1); + if (pool != null) { + lpSupply = lpSupply.plus(toDecimal(pool.reserves[0])); + } + + pool = Pool.load(BEAN_LUSD_V1); + if (pool != null) { + lpSupply = lpSupply.plus(toDecimal(pool.reserves[0])); + } + + bean.supplyInPegLP = lpSupply.div(toDecimal(bean.supply)); + bean.save(); +} diff --git a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts index 42b3421cd1..98b9a008ec 100644 --- a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts +++ b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts @@ -8,6 +8,7 @@ import { import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../../subgraph-core/utils/Constants"; import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadBean } from "../../entities/Bean"; +import { toAddressArray } from "../../../../subgraph-core/utils/Bytes"; // Can't use the autogenerated one because the fields need to be updateable class PriceOverallStruct { @@ -53,13 +54,13 @@ export class BeanstalkPriceResult { private _value: PriceOverallStruct | null = null; private _dewhitelistedPools: Array = []; - constructor(value: BeanstalkPrice__priceResultPStruct | null, whitelistedPools: string[]) { + constructor(value: BeanstalkPrice__priceResultPStruct | null, whitelistedPools: Address[]) { if (value !== null) { this._value = new PriceOverallStruct(value); let poolsCount = this._value!.ps.length; let dewhitelistCount = 0; for (let i = 0; i < this._value!.ps.length; ++i) { - const index = whitelistedPools.indexOf(this._value!.ps[i].pool.toHexString()); + const index = whitelistedPools.indexOf(this._value!.ps[i].pool); if (index == -1) { // The pool was dewhitelisted this._dewhitelistedPools.push(this._value!.ps.splice(i--, 1)[0]); @@ -111,11 +112,11 @@ export function BeanstalkPrice_try_price(beanAddr: Address, blockNumber: BigInt) return new BeanstalkPriceResult(null, []); } - let bean = loadBean(beanAddr.toHexString()); + let bean = loadBean(beanAddr); // changetype is necessary as there are identical responses from different generated contract objects. // If the response structure changes in the future, this will need to be revisited. - return new BeanstalkPriceResult(changetype(beanPrice.value), bean.pools); + return new BeanstalkPriceResult(changetype(beanPrice.value), toAddressArray(bean.pools)); } // Extracts the pool price from the larger result diff --git a/projects/subgraph-bean/src/utils/price/CurvePrice.ts b/projects/subgraph-bean/src/utils/price/CurvePrice.ts index 11d50eac1b..82f783c636 100644 --- a/projects/subgraph-bean/src/utils/price/CurvePrice.ts +++ b/projects/subgraph-bean/src/utils/price/CurvePrice.ts @@ -10,13 +10,13 @@ import { LUSD, LUSD_3POOL } from "../../../../subgraph-core/utils/Constants"; -import { CalculationsCurve } from "../../../generated/Bean-ABIs/CalculationsCurve"; import { ERC20 } from "../../../generated/Bean-ABIs/ERC20"; import { DeltaBAndPrice, DeltaBPriceLiquidity, TWAType } from "./Types"; import { Pool } from "../../../generated/schema"; import { setPoolTwa } from "../Pool"; import { getTWAPrices } from "./TwaOracle"; import { loadOrCreateTwaOracle } from "../../entities/TwaOracle"; +import { CalculationsCurve } from "../../../generated/Bean-ABIs/CalculationsCurve"; // Note that the Bean3CRV type applies to any curve pool (including lusd) @@ -60,11 +60,11 @@ export function curvePriceAndLp(pool: Address): BigDecimal[] { } export function calcCurveInst(pool: Pool): DeltaBPriceLiquidity { - const priceAndLp = curvePriceAndLp(Address.fromString(pool.id)); + const priceAndLp = curvePriceAndLp(pool.id); return { price: priceAndLp[0], liquidity: priceAndLp[1], - deltaB: curveDeltaBUsingVPrice(Address.fromString(pool.id), pool.reserves[0]) + deltaB: curveDeltaBUsingVPrice(pool.id, pool.reserves[0]) }; } @@ -80,11 +80,10 @@ export function curveDeltaBUsingVPrice(pool: Address, beanReserves: BigInt): Big } // Calculates and sets the TWA on the pool hourly/daily snapshots -export function setCurveTwa(poolAddress: string, block: ethereum.Block): void { +export function setCurveTwa(poolAddress: Address, block: ethereum.Block): void { const twaBalances = getTWAPrices(poolAddress, TWAType.CURVE, block.timestamp); - const beanPool = Address.fromString(poolAddress); - const otherPool = beanPool == BEAN_LUSD_V1 ? LUSD_3POOL : CRV3_POOL; - const twaResult = curveTwaDeltaBAndPrice(twaBalances, beanPool, otherPool); + const otherPool = poolAddress == BEAN_LUSD_V1 ? LUSD_3POOL : CRV3_POOL; + const twaResult = curveTwaDeltaBAndPrice(twaBalances, poolAddress, otherPool); setPoolTwa(poolAddress, twaResult, block); } @@ -102,7 +101,7 @@ export function curveCumulativePrices(pool: Address, timestamp: BigInt): BigInt[ // if (pool == BEAN_LUSD_V1) { // BEANLUSD does not have the above functions, uses manual calculation // BEAN_3CRV(_V2) uses this also, oracle values are updated from MetapoolOracle event. - let twaOracle = loadOrCreateTwaOracle(pool.toHexString()); + let twaOracle = loadOrCreateTwaOracle(pool); cumulativeLast = twaOracle.priceCumulativeLast; currentBalances = twaOracle.lastBalances; lastTimestamp = twaOracle.lastUpdated; diff --git a/projects/subgraph-bean/src/utils/price/TwaOracle.ts b/projects/subgraph-bean/src/utils/price/TwaOracle.ts index 99c65425b1..e03868ca98 100644 --- a/projects/subgraph-bean/src/utils/price/TwaOracle.ts +++ b/projects/subgraph-bean/src/utils/price/TwaOracle.ts @@ -5,10 +5,10 @@ import { WETH_USDC_PAIR } from "../../../../subgraph-core/utils/Constants"; import { curveCumulativePrices } from "./CurvePrice"; import { TWAType } from "./Types"; import { wellCumulativePrices, wellTwaReserves } from "./WellPrice"; -import { WellOracle } from "../../../generated/Bean-ABIs/BIP37"; +import { WellOracle } from "../../../generated/Bean-ABIs/BasinBip"; import { loadOrCreateTwaOracle } from "../../entities/TwaOracle"; -export function manualTwa(poolAddress: string, newReserves: BigInt[], timestamp: BigInt): void { +export function manualTwa(poolAddress: Address, newReserves: BigInt[], timestamp: BigInt): void { let twaOracle = loadOrCreateTwaOracle(poolAddress); const elapsedTime = timestamp.minus(twaOracle.lastUpdated); const newPriceCumulative = [ @@ -21,7 +21,7 @@ export function manualTwa(poolAddress: string, newReserves: BigInt[], timestamp: twaOracle.save(); } -export function setTwaLast(poolAddress: string, newCumulative: BigInt[], timestamp: BigInt): void { +export function setTwaLast(poolAddress: Address, newCumulative: BigInt[], timestamp: BigInt): void { let twaOracle = loadOrCreateTwaOracle(poolAddress); twaOracle.priceCumulativeLast = newCumulative; twaOracle.lastUpdated = timestamp; @@ -29,7 +29,7 @@ export function setTwaLast(poolAddress: string, newCumulative: BigInt[], timesta } export function setRawWellReserves(event: WellOracle): void { - let twaOracle = loadOrCreateTwaOracle(event.params.well.toHexString()); + let twaOracle = loadOrCreateTwaOracle(event.params.well); twaOracle.cumulativeWellReservesPrev = twaOracle.cumulativeWellReserves; twaOracle.cumulativeWellReservesPrevTime = twaOracle.cumulativeWellReservesTime; twaOracle.cumulativeWellReservesPrevBlock = twaOracle.cumulativeWellReservesBlock; @@ -40,7 +40,7 @@ export function setRawWellReserves(event: WellOracle): void { } // Returns the current TWA prices (balances) since the previous TwaOracle update -export function getTWAPrices(poolAddress: string, type: TWAType, timestamp: BigInt): BigInt[] { +export function getTWAPrices(poolAddress: Address, type: TWAType, timestamp: BigInt): BigInt[] { let twaOracle = loadOrCreateTwaOracle(poolAddress); const initialized = twaOracle.lastSun != ZERO_BI; @@ -49,7 +49,7 @@ export function getTWAPrices(poolAddress: string, type: TWAType, timestamp: BigI const timeElapsed = timestamp.minus(twaOracle.lastSun); if (type == TWAType.UNISWAP) { - const beanPrice = uniswapCumulativePrice(Address.fromString(poolAddress), 1, timestamp); + const beanPrice = uniswapCumulativePrice(poolAddress, 1, timestamp); const pegPrice = uniswapCumulativePrice(WETH_USDC_PAIR, 0, timestamp); newPriceCumulative = [beanPrice, pegPrice]; @@ -60,13 +60,13 @@ export function getTWAPrices(poolAddress: string, type: TWAType, timestamp: BigI ]; } else if (type == TWAType.CURVE) { // Curve - newPriceCumulative = curveCumulativePrices(Address.fromString(poolAddress), timestamp); + newPriceCumulative = curveCumulativePrices(poolAddress, timestamp); twaPrices = [ newPriceCumulative[0].minus(twaOracle.priceCumulativeSun[0]).div(timeElapsed), newPriceCumulative[1].minus(twaOracle.priceCumulativeSun[1]).div(timeElapsed) ]; } else if (type == TWAType.WELL_PUMP) { - newPriceCumulative = wellCumulativePrices(Address.fromString(poolAddress), timestamp); + newPriceCumulative = wellCumulativePrices(poolAddress, timestamp); twaPrices = wellTwaReserves(newPriceCumulative, twaOracle.priceCumulativeSun, new BigDecimal(timeElapsed)); } diff --git a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts index aad51803b5..91eaec9d8a 100644 --- a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts +++ b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts @@ -73,7 +73,7 @@ export function uniswapV2DeltaB(beanReserves: BigDecimal, token2Reserves: BigDec } // Calculates and sets the TWA on the pool hourly/daily snapshots -export function setUniswapV2Twa(poolAddress: string, block: ethereum.Block): void { +export function setUniswapV2Twa(poolAddress: Address, block: ethereum.Block): void { const twaPrices = getTWAPrices(poolAddress, TWAType.UNISWAP, block.timestamp); const twaResult = uniswapTwaDeltaBAndPrice(twaPrices, block.number); diff --git a/projects/subgraph-bean/src/utils/price/WellPrice.ts b/projects/subgraph-bean/src/utils/price/WellPrice.ts index cc1ac9fa18..f4747787e8 100644 --- a/projects/subgraph-bean/src/utils/price/WellPrice.ts +++ b/projects/subgraph-bean/src/utils/price/WellPrice.ts @@ -29,7 +29,7 @@ export function decodeCumulativeWellReserves(data: Bytes): BigInt[] { // This gets set from WellOracle event export function wellCumulativePrices(pool: Address, timestamp: BigInt): BigInt[] { - let twaOracle = loadOrCreateTwaOracle(pool.toHexString()); + let twaOracle = loadOrCreateTwaOracle(pool); if (twaOracle.lastUpdated != timestamp) { // If this becomes an issue, could call into the pump throw new Error("Attempted to access updated Well cumulative prices when they were not available."); @@ -47,7 +47,7 @@ export function wellTwaReserves(currentReserves: BigInt[], pastReserves: BigInt[ ]; } -export function setWellTwa(wellAddress: string, twaDeltaB: BigInt, block: ethereum.Block): void { +export function setWellTwa(wellAddress: Address, twaDeltaB: BigInt, block: ethereum.Block): void { const twaBalances = getTWAPrices(wellAddress, TWAType.WELL_PUMP, block.timestamp); const twaResult = wellTwaDeltaBAndPrice(twaBalances, twaDeltaB); diff --git a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts index ae465a151c..e39053cc3d 100644 --- a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts +++ b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts @@ -16,6 +16,7 @@ import { BI_10 } from "../../subgraph-core/utils/Decimals"; import { BeanstalkPrice_try_price, getPoolPrice } from "../src/utils/price/BeanstalkPrice"; import { loadBean } from "../src/entities/Bean"; import { handleDewhitelistToken } from "../src/handlers/BeanstalkHandler"; +import { initL1Version } from "./entity-mocking/MockVersion"; const curvePrice = BigInt.fromU32(1012000); const beanEthPrice = BigInt.fromU32(1025000); @@ -68,8 +69,10 @@ describe("BeanstalkPrice", () => { }); beforeEach(() => { - let bean = loadBean(BEAN_ERC20.toHexString()); - bean.pools = [BEAN_3CRV.toHexString(), BEAN_WETH_CP2_WELL.toHexString()]; + initL1Version(); + + let bean = loadBean(BEAN_ERC20); + bean.pools = [BEAN_3CRV, BEAN_WETH_CP2_WELL]; bean.save(); }); @@ -95,7 +98,7 @@ describe("BeanstalkPrice", () => { }); test("Price response only includes whitelisted tokens", () => { - const event = createDewhitelistTokenEvent(BEAN_3CRV.toHexString()); + const event = createDewhitelistTokenEvent(BEAN_3CRV); event.block.number = PRICE_1_BLOCK; handleDewhitelistToken(event); diff --git a/projects/subgraph-bean/tests/Cross.test.ts b/projects/subgraph-bean/tests/Cross.test.ts index 063ca8e200..993ff80a98 100644 --- a/projects/subgraph-bean/tests/Cross.test.ts +++ b/projects/subgraph-bean/tests/Cross.test.ts @@ -7,15 +7,16 @@ import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { mockPreReplantETHPrice, simpleMockPrice } from "../../subgraph-core/tests/event-mocking/Price"; import { BEAN_3CRV_V1, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_CP2_WELL, BEAN_WETH_V1 } from "../../subgraph-core/utils/Constants"; -import { BD_10, BigDecimal_round, ONE_BD, ONE_BI, toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals"; +import { BigDecimal_round, toDecimal, ZERO_BD } from "../../subgraph-core/utils/Decimals"; import { getPreReplantPriceETH, constantProductPrice, uniswapV2Reserves } from "../src/utils/price/UniswapPrice"; -import { mockPoolPriceAndLiquidity, mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves } from "./entity-mocking/MockPool"; +import { mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves } from "./entity-mocking/MockPool"; import { setWhitelistedPools } from "./entity-mocking/MockBean"; import { PEG_CROSS_BLOCKS } from "../cache-builder/results/PegCrossBlocks_eth"; import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; import { handleBlock } from "../src/handlers/BlockHandler"; import { loadBean } from "../src/entities/Bean"; +import { initL1Version } from "./entity-mocking/MockVersion"; const wellCrossId = (n: u32): string => { return BEAN_WETH_CP2_WELL.toHexString() + "-" + n.toString(); @@ -34,12 +35,14 @@ const WELL_CROSS_BLOCK = BigInt.fromU32(18965881); describe("Peg Crosses", () => { beforeEach(() => { + initL1Version(); + // Bean price is init at 1.07, set to 0 so it is consistent will pool starting price - let bean = loadBean(BEAN_ERC20.toHexString()); + let bean = loadBean(BEAN_ERC20); bean.price = ZERO_BD; bean.save(); - let beanv1 = loadBean(BEAN_ERC20_V1.toHexString()); + let beanv1 = loadBean(BEAN_ERC20_V1); beanv1.price = ZERO_BD; beanv1.save(); @@ -121,7 +124,7 @@ describe("Peg Crosses", () => { describe("BEAN:ETH Well", () => { beforeEach(() => { - setWhitelistedPools([BEAN_WETH_CP2_WELL.toHexString()]); + setWhitelistedPools([BEAN_WETH_CP2_WELL]); }); test("Well/Bean cross above", () => { diff --git a/projects/subgraph-bean/tests/DeltaB.test.ts b/projects/subgraph-bean/tests/DeltaB.test.ts index 1e363cf504..593b27f54c 100644 --- a/projects/subgraph-bean/tests/DeltaB.test.ts +++ b/projects/subgraph-bean/tests/DeltaB.test.ts @@ -14,6 +14,7 @@ import { pow2toX } from "../../subgraph-core/utils/ABDKMathQuad"; import { handleMetapoolOracle, handleWellOracle } from "../src/handlers/BeanstalkHandler"; import { loadBean } from "../src/entities/Bean"; import { loadOrCreatePool } from "../src/entities/Pool"; +import { initL1Version } from "./entity-mocking/MockVersion"; const timestamp1 = BigInt.fromU32(1712793374); const hour1 = hourFromTimestamp(timestamp1).toString(); @@ -27,7 +28,9 @@ describe("DeltaB", () => { mock_virtual_price(CRV3_POOL, BigInt.fromString("1000000000000000000")); mock_virtual_price(BEAN_3CRV, BigInt.fromString("1000000000000000000")); }); - + beforeEach(() => { + initL1Version(); + }); afterEach(() => { clearStore(); }); @@ -120,10 +123,10 @@ describe("DeltaB", () => { ]; // Set liquidity so weighted twa prices can be set - let pool = loadOrCreatePool(BEAN_3CRV.toHexString(), b2.number); + let pool = loadOrCreatePool(BEAN_3CRV, b2.number); pool.liquidityUSD = BigDecimal.fromString("10000"); pool.save(); - let bean = loadBean(BEAN_ERC20.toHexString()); + let bean = loadBean(BEAN_ERC20); bean.liquidityUSD = BigDecimal.fromString("10000"); bean.save(); diff --git a/projects/subgraph-bean/tests/Migration.test.ts b/projects/subgraph-bean/tests/Migration.test.ts index 5841543d30..d8fb886701 100644 --- a/projects/subgraph-bean/tests/Migration.test.ts +++ b/projects/subgraph-bean/tests/Migration.test.ts @@ -1,10 +1,14 @@ -import { clearStore, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; +import { clearStore, beforeEach, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; import { handleInitBeanEntity } from "../src/utils/b3-migration/BeanInit"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { BEAN_ERC20 } from "../../subgraph-core/utils/Constants"; import { BEAN_INITIAL_VALUES } from "../cache-builder/results/BeanInit_arb"; +import { initL1Version } from "./entity-mocking/MockVersion"; describe("Beanstalk 3 Migration", () => { + beforeEach(() => { + initL1Version(); + }); afterEach(() => { clearStore(); }); diff --git a/projects/subgraph-bean/tests/Pool.test.ts b/projects/subgraph-bean/tests/Pool.test.ts index 354bdd4e97..b5f4832735 100644 --- a/projects/subgraph-bean/tests/Pool.test.ts +++ b/projects/subgraph-bean/tests/Pool.test.ts @@ -1,24 +1,29 @@ -import { afterEach, clearStore, describe, assert, test } from "matchstick-as/assembly/index"; +import { beforeEach, afterEach, clearStore, describe, assert, test } from "matchstick-as/assembly/index"; import { BEAN_3CRV, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_V1, CRV3_TOKEN, WETH } from "../../subgraph-core/utils/Constants"; -import { BigInt } from "@graphprotocol/graph-ts"; +import { BigInt, Address } from "@graphprotocol/graph-ts"; import { loadOrCreatePool } from "../src/entities/Pool"; +import { toAddress } from "../../subgraph-core/utils/Bytes"; +import { initL1Version } from "./entity-mocking/MockVersion"; describe("Token", () => { + beforeEach(() => { + initL1Version(); + }); afterEach(() => { clearStore(); }); test("Pool and its tokens are assigned appropriate metadata", () => { - const pool = loadOrCreatePool(BEAN_WETH_V1.toHexString(), BigInt.fromU32(14500000)); - assert.stringEquals(BEAN_ERC20_V1.toHexString(), pool.tokens[0]); - assert.stringEquals(WETH.toHexString(), pool.tokens[1]); + const pool = loadOrCreatePool(BEAN_WETH_V1, BigInt.fromU32(14500000)); + assert.addressEquals(BEAN_ERC20_V1, toAddress(pool.tokens[0])); + assert.addressEquals(WETH, toAddress(pool.tokens[1])); assert.fieldEquals("Token", BEAN_ERC20_V1.toHexString(), "decimals", "6"); assert.fieldEquals("Token", WETH.toHexString(), "decimals", "18"); - const pool2 = loadOrCreatePool(BEAN_3CRV.toHexString(), BigInt.fromU32(17500000)); - assert.stringEquals(BEAN_ERC20.toHexString(), pool2.tokens[0]); - assert.stringEquals(CRV3_TOKEN.toHexString(), pool2.tokens[1]); + const pool2 = loadOrCreatePool(BEAN_3CRV, BigInt.fromU32(17500000)); + assert.addressEquals(BEAN_ERC20, toAddress(pool2.tokens[0])); + assert.addressEquals(CRV3_TOKEN, toAddress(pool2.tokens[1])); assert.fieldEquals("Token", BEAN_ERC20.toHexString(), "decimals", "6"); assert.fieldEquals("Token", CRV3_TOKEN.toHexString(), "decimals", "18"); diff --git a/projects/subgraph-bean/tests/Whitelist.test.ts b/projects/subgraph-bean/tests/Whitelist.test.ts index c8d91a3059..621dff5cd0 100644 --- a/projects/subgraph-bean/tests/Whitelist.test.ts +++ b/projects/subgraph-bean/tests/Whitelist.test.ts @@ -3,17 +3,21 @@ import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, BEAN_WETH_CP2_WELL_BLOCK } f import { createDewhitelistTokenEvent } from "./event-mocking/Beanstalk"; import { setWhitelistedPools } from "./entity-mocking/MockBean"; import { handleDewhitelistToken } from "../src/handlers/BeanstalkHandler"; +import { initL1Version } from "./entity-mocking/MockVersion"; describe("Whitelisting", () => { + beforeEach(() => { + initL1Version(); + }); afterEach(() => { // log.debug("clearing the store", []); clearStore(); }); test("Dewhitelist", () => { - setWhitelistedPools([BEAN_3CRV.toHexString(), BEAN_WETH_CP2_WELL.toHexString()]); + setWhitelistedPools([BEAN_3CRV, BEAN_WETH_CP2_WELL]); - const event = createDewhitelistTokenEvent(BEAN_3CRV.toHexString()); + const event = createDewhitelistTokenEvent(BEAN_3CRV); event.block.number = BEAN_WETH_CP2_WELL_BLOCK; handleDewhitelistToken(event); diff --git a/projects/subgraph-bean/tests/entity-mocking/MockBean.ts b/projects/subgraph-bean/tests/entity-mocking/MockBean.ts index ad963d2a95..6ac1de6e65 100644 --- a/projects/subgraph-bean/tests/entity-mocking/MockBean.ts +++ b/projects/subgraph-bean/tests/entity-mocking/MockBean.ts @@ -1,8 +1,10 @@ +import { Address } from "@graphprotocol/graph-ts"; import { BEAN_ERC20 } from "../../../subgraph-core/utils/Constants"; import { loadBean } from "../../src/entities/Bean"; +import { toBytesArray } from "../../../subgraph-core/utils/Bytes"; -export function setWhitelistedPools(pools: string[]): void { - let bean = loadBean(BEAN_ERC20.toHexString()); - bean.pools = pools; +export function setWhitelistedPools(pools: Address[]): void { + let bean = loadBean(BEAN_ERC20); + bean.pools = toBytesArray(pools); bean.save(); } diff --git a/projects/subgraph-bean/tests/entity-mocking/MockPool.ts b/projects/subgraph-bean/tests/entity-mocking/MockPool.ts index 553e0a025a..74295d6c4a 100644 --- a/projects/subgraph-bean/tests/entity-mocking/MockPool.ts +++ b/projects/subgraph-bean/tests/entity-mocking/MockPool.ts @@ -4,7 +4,7 @@ import { BEAN_WETH_V1, BEANSTALK_BLOCK } from "../../../subgraph-core/utils/Cons import { loadOrCreatePool } from "../../src/entities/Pool"; export function mockPoolPriceAndLiquidity(poolAddr: Address, price: BigDecimal, liquidityUSD: BigDecimal, blockNumber: BigInt): void { - let pool = loadOrCreatePool(poolAddr.toHexString(), blockNumber); + let pool = loadOrCreatePool(poolAddr, blockNumber); pool.lastPrice = price; pool.liquidityUSD = liquidityUSD; pool.save(); @@ -15,7 +15,7 @@ export function mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves( liquidity: BigDecimal = BigDecimal.fromString("5000000") ): void { const reserves = mockPreReplantBeanEthPriceAndLiquidity(beanPrice, liquidity); - let pool = loadOrCreatePool(BEAN_WETH_V1.toHexString(), BEANSTALK_BLOCK); + let pool = loadOrCreatePool(BEAN_WETH_V1, BEANSTALK_BLOCK); pool.reserves = reserves; pool.save(); } diff --git a/projects/subgraph-bean/tests/entity-mocking/MockVersion.ts b/projects/subgraph-bean/tests/entity-mocking/MockVersion.ts new file mode 100644 index 0000000000..bfc1a8a7dc --- /dev/null +++ b/projects/subgraph-bean/tests/entity-mocking/MockVersion.ts @@ -0,0 +1,7 @@ +import { BigInt } from "@graphprotocol/graph-ts"; +import { handleInitVersion } from "../../src/utils/constants/Version"; +import { mockBlock } from "../../../subgraph-core/tests/event-mocking/Block"; + +export function initL1Version(): void { + handleInitVersion(mockBlock(BigInt.fromU32(12974075))); +} diff --git a/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts b/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts index 73e9d306bc..1d3f262831 100644 --- a/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts +++ b/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts @@ -1,5 +1,5 @@ import { BigInt, ethereum, Address, Bytes } from "@graphprotocol/graph-ts"; -import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BIP37"; +import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BasinBip"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; import { Convert, DewhitelistToken } from "../../generated/Bean-ABIs/Beanstalk"; @@ -54,10 +54,10 @@ export function createWellOracleEvent( return event as WellOracle; } -export function createDewhitelistTokenEvent(token: string): DewhitelistToken { +export function createDewhitelistTokenEvent(token: Address): DewhitelistToken { let event = changetype(mockBeanstalkEvent()); event.parameters = new Array(); - let param1 = new ethereum.EventParam("token", ethereum.Value.fromAddress(Address.fromString(token))); + let param1 = new ethereum.EventParam("token", ethereum.Value.fromAddress(token)); event.parameters.push(param1); return event as DewhitelistToken; } diff --git a/projects/subgraph-bean/tests/l2sr.test.ts b/projects/subgraph-bean/tests/l2sr.test.ts index 193a11e624..5809b2ca85 100644 --- a/projects/subgraph-bean/tests/l2sr.test.ts +++ b/projects/subgraph-bean/tests/l2sr.test.ts @@ -28,11 +28,12 @@ import { loadOrCreatePool } from "../src/entities/Pool"; import { loadBean } from "../src/entities/Bean"; import { handleChop, handleConvert } from "../src/handlers/BeanstalkHandler"; import { createConvertEvent } from "./event-mocking/Beanstalk"; +import { initL1Version } from "./entity-mocking/MockVersion"; const mockReserves = Bytes.fromHexString("0xabcdef"); const mockReservesTime = BigInt.fromString("123456"); const mockTwaOracle = (): TwaOracle => { - let twaOracle = loadOrCreateTwaOracle(BEAN_WETH_CP2_WELL.toHexString()); + let twaOracle = loadOrCreateTwaOracle(BEAN_WETH_CP2_WELL); twaOracle.cumulativeWellReserves = mockReserves; twaOracle.cumulativeWellReservesTime = mockReservesTime; twaOracle.save(); @@ -40,6 +41,9 @@ const mockTwaOracle = (): TwaOracle => { }; describe("L2SR", () => { + beforeEach(() => { + initL1Version(); + }); afterEach(() => { mockSeedGaugeLockedBeansReverts(mockReserves, mockReservesTime); clearStore(); @@ -57,7 +61,7 @@ describe("L2SR", () => { assert.assertTrue(lockedUnderlyingBean.equals(BigDecimal.fromString("0.6620572696973799"))); assert.assertTrue(lockedUnderlyingLp.equals(BigDecimal.fromString("0.6620572696973799"))); - let pool = loadOrCreatePool(BEAN_WETH_CP2_WELL.toHexString(), BEAN_WETH_UNRIPE_MIGRATION_BLOCK); + let pool = loadOrCreatePool(BEAN_WETH_CP2_WELL, BEAN_WETH_UNRIPE_MIGRATION_BLOCK); pool.reserves = [BigInt.fromString("14544448316811"), BigInt.fromString("4511715111212845829348")]; pool.save(); @@ -73,11 +77,11 @@ describe("L2SR", () => { describe("Post-Replant", () => { beforeEach(() => { - let bean = loadBean(BEAN_ERC20.toHexString()); + let bean = loadBean(BEAN_ERC20); bean.supply = BigInt.fromString("5000").times(BI_10.pow(6)); bean.save(); - let pool = loadOrCreatePool(BEAN_WETH_CP2_WELL.toHexString(), BEAN_WETH_CP2_WELL_BLOCK); + let pool = loadOrCreatePool(BEAN_WETH_CP2_WELL, BEAN_WETH_CP2_WELL_BLOCK); pool.reserves = [BigInt.fromString("1000").times(BI_10.pow(6)), ONE_BI]; pool.save(); }); diff --git a/projects/subgraph-beanft/schema.graphql b/projects/subgraph-beanft/schema.graphql index 4b842617ce..9b000c13ff 100644 --- a/projects/subgraph-beanft/schema.graphql +++ b/projects/subgraph-beanft/schema.graphql @@ -6,6 +6,8 @@ type Version @entity { subgraphName: String! "Verison number of the subgraph" versionNumber: String! + "Address of Beanstalk protocol" + protocolAddress: Bytes! "Which blockchain is being indexed, i.e. 'ethereum', 'arbitrum', etc." chain: String! } diff --git a/projects/subgraph-beanft/src/utils/Init.ts b/projects/subgraph-beanft/src/utils/Init.ts index 19e683964b..b5301973d6 100644 --- a/projects/subgraph-beanft/src/utils/Init.ts +++ b/projects/subgraph-beanft/src/utils/Init.ts @@ -1,10 +1,12 @@ -import { BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../generated/schema"; +import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); versionEntity.versionNumber = "1.0.2"; versionEntity.subgraphName = subgraphNameForBlockNumber(block.number); + versionEntity.protocolAddress = protocolForBlockNumber(block.number); versionEntity.chain = chainForBlockNumber(block.number); versionEntity.save(); } @@ -16,6 +18,13 @@ function subgraphNameForBlockNumber(blockNumber: BigInt): string { throw new Error("Unable to initialize subgraph name for this block number"); } +function protocolForBlockNumber(blockNumber: BigInt): Address { + if (blockNumber == BigInt.fromU32(12974075)) { + return BEANSTALK; + } + throw new Error("Unable to initialize protocol address for this block number"); +} + function chainForBlockNumber(blockNumber: BigInt): string { if (blockNumber == BigInt.fromU32(13323594)) { return "ethereum"; diff --git a/projects/subgraph-beanstalk/schema.graphql b/projects/subgraph-beanstalk/schema.graphql index e486ed70c7..d3bd6f59c7 100644 --- a/projects/subgraph-beanstalk/schema.graphql +++ b/projects/subgraph-beanstalk/schema.graphql @@ -1,4 +1,16 @@ -# Some items included in this schema come from and are inspired by the Messari Generic Schema +# This same entity schema is intended for use across the subgraphs +type Version @entity { + "= 'subgraph'" + id: ID! + "= 'beanstalk'" + subgraphName: String! + "Verison number of the subgraph" + versionNumber: String! + "Address of Beanstalk protocol" + protocolAddress: Bytes! + "Which blockchain is being indexed, i.e. 'ethereum', 'arbitrum', etc." + chain: String! +} enum MarketStatus { ACTIVE @@ -21,18 +33,6 @@ enum EmaWindow { ROLLING_30_DAY } -# This same entity schema is intended for use across the subgraphs -type Version @entity { - "= 'subgraph'" - id: ID! - "= 'beanstalk'" - subgraphName: String! - "Verison number of the subgraph" - versionNumber: String! - "Which blockchain is being indexed, i.e. 'ethereum', 'arbitrum', etc." - chain: String! -} - type Beanstalk @entity { "Smart contract address of the protocol's main contract (Factory, Registry, etc) " id: ID! diff --git a/projects/subgraph-beanstalk/src/handlers/MarketplaceHandler.ts b/projects/subgraph-beanstalk/src/handlers/MarketplaceHandler.ts index 95b5c624be..380b46fe3c 100644 --- a/projects/subgraph-beanstalk/src/handlers/MarketplaceHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/MarketplaceHandler.ts @@ -8,26 +8,13 @@ import { PodOrderCancelled } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { - PodListingCancelled as PodListingCancelledEvent, - PodOrderCancelled as PodOrderCancelledEvent, - PodOrder, - PodListing -} from "../../generated/schema"; -import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { - MarketplaceAction, podListingCancelled, podListingCreated, podListingFilled, podOrderCancelled, podOrderCreated, - podOrderFilled, - updateActiveListings, - updateActiveOrders, - updateMarketListingBalances, - updateMarketOrderBalances + podOrderFilled } from "../utils/Marketplace"; -import { getHarvestableIndex } from "../entities/Beanstalk"; export function handlePodListingCreated(event: PodListingCreated): void { podListingCreated({ diff --git a/projects/subgraph-beanstalk/src/utils/Init.ts b/projects/subgraph-beanstalk/src/utils/Init.ts index c9be680127..cff1e6f4de 100644 --- a/projects/subgraph-beanstalk/src/utils/Init.ts +++ b/projects/subgraph-beanstalk/src/utils/Init.ts @@ -1,10 +1,12 @@ -import { BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../generated/schema"; +import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); versionEntity.versionNumber = "2.4.1"; versionEntity.subgraphName = subgraphNameForBlockNumber(block.number); + versionEntity.protocolAddress = protocolForBlockNumber(block.number); versionEntity.chain = chainForBlockNumber(block.number); versionEntity.save(); } @@ -16,6 +18,13 @@ function subgraphNameForBlockNumber(blockNumber: BigInt): string { throw new Error("Unable to initialize subgraph name for this block number"); } +function protocolForBlockNumber(blockNumber: BigInt): Address { + if (blockNumber == BigInt.fromU32(12974075)) { + return BEANSTALK; + } + throw new Error("Unable to initialize protocol address for this block number"); +} + function chainForBlockNumber(blockNumber: BigInt): string { if (blockNumber == BigInt.fromU32(12974075)) { return "ethereum"; diff --git a/projects/subgraph-core/utils/Bytes.ts b/projects/subgraph-core/utils/Bytes.ts index a74b0ce5e5..df6bf3080f 100644 --- a/projects/subgraph-core/utils/Bytes.ts +++ b/projects/subgraph-core/utils/Bytes.ts @@ -1,4 +1,4 @@ -import { BigInt, Bytes } from "@graphprotocol/graph-ts"; +import { BigInt, Bytes, Address } from "@graphprotocol/graph-ts"; // If all zeros are provided, convert into a null. Otherwise return the provided value export function Bytes4_emptyToNull(b: Bytes): Bytes | null { @@ -13,3 +13,23 @@ export function BigInt_bigEndian(s: string): BigInt { export function Bytes_bigEndian(s: string): Bytes { return Bytes.fromUint8Array(Bytes.fromHexString(s).reverse()); } + +export function toAddress(b: Bytes): Address { + return Address.fromBytes(b); +} + +export function toAddressArray(b: Bytes[]): Address[] { + const retval: Address[] = []; + for (let i = 0; i < b.length; ++i) { + retval.push(Address.fromBytes(b[i])); + } + return retval; +} + +export function toBytesArray(a: Address[]): Bytes[] { + const retval: Bytes[] = []; + for (let i = 0; i < a.length; ++i) { + retval.push(a[i]); + } + return retval; +} From e9420ad393d14bd78dbc3627a3b2ad5151d73bcf Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:26:32 -0700 Subject: [PATCH 09/88] update bean manifest --- .../subgraph-bean/manifests/codegen-abis.yaml | 2 +- .../subgraph-bean/manifests/ethereum.yaml | 121 ++++++++++++++---- .../src/handlers/BeanstalkHandler.ts | 89 ++----------- .../src/handlers/BlockHandler.ts | 73 ----------- .../src/handlers/CrossHandler.ts | 12 ++ .../handlers/legacy/LegacyBean3CRVHandler.ts | 42 +++--- .../src/handlers/legacy/LegacyBeanHandler.ts | 1 + .../handlers/legacy/LegacyBeanstalkHandler.ts | 85 ++++++++++++ .../src/handlers/legacy/LegacyCrossHandler.ts | 12 ++ projects/subgraph-bean/src/utils/Bean.ts | 20 +-- projects/subgraph-bean/src/utils/Cross.ts | 56 +++++++- .../src/utils/legacy/Beanstalk.ts | 20 +++ .../src/utils/price/CurvePrice.ts | 6 +- .../src/utils/price/UniswapPrice.ts | 8 +- projects/subgraph-bean/tests/Cross.test.ts | 11 +- 15 files changed, 335 insertions(+), 223 deletions(-) delete mode 100644 projects/subgraph-bean/src/handlers/BlockHandler.ts create mode 100644 projects/subgraph-bean/src/handlers/CrossHandler.ts create mode 100644 projects/subgraph-bean/src/handlers/legacy/LegacyCrossHandler.ts create mode 100644 projects/subgraph-bean/src/utils/legacy/Beanstalk.ts diff --git a/projects/subgraph-bean/manifests/codegen-abis.yaml b/projects/subgraph-bean/manifests/codegen-abis.yaml index 776757986f..f70b9e4462 100644 --- a/projects/subgraph-bean/manifests/codegen-abis.yaml +++ b/projects/subgraph-bean/manifests/codegen-abis.yaml @@ -47,4 +47,4 @@ dataSources: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 8ed060c003..79c76f894a 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -26,12 +26,12 @@ dataSources: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts ### # BEAN TOKEN ### - kind: ethereum/contract - name: BeanV1 + name: Bean-V1 network: mainnet source: address: "0xDC59ac4FeFa32293A95889Dc396682858d52e5Db" @@ -46,14 +46,12 @@ dataSources: abis: - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: Transfer(indexed address,indexed address,uint256) - handler: handleTransfer - file: ../src/BeanHandler.ts + handler: handleTransfer_v1 + file: ../src/handlers/legacy/LegacyBeanHandler.ts - kind: ethereum/contract - name: Bean + name: BeanV2 network: mainnet source: address: "0xBEA0000029AD1c77D3d5D23Ba2D8893dB9d1Efab" @@ -73,7 +71,7 @@ dataSources: eventHandlers: - event: Transfer(indexed address,indexed address,uint256) handler: handleTransfer - file: ../src/BeanHandler.ts + file: ../src/handlers/BeanHandler.ts ### # BEANSTALK PROTOCOL ### @@ -90,7 +88,7 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - Beanstalk + - Bean abis: - name: Beanstalk file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json @@ -111,8 +109,6 @@ dataSources: - name: ERC20 file: ../../subgraph-core/abis/ERC20.json eventHandlers: - - event: Sunrise(indexed uint256) - handler: handleSunrise - event: DewhitelistToken(indexed address) handler: handleDewhitelistToken - event: Reward(indexed uint32,uint256,uint256,uint256) @@ -121,7 +117,68 @@ dataSources: handler: handleChop - event: Convert(indexed address,address,address,uint256,uint256) handler: handleConvert - file: ../src/BeanstalkHandler.ts + file: ../src/handlers/BeanstalkHandler.ts + - kind: ethereum/contract + name: Beanstalk-V1 + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: PreReplant + startBlock: 12974075 + endBlock: 14602789 # Exploit + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Bean + abis: + - name: PreReplant + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: CurvePrice + file: ../../subgraph-core/abis/CurvePrice.json + - name: UniswapV2Pair + file: ../../subgraph-core/abis/UniswapV2Pair.json + - name: Bean3CRV + file: ../../subgraph-core/abis/Bean3CRV.json + - name: CalculationsCurve + file: ../../subgraph-core/abis/CalculationsCurve.json + eventHandlers: + - event: Sunrise(indexed uint256) + handler: handleSunrise_v1 + file: ../src/handlers/legacy/LegacyBeanstalkHandler.ts + - kind: ethereum/contract + name: BeanstalkV2 + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: PreReplant + startBlock: 15277986 # Replanted + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Bean + abis: + - name: PreReplant + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: CurvePrice + file: ../../subgraph-core/abis/CurvePrice.json + - name: UniswapV2Pair + file: ../../subgraph-core/abis/UniswapV2Pair.json + - name: Bean3CRV + file: ../../subgraph-core/abis/Bean3CRV.json + - name: CalculationsCurve + file: ../../subgraph-core/abis/CalculationsCurve.json + eventHandlers: + - event: Sunrise(indexed uint256) + handler: handleSunrise_v2 + file: ../src/handlers/legacy/LegacyBeanstalkHandler.ts - kind: ethereum/contract name: TWAPOracles network: mainnet @@ -154,11 +211,11 @@ dataSources: # POOLS ### - kind: ethereum/contract - name: BeanUniswapV2Pair + name: BeanETH-V1 network: mainnet source: address: "0x87898263B6C5BABe34b4ec53F22d98430b91e371" - abi: UniswapV2Pair-V1 + abi: UniswapV2Pair startBlock: 12974077 endBlock: 14602790 mapping: @@ -166,12 +223,7 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - Approval - - Burn - - Mint - - Swap - - Sync - - Transfer + - Pool abis: - name: UniswapV2Pair file: ../../subgraph-core/abis/UniswapV2Pair.json @@ -196,7 +248,7 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - Bean3CRV + - Pool abis: - name: Bean3CRV file: ../../subgraph-core/abis/Bean3CRV.json @@ -233,7 +285,7 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - Bean3CRV + - Pool abis: - name: Bean3CRV file: ../../subgraph-core/abis/Bean3CRV.json @@ -269,7 +321,7 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - Bean3CRV + - Pool abis: - name: Bean3CRV file: ../../subgraph-core/abis/Bean3CRV.json @@ -376,14 +428,14 @@ dataSources: ### # PEG CROSS CHECK PER BLOCK ### - # TODO: refactor this into multiple data sources - kind: ethereum/contract - name: BlockHandler + name: CrossCheck-V1 network: mainnet source: address: "0x87898263B6C5BABe34b4ec53F22d98430b91e371" abi: UniswapV2Pair startBlock: 12974077 + endBlock: 14602789 # Exploit mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -393,11 +445,28 @@ dataSources: abis: - name: UniswapV2Pair file: ../../subgraph-core/abis/UniswapV2Pair.json + blockHandlers: + - handler: handleBlock_v1 + file: ../src/handlers/legacy/LegacyCrossHandler.ts + - kind: ethereum/contract + name: CrossCheck + network: mainnet + source: + address: "0xb01CE0008CaD90104651d6A84b6B11e182a9B62A" + abi: BeanstalkPrice + startBlock: 15277986 # Replanted + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - BeanCross + abis: - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json blockHandlers: - handler: handleBlock - file: ../src/handlers/BlockHandler.ts + file: ../src/handlers/CrossHandler.ts # features: # - grafting # graft: diff --git a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts index 0099b2c9e3..5a3e9f6887 100644 --- a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts @@ -1,94 +1,23 @@ import { BigInt } from "@graphprotocol/graph-ts"; -import { beanstalkPrice_updatePoolPrices } from "./BlockHandler"; -import { updateBeanSeason, updateBeanSupplyPegPercent, updateBeanTwa, updateBeanValues } from "../utils/Bean"; +import { updateBeanSupplyPegPercent, updateBeanTwa, updateBeanValues } from "../utils/Bean"; import { Chop, Convert, DewhitelistToken, Reward, Sunrise } from "../../generated/Bean-ABIs/Beanstalk"; -import { CurvePrice } from "../../generated/Bean-ABIs/CurvePrice"; -import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../subgraph-core/utils/Constants"; -import { loadOrCreatePool } from "../entities/Pool"; -import { updatePoolPrice, updatePoolSeason, updatePoolValues } from "../utils/Pool"; +import { BEAN_3CRV } from "../../../subgraph-core/utils/Constants"; import { loadBean } from "../entities/Bean"; -import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { checkBeanCross } from "../utils/Cross"; -import { DeltaBPriceLiquidity } from "../utils/price/Types"; -import { calcUniswapV2Inst, setUniswapV2Twa } from "../utils/price/UniswapPrice"; -import { calcCurveInst, setCurveTwa } from "../utils/price/CurvePrice"; +import { setCurveTwa } from "../utils/price/CurvePrice"; import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BasinBip"; import { setRawWellReserves, setTwaLast } from "../utils/price/TwaOracle"; import { decodeCumulativeWellReserves, setWellTwa } from "../utils/price/WellPrice"; import { getProtocolToken, isUnripe } from "../utils/constants/Addresses"; +import { updateSeason } from "../utils/legacy/Beanstalk"; +import { updatePoolPricesOnCross } from "../utils/Cross"; +// Beanstalk 3 handler here, might not put this in the manifest yet - do not delete. export function handleSunrise(event: Sunrise): void { - // Update the season for hourly and daily liquidity metrics - - let beanToken = getProtocolToken(event.block.number); - - updateBeanSeason(beanToken, event.block.timestamp, event.params.season.toI32()); - - let bean = loadBean(beanToken); - let oldBeanPrice = bean.price; - for (let i = 0; i < bean.pools.length; i++) { - updatePoolSeason(bean.pools[i], event.params.season.toI32(), event.block); - } - - for (let i = 0; i < bean.dewhitelistedPools.length; i++) { - updatePoolSeason(bean.dewhitelistedPools[i], event.params.season.toI32(), event.block); - } + updateSeason(event.params.season.toI32(), event.block); // Fetch price from price contract to capture any non-bean token price movevements - if (event.params.season > BigInt.fromI32(6074)) { - // Attempt to pull from Beanstalk Price contract first for the overall Bean price update - // Update the current price regardless of a peg cross - let updatedPrices = beanstalkPrice_updatePoolPrices(false, event.block); - - if (!updatedPrices) { - // Pre Basin deployment - Use original Curve price contract to update on each season. - let curvePrice = CurvePrice.bind(CURVE_PRICE); - let curve = curvePrice.try_getCurve(); - let beanCurve = loadOrCreatePool(BEAN_3CRV, event.block.number); - - if (!curve.reverted) { - updateBeanValues(beanToken, toDecimal(curve.value.price), ZERO_BI, ZERO_BI, ZERO_BD, ZERO_BD, event.block); - updatePoolValues( - BEAN_3CRV, - ZERO_BI, - ZERO_BD, - toDecimal(curve.value.liquidity).minus(beanCurve.liquidityUSD), - curve.value.deltaB, - event.block - ); - updatePoolPrice(BEAN_3CRV, toDecimal(curve.value.price), event.block); - checkBeanCross(beanToken, oldBeanPrice, toDecimal(curve.value.price), event.block); - } - } - } else { - // Pre-Replant - let bean = loadBean(beanToken); - let weightedPrice = ZERO_BD; - let totalLiquidity = ZERO_BD; - for (let i = 0; i < bean.pools.length; i++) { - const pool = loadOrCreatePool(bean.pools[i], event.block.number); - let inst: DeltaBPriceLiquidity; - if (bean.pools[i] == BEAN_WETH_V1) { - inst = calcUniswapV2Inst(pool); - setUniswapV2Twa(bean.pools[i], event.block); - } else { - inst = calcCurveInst(pool); - setCurveTwa(bean.pools[i], event.block); - } - - // Update price, liquidity, and deltaB in the pool - updatePoolValues(bean.pools[i], ZERO_BI, ZERO_BD, inst.liquidity.minus(pool.liquidityUSD), inst.deltaB, event.block); - updatePoolPrice(bean.pools[i], inst.price, event.block); - - weightedPrice = weightedPrice.plus(inst.price.times(inst.liquidity)); - totalLiquidity = totalLiquidity.plus(inst.liquidity); - } - - const totalPrice = weightedPrice.div(totalLiquidity); - updateBeanValues(beanToken, totalPrice, ZERO_BI, ZERO_BI, ZERO_BD, totalLiquidity.minus(bean.liquidityUSD), event.block); - checkBeanCross(beanToken, bean.price, totalPrice, event.block); - updateBeanTwa(event.block); - } + // Update the current price regardless of a peg cross + updatePoolPricesOnCross(false, event.block); } // Assumption is that the whitelisted token corresponds to a pool lp. If not, this method will simply do nothing. diff --git a/projects/subgraph-bean/src/handlers/BlockHandler.ts b/projects/subgraph-bean/src/handlers/BlockHandler.ts deleted file mode 100644 index 8ff8dbb992..0000000000 --- a/projects/subgraph-bean/src/handlers/BlockHandler.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { ethereum } from "@graphprotocol/graph-ts"; -import { checkPegCrossEth as univ2_checkPegCrossEth } from "./legacy/LegacyUniswapV2Handler"; -import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "../../cache-builder/results/PegCrossBlocks_eth"; -import { BEAN_ERC20, BEAN_WETH_CP2_WELL_BLOCK, EXPLOIT_BLOCK } from "../../../subgraph-core/utils/Constants"; -import { u32_binarySearchIndex } from "../../../subgraph-core/utils/Math"; -import { BeanstalkPrice_try_price } from "../utils/price/BeanstalkPrice"; -import { loadBean } from "../entities/Bean"; -import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { checkBeanCross, checkPoolCross } from "../utils/Cross"; -import { loadOrCreatePool } from "../entities/Pool"; -import { updatePoolPrice, updatePoolValues } from "../utils/Pool"; -import { updateBeanValues } from "../utils/Bean"; - -// Processing as each new ethereum block is created -export function handleBlock(block: ethereum.Block): void { - // Avoid checking for peg crosses on blocks which are already known to not have any cross. - // The underlying methods do not write any data unless there is a cross - if (block.number.toU32() > PEG_CROSS_BLOCKS_LAST || u32_binarySearchIndex(PEG_CROSS_BLOCKS, block.number.toU32()) != -1) { - if (block.number < EXPLOIT_BLOCK) { - univ2_checkPegCrossEth(block); - } else if (block.number >= BEAN_WETH_CP2_WELL_BLOCK) { - beanstalkPrice_updatePoolPrices(true, block); - } - } -} - -/** - * Using the BeanstalkPrice contract, updates pool prices and checks for peg crosses - * @param priceOnlyOnCross - true if the pool price should only be updated on a peg cross - * @param block - * @returns false if the price contract reverted - */ -export function beanstalkPrice_updatePoolPrices(priceOnlyOnCross: boolean, block: ethereum.Block): boolean { - const priceResult = BeanstalkPrice_try_price(BEAN_ERC20, block.number); - if (priceResult.reverted) { - // Price contract was unavailable briefly after well deployment - return false; - } - const bean = loadBean(BEAN_ERC20); - const prevPrice = bean.price; - const newPrice = toDecimal(priceResult.value.price); - - // Check for overall peg cross - const beanCrossed = checkBeanCross(BEAN_ERC20, prevPrice, newPrice, block); - - // Update pool price for each pool - necessary for checking pool cross - let totalLiquidity = ZERO_BD; - for (let i = 0; i < priceResult.value.ps.length; ++i) { - const poolPriceInfo = priceResult.value.ps[i]; - const pool = loadOrCreatePool(poolPriceInfo.pool, block.number); - - const poolCrossed = checkPoolCross(poolPriceInfo.pool, pool.lastPrice, toDecimal(poolPriceInfo.price), block); - - if (!priceOnlyOnCross || poolCrossed || beanCrossed) { - totalLiquidity = totalLiquidity.plus(toDecimal(poolPriceInfo.liquidity)); - updatePoolValues( - poolPriceInfo.pool, - ZERO_BI, - ZERO_BD, - toDecimal(poolPriceInfo.liquidity).minus(pool.liquidityUSD), - poolPriceInfo.deltaB, - block - ); - updatePoolPrice(poolPriceInfo.pool, toDecimal(poolPriceInfo.price), block, false); - } - } - - // Update bean values at the end now that the summation of pool liquidity is known - if (!priceOnlyOnCross || beanCrossed) { - updateBeanValues(BEAN_ERC20, newPrice, ZERO_BI, ZERO_BI, ZERO_BD, totalLiquidity.minus(bean.liquidityUSD), block); - } - return true; -} diff --git a/projects/subgraph-bean/src/handlers/CrossHandler.ts b/projects/subgraph-bean/src/handlers/CrossHandler.ts new file mode 100644 index 0000000000..0f0fb1c752 --- /dev/null +++ b/projects/subgraph-bean/src/handlers/CrossHandler.ts @@ -0,0 +1,12 @@ +import { ethereum } from "@graphprotocol/graph-ts"; +import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "../../cache-builder/results/PegCrossBlocks_eth"; +import { u32_binarySearchIndex } from "../../../subgraph-core/utils/Math"; +import { updatePoolPricesOnCross } from "../utils/Cross"; + +export function handleBlock(block: ethereum.Block): void { + // Avoid checking for peg crosses on blocks which are already known to not have any cross. + // The underlying methods do not write any data unless there is a cross + if (block.number.toU32() > PEG_CROSS_BLOCKS_LAST || u32_binarySearchIndex(PEG_CROSS_BLOCKS, block.number.toU32()) != -1) { + updatePoolPricesOnCross(true, block); + } +} diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts index 570dbe13d8..6be4811d69 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts @@ -57,11 +57,11 @@ export function handleRemoveLiquidityOne(event: RemoveLiquidityOne): void { } function handleLiquidityChange(poolAddress: Address, isBoth: boolean, block: ethereum.Block): void { - // TODO: refactor this part out from liquidity and swap - let deltaB; - let newPoolPrice; - let reserveBalances; - let deltaLiquidityUSD; + // TODO: refactor this part out from liquidity and swap so it is not repeated + let deltaB = ZERO_BI; + let newPoolPrice = ZERO_BD; + let reserveBalances: BigInt[] = []; + let deltaLiquidityUSD = ZERO_BD; if (poolAddress === BEAN_3CRV_V1) { let pool = loadOrCreatePool(poolAddress, block.number); @@ -104,7 +104,7 @@ function handleLiquidityChange(poolAddress: Address, isBoth: boolean, block: eth deltaLiquidityUSD < ZERO_BD ? deltaLiquidityUSD.div(BigDecimal.fromString("2")).times(BigDecimal.fromString("-1")) : deltaLiquidityUSD.div(BigDecimal.fromString("2")); - let volumeBean = BigInt.fromString(volumeUSD.div(newPoolPrice!).times(BigDecimal.fromString("1000000")).truncate(0).toString()); + let volumeBean = BigInt.fromString(volumeUSD.div(newPoolPrice).times(BigDecimal.fromString("1000000")).truncate(0).toString()); // Ideally this would constitute volume if both tokens are involved, but not in equal proportion. if (isBoth) { @@ -114,9 +114,9 @@ function handleLiquidityChange(poolAddress: Address, isBoth: boolean, block: eth setPoolReserves(poolAddress, reserveBalances, block); updatePoolValues(poolAddress, volumeBean, volumeUSD, deltaLiquidityUSD, deltaB, block); - updatePoolPrice(poolAddress, newPoolPrice!, block); + updatePoolPrice(poolAddress, newPoolPrice, block); - updateBeanAfterPoolSwap(poolAddress, newPoolPrice!, volumeBean, volumeUSD, deltaLiquidityUSD, block); + updateBeanAfterPoolSwap(poolAddress, newPoolPrice, volumeBean, volumeUSD, deltaLiquidityUSD, block); } function handleSwap( @@ -127,29 +127,29 @@ function handleSwap( tokens_bought: BigInt, block: ethereum.Block ): void { - let deltaB; - let newPoolPrice; - let reserveBalances; - let deltaLiquidityUSD; - if (poolAddress === BEAN_3CRV_V1.toHexString()) { + let deltaB = ZERO_BI; + let newPoolPrice = ZERO_BD; + let reserveBalances: BigInt[] = []; + let deltaLiquidityUSD = ZERO_BD; + if (poolAddress === BEAN_3CRV_V1) { let pool = loadOrCreatePool(poolAddress, block.number); - let priceAndLp = curvePriceAndLp(Address.fromString(poolAddress)); + let priceAndLp = curvePriceAndLp(poolAddress); let newPoolPrice = priceAndLp[0]; let lpValue = priceAndLp[1]; let beanContract = ERC20.bind(BEAN_ERC20_V1); - let beanHolding = toDecimal(beanContract.balanceOf(Address.fromString(poolAddress))); + let beanHolding = toDecimal(beanContract.balanceOf(poolAddress)); let beanValue = beanHolding.times(newPoolPrice); let liquidityUSD = beanValue.plus(lpValue); deltaLiquidityUSD = liquidityUSD.minus(pool.liquidityUSD); - let lpContract = Bean3CRV.bind(Address.fromString(poolAddress)); + let lpContract = Bean3CRV.bind(poolAddress); reserveBalances = lpContract.get_balances(); - deltaB = curveDeltaBUsingVPrice(Address.fromString(poolAddress), reserveBalances[0]); + deltaB = curveDeltaBUsingVPrice(poolAddress, reserveBalances[0]); - if (poolAddress == BEAN_LUSD_V1.toHexString()) { + if (poolAddress == BEAN_LUSD_V1) { manualTwa(poolAddress, reserveBalances, block.timestamp); } } else { @@ -175,11 +175,11 @@ function handleSwap( } else if (bought_id == ZERO_BI) { volumeBean = tokens_bought; } - let volumeUSD = toDecimal(volumeBean).times(newPoolPrice!); + let volumeUSD = toDecimal(volumeBean).times(newPoolPrice); setPoolReserves(poolAddress, reserveBalances, block); updatePoolValues(poolAddress, volumeBean, volumeUSD, deltaLiquidityUSD, deltaB, block); - updatePoolPrice(poolAddress, newPoolPrice!, block); + updatePoolPrice(poolAddress, newPoolPrice, block); - updateBeanAfterPoolSwap(poolAddress, newPoolPrice!, volumeBean, volumeUSD, deltaLiquidityUSD, block); + updateBeanAfterPoolSwap(poolAddress, newPoolPrice, volumeBean, volumeUSD, deltaLiquidityUSD, block); } diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts index b0485fd80e..0454fab151 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts @@ -5,5 +5,6 @@ import { adjustSupply } from "../../utils/Bean"; export function handleTransfer_v1(event: Transfer): void { if (event.params.from == ADDRESS_ZERO || event.params.to == ADDRESS_ZERO) { adjustSupply(event.address, event.params.from == ADDRESS_ZERO ? event.params.value : event.params.value.neg()); + // Does not updateBeanSupplyPegPercent } } diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts index e69de29bb2..47182f6380 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts @@ -0,0 +1,85 @@ +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; +import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../../subgraph-core/utils/Constants"; +import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { CurvePrice } from "../../../generated/Bean-ABIs/CurvePrice"; +import { Sunrise } from "../../../generated/Bean-ABIs/PreReplant"; +import { loadBean } from "../../entities/Bean"; +import { loadOrCreatePool } from "../../entities/Pool"; +import { updateBeanTwa, updateBeanValues } from "../../utils/Bean"; +import { getProtocolToken } from "../../utils/constants/Addresses"; +import { checkBeanCross, updatePoolPricesOnCross } from "../../utils/Cross"; +import { updateSeason } from "../../utils/legacy/Beanstalk"; +import { updatePoolPrice, updatePoolValues } from "../../utils/Pool"; +import { calcCurveInst, setCurveTwa } from "../../utils/price/CurvePrice"; +import { DeltaBPriceLiquidity } from "../../utils/price/Types"; +import { calcUniswapV2Inst, setUniswapV2Twa } from "../../utils/price/UniswapPrice"; + +export function handleSunrise_v1(event: Sunrise): void { + updateSeason(event.params.season.toI32(), event.block); + + // V1 logic below + let beanToken = getProtocolToken(event.block.number); + + let bean = loadBean(beanToken); + let weightedPrice = ZERO_BD; + let totalLiquidity = ZERO_BD; + for (let i = 0; i < bean.pools.length; i++) { + const poolAddress = toAddress(bean.pools[i]); + const pool = loadOrCreatePool(poolAddress, event.block.number); + let inst: DeltaBPriceLiquidity; + if (poolAddress == BEAN_WETH_V1) { + inst = calcUniswapV2Inst(pool); + setUniswapV2Twa(poolAddress, event.block); + } else { + inst = calcCurveInst(pool); + setCurveTwa(poolAddress, event.block); + } + + // Update price, liquidity, and deltaB in the pool + updatePoolValues(poolAddress, ZERO_BI, ZERO_BD, inst.liquidity.minus(pool.liquidityUSD), inst.deltaB, event.block); + updatePoolPrice(poolAddress, inst.price, event.block); + + weightedPrice = weightedPrice.plus(inst.price.times(inst.liquidity)); + totalLiquidity = totalLiquidity.plus(inst.liquidity); + } + + const totalPrice = weightedPrice.div(totalLiquidity); + updateBeanValues(beanToken, totalPrice, ZERO_BI, ZERO_BI, ZERO_BD, totalLiquidity.minus(bean.liquidityUSD), event.block); + checkBeanCross(beanToken, bean.price, totalPrice, event.block); + updateBeanTwa(event.block); +} + +export function handleSunrise_v2(event: Sunrise): void { + updateSeason(event.params.season.toI32(), event.block); + + // V2 logic below + let beanToken = getProtocolToken(event.block.number); + let bean = loadBean(beanToken); + let oldBeanPrice = bean.price; + + // Fetch price from price contract to capture any non-bean token price movevements + // Attempt to pull from Beanstalk Price contract first for the overall Bean price update + // Update the current price regardless of a peg cross + let updatedPrices = updatePoolPricesOnCross(false, event.block); + + if (!updatedPrices) { + // Pre Basin deployment - Use original Curve price contract to update on each season. + let curvePrice = CurvePrice.bind(CURVE_PRICE); + let curve = curvePrice.try_getCurve(); + let beanCurve = loadOrCreatePool(BEAN_3CRV, event.block.number); + + if (!curve.reverted) { + updateBeanValues(beanToken, toDecimal(curve.value.price), ZERO_BI, ZERO_BI, ZERO_BD, ZERO_BD, event.block); + updatePoolValues( + BEAN_3CRV, + ZERO_BI, + ZERO_BD, + toDecimal(curve.value.liquidity).minus(beanCurve.liquidityUSD), + curve.value.deltaB, + event.block + ); + updatePoolPrice(BEAN_3CRV, toDecimal(curve.value.price), event.block); + checkBeanCross(beanToken, oldBeanPrice, toDecimal(curve.value.price), event.block); + } + } +} diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyCrossHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyCrossHandler.ts new file mode 100644 index 0000000000..dc80713b91 --- /dev/null +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyCrossHandler.ts @@ -0,0 +1,12 @@ +import { ethereum } from "@graphprotocol/graph-ts"; +import { checkPegCrossEth as univ2_checkPegCrossEth } from "./LegacyUniswapV2Handler"; +import { u32_binarySearchIndex } from "../../../../subgraph-core/utils/Math"; +import { PEG_CROSS_BLOCKS, PEG_CROSS_BLOCKS_LAST } from "../../../cache-builder/results/PegCrossBlocks_eth"; + +export function handleBlock_v1(block: ethereum.Block): void { + // Avoid checking for peg crosses on blocks which are already known to not have any cross. + // The underlying methods do not write any data unless there is a cross + if (block.number.toU32() > PEG_CROSS_BLOCKS_LAST || u32_binarySearchIndex(PEG_CROSS_BLOCKS, block.number.toU32()) != -1) { + univ2_checkPegCrossEth(block); + } +} diff --git a/projects/subgraph-bean/src/utils/Bean.ts b/projects/subgraph-bean/src/utils/Bean.ts index 9f8abccff4..2d9df026af 100644 --- a/projects/subgraph-bean/src/utils/Bean.ts +++ b/projects/subgraph-bean/src/utils/Bean.ts @@ -128,30 +128,30 @@ export function updateBeanAfterPoolSwap( block: ethereum.Block, priceContractResult: BeanstalkPriceResult | null = null ): void { - let pool = loadOrCreatePool(poolAddress, block.number); - let bean = loadBean(pool.bean); - const beanToken = toAddress(bean.id); + const pool = loadOrCreatePool(poolAddress, block.number); + const beanAddr = toAddress(pool.bean); + const bean = loadBean(beanAddr); // Verify the pool is still whitelisted if (bean.pools.indexOf(poolAddress) >= 0) { - let oldBeanPrice = bean.price; + const oldBeanPrice = bean.price; let beanPrice = poolPrice; // Get overall price from price contract if a result was not already provided - if (beanToken == BEAN_ERC20_V1) { + if (beanAddr == BEAN_ERC20_V1) { univ2_externalUpdatePoolPrice(BEAN_WETH_V1, block); - beanPrice = calcLiquidityWeightedBeanPrice(beanToken); + beanPrice = calcLiquidityWeightedBeanPrice(beanAddr); } else { if (priceContractResult === null) { - priceContractResult = BeanstalkPrice_try_price(beanToken, block.number); + priceContractResult = BeanstalkPrice_try_price(beanAddr, block.number); } if (!priceContractResult.reverted) { beanPrice = toDecimal(priceContractResult.value.price); } } - updateBeanSupplyPegPercent(pool.bean, block.number); - updateBeanValues(beanToken, beanPrice, ZERO_BI, volumeBean, volumeUSD, deltaLiquidityUSD, block); - checkBeanCross(beanToken, oldBeanPrice, beanPrice, block); + updateBeanSupplyPegPercent(beanAddr, block.number); + updateBeanValues(beanAddr, beanPrice, ZERO_BI, volumeBean, volumeUSD, deltaLiquidityUSD, block); + checkBeanCross(beanAddr, oldBeanPrice, beanPrice, block); } } diff --git a/projects/subgraph-bean/src/utils/Cross.ts b/projects/subgraph-bean/src/utils/Cross.ts index 92b8329dda..794a76d415 100644 --- a/projects/subgraph-bean/src/utils/Cross.ts +++ b/projects/subgraph-bean/src/utils/Cross.ts @@ -1,9 +1,13 @@ import { BigDecimal, Address, ethereum, log } from "@graphprotocol/graph-ts"; -import { ONE_BD } from "../../../subgraph-core/utils/Decimals"; +import { ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { BEAN_ERC20_V1 } from "../../../subgraph-core/utils/Constants"; import { loadOrCreatePool, loadOrCreatePoolDailySnapshot, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../entities/Bean"; import { loadOrCreateBeanCross, loadOrCreatePoolCross } from "../entities/Cross"; +import { BeanstalkPrice_try_price } from "./price/BeanstalkPrice"; +import { updatePoolPrice, updatePoolValues } from "./Pool"; +import { updateBeanValues } from "./Bean"; +import { getProtocolToken } from "./constants/Addresses"; export function checkPoolCross(pool: Address, oldPrice: BigDecimal, newPrice: BigDecimal, block: ethereum.Block): boolean { let poolInfo = loadOrCreatePool(pool, block.number); @@ -115,3 +119,53 @@ export function getV1Crosses(): i32 { let bean = loadBean(BEAN_ERC20_V1); return bean.crosses; } + +/** + * Using the BeanstalkPrice contract, updates pool prices and checks for peg crosses + * @param priceOnlyOnCross - true if the pool price should only be updated on a peg cross + * @param block + * @returns false if the price contract reverted + */ +export function updatePoolPricesOnCross(priceOnlyOnCross: boolean, block: ethereum.Block): boolean { + const beanToken = getProtocolToken(block.number); + + const priceResult = BeanstalkPrice_try_price(beanToken, block.number); + if (priceResult.reverted) { + // Price contract was unavailable briefly after well deployment + return false; + } + const bean = loadBean(beanToken); + const prevPrice = bean.price; + const newPrice = toDecimal(priceResult.value.price); + + // Check for overall peg cross + const beanCrossed = checkBeanCross(beanToken, prevPrice, newPrice, block); + + // Update pool price for each pool - necessary for checking pool cross + let totalLiquidity = ZERO_BD; + for (let i = 0; i < priceResult.value.ps.length; ++i) { + const poolPriceInfo = priceResult.value.ps[i]; + const pool = loadOrCreatePool(poolPriceInfo.pool, block.number); + + const poolCrossed = checkPoolCross(poolPriceInfo.pool, pool.lastPrice, toDecimal(poolPriceInfo.price), block); + + if (!priceOnlyOnCross || poolCrossed || beanCrossed) { + totalLiquidity = totalLiquidity.plus(toDecimal(poolPriceInfo.liquidity)); + updatePoolValues( + poolPriceInfo.pool, + ZERO_BI, + ZERO_BD, + toDecimal(poolPriceInfo.liquidity).minus(pool.liquidityUSD), + poolPriceInfo.deltaB, + block + ); + updatePoolPrice(poolPriceInfo.pool, toDecimal(poolPriceInfo.price), block, false); + } + } + + // Update bean values at the end now that the summation of pool liquidity is known + if (!priceOnlyOnCross || beanCrossed) { + updateBeanValues(beanToken, newPrice, ZERO_BI, ZERO_BI, ZERO_BD, totalLiquidity.minus(bean.liquidityUSD), block); + } + return true; +} diff --git a/projects/subgraph-bean/src/utils/legacy/Beanstalk.ts b/projects/subgraph-bean/src/utils/legacy/Beanstalk.ts new file mode 100644 index 0000000000..a43129c7bc --- /dev/null +++ b/projects/subgraph-bean/src/utils/legacy/Beanstalk.ts @@ -0,0 +1,20 @@ +import { ethereum } from "@graphprotocol/graph-ts"; +import { loadBean } from "../../entities/Bean"; +import { updateBeanSeason } from "../Bean"; +import { getProtocolToken } from "../constants/Addresses"; +import { updatePoolSeason } from "../Pool"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; + +export function updateSeason(season: i32, block: ethereum.Block): void { + let beanToken = getProtocolToken(block.number); + updateBeanSeason(beanToken, block.timestamp, season); + + let bean = loadBean(beanToken); + for (let i = 0; i < bean.pools.length; i++) { + updatePoolSeason(toAddress(bean.pools[i]), season, block); + } + + for (let i = 0; i < bean.dewhitelistedPools.length; i++) { + updatePoolSeason(toAddress(bean.dewhitelistedPools[i]), season, block); + } +} diff --git a/projects/subgraph-bean/src/utils/price/CurvePrice.ts b/projects/subgraph-bean/src/utils/price/CurvePrice.ts index 82f783c636..9dd4428edc 100644 --- a/projects/subgraph-bean/src/utils/price/CurvePrice.ts +++ b/projects/subgraph-bean/src/utils/price/CurvePrice.ts @@ -17,6 +17,7 @@ import { setPoolTwa } from "../Pool"; import { getTWAPrices } from "./TwaOracle"; import { loadOrCreateTwaOracle } from "../../entities/TwaOracle"; import { CalculationsCurve } from "../../../generated/Bean-ABIs/CalculationsCurve"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; // Note that the Bean3CRV type applies to any curve pool (including lusd) @@ -60,11 +61,12 @@ export function curvePriceAndLp(pool: Address): BigDecimal[] { } export function calcCurveInst(pool: Pool): DeltaBPriceLiquidity { - const priceAndLp = curvePriceAndLp(pool.id); + const poolAddr = toAddress(pool.id); + const priceAndLp = curvePriceAndLp(poolAddr); return { price: priceAndLp[0], liquidity: priceAndLp[1], - deltaB: curveDeltaBUsingVPrice(pool.id, pool.reserves[0]) + deltaB: curveDeltaBUsingVPrice(poolAddr, pool.reserves[0]) }; } diff --git a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts index 91eaec9d8a..d710627a23 100644 --- a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts +++ b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts @@ -1,16 +1,16 @@ import { Address, BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { BD_10, BI_10, ONE_BI, pow, sqrt, toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; -import { Pool } from "../../../generated/schema"; -import { UniswapV2Pair } from "../../../generated/Bean-ABIs/UniswapV2Pair"; import { BEANSTALK, WETH, WETH_USDC_PAIR } from "../../../../subgraph-core/utils/Constants"; -import { PreReplant } from "../../../generated/Bean-ABIs/PreReplant"; import { DeltaBAndPrice, DeltaBPriceLiquidity, TWAType } from "./Types"; import { setPoolTwa } from "../Pool"; import { getTWAPrices } from "./TwaOracle"; import { loadOrCreateToken } from "../../entities/Token"; +import { UniswapV2Pair } from "../../../generated/Bean-ABIs/UniswapV2Pair"; +import { Pool } from "../../../generated/schema"; +import { PreReplant } from "../../../generated/Bean-ABIs/PreReplant"; export function updatePreReplantPriceETH(): BigDecimal { - let token = loadOrCreateToken(WETH.toHexString()); + let token = loadOrCreateToken(WETH); let price = getPreReplantPriceETH(); if (price.lt(ZERO_BD)) { return token.lastPriceUSD; diff --git a/projects/subgraph-bean/tests/Cross.test.ts b/projects/subgraph-bean/tests/Cross.test.ts index 993ff80a98..e7a3260439 100644 --- a/projects/subgraph-bean/tests/Cross.test.ts +++ b/projects/subgraph-bean/tests/Cross.test.ts @@ -14,9 +14,10 @@ import { mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves } from "./entity import { setWhitelistedPools } from "./entity-mocking/MockBean"; import { PEG_CROSS_BLOCKS } from "../cache-builder/results/PegCrossBlocks_eth"; import { u32_binarySearchIndex } from "../../subgraph-core/utils/Math"; -import { handleBlock } from "../src/handlers/BlockHandler"; +import { handleBlock } from "../src/handlers/CrossHandler"; import { loadBean } from "../src/entities/Bean"; import { initL1Version } from "./entity-mocking/MockVersion"; +import { handleBlock_v1 } from "../src/handlers/legacy/LegacyCrossHandler"; const wellCrossId = (n: u32): string => { return BEAN_WETH_CP2_WELL.toHexString() + "-" + n.toString(); @@ -95,13 +96,13 @@ describe("Peg Crosses", () => { test("UniswapV2/Bean cross above", () => { mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("0.99")); - handleBlock(mockBlock(UNIV2_CROSS_BLOCK)); + handleBlock_v1(mockBlock(UNIV2_CROSS_BLOCK)); assert.notInStore("BeanCross", "0"); assert.notInStore("PoolCross", univ2CrossId(0)); mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("1.01")); - handleBlock(mockBlock(UNIV2_CROSS_BLOCK)); + handleBlock_v1(mockBlock(UNIV2_CROSS_BLOCK)); assert.fieldEquals("BeanCross", "0", "above", "true"); assert.fieldEquals("PoolCross", univ2CrossId(0), "above", "true"); @@ -109,13 +110,13 @@ describe("Peg Crosses", () => { test("UniswapV2/Bean cross below", () => { mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("1.25")); - handleBlock(mockBlock(UNIV2_CROSS_BLOCK)); + handleBlock_v1(mockBlock(UNIV2_CROSS_BLOCK)); assert.fieldEquals("BeanCross", "0", "above", "true"); assert.fieldEquals("PoolCross", univ2CrossId(0), "above", "true"); mockPreReplantBeanEthPriceAndLiquidityWithPoolReserves(BigDecimal.fromString("0.8")); - handleBlock(mockBlock(UNIV2_CROSS_BLOCK)); + handleBlock_v1(mockBlock(UNIV2_CROSS_BLOCK)); assert.fieldEquals("BeanCross", "1", "above", "false"); assert.fieldEquals("PoolCross", univ2CrossId(1), "above", "false"); From 5893bb6c99451648e90e47b7d123734edcd2c34b Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:55:02 -0700 Subject: [PATCH 10/88] aggregate 3crv logic --- .../subgraph-bean/manifests/ethereum.yaml | 2 + .../handlers/legacy/LegacyBean3CRVHandler.ts | 114 +++--------------- .../subgraph-bean/src/utils/legacy/Curve.ts | 67 ++++++++++ 3 files changed, 89 insertions(+), 94 deletions(-) create mode 100644 projects/subgraph-bean/src/utils/legacy/Curve.ts diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 79c76f894a..933ea4f619 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -227,6 +227,8 @@ dataSources: abis: - name: UniswapV2Pair file: ../../subgraph-core/abis/UniswapV2Pair.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json eventHandlers: diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts index 6be4811d69..ef91f32b4f 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts @@ -17,6 +17,7 @@ import { manualTwa } from "../../utils/price/TwaOracle"; import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues } from "../../utils/Pool"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { CurvePrice } from "../../../generated/Bean-ABIs/CurvePrice"; +import { calcPostSwapValues } from "../../utils/legacy/Curve"; export function handleTokenExchange(event: TokenExchange): void { handleSwap( @@ -57,54 +58,16 @@ export function handleRemoveLiquidityOne(event: RemoveLiquidityOne): void { } function handleLiquidityChange(poolAddress: Address, isBoth: boolean, block: ethereum.Block): void { - // TODO: refactor this part out from liquidity and swap so it is not repeated - let deltaB = ZERO_BI; - let newPoolPrice = ZERO_BD; - let reserveBalances: BigInt[] = []; - let deltaLiquidityUSD = ZERO_BD; - if (poolAddress === BEAN_3CRV_V1) { - let pool = loadOrCreatePool(poolAddress, block.number); - - let priceAndLp = curvePriceAndLp(poolAddress); - let newPoolPrice = priceAndLp[0]; - let lpValue = priceAndLp[1]; - - let beanContract = ERC20.bind(BEAN_ERC20_V1); - let beanHolding = toDecimal(beanContract.balanceOf(poolAddress)); - let beanValue = beanHolding.times(newPoolPrice); - - let liquidityUSD = beanValue.plus(lpValue); - deltaLiquidityUSD = liquidityUSD.minus(pool.liquidityUSD); - - let lpContract = Bean3CRV.bind(poolAddress); - reserveBalances = lpContract.get_balances(); - deltaB = curveDeltaBUsingVPrice(poolAddress, reserveBalances[0]); - - if (poolAddress == BEAN_LUSD_V1) { - manualTwa(poolAddress, reserveBalances, block.timestamp); - } - } else { - // Use curve price contract - let curvePrice = CurvePrice.bind(CURVE_PRICE); - let curve = curvePrice.try_getCurve(); - - if (curve.reverted) { - return; - } - - let startingLiquidity = getPoolLiquidityUSD(poolAddress, block); - - deltaB = curve.value.deltaB; - newPoolPrice = toDecimal(curve.value.price); - reserveBalances = curve.value.balances; - deltaLiquidityUSD = toDecimal(curve.value.liquidity).minus(startingLiquidity); + const values = calcPostSwapValues(poolAddress, block); + if (values == null) { + return; } let volumeUSD = - deltaLiquidityUSD < ZERO_BD - ? deltaLiquidityUSD.div(BigDecimal.fromString("2")).times(BigDecimal.fromString("-1")) - : deltaLiquidityUSD.div(BigDecimal.fromString("2")); - let volumeBean = BigInt.fromString(volumeUSD.div(newPoolPrice).times(BigDecimal.fromString("1000000")).truncate(0).toString()); + values.deltaLiquidityUSD < ZERO_BD + ? values.deltaLiquidityUSD.div(BigDecimal.fromString("2")).times(BigDecimal.fromString("-1")) + : values.deltaLiquidityUSD.div(BigDecimal.fromString("2")); + let volumeBean = BigInt.fromString(volumeUSD.div(values.newPoolPrice).times(BigDecimal.fromString("1000000")).truncate(0).toString()); // Ideally this would constitute volume if both tokens are involved, but not in equal proportion. if (isBoth) { @@ -112,11 +75,11 @@ function handleLiquidityChange(poolAddress: Address, isBoth: boolean, block: eth volumeBean = ZERO_BI; } - setPoolReserves(poolAddress, reserveBalances, block); - updatePoolValues(poolAddress, volumeBean, volumeUSD, deltaLiquidityUSD, deltaB, block); - updatePoolPrice(poolAddress, newPoolPrice, block); + setPoolReserves(poolAddress, values.reserveBalances, block); + updatePoolValues(poolAddress, volumeBean, volumeUSD, values.deltaLiquidityUSD, values.deltaB, block); + updatePoolPrice(poolAddress, values.newPoolPrice, block); - updateBeanAfterPoolSwap(poolAddress, newPoolPrice, volumeBean, volumeUSD, deltaLiquidityUSD, block); + updateBeanAfterPoolSwap(poolAddress, values.newPoolPrice, volumeBean, volumeUSD, values.deltaLiquidityUSD, block); } function handleSwap( @@ -127,46 +90,9 @@ function handleSwap( tokens_bought: BigInt, block: ethereum.Block ): void { - let deltaB = ZERO_BI; - let newPoolPrice = ZERO_BD; - let reserveBalances: BigInt[] = []; - let deltaLiquidityUSD = ZERO_BD; - if (poolAddress === BEAN_3CRV_V1) { - let pool = loadOrCreatePool(poolAddress, block.number); - - let priceAndLp = curvePriceAndLp(poolAddress); - let newPoolPrice = priceAndLp[0]; - let lpValue = priceAndLp[1]; - - let beanContract = ERC20.bind(BEAN_ERC20_V1); - let beanHolding = toDecimal(beanContract.balanceOf(poolAddress)); - let beanValue = beanHolding.times(newPoolPrice); - - let liquidityUSD = beanValue.plus(lpValue); - deltaLiquidityUSD = liquidityUSD.minus(pool.liquidityUSD); - - let lpContract = Bean3CRV.bind(poolAddress); - reserveBalances = lpContract.get_balances(); - deltaB = curveDeltaBUsingVPrice(poolAddress, reserveBalances[0]); - - if (poolAddress == BEAN_LUSD_V1) { - manualTwa(poolAddress, reserveBalances, block.timestamp); - } - } else { - // Use curve price contract - let curvePrice = CurvePrice.bind(CURVE_PRICE); - let curve = curvePrice.try_getCurve(); - - if (curve.reverted) { - return; - } - - let startingLiquidity = getPoolLiquidityUSD(poolAddress, block); - - deltaB = curve.value.deltaB; - newPoolPrice = toDecimal(curve.value.price); - reserveBalances = curve.value.balances; - deltaLiquidityUSD = toDecimal(curve.value.liquidity).minus(startingLiquidity); + const values = calcPostSwapValues(poolAddress, block); + if (values == null) { + return; } let volumeBean = ZERO_BI; @@ -175,11 +101,11 @@ function handleSwap( } else if (bought_id == ZERO_BI) { volumeBean = tokens_bought; } - let volumeUSD = toDecimal(volumeBean).times(newPoolPrice); + let volumeUSD = toDecimal(volumeBean).times(values.newPoolPrice); - setPoolReserves(poolAddress, reserveBalances, block); - updatePoolValues(poolAddress, volumeBean, volumeUSD, deltaLiquidityUSD, deltaB, block); - updatePoolPrice(poolAddress, newPoolPrice, block); + setPoolReserves(poolAddress, values.reserveBalances, block); + updatePoolValues(poolAddress, volumeBean, volumeUSD, values.deltaLiquidityUSD, values.deltaB, block); + updatePoolPrice(poolAddress, values.newPoolPrice, block); - updateBeanAfterPoolSwap(poolAddress, newPoolPrice, volumeBean, volumeUSD, deltaLiquidityUSD, block); + updateBeanAfterPoolSwap(poolAddress, values.newPoolPrice, volumeBean, volumeUSD, values.deltaLiquidityUSD, block); } diff --git a/projects/subgraph-bean/src/utils/legacy/Curve.ts b/projects/subgraph-bean/src/utils/legacy/Curve.ts new file mode 100644 index 0000000000..a4ed489d16 --- /dev/null +++ b/projects/subgraph-bean/src/utils/legacy/Curve.ts @@ -0,0 +1,67 @@ +import { Address, BigInt, BigDecimal, ethereum } from "@graphprotocol/graph-ts"; +import { BEAN_3CRV_V1, BEAN_ERC20_V1, BEAN_LUSD_V1, CURVE_PRICE } from "../../../../subgraph-core/utils/Constants"; +import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { loadOrCreatePool } from "../../entities/Pool"; +import { manualTwa } from "../price/TwaOracle"; +import { CurvePrice } from "../../../generated/Bean-ABIs/CurvePrice"; +import { getPoolLiquidityUSD } from "../Pool"; +import { curveDeltaBUsingVPrice, curvePriceAndLp } from "../price/CurvePrice"; +import { Bean3CRV } from "../../../generated/Bean-ABIs/Bean3CRV"; +import { ERC20 } from "../../../generated/Bean-ABIs/ERC20"; + +class PostSwapValues { + deltaB: BigInt; + newPoolPrice: BigDecimal; + reserveBalances: BigInt[]; + deltaLiquidityUSD: BigDecimal; +} + +export function calcPostSwapValues(poolAddress: Address, block: ethereum.Block): PostSwapValues | null { + let deltaB = ZERO_BI; + let newPoolPrice = ZERO_BD; + let reserveBalances: BigInt[] = []; + let deltaLiquidityUSD = ZERO_BD; + if (poolAddress === BEAN_3CRV_V1) { + let pool = loadOrCreatePool(poolAddress, block.number); + + let priceAndLp = curvePriceAndLp(poolAddress); + let newPoolPrice = priceAndLp[0]; + let lpValue = priceAndLp[1]; + + let beanContract = ERC20.bind(BEAN_ERC20_V1); + let beanHolding = toDecimal(beanContract.balanceOf(poolAddress)); + let beanValue = beanHolding.times(newPoolPrice); + + let liquidityUSD = beanValue.plus(lpValue); + deltaLiquidityUSD = liquidityUSD.minus(pool.liquidityUSD); + + let lpContract = Bean3CRV.bind(poolAddress); + reserveBalances = lpContract.get_balances(); + deltaB = curveDeltaBUsingVPrice(poolAddress, reserveBalances[0]); + + if (poolAddress == BEAN_LUSD_V1) { + manualTwa(poolAddress, reserveBalances, block.timestamp); + } + } else { + // Use curve price contract + let curvePrice = CurvePrice.bind(CURVE_PRICE); + let curve = curvePrice.try_getCurve(); + + if (curve.reverted) { + return null; + } + + let startingLiquidity = getPoolLiquidityUSD(poolAddress, block); + + deltaB = curve.value.deltaB; + newPoolPrice = toDecimal(curve.value.price); + reserveBalances = curve.value.balances; + deltaLiquidityUSD = toDecimal(curve.value.liquidity).minus(startingLiquidity); + } + return { + deltaB, + newPoolPrice, + reserveBalances, + deltaLiquidityUSD + }; +} From 1df89b2e13c8139555adf12d7f7ebaa9803dde1e Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:23:46 -0700 Subject: [PATCH 11/88] refactor constants usage --- projects/subgraph-bean/src/entities/Bean.ts | 11 +++-- .../subgraph-bean/src/handlers/BeanHandler.ts | 2 +- .../src/handlers/BeanWellHandler.ts | 18 +++++--- .../src/handlers/BeanstalkHandler.ts | 1 + .../handlers/legacy/LegacyBean3CRVHandler.ts | 8 +--- projects/subgraph-bean/src/utils/Bean.ts | 2 +- projects/subgraph-bean/src/utils/Cross.ts | 5 +-- .../subgraph-bean/src/utils/LockedBeans.ts | 45 +++++++------------ .../src/utils/b3-migration/BeanInit.ts | 5 +-- .../src/utils/constants/Addresses.ts | 38 +++++++++++++++- .../src/utils/price/BeanstalkPrice.ts | 4 +- .../src/utils/price/UniswapPrice.ts | 7 ++- .../tests/BeanstalkPrice.test.ts | 10 ++--- 13 files changed, 91 insertions(+), 65 deletions(-) diff --git a/projects/subgraph-bean/src/entities/Bean.ts b/projects/subgraph-bean/src/entities/Bean.ts index 9a99bfbb69..3ce93457f5 100644 --- a/projects/subgraph-bean/src/entities/Bean.ts +++ b/projects/subgraph-bean/src/entities/Bean.ts @@ -1,16 +1,19 @@ import { BigInt, BigDecimal, Address } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20, BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20 } from "../../../subgraph-core/utils/Constants"; import { dayFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { Bean, BeanDailySnapshot, BeanHourlySnapshot } from "../../generated/schema"; import { getV1Crosses } from "../utils/Cross"; +import { getVersionEntity } from "../utils/constants/Version"; export function loadBean(token: Address): Bean { let bean = Bean.load(token); if (bean == null) { bean = new Bean(token); - bean.chain = "ethereum"; - bean.beanstalk = BEANSTALK.toHexString(); + const version = getVersionEntity(); + bean.chain = version.chain; + bean.beanstalk = version.protocolAddress.toHexString(); + bean.supply = ZERO_BI; bean.marketCap = ZERO_BD; bean.lockedBeans = ZERO_BI; @@ -19,7 +22,7 @@ export function loadBean(token: Address): Bean { bean.volumeUSD = ZERO_BD; bean.liquidityUSD = ZERO_BD; bean.price = BigDecimal.fromString("1.072"); - bean.crosses = token == BEAN_ERC20 ? getV1Crosses() : 0; // starting point for v2 is where v1 left off + bean.crosses = token == BEAN_ERC20 ? getV1Crosses() : 0; bean.lastCross = ZERO_BI; bean.lastSeason = token == BEAN_ERC20 ? 6074 : 0; bean.pools = []; diff --git a/projects/subgraph-bean/src/handlers/BeanHandler.ts b/projects/subgraph-bean/src/handlers/BeanHandler.ts index eea762fb60..566ea8cb37 100644 --- a/projects/subgraph-bean/src/handlers/BeanHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanHandler.ts @@ -1,4 +1,4 @@ -import { ADDRESS_ZERO, BEAN_ERC20_V1 } from "../../../subgraph-core/utils/Constants"; +import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Constants"; import { Transfer } from "../../generated/Bean-ABIs/ERC20"; import { adjustSupply, updateBeanSupplyPegPercent } from "../utils/Bean"; diff --git a/projects/subgraph-bean/src/handlers/BeanWellHandler.ts b/projects/subgraph-bean/src/handlers/BeanWellHandler.ts index 7901fcd6f8..e4c773e9bc 100644 --- a/projects/subgraph-bean/src/handlers/BeanWellHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanWellHandler.ts @@ -1,11 +1,12 @@ import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { AddLiquidity, RemoveLiquidity, RemoveLiquidityOneToken, Shift, Swap, Sync } from "../../generated/Bean-ABIs/Well"; import { deltaBigIntArray, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEAN_ERC20 } from "../../../subgraph-core/utils/Constants"; import { loadOrCreatePool } from "../entities/Pool"; import { BeanstalkPrice_try_price, getPoolPrice } from "../utils/price/BeanstalkPrice"; import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues } from "../utils/Pool"; import { updateBeanAfterPoolSwap } from "../utils/Bean"; +import { getProtocolToken } from "../utils/constants/Addresses"; +import { toAddress } from "../../../subgraph-core/utils/Bytes"; export function handleAddLiquidity(event: AddLiquidity): void { handleLiquidityChange(event.address, event.params.tokenAmountsIn[0], event.params.tokenAmountsIn[1], false, event.block); @@ -16,10 +17,11 @@ export function handleRemoveLiquidity(event: RemoveLiquidity): void { } export function handleRemoveLiquidityOneToken(event: RemoveLiquidityOneToken): void { + const beanAddr = getProtocolToken(event.block.number); handleLiquidityChange( event.address, - event.params.tokenOut == BEAN_ERC20 ? event.params.tokenAmountOut : ZERO_BI, - event.params.tokenOut != BEAN_ERC20 ? event.params.tokenAmountOut : ZERO_BI, + event.params.tokenOut == beanAddr ? event.params.tokenAmountOut : ZERO_BI, + event.params.tokenOut != beanAddr ? event.params.tokenAmountOut : ZERO_BI, true, event.block ); @@ -45,7 +47,7 @@ export function handleShift(event: Shift): void { handleSwapEvent( event.address, event.params.toToken, - event.params.toToken == BEAN_ERC20 ? deltaReserves[1] : deltaReserves[0], + event.params.toToken == toAddress(pool.bean) ? deltaReserves[1] : deltaReserves[0], event.params.amountOut, event.block ); @@ -59,7 +61,7 @@ function handleLiquidityChange( block: ethereum.Block ): void { // Get Price Details via Price contract - let beanPrice = BeanstalkPrice_try_price(BEAN_ERC20, block.number); + let beanPrice = BeanstalkPrice_try_price(block.number); if (beanPrice.reverted) { return; } @@ -102,7 +104,7 @@ function handleLiquidityChange( function handleSwapEvent(poolAddress: Address, toToken: Address, amountIn: BigInt, amountOut: BigInt, block: ethereum.Block): void { // Get Price Details via Price contract - let beanPrice = BeanstalkPrice_try_price(BEAN_ERC20, block.number); + let beanPrice = BeanstalkPrice_try_price(block.number); if (beanPrice.reverted) { return; } @@ -111,10 +113,12 @@ function handleSwapEvent(poolAddress: Address, toToken: Address, amountIn: BigIn return; } + const beanAddr = getProtocolToken(block.number); + let startingLiquidity = getPoolLiquidityUSD(poolAddress, block); let newPrice = toDecimal(wellPrice.price); - let volumeBean = toToken == BEAN_ERC20 ? amountOut : amountIn; + let volumeBean = toToken == beanAddr ? amountOut : amountIn; let volumeUSD = toDecimal(volumeBean).times(newPrice); let deltaLiquidityUSD = toDecimal(wellPrice.liquidity).minus(startingLiquidity); diff --git a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts index 5a3e9f6887..489c47709b 100644 --- a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts @@ -37,6 +37,7 @@ export function handleDewhitelistToken(event: DewhitelistToken): void { // POST REPLANT TWA DELTAB // +// TODO: move to legacy export function handleMetapoolOracle(event: MetapoolOracle): void { setTwaLast(BEAN_3CRV, event.params.balances, event.block.timestamp); setCurveTwa(BEAN_3CRV, event.block); diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts index ef91f32b4f..7be35ecad8 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts @@ -9,14 +9,8 @@ import { TokenExchangeUnderlying } from "../../../generated/Bean-ABIs/Bean3CRV"; import { updateBeanAfterPoolSwap } from "../../utils/Bean"; -import { BEAN_3CRV_V1, BEAN_ERC20_V1, BEAN_LUSD_V1, CURVE_PRICE } from "../../../../subgraph-core/utils/Constants"; -import { curveDeltaBUsingVPrice, curvePriceAndLp } from "../../utils/price/CurvePrice"; -import { loadOrCreatePool } from "../../entities/Pool"; -import { ERC20 } from "../../../generated/Bean-ABIs/ERC20"; -import { manualTwa } from "../../utils/price/TwaOracle"; -import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues } from "../../utils/Pool"; +import { setPoolReserves, updatePoolPrice, updatePoolValues } from "../../utils/Pool"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; -import { CurvePrice } from "../../../generated/Bean-ABIs/CurvePrice"; import { calcPostSwapValues } from "../../utils/legacy/Curve"; export function handleTokenExchange(event: TokenExchange): void { diff --git a/projects/subgraph-bean/src/utils/Bean.ts b/projects/subgraph-bean/src/utils/Bean.ts index 2d9df026af..84d413393c 100644 --- a/projects/subgraph-bean/src/utils/Bean.ts +++ b/projects/subgraph-bean/src/utils/Bean.ts @@ -142,7 +142,7 @@ export function updateBeanAfterPoolSwap( beanPrice = calcLiquidityWeightedBeanPrice(beanAddr); } else { if (priceContractResult === null) { - priceContractResult = BeanstalkPrice_try_price(beanAddr, block.number); + priceContractResult = BeanstalkPrice_try_price(block.number); } if (!priceContractResult.reverted) { beanPrice = toDecimal(priceContractResult.value.price); diff --git a/projects/subgraph-bean/src/utils/Cross.ts b/projects/subgraph-bean/src/utils/Cross.ts index 794a76d415..6dd6611676 100644 --- a/projects/subgraph-bean/src/utils/Cross.ts +++ b/projects/subgraph-bean/src/utils/Cross.ts @@ -127,13 +127,12 @@ export function getV1Crosses(): i32 { * @returns false if the price contract reverted */ export function updatePoolPricesOnCross(priceOnlyOnCross: boolean, block: ethereum.Block): boolean { - const beanToken = getProtocolToken(block.number); - - const priceResult = BeanstalkPrice_try_price(beanToken, block.number); + const priceResult = BeanstalkPrice_try_price(block.number); if (priceResult.reverted) { // Price contract was unavailable briefly after well deployment return false; } + const beanToken = getProtocolToken(block.number); const bean = loadBean(beanToken); const prevPrice = bean.price; const newPrice = toDecimal(priceResult.value.price); diff --git a/projects/subgraph-bean/src/utils/LockedBeans.ts b/projects/subgraph-bean/src/utils/LockedBeans.ts index 3c0960aa54..dbfb6307c8 100644 --- a/projects/subgraph-bean/src/utils/LockedBeans.ts +++ b/projects/subgraph-bean/src/utils/LockedBeans.ts @@ -1,26 +1,22 @@ import { BigDecimal, BigInt, Address, log } from "@graphprotocol/graph-ts"; -import { - BEAN_3CRV, - BEAN_WETH_CP2_WELL, - BEAN_WETH_UNRIPE_MIGRATION_BLOCK, - BEAN_WSTETH_CP2_WELL, - BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK, - BEANSTALK, - GAUGE_BIP45_BLOCK, - UNRIPE_BEAN, - UNRIPE_LP -} from "../../../subgraph-core/utils/Constants"; +import { GAUGE_BIP45_BLOCK } from "../../../subgraph-core/utils/Constants"; import { SeedGauge } from "../../generated/Bean-ABIs/SeedGauge"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { ERC20 } from "../../generated/Bean-ABIs/ERC20"; import { loadOrCreateTwaOracle } from "../entities/TwaOracle"; import { loadOrCreatePool } from "../entities/Pool"; +import { getVersionEntity } from "./constants/Version"; +import { toAddress } from "../../../subgraph-core/utils/Bytes"; +import { getUnripeBeanAddr, getUnripeLpAddr, getUnripeUnderlying } from "./constants/Addresses"; export function calcLockedBeans(blockNumber: BigInt): BigInt { + const protocol = toAddress(getVersionEntity().protocolAddress); + const underlyingLpPool = getUnripeUnderlying(getUnripeLpAddr(), blockNumber); + // If BIP45 is deployed - return the result from the contract if (blockNumber >= GAUGE_BIP45_BLOCK) { // If we are trying to calculate locked beans on the same block as the sunrise, use the values from the previous hour - const twaOracle = loadOrCreateTwaOracle(getUnderlyingUnripe(blockNumber)); + const twaOracle = loadOrCreateTwaOracle(underlyingLpPool); const twaReserves = blockNumber == twaOracle.cumulativeWellReservesBlock ? twaOracle.cumulativeWellReservesPrev : twaOracle.cumulativeWellReserves; const twaTime = @@ -28,7 +24,7 @@ export function calcLockedBeans(blockNumber: BigInt): BigInt { ? twaOracle.cumulativeWellReservesPrevTime : twaOracle.cumulativeWellReservesTime; - let beanstalkBIP45 = SeedGauge.bind(BEANSTALK); + let beanstalkBIP45 = SeedGauge.bind(protocol); let lockedBeans = beanstalkBIP45.try_getLockedBeansFromTwaReserves(twaReserves, twaTime); if (!lockedBeans.reverted) { return lockedBeans.value; @@ -36,7 +32,7 @@ export function calcLockedBeans(blockNumber: BigInt): BigInt { } // Pre-gauge there was no lockedBeans contract function, instead we recreate the same calculation. - let beanstalk = SeedGauge.bind(BEANSTALK); + let beanstalk = SeedGauge.bind(protocol); const recapPercentResult = beanstalk.try_getRecapPaidPercent(); if (recapPercentResult.reverted) { // This function was made available later in the Replant process, for a few hundred blocks it is unavailable @@ -44,30 +40,19 @@ export function calcLockedBeans(blockNumber: BigInt): BigInt { } const recapPaidPercent = new BigDecimal(recapPercentResult.value).div(BigDecimal.fromString("1000000")); - const lockedBeansUrBean = LibLockedUnderlying_getLockedUnderlying(UNRIPE_BEAN, recapPaidPercent); - const lockedUnripeLp = LibLockedUnderlying_getLockedUnderlying(UNRIPE_LP, recapPaidPercent); - const underlyingLpPool = getUnderlyingUnripe(blockNumber); + const lockedBeansUrBean = LibLockedUnderlying_getLockedUnderlying(protocol, getUnripeBeanAddr(), recapPaidPercent); + const lockedUnripeLp = LibLockedUnderlying_getLockedUnderlying(protocol, getUnripeLpAddr(), recapPaidPercent); const poolBeanReserves = loadOrCreatePool(underlyingLpPool, blockNumber).reserves[0]; - const totalLpTokens = ERC20.bind(getUnderlyingUnripe(blockNumber)).totalSupply(); + const totalLpTokens = ERC20.bind(underlyingLpPool).totalSupply(); // Simplification here: does not account for twa reserves nor twa lp tokens const lockedBeansUrLP = lockedUnripeLp.times(poolBeanReserves).div(totalLpTokens); return lockedBeansUrBean.plus(lockedBeansUrLP); } -function getUnderlyingUnripe(blockNumber: BigInt): Address { - if (blockNumber < BEAN_WETH_UNRIPE_MIGRATION_BLOCK) { - return BEAN_3CRV; - } else if (blockNumber < BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK) { - return BEAN_WETH_CP2_WELL; - } else { - return BEAN_WSTETH_CP2_WELL; - } -} - -export function LibLockedUnderlying_getLockedUnderlying(unripeToken: Address, recapPercentPaid: BigDecimal): BigInt { - const balanceOfUnderlying = SeedGauge.bind(BEANSTALK).getTotalUnderlying(unripeToken); +export function LibLockedUnderlying_getLockedUnderlying(protocol: Address, unripeToken: Address, recapPercentPaid: BigDecimal): BigInt { + const balanceOfUnderlying = SeedGauge.bind(protocol).getTotalUnderlying(unripeToken); const percentLocked = LibLockedUnderlying_getPercentLockedUnderlying(unripeToken, recapPercentPaid); return BigInt.fromString(new BigDecimal(balanceOfUnderlying).times(percentLocked).truncate(0).toString()); } diff --git a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts index 6dc93eddc9..453c23194e 100644 --- a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts +++ b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts @@ -1,11 +1,10 @@ import { ethereum } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20 } from "../../../../subgraph-core/utils/Constants"; import { BEAN_INITIAL_VALUES } from "../../../cache-builder/results/BeanInit_arb"; import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../../entities/Bean"; +import { getProtocolToken } from "../constants/Addresses"; export function handleInitBeanEntity(block: ethereum.Block): void { - // TODO: how to determine correct token address? this is wrong - const token = BEAN_ERC20; + const token = getProtocolToken(block.number); const bean = loadBean(token); bean.volume = BEAN_INITIAL_VALUES.volume; diff --git a/projects/subgraph-bean/src/utils/constants/Addresses.ts b/projects/subgraph-bean/src/utils/constants/Addresses.ts index bc9efc0a45..f5fb41245f 100644 --- a/projects/subgraph-bean/src/utils/constants/Addresses.ts +++ b/projects/subgraph-bean/src/utils/constants/Addresses.ts @@ -1,7 +1,12 @@ import { BigInt, Address } from "@graphprotocol/graph-ts"; import { + BEAN_3CRV, BEAN_ERC20, BEAN_ERC20_V1, + BEAN_WETH_CP2_WELL, + BEAN_WETH_UNRIPE_MIGRATION_BLOCK, + BEAN_WSTETH_CP2_WELL, + BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK, BEANSTALK, NEW_BEAN_TOKEN_BLOCK, UNRIPE_BEAN, @@ -21,8 +26,39 @@ export function getProtocolToken(blockNumber: BigInt): Address { throw new Error("Unsupported protocol"); } +export function getUnripeBeanAddr(): Address { + const protocol = getVersionEntity().protocolAddress; + if (protocol == BEANSTALK) { + return UNRIPE_BEAN; + } + throw new Error("Unsupported protocol"); +} + +export function getUnripeLpAddr(): Address { + const protocol = getVersionEntity().protocolAddress; + if (protocol == BEANSTALK) { + return UNRIPE_LP; + } + throw new Error("Unsupported protocol"); +} + +export function getUnripeUnderlying(unripeToken: Address, blockNumber: BigInt): Address { + if (unripeToken == UNRIPE_BEAN) { + return BEAN_ERC20; + } else if (unripeToken == UNRIPE_LP) { + if (blockNumber < BEAN_WETH_UNRIPE_MIGRATION_BLOCK) { + return BEAN_3CRV; + } else if (blockNumber < BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK) { + return BEAN_WETH_CP2_WELL; + } else { + return BEAN_WSTETH_CP2_WELL; + } + } + throw new Error("Unsupported unripe token"); +} + export function isUnripe(token: Address): boolean { - const unripeTokens = [UNRIPE_BEAN, UNRIPE_LP]; + const unripeTokens = [getUnripeBeanAddr(), getUnripeLpAddr()]; for (let i = 0; i < unripeTokens.length; ++i) { if (unripeTokens[i] == token) { return true; diff --git a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts index 98b9a008ec..add97d0ee8 100644 --- a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts +++ b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts @@ -9,6 +9,7 @@ import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../.. import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadBean } from "../../entities/Bean"; import { toAddressArray } from "../../../../subgraph-core/utils/Bytes"; +import { getProtocolToken } from "../constants/Addresses"; // Can't use the autogenerated one because the fields need to be updateable class PriceOverallStruct { @@ -104,7 +105,8 @@ export class BeanstalkPriceResult { // Wrapper for BeanstalkPrice contract that handles a few things: // (1) Only including whitelisted tokens in the final price calculation and the prices list // (2) Which contract to call (in anticipation of new BeanstalkPrice contract deployments) -export function BeanstalkPrice_try_price(beanAddr: Address, blockNumber: BigInt): BeanstalkPriceResult { +export function BeanstalkPrice_try_price(blockNumber: BigInt): BeanstalkPriceResult { + const beanAddr = getProtocolToken(blockNumber); let beanstalkPrice = getBeanstalkPrice(blockNumber); let beanPrice = beanstalkPrice.try_price(); diff --git a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts index d710627a23..4ceef36492 100644 --- a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts +++ b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts @@ -1,6 +1,6 @@ import { Address, BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { BD_10, BI_10, ONE_BI, pow, sqrt, toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; -import { BEANSTALK, WETH, WETH_USDC_PAIR } from "../../../../subgraph-core/utils/Constants"; +import { WETH, WETH_USDC_PAIR } from "../../../../subgraph-core/utils/Constants"; import { DeltaBAndPrice, DeltaBPriceLiquidity, TWAType } from "./Types"; import { setPoolTwa } from "../Pool"; import { getTWAPrices } from "./TwaOracle"; @@ -8,6 +8,8 @@ import { loadOrCreateToken } from "../../entities/Token"; import { UniswapV2Pair } from "../../../generated/Bean-ABIs/UniswapV2Pair"; import { Pool } from "../../../generated/schema"; import { PreReplant } from "../../../generated/Bean-ABIs/PreReplant"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; +import { getVersionEntity } from "../constants/Version"; export function updatePreReplantPriceETH(): BigDecimal { let token = loadOrCreateToken(WETH); @@ -97,7 +99,8 @@ export function uniswapCumulativePrice(pool: Address, tokenIndex: u32, timestamp } export function uniswapTwaDeltaBAndPrice(prices: BigInt[], blockNumber: BigInt): DeltaBAndPrice { - let beanstalk = PreReplant.bind(BEANSTALK); + const protocol = toAddress(getVersionEntity().protocolAddress); + let beanstalk = PreReplant.bind(protocol); let reserves: BigInt[]; // After BIP-9, reserves calculation changes if (blockNumber.lt(BigInt.fromU64(13953949))) { diff --git a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts index e39053cc3d..7251077625 100644 --- a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts +++ b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts @@ -82,14 +82,14 @@ describe("BeanstalkPrice", () => { }); test("Can set the price", () => { - const priceResult = BeanstalkPrice_try_price(BEAN_ERC20, PRICE_1_BLOCK); + const priceResult = BeanstalkPrice_try_price(PRICE_1_BLOCK); assert.assertTrue(priceResult.value.price.equals(overallPrice)); assert.assertTrue(priceResult.value.ps.length == 2); assert.assertTrue(priceResult.dewhitelistedPools.length == 0); }); test("Extract pool price", () => { - const priceResult = BeanstalkPrice_try_price(BEAN_ERC20, PRICE_1_BLOCK); + const priceResult = BeanstalkPrice_try_price(PRICE_1_BLOCK); const curvePriceResult = getPoolPrice(priceResult, BEAN_3CRV)!; assert.assertTrue(curvePriceResult.price.equals(curvePrice)); @@ -102,7 +102,7 @@ describe("BeanstalkPrice", () => { event.block.number = PRICE_1_BLOCK; handleDewhitelistToken(event); - const priceResult = BeanstalkPrice_try_price(BEAN_ERC20, PRICE_1_BLOCK); + const priceResult = BeanstalkPrice_try_price(PRICE_1_BLOCK); const curvePriceResult = getPoolPrice(priceResult, BEAN_3CRV); assert.assertTrue(priceResult.value.ps.length == 1); assert.assertTrue(priceResult.dewhitelistedPools.length == 1); @@ -111,10 +111,10 @@ describe("BeanstalkPrice", () => { }); test("Calls correct price contract by block", () => { - const price1 = BeanstalkPrice_try_price(BEAN_ERC20, PRICE_1_BLOCK); + const price1 = BeanstalkPrice_try_price(PRICE_1_BLOCK); assert.assertTrue(price1.value.price.equals(overallPrice)); - const price2 = BeanstalkPrice_try_price(BEAN_ERC20, PRICE_2_BLOCK); + const price2 = BeanstalkPrice_try_price(PRICE_2_BLOCK); assert.assertTrue(price2.value.price.equals(contract2Price)); }); }); From 83cc7ad92c5969298b157ebd8812ec591f57130a Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:33:23 -0700 Subject: [PATCH 12/88] more constants refactor --- .../subgraph-bean/manifests/ethereum.yaml | 1 - .../handlers/legacy/LegacyBean3CRVHandler.ts | 1 - .../subgraph-bean/src/utils/LockedBeans.ts | 6 +- .../src/utils/constants/Addresses.ts | 15 ----- .../src/utils/constants/BeanWells.ts | 30 ---------- .../src/utils/constants/Milestone.ts | 56 +++++++++++++++++++ .../src/utils/price/BeanstalkPrice.ts | 12 +--- .../tests/event-mocking/Silo.ts | 11 +--- projects/subgraph-core/utils/Constants.ts | 3 - 9 files changed, 64 insertions(+), 71 deletions(-) delete mode 100644 projects/subgraph-bean/src/utils/constants/BeanWells.ts create mode 100644 projects/subgraph-bean/src/utils/constants/Milestone.ts diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 933ea4f619..90a44f9a8d 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -75,7 +75,6 @@ dataSources: ### # BEANSTALK PROTOCOL ### - # TODO: refactor sunrise part to pre/post exploit - kind: ethereum/contract name: Beanstalk network: mainnet diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts index 7be35ecad8..b37cd9bcd2 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBean3CRVHandler.ts @@ -1,7 +1,6 @@ import { BigInt, BigDecimal, ethereum, Address } from "@graphprotocol/graph-ts"; import { AddLiquidity, - Bean3CRV, RemoveLiquidity, RemoveLiquidityImbalance, RemoveLiquidityOne, diff --git a/projects/subgraph-bean/src/utils/LockedBeans.ts b/projects/subgraph-bean/src/utils/LockedBeans.ts index dbfb6307c8..ecd06027b7 100644 --- a/projects/subgraph-bean/src/utils/LockedBeans.ts +++ b/projects/subgraph-bean/src/utils/LockedBeans.ts @@ -1,5 +1,4 @@ import { BigDecimal, BigInt, Address, log } from "@graphprotocol/graph-ts"; -import { GAUGE_BIP45_BLOCK } from "../../../subgraph-core/utils/Constants"; import { SeedGauge } from "../../generated/Bean-ABIs/SeedGauge"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { ERC20 } from "../../generated/Bean-ABIs/ERC20"; @@ -7,14 +6,15 @@ import { loadOrCreateTwaOracle } from "../entities/TwaOracle"; import { loadOrCreatePool } from "../entities/Pool"; import { getVersionEntity } from "./constants/Version"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; -import { getUnripeBeanAddr, getUnripeLpAddr, getUnripeUnderlying } from "./constants/Addresses"; +import { getUnripeBeanAddr, getUnripeLpAddr } from "./constants/Addresses"; +import { getUnripeUnderlying, isGaugeDeployed } from "./constants/Milestone"; export function calcLockedBeans(blockNumber: BigInt): BigInt { const protocol = toAddress(getVersionEntity().protocolAddress); const underlyingLpPool = getUnripeUnderlying(getUnripeLpAddr(), blockNumber); // If BIP45 is deployed - return the result from the contract - if (blockNumber >= GAUGE_BIP45_BLOCK) { + if (isGaugeDeployed(blockNumber)) { // If we are trying to calculate locked beans on the same block as the sunrise, use the values from the previous hour const twaOracle = loadOrCreateTwaOracle(underlyingLpPool); const twaReserves = diff --git a/projects/subgraph-bean/src/utils/constants/Addresses.ts b/projects/subgraph-bean/src/utils/constants/Addresses.ts index f5fb41245f..c4c7a9da1d 100644 --- a/projects/subgraph-bean/src/utils/constants/Addresses.ts +++ b/projects/subgraph-bean/src/utils/constants/Addresses.ts @@ -42,21 +42,6 @@ export function getUnripeLpAddr(): Address { throw new Error("Unsupported protocol"); } -export function getUnripeUnderlying(unripeToken: Address, blockNumber: BigInt): Address { - if (unripeToken == UNRIPE_BEAN) { - return BEAN_ERC20; - } else if (unripeToken == UNRIPE_LP) { - if (blockNumber < BEAN_WETH_UNRIPE_MIGRATION_BLOCK) { - return BEAN_3CRV; - } else if (blockNumber < BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK) { - return BEAN_WETH_CP2_WELL; - } else { - return BEAN_WSTETH_CP2_WELL; - } - } - throw new Error("Unsupported unripe token"); -} - export function isUnripe(token: Address): boolean { const unripeTokens = [getUnripeBeanAddr(), getUnripeLpAddr()]; for (let i = 0; i < unripeTokens.length; ++i) { diff --git a/projects/subgraph-bean/src/utils/constants/BeanWells.ts b/projects/subgraph-bean/src/utils/constants/BeanWells.ts deleted file mode 100644 index c2c5bb6cda..0000000000 --- a/projects/subgraph-bean/src/utils/constants/BeanWells.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { BigInt, Address } from "@graphprotocol/graph-ts"; -import { - BEAN_WETH_CP2_WELL, - BEAN_WETH_CP2_WELL_BLOCK, - BEAN_WSTETH_CP2_WELL, - BEAN_WSTETH_CP2_WELL_BLOCK -} from "../../../../subgraph-core/utils/Constants"; - -export enum WellFunction { - ConstantProduct -} - -class BeanWell { - address: Address; - startBlock: BigInt; - wellFunction: WellFunction; -} - -export const BEAN_WELLS: BeanWell[] = [ - { - address: BEAN_WETH_CP2_WELL, - startBlock: BEAN_WETH_CP2_WELL_BLOCK, - wellFunction: WellFunction.ConstantProduct - }, - { - address: BEAN_WSTETH_CP2_WELL, - startBlock: BEAN_WSTETH_CP2_WELL_BLOCK, - wellFunction: WellFunction.ConstantProduct - } -]; diff --git a/projects/subgraph-bean/src/utils/constants/Milestone.ts b/projects/subgraph-bean/src/utils/constants/Milestone.ts new file mode 100644 index 0000000000..3382dc331a --- /dev/null +++ b/projects/subgraph-bean/src/utils/constants/Milestone.ts @@ -0,0 +1,56 @@ +import { BigInt, Address } from "@graphprotocol/graph-ts"; +import { + BEAN_3CRV, + BEAN_ERC20, + BEAN_WETH_CP2_WELL, + BEAN_WETH_UNRIPE_MIGRATION_BLOCK, + BEAN_WSTETH_CP2_WELL, + BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK, + BEANSTALK, + BEANSTALK_PRICE_1, + BEANSTALK_PRICE_2, + GAUGE_BIP45_BLOCK, + PRICE_2_BLOCK, + UNRIPE_BEAN, + UNRIPE_LP +} from "../../../../subgraph-core/utils/Constants"; +import { getVersionEntity } from "./Version"; + +export function isGaugeDeployed(blockNumber: BigInt): boolean { + const protocol = getVersionEntity().protocolAddress; + if (protocol == BEANSTALK) { + return blockNumber >= GAUGE_BIP45_BLOCK; + } + throw new Error("Unsupported protocol"); +} + +export function getUnripeUnderlying(unripeToken: Address, blockNumber: BigInt): Address { + const protocol = getVersionEntity().protocolAddress; + if (protocol == BEANSTALK) { + if (unripeToken == UNRIPE_BEAN) { + return BEAN_ERC20; + } else if (unripeToken == UNRIPE_LP) { + if (blockNumber < BEAN_WETH_UNRIPE_MIGRATION_BLOCK) { + return BEAN_3CRV; + } else if (blockNumber < BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK) { + return BEAN_WETH_CP2_WELL; + } else { + return BEAN_WSTETH_CP2_WELL; + } + } + throw new Error("Unsupported unripe token"); + } + throw new Error("Unsupported protocol"); +} + +export function getBeanstalkPriceAddress(blockNumber: BigInt): Address { + const protocol = getVersionEntity().protocolAddress; + if (protocol == BEANSTALK) { + if (blockNumber < PRICE_2_BLOCK) { + return BEANSTALK_PRICE_1; + } else { + return BEANSTALK_PRICE_2; + } + } + throw new Error("Unsupported protocol"); +} diff --git a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts index add97d0ee8..174cc0e855 100644 --- a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts +++ b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts @@ -10,6 +10,7 @@ import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadBean } from "../../entities/Bean"; import { toAddressArray } from "../../../../subgraph-core/utils/Bytes"; import { getProtocolToken } from "../constants/Addresses"; +import { getBeanstalkPriceAddress } from "../constants/Milestone"; // Can't use the autogenerated one because the fields need to be updateable class PriceOverallStruct { @@ -141,14 +142,7 @@ export function getPoolPrice(priceResult: BeanstalkPriceResult, pool: Address): } // Gets the BeanstalkPrice contract, bound to the appropriate instance of the contract. -// Note: Will bind to PRICE_1 even if that contract has not been deployed yet -// Thus the caller still needs to check for reverts. +// Note: The caller still needs to check for reverts. export function getBeanstalkPrice(blockNumber: BigInt): BeanstalkPrice { - let contractAddress: Address; - if (blockNumber < PRICE_2_BLOCK) { - contractAddress = BEANSTALK_PRICE_1; - } else { - contractAddress = BEANSTALK_PRICE_2; - } - return BeanstalkPrice.bind(contractAddress); + return BeanstalkPrice.bind(getBeanstalkPriceAddress(blockNumber)); } diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Silo.ts b/projects/subgraph-beanstalk/tests/event-mocking/Silo.ts index 3150b81c4b..25b2a9fa73 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Silo.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Silo.ts @@ -7,7 +7,6 @@ import { RemoveWithdrawal, RemoveWithdrawals } from "../../generated/Beanstalk-ABIs/Replanted"; -import { BEAN_DECIMALS } from "../../../subgraph-core/utils/Constants"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; import { AddDeposit, @@ -34,10 +33,7 @@ export function createAddDepositV2Event( "amount", ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(amount).times(BigInt.fromI32(10 ** tokenDecimals))) ); - let bdvParam = new ethereum.EventParam( - "bdv", - ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(bdv).times(BigInt.fromI32(10 ** BEAN_DECIMALS))) - ); + let bdvParam = new ethereum.EventParam("bdv", ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(bdv).times(BigInt.fromI32(10 ** 6)))); addDepositEvent.parameters.push(accountParam); addDepositEvent.parameters.push(tokenParam); @@ -65,10 +61,7 @@ export function createAddDepositV3Event( "amount", ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(amount).times(BigInt.fromI32(10 ** tokenDecimals))) ); - let bdvParam = new ethereum.EventParam( - "bdv", - ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(bdv).times(BigInt.fromI32(10 ** BEAN_DECIMALS))) - ); + let bdvParam = new ethereum.EventParam("bdv", ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(bdv).times(BigInt.fromI32(10 ** 6)))); addDepositEvent.parameters.push(accountParam); addDepositEvent.parameters.push(tokenParam); diff --git a/projects/subgraph-core/utils/Constants.ts b/projects/subgraph-core/utils/Constants.ts index 2c68a7d943..1319d336ec 100644 --- a/projects/subgraph-core/utils/Constants.ts +++ b/projects/subgraph-core/utils/Constants.ts @@ -34,9 +34,6 @@ export const LUSD_3POOL = Address.fromString("0xEd279fDD11cA84bEef15AF5D39BB4d4b export const BEAN_WETH_CP2_WELL = Address.fromString("0xBEA0e11282e2bB5893bEcE110cF199501e872bAd"); export const BEAN_WSTETH_CP2_WELL = Address.fromString("0xBeA0000113B0d182f4064C86B71c315389E4715D"); -// Other Constants -export const BEAN_DECIMALS = 6; - export const INITIAL_HUMIDITY = BigDecimal.fromString("500"); export const MIN_HUMIDITY = BigDecimal.fromString("500"); export const DELTA_HUMIDITY = BigDecimal.fromString("0.5"); From d4c791dda08510fe5f9d6f306fc71f8b25885ebb Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:45:48 -0700 Subject: [PATCH 13/88] metapooloracle as legacy handler --- .../subgraph-bean/manifests/codegen-abis.yaml | 2 +- .../subgraph-bean/manifests/ethereum.yaml | 45 +++++++++++++------ .../src/handlers/BeanstalkHandler.ts | 15 ++----- .../handlers/legacy/LegacyBeanstalkHandler.ts | 10 +++++ .../src/utils/price/BeanstalkPrice.ts | 1 - projects/subgraph-bean/tests/DeltaB.test.ts | 3 +- .../tests/event-mocking/Beanstalk.ts | 4 +- projects/subgraph-bean/tests/l2sr.test.ts | 2 +- 8 files changed, 50 insertions(+), 32 deletions(-) diff --git a/projects/subgraph-bean/manifests/codegen-abis.yaml b/projects/subgraph-bean/manifests/codegen-abis.yaml index f70b9e4462..e08b49436e 100644 --- a/projects/subgraph-bean/manifests/codegen-abis.yaml +++ b/projects/subgraph-bean/manifests/codegen-abis.yaml @@ -31,7 +31,7 @@ dataSources: file: ../../subgraph-core/abis/Well.json - name: PreReplant file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json - - name: Beanstalk + - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - name: BasinBip file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP37.json diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 90a44f9a8d..006d245a79 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -10,7 +10,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: Beanstalk + abi: Replanted startBlock: 12974075 endBlock: 12974075 mapping: @@ -20,7 +20,7 @@ dataSources: entities: - Version abis: - - name: Beanstalk + - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json blockHandlers: - handler: handleInitVersion @@ -80,7 +80,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: Beanstalk + abi: Replanted startBlock: 12974075 mapping: kind: ethereum/events @@ -89,7 +89,7 @@ dataSources: entities: - Bean abis: - - name: Beanstalk + - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json @@ -179,7 +179,30 @@ dataSources: handler: handleSunrise_v2 file: ../src/handlers/legacy/LegacyBeanstalkHandler.ts - kind: ethereum/contract - name: TWAPOracles + name: LegacyCurveTWAP + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: Replanted + startBlock: 15277988 + endBlock: 19927634 # SeedGauge + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Bean + abis: + - name: Replanted + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + - name: Bean3CRV + file: ../../subgraph-core/abis/Bean3CRV.json + eventHandlers: + - event: MetapoolOracle(indexed uint32,int256,uint256[2]) + handler: handleMetapoolOracle + file: ../src/handlers/legacy/LegacyBeanstalkHandler.ts + - kind: ethereum/contract + name: WellTWAP network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" @@ -192,17 +215,11 @@ dataSources: entities: - Bean abis: - # This abi is chosen because it contains both MetapoolOracle and WellOracle events. - # Indexing of this source should begin prior to BIP37 deployment. - name: BasinBip file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP37.json - - name: Bean3CRV - file: ../../subgraph-core/abis/Bean3CRV.json - name: Well file: ../../subgraph-core/abis/Well.json eventHandlers: - - event: MetapoolOracle(indexed uint32,int256,uint256[2]) - handler: handleMetapoolOracle - event: WellOracle(indexed uint32,address,int256,bytes) handler: handleWellOracle file: ../src/handlers/BeanstalkHandler.ts @@ -332,7 +349,7 @@ dataSources: file: ../../subgraph-core/abis/CurvePrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Beanstalk + - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json @@ -370,7 +387,7 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Beanstalk + - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json @@ -408,7 +425,7 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Beanstalk + - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json diff --git a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts index 489c47709b..88c1e8b87c 100644 --- a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts @@ -1,10 +1,8 @@ import { BigInt } from "@graphprotocol/graph-ts"; -import { updateBeanSupplyPegPercent, updateBeanTwa, updateBeanValues } from "../utils/Bean"; -import { Chop, Convert, DewhitelistToken, Reward, Sunrise } from "../../generated/Bean-ABIs/Beanstalk"; -import { BEAN_3CRV } from "../../../subgraph-core/utils/Constants"; +import { updateBeanSupplyPegPercent, updateBeanTwa } from "../utils/Bean"; +import { Chop, Convert, DewhitelistToken, Reward, Sunrise } from "../../generated/Bean-ABIs/Replanted"; import { loadBean } from "../entities/Bean"; -import { setCurveTwa } from "../utils/price/CurvePrice"; -import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BasinBip"; +import { WellOracle } from "../../generated/Bean-ABIs/BasinBip"; import { setRawWellReserves, setTwaLast } from "../utils/price/TwaOracle"; import { decodeCumulativeWellReserves, setWellTwa } from "../utils/price/WellPrice"; import { getProtocolToken, isUnripe } from "../utils/constants/Addresses"; @@ -37,13 +35,6 @@ export function handleDewhitelistToken(event: DewhitelistToken): void { // POST REPLANT TWA DELTAB // -// TODO: move to legacy -export function handleMetapoolOracle(event: MetapoolOracle): void { - setTwaLast(BEAN_3CRV, event.params.balances, event.block.timestamp); - setCurveTwa(BEAN_3CRV, event.block); - updateBeanTwa(event.block); -} - export function handleWellOracle(event: WellOracle): void { setRawWellReserves(event); setTwaLast(event.params.well, decodeCumulativeWellReserves(event.params.cumulativeReserves), event.block.timestamp); diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts index 47182f6380..c472b369c5 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts @@ -3,6 +3,7 @@ import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../../subgraph-core/ import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { CurvePrice } from "../../../generated/Bean-ABIs/CurvePrice"; import { Sunrise } from "../../../generated/Bean-ABIs/PreReplant"; +import { MetapoolOracle } from "../../../generated/Bean-ABIs/Replanted"; import { loadBean } from "../../entities/Bean"; import { loadOrCreatePool } from "../../entities/Pool"; import { updateBeanTwa, updateBeanValues } from "../../utils/Bean"; @@ -11,6 +12,7 @@ import { checkBeanCross, updatePoolPricesOnCross } from "../../utils/Cross"; import { updateSeason } from "../../utils/legacy/Beanstalk"; import { updatePoolPrice, updatePoolValues } from "../../utils/Pool"; import { calcCurveInst, setCurveTwa } from "../../utils/price/CurvePrice"; +import { setTwaLast } from "../../utils/price/TwaOracle"; import { DeltaBPriceLiquidity } from "../../utils/price/Types"; import { calcUniswapV2Inst, setUniswapV2Twa } from "../../utils/price/UniswapPrice"; @@ -83,3 +85,11 @@ export function handleSunrise_v2(event: Sunrise): void { } } } + +// POST REPLANT TWA DELTAB // + +export function handleMetapoolOracle(event: MetapoolOracle): void { + setTwaLast(BEAN_3CRV, event.params.balances, event.block.timestamp); + setCurveTwa(BEAN_3CRV, event.block); + updateBeanTwa(event.block); +} diff --git a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts index 174cc0e855..2a24feb141 100644 --- a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts +++ b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts @@ -5,7 +5,6 @@ import { BeanstalkPrice__priceResultPPsStruct, BeanstalkPrice__priceResultPStruct } from "../../../generated/Bean-ABIs/BeanstalkPrice"; -import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../../subgraph-core/utils/Constants"; import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadBean } from "../../entities/Bean"; import { toAddressArray } from "../../../../subgraph-core/utils/Bytes"; diff --git a/projects/subgraph-bean/tests/DeltaB.test.ts b/projects/subgraph-bean/tests/DeltaB.test.ts index 593b27f54c..42f68b8faf 100644 --- a/projects/subgraph-bean/tests/DeltaB.test.ts +++ b/projects/subgraph-bean/tests/DeltaB.test.ts @@ -11,10 +11,11 @@ import { decodeCumulativeWellReserves } from "../src/utils/price/WellPrice"; import { mock_virtual_price } from "./event-mocking/Curve"; import { getD, getY, priceFromY } from "../src/utils/price/CurvePrice"; import { pow2toX } from "../../subgraph-core/utils/ABDKMathQuad"; -import { handleMetapoolOracle, handleWellOracle } from "../src/handlers/BeanstalkHandler"; +import { handleWellOracle } from "../src/handlers/BeanstalkHandler"; import { loadBean } from "../src/entities/Bean"; import { loadOrCreatePool } from "../src/entities/Pool"; import { initL1Version } from "./entity-mocking/MockVersion"; +import { handleMetapoolOracle } from "../src/handlers/legacy/LegacyBeanstalkHandler"; const timestamp1 = BigInt.fromU32(1712793374); const hour1 = hourFromTimestamp(timestamp1).toString(); diff --git a/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts b/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts index 1d3f262831..dba01552dc 100644 --- a/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts +++ b/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts @@ -1,7 +1,7 @@ import { BigInt, ethereum, Address, Bytes } from "@graphprotocol/graph-ts"; -import { MetapoolOracle, WellOracle } from "../../generated/Bean-ABIs/BasinBip"; +import { WellOracle } from "../../generated/Bean-ABIs/BasinBip"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; -import { Convert, DewhitelistToken } from "../../generated/Bean-ABIs/Beanstalk"; +import { Convert, DewhitelistToken, MetapoolOracle } from "../../generated/Bean-ABIs/Replanted"; export function createMetapoolOracleEvent( season: BigInt, diff --git a/projects/subgraph-bean/tests/l2sr.test.ts b/projects/subgraph-bean/tests/l2sr.test.ts index 5809b2ca85..d87f382ee5 100644 --- a/projects/subgraph-bean/tests/l2sr.test.ts +++ b/projects/subgraph-bean/tests/l2sr.test.ts @@ -19,7 +19,7 @@ import { mockSeedGaugeLockedBeansReverts } from "./call-mocking/Beanstalk"; import { mockBeanstalkEvent } from "../../subgraph-core/tests/event-mocking/Util"; -import { Chop, Convert } from "../generated/Bean-ABIs/Beanstalk"; +import { Chop, Convert } from "../generated/Bean-ABIs/Replanted"; import { calcLockedBeans, LibLockedUnderlying_getPercentLockedUnderlying } from "../src/utils/LockedBeans"; import { mockERC20TokenSupply } from "../../subgraph-core/tests/event-mocking/Tokens"; import { TwaOracle } from "../generated/schema"; From 2464293508a31ed749f384b6058a34aa67045d37 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 6 Sep 2024 18:16:11 -0700 Subject: [PATCH 14/88] refactor constants --- .../subgraph-basin/src/BeanstalkHandler.ts | 2 +- .../src/utils/BeanstalkPrice.ts | 2 +- projects/subgraph-basin/src/utils/Init.ts | 2 +- projects/subgraph-basin/src/utils/Token.ts | 2 +- projects/subgraph-basin/src/utils/Well.ts | 2 +- projects/subgraph-basin/tests/Aquifer.test.ts | 2 +- .../tests/DepositWithdrawEntity.test.ts | 2 +- .../subgraph-basin/tests/Exchange.test.ts | 2 +- .../subgraph-basin/tests/Liquidity.test.ts | 2 +- .../subgraph-basin/tests/SwapEntity.test.ts | 2 +- .../subgraph-basin/tests/helpers/Aquifer.ts | 2 +- .../subgraph-basin/tests/helpers/Functions.ts | 9 +++++- .../subgraph-basin/tests/helpers/Liquidity.ts | 2 +- projects/subgraph-basin/tests/helpers/Swap.ts | 2 +- projects/subgraph-bean/src/entities/Bean.ts | 2 +- .../subgraph-bean/src/handlers/BeanHandler.ts | 2 +- .../src/handlers/legacy/LegacyBeanHandler.ts | 2 +- .../handlers/legacy/LegacyBeanstalkHandler.ts | 2 +- .../handlers/legacy/LegacyUniswapV2Handler.ts | 2 +- projects/subgraph-bean/src/utils/Bean.ts | 2 +- projects/subgraph-bean/src/utils/Cross.ts | 2 +- .../src/utils/constants/Addresses.ts | 30 ++++++------------- .../src/utils/constants/Milestone.ts | 2 +- .../src/utils/constants/PooledTokens.ts | 2 +- .../src/utils/constants/Version.ts | 4 +-- .../subgraph-bean/src/utils/legacy/Bean.ts | 2 +- .../subgraph-bean/src/utils/legacy/Curve.ts | 2 +- .../src/utils/price/CurvePrice.ts | 2 +- .../src/utils/price/TwaOracle.ts | 2 +- .../src/utils/price/UniswapPrice.ts | 2 +- .../tests/BeanstalkPrice.test.ts | 2 +- projects/subgraph-bean/tests/Cross.test.ts | 2 +- projects/subgraph-bean/tests/DeltaB.test.ts | 2 +- .../subgraph-bean/tests/Migration.test.ts | 2 +- projects/subgraph-bean/tests/Pool.test.ts | 2 +- .../subgraph-bean/tests/Whitelist.test.ts | 2 +- .../tests/call-mocking/Beanstalk.ts | 2 +- .../tests/entity-mocking/MockBean.ts | 2 +- .../tests/entity-mocking/MockPool.ts | 2 +- .../tests/event-mocking/Curve.ts | 2 +- projects/subgraph-bean/tests/l2sr.test.ts | 4 +-- projects/subgraph-beanft/src/utils/Init.ts | 2 +- .../src/entities/Fertilizer.ts | 1 - .../subgraph-beanstalk/src/entities/Field.ts | 4 +-- .../src/entities/PodMarketplace.ts | 2 +- .../subgraph-beanstalk/src/entities/Silo.ts | 2 +- .../src/handlers/BeanHandler.ts | 3 +- .../src/handlers/FieldHandler.ts | 3 +- .../src/handlers/GaugeHandler.ts | 2 +- .../src/handlers/SeasonHandler.ts | 3 +- .../handlers/legacy/LegacySeasonHandler.ts | 2 +- projects/subgraph-beanstalk/src/utils/Barn.ts | 2 +- .../subgraph-beanstalk/src/utils/Constants.ts | 2 +- .../subgraph-beanstalk/src/utils/Field.ts | 2 +- projects/subgraph-beanstalk/src/utils/Init.ts | 2 +- projects/subgraph-beanstalk/src/utils/Silo.ts | 2 +- .../subgraph-beanstalk/src/utils/Yield.ts | 2 +- .../src/utils/contracts/BeanstalkPrice.ts | 2 +- .../src/utils/contracts/SiloCalculations.ts | 2 +- .../subgraph-beanstalk/tests/Field.test.ts | 2 +- .../tests/MarketplaceV1.test.ts | 2 +- .../tests/MarketplaceV2.test.ts | 2 +- .../tests/PlotTransfer.test.ts | 2 +- .../tests/SeedGauge.test.ts | 2 +- .../subgraph-beanstalk/tests/Silo.test.ts | 2 +- .../subgraph-beanstalk/tests/Yield.test.ts | 2 +- .../subgraph-beanstalk/tests/utils/Field.ts | 2 +- .../tests/utils/Marketplace.ts | 2 +- .../subgraph-beanstalk/tests/utils/Season.ts | 2 +- .../BeanstalkEth.ts} | 9 +----- .../tests/event-mocking/Price.ts | 2 +- .../subgraph-core/tests/event-mocking/Util.ts | 2 +- projects/subgraph-core/utils/Bytes.ts | 2 ++ 73 files changed, 94 insertions(+), 102 deletions(-) rename projects/subgraph-core/{utils/Constants.ts => constants/BeanstalkEth.ts} (89%) diff --git a/projects/subgraph-basin/src/BeanstalkHandler.ts b/projects/subgraph-basin/src/BeanstalkHandler.ts index 6f58e82738..60a767eb76 100644 --- a/projects/subgraph-basin/src/BeanstalkHandler.ts +++ b/projects/subgraph-basin/src/BeanstalkHandler.ts @@ -1,5 +1,5 @@ import { Address } from "@graphprotocol/graph-ts"; -import { AQUIFER } from "../../subgraph-core/utils/Constants"; +import { AQUIFER } from "../../subgraph-core/constants/BeanstalkEth"; import { Sunrise } from "../generated/Basin-ABIs/Beanstalk"; import { loadOrCreateAquifer } from "./utils/Aquifer"; import { checkForSnapshot } from "./utils/Well"; diff --git a/projects/subgraph-basin/src/utils/BeanstalkPrice.ts b/projects/subgraph-basin/src/utils/BeanstalkPrice.ts index bbd525f66b..17e46a7825 100644 --- a/projects/subgraph-basin/src/utils/BeanstalkPrice.ts +++ b/projects/subgraph-basin/src/utils/BeanstalkPrice.ts @@ -1,7 +1,7 @@ // Unfortunately this file must be copied across the various subgraph projects. This is due to the codegen import { Address, BigInt } from "@graphprotocol/graph-ts"; import { BeanstalkPrice } from "../../generated/Basin-ABIs/BeanstalkPrice"; -import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../subgraph-core/constants/BeanstalkEth"; // Gets the BeanstalkPrice contract, bound to the appropriate instance of the contract. // Note: Will bind to PRICE_1 even if that contract has not been deployed yet diff --git a/projects/subgraph-basin/src/utils/Init.ts b/projects/subgraph-basin/src/utils/Init.ts index 87b76fa584..d45b31878a 100644 --- a/projects/subgraph-basin/src/utils/Init.ts +++ b/projects/subgraph-basin/src/utils/Init.ts @@ -1,6 +1,6 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../generated/schema"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); diff --git a/projects/subgraph-basin/src/utils/Token.ts b/projects/subgraph-basin/src/utils/Token.ts index 04298d539a..c331d1e7a2 100644 --- a/projects/subgraph-basin/src/utils/Token.ts +++ b/projects/subgraph-basin/src/utils/Token.ts @@ -2,7 +2,7 @@ import { Address, BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; import { ERC20 } from "../../generated/Basin-ABIs/ERC20"; import { Token } from "../../generated/schema"; import { CurvePrice } from "../../generated/Basin-ABIs/CurvePrice"; -import { BEAN_ERC20, CURVE_PRICE } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20, CURVE_PRICE } from "../../../subgraph-core/constants/BeanstalkEth"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { getBeanstalkPrice } from "./BeanstalkPrice"; diff --git a/projects/subgraph-basin/src/utils/Well.ts b/projects/subgraph-basin/src/utils/Well.ts index 6a5007ce4f..7e22b01ea3 100644 --- a/projects/subgraph-basin/src/utils/Well.ts +++ b/projects/subgraph-basin/src/utils/Well.ts @@ -2,7 +2,7 @@ import { Address, BigDecimal, BigInt, Bytes, log } from "@graphprotocol/graph-ts import { BoreWellWellFunctionStruct } from "../../generated/Basin-ABIs/Aquifer"; import { Well, WellDailySnapshot, WellFunction, WellHourlySnapshot } from "../../generated/schema"; import { ERC20 } from "../../generated/Basin-ABIs/ERC20"; -import { BEAN_ERC20 } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20 } from "../../../subgraph-core/constants/BeanstalkEth"; import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { deltaBigDecimalArray, diff --git a/projects/subgraph-basin/tests/Aquifer.test.ts b/projects/subgraph-basin/tests/Aquifer.test.ts index d4f60cad2e..2c70c7f739 100644 --- a/projects/subgraph-basin/tests/Aquifer.test.ts +++ b/projects/subgraph-basin/tests/Aquifer.test.ts @@ -1,5 +1,5 @@ import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; -import { BEAN_ERC20, WETH } from "../../subgraph-core/utils/Constants"; +import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/BeanstalkEth"; import { boreDefaultWell } from "./helpers/Aquifer"; import { AQUIFER, PUMP, WELL } from "./helpers/Constants"; diff --git a/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts b/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts index 86761bab3c..1e49b20f9d 100644 --- a/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts +++ b/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts @@ -1,5 +1,5 @@ import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; -import { BEAN_ERC20, WETH } from "../../subgraph-core/utils/Constants"; +import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/BeanstalkEth"; import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { loadWell } from "../src/utils/Well"; import { diff --git a/projects/subgraph-basin/tests/Exchange.test.ts b/projects/subgraph-basin/tests/Exchange.test.ts index 8b07609459..c6f2d3005c 100644 --- a/projects/subgraph-basin/tests/Exchange.test.ts +++ b/projects/subgraph-basin/tests/Exchange.test.ts @@ -17,7 +17,7 @@ import { mockShift, mockSwap } from "./helpers/Swap"; import { mockAddLiquidity } from "./helpers/Liquidity"; import { dayFromTimestamp, hourFromTimestamp } from "../../subgraph-core/utils/Dates"; import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20 } from "../../subgraph-core/utils/Constants"; +import { BEAN_ERC20 } from "../../subgraph-core/constants/BeanstalkEth"; describe("Well Entity: Exchange Tests", () => { beforeEach(() => { diff --git a/projects/subgraph-basin/tests/Liquidity.test.ts b/projects/subgraph-basin/tests/Liquidity.test.ts index ec903af16b..9bec2ee798 100644 --- a/projects/subgraph-basin/tests/Liquidity.test.ts +++ b/projects/subgraph-basin/tests/Liquidity.test.ts @@ -22,7 +22,7 @@ import { BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; import { BigDecimal_max, BigDecimal_min } from "../../subgraph-core/utils/ArrayMath"; import { calcLiquidityVolume } from "../src/utils/VolumeCP"; import { loadToken } from "../src/utils/Token"; -import { BEAN_ERC20, WETH } from "../../subgraph-core/utils/Constants"; +import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/BeanstalkEth"; const BI_2 = BigInt.fromU32(2); const BI_3 = BigInt.fromU32(3); diff --git a/projects/subgraph-basin/tests/SwapEntity.test.ts b/projects/subgraph-basin/tests/SwapEntity.test.ts index 0ee2806309..c0e143c49e 100644 --- a/projects/subgraph-basin/tests/SwapEntity.test.ts +++ b/projects/subgraph-basin/tests/SwapEntity.test.ts @@ -1,5 +1,5 @@ import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; -import { BEAN_ERC20, WETH } from "../../subgraph-core/utils/Constants"; +import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/BeanstalkEth"; import { ACCOUNT_ENTITY_TYPE, BEAN_SWAP_AMOUNT, SWAP_ACCOUNT, SWAP_ENTITY_TYPE, WELL, WETH_SWAP_AMOUNT } from "./helpers/Constants"; import { boreDefaultWell } from "./helpers/Aquifer"; import { mockShift, mockSwap } from "./helpers/Swap"; diff --git a/projects/subgraph-basin/tests/helpers/Aquifer.ts b/projects/subgraph-basin/tests/helpers/Aquifer.ts index b51172292b..7fefba8a0b 100644 --- a/projects/subgraph-basin/tests/helpers/Aquifer.ts +++ b/projects/subgraph-basin/tests/helpers/Aquifer.ts @@ -2,7 +2,7 @@ import { Address, Bytes, ethereum } from "@graphprotocol/graph-ts"; import { newMockEvent } from "matchstick-as/assembly/index"; import { BoreWell } from "../../generated/Basin-ABIs/Aquifer"; import { handleBoreWell } from "../../src/templates/AquiferHandler"; -import { BEAN_ERC20, WETH } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/BeanstalkEth"; import { AQUIFER, IMPLEMENTATION, PUMP, WELL, WELL_DATA, WELL_FUNCTION } from "./Constants"; import { createContractCallMocks } from "./Functions"; diff --git a/projects/subgraph-basin/tests/helpers/Functions.ts b/projects/subgraph-basin/tests/helpers/Functions.ts index c4feab1ca1..72b42a16eb 100644 --- a/projects/subgraph-basin/tests/helpers/Functions.ts +++ b/projects/subgraph-basin/tests/helpers/Functions.ts @@ -1,6 +1,13 @@ import { BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { createMockedFunction } from "matchstick-as/assembly/index"; -import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, BEANSTALK_PRICE_1, CRV3_TOKEN, WETH } from "../../../subgraph-core/utils/Constants"; +import { + BEAN_3CRV, + BEAN_ERC20, + BEAN_WETH_CP2_WELL, + BEANSTALK_PRICE_1, + CRV3_TOKEN, + WETH +} from "../../../subgraph-core/constants/BeanstalkEth"; import { BEAN_USD_PRICE, WELL } from "./Constants"; import { setMockBeanPrice } from "../../../subgraph-core/tests/event-mocking/Price"; import { ONE_BD, ZERO_BD } from "../../../subgraph-core/utils/Decimals"; diff --git a/projects/subgraph-basin/tests/helpers/Liquidity.ts b/projects/subgraph-basin/tests/helpers/Liquidity.ts index b547596b6f..d3235dece9 100644 --- a/projects/subgraph-basin/tests/helpers/Liquidity.ts +++ b/projects/subgraph-basin/tests/helpers/Liquidity.ts @@ -1,6 +1,6 @@ import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { Deposit, Withdraw } from "../../generated/schema"; -import { BEAN_ERC20, WETH } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/BeanstalkEth"; import { handleAddLiquidity, handleRemoveLiquidity, handleRemoveLiquidityOneToken, handleSync } from "../../src/WellHandler"; import { BEAN_SWAP_AMOUNT, SWAP_ACCOUNT, WELL, WELL_LP_AMOUNT, WETH_SWAP_AMOUNT } from "./Constants"; import { createContractCallMocks } from "./Functions"; diff --git a/projects/subgraph-basin/tests/helpers/Swap.ts b/projects/subgraph-basin/tests/helpers/Swap.ts index b1d0977200..c31e226eda 100644 --- a/projects/subgraph-basin/tests/helpers/Swap.ts +++ b/projects/subgraph-basin/tests/helpers/Swap.ts @@ -1,5 +1,5 @@ import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20, WETH } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/BeanstalkEth"; import { handleShift, handleSwap } from "../../src/WellHandler"; import { BEAN_SWAP_AMOUNT, SWAP_ACCOUNT, WELL, WETH_SWAP_AMOUNT } from "./Constants"; import { createContractCallMocks } from "./Functions"; diff --git a/projects/subgraph-bean/src/entities/Bean.ts b/projects/subgraph-bean/src/entities/Bean.ts index 3ce93457f5..8f9dd74815 100644 --- a/projects/subgraph-bean/src/entities/Bean.ts +++ b/projects/subgraph-bean/src/entities/Bean.ts @@ -1,5 +1,5 @@ import { BigInt, BigDecimal, Address } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20 } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20 } from "../../../subgraph-core/constants/BeanstalkEth"; import { dayFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { Bean, BeanDailySnapshot, BeanHourlySnapshot } from "../../generated/schema"; diff --git a/projects/subgraph-bean/src/handlers/BeanHandler.ts b/projects/subgraph-bean/src/handlers/BeanHandler.ts index 566ea8cb37..0059d6b6ae 100644 --- a/projects/subgraph-bean/src/handlers/BeanHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanHandler.ts @@ -1,4 +1,4 @@ -import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Constants"; +import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; import { Transfer } from "../../generated/Bean-ABIs/ERC20"; import { adjustSupply, updateBeanSupplyPegPercent } from "../utils/Bean"; diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts index 0454fab151..d8c12274a6 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanHandler.ts @@ -1,4 +1,4 @@ -import { ADDRESS_ZERO } from "../../../../subgraph-core/utils/Constants"; +import { ADDRESS_ZERO } from "../../../../subgraph-core/utils/Bytes"; import { Transfer } from "../../../generated/Bean-ABIs/ERC20"; import { adjustSupply } from "../../utils/Bean"; diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts index c472b369c5..72b16bc4a1 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts @@ -1,5 +1,5 @@ import { toAddress } from "../../../../subgraph-core/utils/Bytes"; -import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../../subgraph-core/utils/Constants"; +import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../../subgraph-core/constants/BeanstalkEth"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { CurvePrice } from "../../../generated/Bean-ABIs/CurvePrice"; import { Sunrise } from "../../../generated/Bean-ABIs/PreReplant"; diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts index cdba233bf3..b2c01bc520 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts @@ -2,7 +2,7 @@ import { BigInt, ethereum, Address, log } from "@graphprotocol/graph-ts"; import { getLastBeanPrice, calcLiquidityWeightedBeanPrice, updateBeanSupplyPegPercent, updateBeanValues } from "../../utils/Bean"; import { Swap, Sync } from "../../../generated/Bean-ABIs/UniswapV2Pair"; import { loadOrCreateToken } from "../../entities/Token"; -import { BEAN_ERC20_V1, BEAN_WETH_V1, WETH } from "../../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20_V1, BEAN_WETH_V1, WETH } from "../../../../subgraph-core/constants/BeanstalkEth"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadOrCreatePool } from "../../entities/Pool"; import { setPoolReserves, updatePoolPrice, updatePoolValues } from "../../utils/Pool"; diff --git a/projects/subgraph-bean/src/utils/Bean.ts b/projects/subgraph-bean/src/utils/Bean.ts index 84d413393c..2867fc7a6b 100644 --- a/projects/subgraph-bean/src/utils/Bean.ts +++ b/projects/subgraph-bean/src/utils/Bean.ts @@ -1,6 +1,6 @@ import { BigDecimal, BigInt, ethereum, Address } from "@graphprotocol/graph-ts"; import { Pool } from "../../generated/schema"; -import { BEAN_ERC20_V1, BEAN_WETH_V1 } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20_V1, BEAN_WETH_V1 } from "../../../subgraph-core/constants/BeanstalkEth"; import { ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { checkBeanCross } from "./Cross"; import { BeanstalkPrice_try_price, BeanstalkPriceResult } from "./price/BeanstalkPrice"; diff --git a/projects/subgraph-bean/src/utils/Cross.ts b/projects/subgraph-bean/src/utils/Cross.ts index 6dd6611676..a1f6877831 100644 --- a/projects/subgraph-bean/src/utils/Cross.ts +++ b/projects/subgraph-bean/src/utils/Cross.ts @@ -1,6 +1,6 @@ import { BigDecimal, Address, ethereum, log } from "@graphprotocol/graph-ts"; import { ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEAN_ERC20_V1 } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20_V1 } from "../../../subgraph-core/constants/BeanstalkEth"; import { loadOrCreatePool, loadOrCreatePoolDailySnapshot, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../entities/Bean"; import { loadOrCreateBeanCross, loadOrCreatePoolCross } from "../entities/Cross"; diff --git a/projects/subgraph-bean/src/utils/constants/Addresses.ts b/projects/subgraph-bean/src/utils/constants/Addresses.ts index c4c7a9da1d..defccd03cc 100644 --- a/projects/subgraph-bean/src/utils/constants/Addresses.ts +++ b/projects/subgraph-bean/src/utils/constants/Addresses.ts @@ -1,26 +1,14 @@ import { BigInt, Address } from "@graphprotocol/graph-ts"; -import { - BEAN_3CRV, - BEAN_ERC20, - BEAN_ERC20_V1, - BEAN_WETH_CP2_WELL, - BEAN_WETH_UNRIPE_MIGRATION_BLOCK, - BEAN_WSTETH_CP2_WELL, - BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK, - BEANSTALK, - NEW_BEAN_TOKEN_BLOCK, - UNRIPE_BEAN, - UNRIPE_LP -} from "../../../../subgraph-core/utils/Constants"; +import * as BeanstalkEth from "../../../../subgraph-core/constants/BeanstalkEth"; import { getVersionEntity } from "./Version"; export function getProtocolToken(blockNumber: BigInt): Address { const protocol = getVersionEntity().protocolAddress; - if (protocol == BEANSTALK) { - if (blockNumber < NEW_BEAN_TOKEN_BLOCK) { - return BEAN_ERC20_V1; + if (protocol == BeanstalkEth.BEANSTALK) { + if (blockNumber < BeanstalkEth.NEW_BEAN_TOKEN_BLOCK) { + return BeanstalkEth.BEAN_ERC20_V1; } else { - return BEAN_ERC20; + return BeanstalkEth.BEAN_ERC20; } } throw new Error("Unsupported protocol"); @@ -28,16 +16,16 @@ export function getProtocolToken(blockNumber: BigInt): Address { export function getUnripeBeanAddr(): Address { const protocol = getVersionEntity().protocolAddress; - if (protocol == BEANSTALK) { - return UNRIPE_BEAN; + if (protocol == BeanstalkEth.BEANSTALK) { + return BeanstalkEth.UNRIPE_BEAN; } throw new Error("Unsupported protocol"); } export function getUnripeLpAddr(): Address { const protocol = getVersionEntity().protocolAddress; - if (protocol == BEANSTALK) { - return UNRIPE_LP; + if (protocol == BeanstalkEth.BEANSTALK) { + return BeanstalkEth.UNRIPE_LP; } throw new Error("Unsupported protocol"); } diff --git a/projects/subgraph-bean/src/utils/constants/Milestone.ts b/projects/subgraph-bean/src/utils/constants/Milestone.ts index 3382dc331a..21d5850f74 100644 --- a/projects/subgraph-bean/src/utils/constants/Milestone.ts +++ b/projects/subgraph-bean/src/utils/constants/Milestone.ts @@ -13,7 +13,7 @@ import { PRICE_2_BLOCK, UNRIPE_BEAN, UNRIPE_LP -} from "../../../../subgraph-core/utils/Constants"; +} from "../../../../subgraph-core/constants/BeanstalkEth"; import { getVersionEntity } from "./Version"; export function isGaugeDeployed(blockNumber: BigInt): boolean { diff --git a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts index c8d7fe5d57..a551dd528c 100644 --- a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts +++ b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts @@ -12,7 +12,7 @@ import { BEAN_WETH_CP2_WELL, BEAN_WSTETH_CP2_WELL, WSTETH -} from "../../../../subgraph-core/utils/Constants"; +} from "../../../../subgraph-core/constants/BeanstalkEth"; // Use this mapping to determine which tokens are in each pool. Pools may each follow a distinct interface, // so a view function shouldn't be used, and a new subgraph build is already required to track a newly whitelisted asset. diff --git a/projects/subgraph-bean/src/utils/constants/Version.ts b/projects/subgraph-bean/src/utils/constants/Version.ts index 2f33371239..3803d9655d 100644 --- a/projects/subgraph-bean/src/utils/constants/Version.ts +++ b/projects/subgraph-bean/src/utils/constants/Version.ts @@ -1,10 +1,10 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../../generated/schema"; -import { BEANSTALK } from "../../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../../subgraph-core/constants/BeanstalkEth"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); - versionEntity.versionNumber = "2.3.1"; + versionEntity.versionNumber = "3.0.0"; versionEntity.subgraphName = subgraphNameForBlockNumber(block.number); versionEntity.protocolAddress = protocolForBlockNumber(block.number); versionEntity.chain = chainForBlockNumber(block.number); diff --git a/projects/subgraph-bean/src/utils/legacy/Bean.ts b/projects/subgraph-bean/src/utils/legacy/Bean.ts index 9f749b4497..152519a66b 100644 --- a/projects/subgraph-bean/src/utils/legacy/Bean.ts +++ b/projects/subgraph-bean/src/utils/legacy/Bean.ts @@ -1,5 +1,5 @@ import { BigInt, Address } from "@graphprotocol/graph-ts"; -import { BEAN_3CRV_V1, BEAN_LUSD_V1, BEAN_WETH_V1 } from "../../../../subgraph-core/utils/Constants"; +import { BEAN_3CRV_V1, BEAN_LUSD_V1, BEAN_WETH_V1 } from "../../../../subgraph-core/constants/BeanstalkEth"; import { toDecimal, ZERO_BD } from "../../../../subgraph-core/utils/Decimals"; import { Pool } from "../../../generated/schema"; import { loadBean } from "../../entities/Bean"; diff --git a/projects/subgraph-bean/src/utils/legacy/Curve.ts b/projects/subgraph-bean/src/utils/legacy/Curve.ts index a4ed489d16..2a9a42261d 100644 --- a/projects/subgraph-bean/src/utils/legacy/Curve.ts +++ b/projects/subgraph-bean/src/utils/legacy/Curve.ts @@ -1,5 +1,5 @@ import { Address, BigInt, BigDecimal, ethereum } from "@graphprotocol/graph-ts"; -import { BEAN_3CRV_V1, BEAN_ERC20_V1, BEAN_LUSD_V1, CURVE_PRICE } from "../../../../subgraph-core/utils/Constants"; +import { BEAN_3CRV_V1, BEAN_ERC20_V1, BEAN_LUSD_V1, CURVE_PRICE } from "../../../../subgraph-core/constants/BeanstalkEth"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadOrCreatePool } from "../../entities/Pool"; import { manualTwa } from "../price/TwaOracle"; diff --git a/projects/subgraph-bean/src/utils/price/CurvePrice.ts b/projects/subgraph-bean/src/utils/price/CurvePrice.ts index 9dd4428edc..5ac60e6e16 100644 --- a/projects/subgraph-bean/src/utils/price/CurvePrice.ts +++ b/projects/subgraph-bean/src/utils/price/CurvePrice.ts @@ -9,7 +9,7 @@ import { CRV3_TOKEN, LUSD, LUSD_3POOL -} from "../../../../subgraph-core/utils/Constants"; +} from "../../../../subgraph-core/constants/BeanstalkEth"; import { ERC20 } from "../../../generated/Bean-ABIs/ERC20"; import { DeltaBAndPrice, DeltaBPriceLiquidity, TWAType } from "./Types"; import { Pool } from "../../../generated/schema"; diff --git a/projects/subgraph-bean/src/utils/price/TwaOracle.ts b/projects/subgraph-bean/src/utils/price/TwaOracle.ts index e03868ca98..43fec10003 100644 --- a/projects/subgraph-bean/src/utils/price/TwaOracle.ts +++ b/projects/subgraph-bean/src/utils/price/TwaOracle.ts @@ -1,7 +1,7 @@ import { BigInt, Address, BigDecimal } from "@graphprotocol/graph-ts"; import { BI_10, ONE_BI, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { uniswapCumulativePrice } from "./UniswapPrice"; -import { WETH_USDC_PAIR } from "../../../../subgraph-core/utils/Constants"; +import { WETH_USDC_PAIR } from "../../../../subgraph-core/constants/BeanstalkEth"; import { curveCumulativePrices } from "./CurvePrice"; import { TWAType } from "./Types"; import { wellCumulativePrices, wellTwaReserves } from "./WellPrice"; diff --git a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts index 4ceef36492..862c765f62 100644 --- a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts +++ b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts @@ -1,6 +1,6 @@ import { Address, BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { BD_10, BI_10, ONE_BI, pow, sqrt, toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; -import { WETH, WETH_USDC_PAIR } from "../../../../subgraph-core/utils/Constants"; +import { WETH, WETH_USDC_PAIR } from "../../../../subgraph-core/constants/BeanstalkEth"; import { DeltaBAndPrice, DeltaBPriceLiquidity, TWAType } from "./Types"; import { setPoolTwa } from "../Pool"; import { getTWAPrices } from "./TwaOracle"; diff --git a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts index 7251077625..6107c4ffcd 100644 --- a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts +++ b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts @@ -8,7 +8,7 @@ import { PRICE_1_BLOCK, PRICE_2_BLOCK, WETH -} from "../../subgraph-core/utils/Constants"; +} from "../../subgraph-core/constants/BeanstalkEth"; import { createDewhitelistTokenEvent } from "./event-mocking/Beanstalk"; import { setMockBeanPrice } from "../../subgraph-core/tests/event-mocking/Price"; import { BigInt } from "@graphprotocol/graph-ts"; diff --git a/projects/subgraph-bean/tests/Cross.test.ts b/projects/subgraph-bean/tests/Cross.test.ts index e7a3260439..dc6e5e2ac6 100644 --- a/projects/subgraph-bean/tests/Cross.test.ts +++ b/projects/subgraph-bean/tests/Cross.test.ts @@ -6,7 +6,7 @@ import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { mockPreReplantETHPrice, simpleMockPrice } from "../../subgraph-core/tests/event-mocking/Price"; -import { BEAN_3CRV_V1, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_CP2_WELL, BEAN_WETH_V1 } from "../../subgraph-core/utils/Constants"; +import { BEAN_3CRV_V1, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_CP2_WELL, BEAN_WETH_V1 } from "../../subgraph-core/constants/BeanstalkEth"; import { BigDecimal_round, toDecimal, ZERO_BD } from "../../subgraph-core/utils/Decimals"; import { getPreReplantPriceETH, constantProductPrice, uniswapV2Reserves } from "../src/utils/price/UniswapPrice"; diff --git a/projects/subgraph-bean/tests/DeltaB.test.ts b/projects/subgraph-bean/tests/DeltaB.test.ts index 42f68b8faf..41b37186c6 100644 --- a/projects/subgraph-bean/tests/DeltaB.test.ts +++ b/projects/subgraph-bean/tests/DeltaB.test.ts @@ -3,7 +3,7 @@ import { BigInt, Bytes, BigDecimal, log } from "@graphprotocol/graph-ts"; // import { log } from "matchstick-as/assembly/log"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { createMetapoolOracleEvent, createWellOracleEvent } from "./event-mocking/Beanstalk"; -import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, CRV3_POOL } from "../../subgraph-core/utils/Constants"; +import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, CRV3_POOL } from "../../subgraph-core/constants/BeanstalkEth"; import { hourFromTimestamp } from "../../subgraph-core/utils/Dates"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { uniswapV2DeltaB } from "../src/utils/price/UniswapPrice"; diff --git a/projects/subgraph-bean/tests/Migration.test.ts b/projects/subgraph-bean/tests/Migration.test.ts index d8fb886701..de8189e739 100644 --- a/projects/subgraph-bean/tests/Migration.test.ts +++ b/projects/subgraph-bean/tests/Migration.test.ts @@ -1,7 +1,7 @@ import { clearStore, beforeEach, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; import { handleInitBeanEntity } from "../src/utils/b3-migration/BeanInit"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; -import { BEAN_ERC20 } from "../../subgraph-core/utils/Constants"; +import { BEAN_ERC20 } from "../../subgraph-core/constants/BeanstalkEth"; import { BEAN_INITIAL_VALUES } from "../cache-builder/results/BeanInit_arb"; import { initL1Version } from "./entity-mocking/MockVersion"; diff --git a/projects/subgraph-bean/tests/Pool.test.ts b/projects/subgraph-bean/tests/Pool.test.ts index b5f4832735..6de53dd993 100644 --- a/projects/subgraph-bean/tests/Pool.test.ts +++ b/projects/subgraph-bean/tests/Pool.test.ts @@ -1,5 +1,5 @@ import { beforeEach, afterEach, clearStore, describe, assert, test } from "matchstick-as/assembly/index"; -import { BEAN_3CRV, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_V1, CRV3_TOKEN, WETH } from "../../subgraph-core/utils/Constants"; +import { BEAN_3CRV, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_V1, CRV3_TOKEN, WETH } from "../../subgraph-core/constants/BeanstalkEth"; import { BigInt, Address } from "@graphprotocol/graph-ts"; import { loadOrCreatePool } from "../src/entities/Pool"; import { toAddress } from "../../subgraph-core/utils/Bytes"; diff --git a/projects/subgraph-bean/tests/Whitelist.test.ts b/projects/subgraph-bean/tests/Whitelist.test.ts index 621dff5cd0..652ce70165 100644 --- a/projects/subgraph-bean/tests/Whitelist.test.ts +++ b/projects/subgraph-bean/tests/Whitelist.test.ts @@ -1,5 +1,5 @@ import { beforeEach, beforeAll, afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; -import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, BEAN_WETH_CP2_WELL_BLOCK } from "../../subgraph-core/utils/Constants"; +import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, BEAN_WETH_CP2_WELL_BLOCK } from "../../subgraph-core/constants/BeanstalkEth"; import { createDewhitelistTokenEvent } from "./event-mocking/Beanstalk"; import { setWhitelistedPools } from "./entity-mocking/MockBean"; import { handleDewhitelistToken } from "../src/handlers/BeanstalkHandler"; diff --git a/projects/subgraph-bean/tests/call-mocking/Beanstalk.ts b/projects/subgraph-bean/tests/call-mocking/Beanstalk.ts index 2691c0b93f..0d6fb7794f 100644 --- a/projects/subgraph-bean/tests/call-mocking/Beanstalk.ts +++ b/projects/subgraph-bean/tests/call-mocking/Beanstalk.ts @@ -1,6 +1,6 @@ import { BigDecimal, BigInt, ethereum, Address, Bytes } from "@graphprotocol/graph-ts"; import { createMockedFunction } from "matchstick-as/assembly/index"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; export function mockSeedGaugeLockedBeans(reserveBytes: Bytes, twaTimestamp: BigInt, lockedBeans: BigInt): void { createMockedFunction(BEANSTALK, "getLockedBeansFromTwaReserves", "getLockedBeansFromTwaReserves(bytes,uint40):(uint256)") diff --git a/projects/subgraph-bean/tests/entity-mocking/MockBean.ts b/projects/subgraph-bean/tests/entity-mocking/MockBean.ts index 6ac1de6e65..97a79365e7 100644 --- a/projects/subgraph-bean/tests/entity-mocking/MockBean.ts +++ b/projects/subgraph-bean/tests/entity-mocking/MockBean.ts @@ -1,5 +1,5 @@ import { Address } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20 } from "../../../subgraph-core/utils/Constants"; +import { BEAN_ERC20 } from "../../../subgraph-core/constants/BeanstalkEth"; import { loadBean } from "../../src/entities/Bean"; import { toBytesArray } from "../../../subgraph-core/utils/Bytes"; diff --git a/projects/subgraph-bean/tests/entity-mocking/MockPool.ts b/projects/subgraph-bean/tests/entity-mocking/MockPool.ts index 74295d6c4a..cb6879cfab 100644 --- a/projects/subgraph-bean/tests/entity-mocking/MockPool.ts +++ b/projects/subgraph-bean/tests/entity-mocking/MockPool.ts @@ -1,6 +1,6 @@ import { BigInt, Address, BigDecimal } from "@graphprotocol/graph-ts"; import { mockPreReplantBeanEthPriceAndLiquidity } from "../../../subgraph-core/tests/event-mocking/Price"; -import { BEAN_WETH_V1, BEANSTALK_BLOCK } from "../../../subgraph-core/utils/Constants"; +import { BEAN_WETH_V1, BEANSTALK_BLOCK } from "../../../subgraph-core/constants/BeanstalkEth"; import { loadOrCreatePool } from "../../src/entities/Pool"; export function mockPoolPriceAndLiquidity(poolAddr: Address, price: BigDecimal, liquidityUSD: BigDecimal, blockNumber: BigInt): void { diff --git a/projects/subgraph-bean/tests/event-mocking/Curve.ts b/projects/subgraph-bean/tests/event-mocking/Curve.ts index 71fa6d67bf..1ab27bb4ed 100644 --- a/projects/subgraph-bean/tests/event-mocking/Curve.ts +++ b/projects/subgraph-bean/tests/event-mocking/Curve.ts @@ -3,7 +3,7 @@ import { createMockedFunction } from "matchstick-as"; import { TokenExchangeUnderlying } from "../../generated/Bean-ABIs/Bean3CRV"; import { mockContractEvent } from "../../../subgraph-core/tests/event-mocking/Util"; -import { BEAN_3CRV_V1 } from "../../../subgraph-core/utils/Constants"; +import { BEAN_3CRV_V1 } from "../../../subgraph-core/constants/BeanstalkEth"; export function mock_virtual_price(contract: Address, retval: BigInt): void { createMockedFunction(contract, "get_virtual_price", "get_virtual_price():(uint256)") diff --git a/projects/subgraph-bean/tests/l2sr.test.ts b/projects/subgraph-bean/tests/l2sr.test.ts index d87f382ee5..f195e8e9e3 100644 --- a/projects/subgraph-bean/tests/l2sr.test.ts +++ b/projects/subgraph-bean/tests/l2sr.test.ts @@ -1,7 +1,6 @@ import { beforeEach, beforeAll, afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; import { BigInt, Bytes, BigDecimal, log } from "@graphprotocol/graph-ts"; import { - ADDRESS_ZERO, BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, @@ -10,7 +9,7 @@ import { GAUGE_BIP45_BLOCK, UNRIPE_BEAN, UNRIPE_LP -} from "../../subgraph-core/utils/Constants"; +} from "../../subgraph-core/constants/BeanstalkEth"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { mockGetRecapPaidPercent, @@ -29,6 +28,7 @@ import { loadBean } from "../src/entities/Bean"; import { handleChop, handleConvert } from "../src/handlers/BeanstalkHandler"; import { createConvertEvent } from "./event-mocking/Beanstalk"; import { initL1Version } from "./entity-mocking/MockVersion"; +import { ADDRESS_ZERO } from "../../subgraph-core/utils/Bytes"; const mockReserves = Bytes.fromHexString("0xabcdef"); const mockReservesTime = BigInt.fromString("123456"); diff --git a/projects/subgraph-beanft/src/utils/Init.ts b/projects/subgraph-beanft/src/utils/Init.ts index b5301973d6..9557c066ec 100644 --- a/projects/subgraph-beanft/src/utils/Init.ts +++ b/projects/subgraph-beanft/src/utils/Init.ts @@ -1,6 +1,6 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../generated/schema"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); diff --git a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts index 20445b0754..25da09e4d4 100644 --- a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts +++ b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts @@ -1,7 +1,6 @@ import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { Farmer, Fertilizer, FertilizerBalance, FertilizerToken, FertilizerYield } from "../../generated/schema"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { getFertilizerProtocol } from "../utils/Constants"; diff --git a/projects/subgraph-beanstalk/src/entities/Field.ts b/projects/subgraph-beanstalk/src/entities/Field.ts index 4bc661c8c9..38feba1b4b 100644 --- a/projects/subgraph-beanstalk/src/entities/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/Field.ts @@ -1,8 +1,8 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { Field, Plot } from "../../generated/schema"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { ADDRESS_ZERO, BEANSTALK, CURVE_PRICE } from "../../../subgraph-core/utils/Constants"; -import { loadBeanstalk, loadSeason } from "./Beanstalk"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; export function loadField(account: Address): Field { let field = Field.load(account.toHexString()); diff --git a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts index 96c1c803cd..68b4f1ad53 100644 --- a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts +++ b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts @@ -2,7 +2,7 @@ import { Address, BigInt, Bytes, log } from "@graphprotocol/graph-ts"; import { loadField } from "./Field"; import { PodFill, PodListing, PodMarketplace, PodOrder } from "../../generated/schema"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; export function loadPodMarketplace(protocol: Address): PodMarketplace { let marketplace = PodMarketplace.load(protocol.toHexString()); diff --git a/projects/subgraph-beanstalk/src/entities/Silo.ts b/projects/subgraph-beanstalk/src/entities/Silo.ts index e53dd4769c..4580d754d4 100644 --- a/projects/subgraph-beanstalk/src/entities/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/Silo.ts @@ -9,7 +9,7 @@ import { TokenYield, UnripeToken } from "../../generated/schema"; -import { BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../../subgraph-core/constants/BeanstalkEth"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { getTokenDecimals, getUnripeUnderlying } from "../utils/Constants"; diff --git a/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts b/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts index 1569946103..78a8097ab8 100644 --- a/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts @@ -1,9 +1,10 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Transfer } from "../../generated/Beanstalk-ABIs/ERC20"; -import { ADDRESS_ZERO, BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; import { getTokenProtocol } from "../utils/Constants"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; export function handleTransfer(event: Transfer): void { if (event.params.from == ADDRESS_ZERO || event.params.to == ADDRESS_ZERO) { diff --git a/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts b/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts index 6477e27923..ecb9ee5b05 100644 --- a/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts @@ -1,9 +1,10 @@ import { BigInt, log } from "@graphprotocol/graph-ts"; -import { BEANSTALK_FARMS } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK_FARMS } from "../../../subgraph-core/constants/BeanstalkEth"; import { loadField } from "../entities/Field"; import { harvest, plotTransfer, sow, temperatureChanged } from "../utils/Field"; import { Sow, Harvest, PlotTransfer, TemperatureChange } from "../../generated/Beanstalk-ABIs/SeedGauge"; +// TODO: add legacy field for the part using beanstalk farms address export function handleSow(event: Sow): void { let sownOverride: BigInt | null = null; if (event.params.account == BEANSTALK_FARMS) { diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index e294a51500..1f5a96a141 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -19,7 +19,7 @@ import { savePrevFarmerGerminatingEvent } from "../entities/Germinating"; import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEAN_WETH_CP2_WELL } from "../../../subgraph-core/utils/Constants"; +import { BEAN_WETH_CP2_WELL } from "../../../subgraph-core/constants/BeanstalkEth"; import { Bytes4_emptyToNull } from "../../../subgraph-core/utils/Bytes"; import { setSiloHourlyCaseId, takeSiloSnapshots } from "../entities/snapshots/Silo"; import { loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index 16f005acd2..8c24979637 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -1,6 +1,6 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { Reward, Soil, WellOracle, Sunrise, Incentivization, SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { BEANSTALK, GAUGE_BIP45_BLOCK, REPLANT_SEASON } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK, GAUGE_BIP45_BLOCK, REPLANT_SEASON } from "../../../subgraph-core/constants/BeanstalkEth"; import { toDecimal, ZERO_BD } from "../../../subgraph-core/utils/Decimals"; import { updateStalkWithCalls } from "../utils/legacy/LegacySilo"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; @@ -55,6 +55,7 @@ export function handleReward(event: Reward): void { export function handleWellOracle(event: WellOracle): void { let season = loadSeason(event.address, event.params.season); season.deltaB = season.deltaB.plus(event.params.deltaB); + // TODO: something like isGaugeDeployed(v())? if (event.block.number >= GAUGE_BIP45_BLOCK && season.price == ZERO_BD) { let beanstalkPrice = getBeanstalkPrice(event.block.number); let beanstalkQuery = beanstalkPrice.getConstantProductWell(event.params.well); diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts index f320b1d12e..ccfd7553d2 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts @@ -1,5 +1,5 @@ import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; -import { CURVE_PRICE, REPLANT_SEASON } from "../../../../subgraph-core/utils/Constants"; +import { CURVE_PRICE, REPLANT_SEASON } from "../../../../subgraph-core/constants/BeanstalkEth"; import { toDecimal } from "../../../../subgraph-core/utils/Decimals"; import { CurvePrice } from "../../../generated/Beanstalk-ABIs/CurvePrice"; import { SeasonSnapshot, Sunrise } from "../../../generated/Beanstalk-ABIs/PreReplant"; diff --git a/projects/subgraph-beanstalk/src/utils/Barn.ts b/projects/subgraph-beanstalk/src/utils/Barn.ts index a22b120218..a580dcda84 100644 --- a/projects/subgraph-beanstalk/src/utils/Barn.ts +++ b/projects/subgraph-beanstalk/src/utils/Barn.ts @@ -1,7 +1,6 @@ import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Chop as ChopEntity } from "../../generated/schema"; import { loadFertilizer, loadFertilizerBalance, loadFertilizerToken } from "../entities/Fertilizer"; -import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Constants"; import { loadFarmer } from "../entities/Beanstalk"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { loadUnripeToken, loadWhitelistTokenSetting } from "../entities/Silo"; @@ -9,6 +8,7 @@ import { takeUnripeTokenSnapshots } from "../entities/snapshots/UnripeToken"; import { getUnripeUnderlying } from "./Constants"; import { BI_10, toDecimal } from "../../../subgraph-core/utils/Decimals"; import { getLatestBdv } from "../entities/snapshots/WhitelistTokenSetting"; +import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; class ChopParams { event: ethereum.Event; diff --git a/projects/subgraph-beanstalk/src/utils/Constants.ts b/projects/subgraph-beanstalk/src/utils/Constants.ts index 182a1d6806..ff62234732 100644 --- a/projects/subgraph-beanstalk/src/utils/Constants.ts +++ b/projects/subgraph-beanstalk/src/utils/Constants.ts @@ -14,7 +14,7 @@ import { FERTILIZER, UNRIPE_BEAN, UNRIPE_LP -} from "../../../subgraph-core/utils/Constants"; +} from "../../../subgraph-core/constants/BeanstalkEth"; export function getProtocolToken(protocol: Address): Address { if (protocol == BEANSTALK) { diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index da920707d7..95ccd4b181 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -1,7 +1,7 @@ import { Address, BigInt, BigDecimal, ethereum } from "@graphprotocol/graph-ts"; import { CurvePrice } from "../../generated/Beanstalk-ABIs/CurvePrice"; import { BeanstalkPrice_try_price } from "./contracts/BeanstalkPrice"; -import { CURVE_PRICE } from "../../../subgraph-core/utils/Constants"; +import { CURVE_PRICE } from "../../../subgraph-core/constants/BeanstalkEth"; import { BI_10, ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { setFieldHourlyCaseId, setHourlySoilSoldOut, takeFieldSnapshots } from "../entities/snapshots/Field"; import { getCurrentSeason, getHarvestableIndex, loadBeanstalk, loadFarmer, loadSeason } from "../entities/Beanstalk"; diff --git a/projects/subgraph-beanstalk/src/utils/Init.ts b/projects/subgraph-beanstalk/src/utils/Init.ts index cff1e6f4de..78b43bca47 100644 --- a/projects/subgraph-beanstalk/src/utils/Init.ts +++ b/projects/subgraph-beanstalk/src/utils/Init.ts @@ -1,6 +1,6 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../generated/schema"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); diff --git a/projects/subgraph-beanstalk/src/utils/Silo.ts b/projects/subgraph-beanstalk/src/utils/Silo.ts index 35976decc0..d9db53b180 100644 --- a/projects/subgraph-beanstalk/src/utils/Silo.ts +++ b/projects/subgraph-beanstalk/src/utils/Silo.ts @@ -3,7 +3,7 @@ import { takeSiloSnapshots } from "../entities/snapshots/Silo"; import { loadSilo, loadSiloAsset, loadSiloDeposit, loadWhitelistTokenSetting, updateDeposit } from "../entities/Silo"; import { takeSiloAssetSnapshots } from "../entities/snapshots/SiloAsset"; import { stemFromSeason } from "./contracts/SiloCalculations"; -import { GAUGE_BIP45_BLOCK } from "../../../subgraph-core/utils/Constants"; +import { GAUGE_BIP45_BLOCK } from "../../../subgraph-core/constants/BeanstalkEth"; import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { loadBeanstalk, loadFarmer } from "../entities/Beanstalk"; diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index 7f619676a5..d63187ed80 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -15,7 +15,7 @@ import { getGerminatingBdvs } from "../entities/Germinating"; import { getCurrentSeason, getRewardMinted, loadBeanstalk } from "../entities/Beanstalk"; import { loadFertilizer, loadFertilizerYield } from "../entities/Fertilizer"; import { getProtocolFertilizer } from "./Constants"; -import { REPLANT_SEASON } from "../../../subgraph-core/utils/Constants"; +import { REPLANT_SEASON } from "../../../subgraph-core/constants/BeanstalkEth"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; const ROLLING_24_WINDOW = 24; diff --git a/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts b/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts index 53a5da5dca..1297baf238 100644 --- a/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts +++ b/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts @@ -5,7 +5,7 @@ import { BeanstalkPrice__priceResultPPsStruct, BeanstalkPrice__priceResultPStruct } from "../../../generated/Beanstalk-ABIs/BeanstalkPrice"; -import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../../subgraph-core/utils/Constants"; +import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../../subgraph-core/constants/BeanstalkEth"; import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadSilo } from "../../entities/Silo"; diff --git a/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts b/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts index 902490fbf0..04c25865a0 100644 --- a/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts +++ b/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts @@ -1,5 +1,5 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; -import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/utils/Constants"; +import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/BeanstalkEth"; import { BI_10 } from "../../../../subgraph-core/utils/Decimals"; const STEM_START_SEASON = 14210; diff --git a/projects/subgraph-beanstalk/tests/Field.test.ts b/projects/subgraph-beanstalk/tests/Field.test.ts index a5b4687336..51af669ac2 100644 --- a/projects/subgraph-beanstalk/tests/Field.test.ts +++ b/projects/subgraph-beanstalk/tests/Field.test.ts @@ -1,7 +1,7 @@ import { afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; import { BigInt } from "@graphprotocol/graph-ts"; -import { BEANSTALK } from "../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { beans_BI as beans, podlineMil_BI as mil } from "../../subgraph-core/tests/Values"; import { assertFarmerHasPlot, assertFieldHas, sow } from "./utils/Field"; diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts index d80d09f8c0..fab4e7c45c 100644 --- a/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts +++ b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts @@ -2,7 +2,7 @@ import { BigInt, Bytes, log } from "@graphprotocol/graph-ts"; import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; import { beans_BI, podlineMil_BI } from "../../subgraph-core/tests/Values"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; import { assertMarketListingsState, assertMarketOrdersState, diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts index 80605ffd0f..7f0994b9d0 100644 --- a/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts +++ b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts @@ -2,7 +2,7 @@ import { BigInt, Bytes, log } from "@graphprotocol/graph-ts"; import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; import { beans_BI, podlineMil_BI } from "../../subgraph-core/tests/Values"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; import { assertMarketListingsState, assertMarketOrdersState, diff --git a/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts b/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts index b87e47bcbb..238223d98a 100644 --- a/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts +++ b/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts @@ -4,7 +4,7 @@ import { beforeEach, afterEach, assert, clearStore, describe, test, createMocked import { log } from "matchstick-as/assembly/log"; import { BigInt, Bytes } from "@graphprotocol/graph-ts"; -import { BEANSTALK } from "../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { beans_BI as beans, podlineMil_BI } from "../../subgraph-core/tests/Values"; import { assertFarmerHasPlot, assertFieldHas, setHarvestable, sow, transferPlot } from "./utils/Field"; diff --git a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts index 6a409524c9..b7da66bf1b 100644 --- a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts +++ b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts @@ -11,7 +11,7 @@ import { handleTotalGerminatingStalkChanged, handleTotalStalkChangedFromGermination } from "../src/handlers/GaugeHandler"; -import { BEAN_ERC20, BEANSTALK } from "../../subgraph-core/utils/Constants"; +import { BEAN_ERC20, BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; import { createBeanToMaxLpGpPerBdvRatioChangeEvent, createFarmerGerminatingStalkBalanceChangedEvent, diff --git a/projects/subgraph-beanstalk/tests/Silo.test.ts b/projects/subgraph-beanstalk/tests/Silo.test.ts index 6b3fb9a5e0..04a6b498f4 100644 --- a/projects/subgraph-beanstalk/tests/Silo.test.ts +++ b/projects/subgraph-beanstalk/tests/Silo.test.ts @@ -9,7 +9,7 @@ import { LUSD_3POOL, UNRIPE_BEAN, UNRIPE_LP -} from "../../subgraph-core/utils/Constants"; +} from "../../subgraph-core/constants/BeanstalkEth"; import { createAddDepositV2Event, createAddDepositV3Event, diff --git a/projects/subgraph-beanstalk/tests/Yield.test.ts b/projects/subgraph-beanstalk/tests/Yield.test.ts index 088c92e434..490e4f171b 100644 --- a/projects/subgraph-beanstalk/tests/Yield.test.ts +++ b/projects/subgraph-beanstalk/tests/Yield.test.ts @@ -10,7 +10,7 @@ import { UNRIPE_BEAN, UNRIPE_LP, LUSD_3POOL -} from "../../subgraph-core/utils/Constants"; +} from "../../subgraph-core/constants/BeanstalkEth"; import { setSeason } from "./utils/Season"; import { calculateAPYPreGauge } from "../src/utils/legacy/LegacyYield"; import { calculateGaugeVAPYs, updateSiloVAPYs } from "../src/utils/Yield"; diff --git a/projects/subgraph-beanstalk/tests/utils/Field.ts b/projects/subgraph-beanstalk/tests/utils/Field.ts index 879381bcf5..07779a6735 100644 --- a/projects/subgraph-beanstalk/tests/utils/Field.ts +++ b/projects/subgraph-beanstalk/tests/utils/Field.ts @@ -5,7 +5,7 @@ import { handleHarvest, handlePlotTransfer, handleSow } from "../../src/handlers import { createIncentivizationEvent } from "../event-mocking/Season"; import { handleIncentive } from "../../src/handlers/SeasonHandler"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); diff --git a/projects/subgraph-beanstalk/tests/utils/Marketplace.ts b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts index 2411a8fc87..24336e4bea 100644 --- a/projects/subgraph-beanstalk/tests/utils/Marketplace.ts +++ b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts @@ -22,7 +22,7 @@ import { PodOrderCancelled, PodListingCancelled } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; import { transferPlot } from "./Field"; import { PodListingCreated as PodListingCreated_v1, diff --git a/projects/subgraph-beanstalk/tests/utils/Season.ts b/projects/subgraph-beanstalk/tests/utils/Season.ts index 79ab3b69b1..4e57fda9ce 100644 --- a/projects/subgraph-beanstalk/tests/utils/Season.ts +++ b/projects/subgraph-beanstalk/tests/utils/Season.ts @@ -1,4 +1,4 @@ -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; import { loadBeanstalk } from "../../src/entities/Beanstalk"; export function setSeason(season: u32): void { diff --git a/projects/subgraph-core/utils/Constants.ts b/projects/subgraph-core/constants/BeanstalkEth.ts similarity index 89% rename from projects/subgraph-core/utils/Constants.ts rename to projects/subgraph-core/constants/BeanstalkEth.ts index 1319d336ec..8ce21ebd52 100644 --- a/projects/subgraph-core/utils/Constants.ts +++ b/projects/subgraph-core/constants/BeanstalkEth.ts @@ -1,7 +1,4 @@ -import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; - -// Standard Addresses -export const ADDRESS_ZERO = Address.fromString("0x0000000000000000000000000000000000000000"); +import { Address, BigInt } from "@graphprotocol/graph-ts"; // Token Addresses export const BEAN_ERC20_V1 = Address.fromString("0xDC59ac4FeFa32293A95889Dc396682858d52e5Db"); @@ -34,10 +31,6 @@ export const LUSD_3POOL = Address.fromString("0xEd279fDD11cA84bEef15AF5D39BB4d4b export const BEAN_WETH_CP2_WELL = Address.fromString("0xBEA0e11282e2bB5893bEcE110cF199501e872bAd"); export const BEAN_WSTETH_CP2_WELL = Address.fromString("0xBeA0000113B0d182f4064C86B71c315389E4715D"); -export const INITIAL_HUMIDITY = BigDecimal.fromString("500"); -export const MIN_HUMIDITY = BigDecimal.fromString("500"); -export const DELTA_HUMIDITY = BigDecimal.fromString("0.5"); - export const CALCULATIONS_CURVE = Address.fromString("0x25BF7b72815476Dd515044F9650Bf79bAd0Df655"); export const REPLANT_SEASON = BigInt.fromU32(6075); diff --git a/projects/subgraph-core/tests/event-mocking/Price.ts b/projects/subgraph-core/tests/event-mocking/Price.ts index 06ecef4114..4aff720f35 100644 --- a/projects/subgraph-core/tests/event-mocking/Price.ts +++ b/projects/subgraph-core/tests/event-mocking/Price.ts @@ -9,7 +9,7 @@ import { CURVE_PRICE, WETH, WETH_USDC_PAIR -} from "../../utils/Constants"; +} from "../../constants/BeanstalkEth"; import { BD_10, BI_10, pow, toDecimal, ZERO_BI } from "../../utils/Decimals"; // These 2 classes are analagous to structs used by BeanstalkPrice contract diff --git a/projects/subgraph-core/tests/event-mocking/Util.ts b/projects/subgraph-core/tests/event-mocking/Util.ts index 4fb23505ba..9e5a212fb7 100644 --- a/projects/subgraph-core/tests/event-mocking/Util.ts +++ b/projects/subgraph-core/tests/event-mocking/Util.ts @@ -1,6 +1,6 @@ import { Address, ethereum } from "@graphprotocol/graph-ts"; import { newMockEvent } from "matchstick-as/assembly/index"; -import { BEANSTALK } from "../../utils/Constants"; +import { BEANSTALK } from "../../constants/BeanstalkEth"; // Default mock to include beanstalk address export function mockBeanstalkEvent(): ethereum.Event { diff --git a/projects/subgraph-core/utils/Bytes.ts b/projects/subgraph-core/utils/Bytes.ts index df6bf3080f..1657a5d94d 100644 --- a/projects/subgraph-core/utils/Bytes.ts +++ b/projects/subgraph-core/utils/Bytes.ts @@ -1,5 +1,7 @@ import { BigInt, Bytes, Address } from "@graphprotocol/graph-ts"; +export const ADDRESS_ZERO = Address.fromString("0x0000000000000000000000000000000000000000"); + // If all zeros are provided, convert into a null. Otherwise return the provided value export function Bytes4_emptyToNull(b: Bytes): Bytes | null { return b == Bytes.fromHexString("0x00000000") ? null : b; From 7468335886f15920d8ce3dec7565199c4703f710 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 9 Sep 2024 10:49:30 -0700 Subject: [PATCH 15/88] add missing abis --- .../subgraph-bean/manifests/ethereum.yaml | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 006d245a79..c02ee3a8d8 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -270,12 +270,16 @@ dataSources: abis: - name: Bean3CRV file: ../../subgraph-core/abis/Bean3CRV.json - - name: CalculationsCurve - file: ../../subgraph-core/abis/CalculationsCurve.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: CurvePrice + file: ../../subgraph-core/abis/CurvePrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: UniswapV2Pair - file: ../../subgraph-core/abis/UniswapV2Pair.json + - name: Replanted + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: TokenExchange(indexed address,int128,uint256,int128,uint256) handler: handleTokenExchange @@ -307,12 +311,16 @@ dataSources: abis: - name: Bean3CRV file: ../../subgraph-core/abis/Bean3CRV.json - - name: CalculationsCurve - file: ../../subgraph-core/abis/CalculationsCurve.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: CurvePrice + file: ../../subgraph-core/abis/CurvePrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: UniswapV2Pair - file: ../../subgraph-core/abis/UniswapV2Pair.json + - name: Replanted + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: TokenExchange(indexed address,int128,uint256,int128,uint256) handler: handleTokenExchange From 07fd6f7b70c1ad2e1efc331cb8fce0f827daac9e Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:29:34 -0700 Subject: [PATCH 16/88] refactor bean constants to core --- .../subgraph-basin/src/BeanstalkHandler.ts | 2 +- .../src/utils/BeanstalkPrice.ts | 2 +- projects/subgraph-basin/src/utils/Init.ts | 2 +- projects/subgraph-basin/src/utils/Token.ts | 2 +- projects/subgraph-basin/src/utils/Well.ts | 2 +- projects/subgraph-basin/tests/Aquifer.test.ts | 2 +- .../tests/DepositWithdrawEntity.test.ts | 2 +- .../subgraph-basin/tests/Exchange.test.ts | 2 +- .../subgraph-basin/tests/Liquidity.test.ts | 2 +- .../subgraph-basin/tests/SwapEntity.test.ts | 2 +- .../subgraph-basin/tests/helpers/Aquifer.ts | 2 +- .../subgraph-basin/tests/helpers/Functions.ts | 2 +- .../subgraph-basin/tests/helpers/Liquidity.ts | 2 +- projects/subgraph-basin/tests/helpers/Swap.ts | 2 +- projects/subgraph-bean/src/entities/Bean.ts | 2 +- projects/subgraph-bean/src/entities/Pool.ts | 5 +- .../src/handlers/BeanWellHandler.ts | 7 +- .../src/handlers/BeanstalkHandler.ts | 13 +- .../handlers/legacy/LegacyBeanstalkHandler.ts | 9 +- .../handlers/legacy/LegacyUniswapV2Handler.ts | 2 +- projects/subgraph-bean/src/utils/Bean.ts | 7 +- projects/subgraph-bean/src/utils/Cross.ts | 7 +- .../subgraph-bean/src/utils/LockedBeans.ts | 18 ++- .../src/utils/b3-migration/BeanInit.ts | 5 +- .../src/utils/constants/Addresses.ts | 41 ------ .../src/utils/constants/Milestone.ts | 56 -------- .../src/utils/constants/PooledTokens.ts | 2 +- .../src/utils/constants/Version.ts | 14 +- .../subgraph-bean/src/utils/legacy/Bean.ts | 2 +- .../src/utils/legacy/Beanstalk.ts | 5 +- .../subgraph-bean/src/utils/legacy/Curve.ts | 2 +- .../src/utils/price/BeanstalkPrice.ts | 8 +- .../src/utils/price/CurvePrice.ts | 2 +- .../src/utils/price/TwaOracle.ts | 2 +- .../src/utils/price/UniswapPrice.ts | 2 +- .../tests/BeanstalkPrice.test.ts | 2 +- projects/subgraph-bean/tests/Cross.test.ts | 8 +- projects/subgraph-bean/tests/DeltaB.test.ts | 2 +- .../subgraph-bean/tests/Migration.test.ts | 2 +- projects/subgraph-bean/tests/Pool.test.ts | 9 +- .../subgraph-bean/tests/Whitelist.test.ts | 7 +- .../tests/call-mocking/Beanstalk.ts | 2 +- .../tests/entity-mocking/MockBean.ts | 2 +- .../tests/entity-mocking/MockPool.ts | 2 +- .../tests/event-mocking/Curve.ts | 2 +- projects/subgraph-bean/tests/l2sr.test.ts | 2 +- projects/subgraph-beanft/src/utils/Init.ts | 2 +- .../subgraph-beanstalk/src/entities/Field.ts | 2 +- .../src/entities/PodMarketplace.ts | 2 +- .../subgraph-beanstalk/src/entities/Silo.ts | 2 +- .../src/handlers/BeanHandler.ts | 2 +- .../src/handlers/FieldHandler.ts | 2 +- .../src/handlers/GaugeHandler.ts | 2 +- .../src/handlers/SeasonHandler.ts | 2 +- .../handlers/legacy/LegacySeasonHandler.ts | 2 +- .../subgraph-beanstalk/src/utils/Constants.ts | 2 +- .../subgraph-beanstalk/src/utils/Field.ts | 2 +- projects/subgraph-beanstalk/src/utils/Init.ts | 2 +- projects/subgraph-beanstalk/src/utils/Silo.ts | 2 +- .../subgraph-beanstalk/src/utils/Yield.ts | 2 +- .../src/utils/contracts/BeanstalkPrice.ts | 2 +- .../src/utils/contracts/SiloCalculations.ts | 2 +- .../subgraph-beanstalk/tests/Field.test.ts | 2 +- .../tests/MarketplaceV1.test.ts | 2 +- .../tests/MarketplaceV2.test.ts | 2 +- .../tests/PlotTransfer.test.ts | 2 +- .../tests/SeedGauge.test.ts | 2 +- .../subgraph-beanstalk/tests/Silo.test.ts | 2 +- .../subgraph-beanstalk/tests/Yield.test.ts | 2 +- .../subgraph-beanstalk/tests/utils/Field.ts | 2 +- .../tests/utils/Marketplace.ts | 2 +- .../subgraph-beanstalk/tests/utils/Season.ts | 2 +- .../subgraph-core/constants/BeanstalkEth.ts | 123 +++++++++++------- .../constants/RuntimeConstants.ts | 63 +++++++++ .../constants/raw/BeanstalkEthConstants.ts | 52 ++++++++ .../tests/event-mocking/Price.ts | 2 +- .../subgraph-core/tests/event-mocking/Util.ts | 2 +- 77 files changed, 328 insertions(+), 245 deletions(-) delete mode 100644 projects/subgraph-bean/src/utils/constants/Addresses.ts delete mode 100644 projects/subgraph-bean/src/utils/constants/Milestone.ts create mode 100644 projects/subgraph-core/constants/RuntimeConstants.ts create mode 100644 projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts diff --git a/projects/subgraph-basin/src/BeanstalkHandler.ts b/projects/subgraph-basin/src/BeanstalkHandler.ts index 60a767eb76..7a4bbee916 100644 --- a/projects/subgraph-basin/src/BeanstalkHandler.ts +++ b/projects/subgraph-basin/src/BeanstalkHandler.ts @@ -1,5 +1,5 @@ import { Address } from "@graphprotocol/graph-ts"; -import { AQUIFER } from "../../subgraph-core/constants/BeanstalkEth"; +import { AQUIFER } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { Sunrise } from "../generated/Basin-ABIs/Beanstalk"; import { loadOrCreateAquifer } from "./utils/Aquifer"; import { checkForSnapshot } from "./utils/Well"; diff --git a/projects/subgraph-basin/src/utils/BeanstalkPrice.ts b/projects/subgraph-basin/src/utils/BeanstalkPrice.ts index 17e46a7825..c27b9bcdf4 100644 --- a/projects/subgraph-basin/src/utils/BeanstalkPrice.ts +++ b/projects/subgraph-basin/src/utils/BeanstalkPrice.ts @@ -1,7 +1,7 @@ // Unfortunately this file must be copied across the various subgraph projects. This is due to the codegen import { Address, BigInt } from "@graphprotocol/graph-ts"; import { BeanstalkPrice } from "../../generated/Basin-ABIs/BeanstalkPrice"; -import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; // Gets the BeanstalkPrice contract, bound to the appropriate instance of the contract. // Note: Will bind to PRICE_1 even if that contract has not been deployed yet diff --git a/projects/subgraph-basin/src/utils/Init.ts b/projects/subgraph-basin/src/utils/Init.ts index d45b31878a..ff2bc21a39 100644 --- a/projects/subgraph-basin/src/utils/Init.ts +++ b/projects/subgraph-basin/src/utils/Init.ts @@ -1,6 +1,6 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../generated/schema"; -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); diff --git a/projects/subgraph-basin/src/utils/Token.ts b/projects/subgraph-basin/src/utils/Token.ts index c331d1e7a2..69ac8b4021 100644 --- a/projects/subgraph-basin/src/utils/Token.ts +++ b/projects/subgraph-basin/src/utils/Token.ts @@ -2,7 +2,7 @@ import { Address, BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; import { ERC20 } from "../../generated/Basin-ABIs/ERC20"; import { Token } from "../../generated/schema"; import { CurvePrice } from "../../generated/Basin-ABIs/CurvePrice"; -import { BEAN_ERC20, CURVE_PRICE } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20, CURVE_PRICE } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { getBeanstalkPrice } from "./BeanstalkPrice"; diff --git a/projects/subgraph-basin/src/utils/Well.ts b/projects/subgraph-basin/src/utils/Well.ts index 7e22b01ea3..1ee559b690 100644 --- a/projects/subgraph-basin/src/utils/Well.ts +++ b/projects/subgraph-basin/src/utils/Well.ts @@ -2,7 +2,7 @@ import { Address, BigDecimal, BigInt, Bytes, log } from "@graphprotocol/graph-ts import { BoreWellWellFunctionStruct } from "../../generated/Basin-ABIs/Aquifer"; import { Well, WellDailySnapshot, WellFunction, WellHourlySnapshot } from "../../generated/schema"; import { ERC20 } from "../../generated/Basin-ABIs/ERC20"; -import { BEAN_ERC20 } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20 } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { deltaBigDecimalArray, diff --git a/projects/subgraph-basin/tests/Aquifer.test.ts b/projects/subgraph-basin/tests/Aquifer.test.ts index 2c70c7f739..db7e0a8d3e 100644 --- a/projects/subgraph-basin/tests/Aquifer.test.ts +++ b/projects/subgraph-basin/tests/Aquifer.test.ts @@ -1,5 +1,5 @@ import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; -import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { boreDefaultWell } from "./helpers/Aquifer"; import { AQUIFER, PUMP, WELL } from "./helpers/Constants"; diff --git a/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts b/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts index 1e49b20f9d..967048b847 100644 --- a/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts +++ b/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts @@ -1,5 +1,5 @@ import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; -import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { loadWell } from "../src/utils/Well"; import { diff --git a/projects/subgraph-basin/tests/Exchange.test.ts b/projects/subgraph-basin/tests/Exchange.test.ts index c6f2d3005c..8a628b5cc7 100644 --- a/projects/subgraph-basin/tests/Exchange.test.ts +++ b/projects/subgraph-basin/tests/Exchange.test.ts @@ -17,7 +17,7 @@ import { mockShift, mockSwap } from "./helpers/Swap"; import { mockAddLiquidity } from "./helpers/Liquidity"; import { dayFromTimestamp, hourFromTimestamp } from "../../subgraph-core/utils/Dates"; import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20 } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20 } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; describe("Well Entity: Exchange Tests", () => { beforeEach(() => { diff --git a/projects/subgraph-basin/tests/Liquidity.test.ts b/projects/subgraph-basin/tests/Liquidity.test.ts index 9bec2ee798..9462bf7d7f 100644 --- a/projects/subgraph-basin/tests/Liquidity.test.ts +++ b/projects/subgraph-basin/tests/Liquidity.test.ts @@ -22,7 +22,7 @@ import { BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; import { BigDecimal_max, BigDecimal_min } from "../../subgraph-core/utils/ArrayMath"; import { calcLiquidityVolume } from "../src/utils/VolumeCP"; import { loadToken } from "../src/utils/Token"; -import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; const BI_2 = BigInt.fromU32(2); const BI_3 = BigInt.fromU32(3); diff --git a/projects/subgraph-basin/tests/SwapEntity.test.ts b/projects/subgraph-basin/tests/SwapEntity.test.ts index c0e143c49e..152f47f69e 100644 --- a/projects/subgraph-basin/tests/SwapEntity.test.ts +++ b/projects/subgraph-basin/tests/SwapEntity.test.ts @@ -1,5 +1,5 @@ import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; -import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ACCOUNT_ENTITY_TYPE, BEAN_SWAP_AMOUNT, SWAP_ACCOUNT, SWAP_ENTITY_TYPE, WELL, WETH_SWAP_AMOUNT } from "./helpers/Constants"; import { boreDefaultWell } from "./helpers/Aquifer"; import { mockShift, mockSwap } from "./helpers/Swap"; diff --git a/projects/subgraph-basin/tests/helpers/Aquifer.ts b/projects/subgraph-basin/tests/helpers/Aquifer.ts index 7fefba8a0b..874ba5cf66 100644 --- a/projects/subgraph-basin/tests/helpers/Aquifer.ts +++ b/projects/subgraph-basin/tests/helpers/Aquifer.ts @@ -2,7 +2,7 @@ import { Address, Bytes, ethereum } from "@graphprotocol/graph-ts"; import { newMockEvent } from "matchstick-as/assembly/index"; import { BoreWell } from "../../generated/Basin-ABIs/Aquifer"; import { handleBoreWell } from "../../src/templates/AquiferHandler"; -import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { AQUIFER, IMPLEMENTATION, PUMP, WELL, WELL_DATA, WELL_FUNCTION } from "./Constants"; import { createContractCallMocks } from "./Functions"; diff --git a/projects/subgraph-basin/tests/helpers/Functions.ts b/projects/subgraph-basin/tests/helpers/Functions.ts index 72b42a16eb..c7a2f0d311 100644 --- a/projects/subgraph-basin/tests/helpers/Functions.ts +++ b/projects/subgraph-basin/tests/helpers/Functions.ts @@ -7,7 +7,7 @@ import { BEANSTALK_PRICE_1, CRV3_TOKEN, WETH -} from "../../../subgraph-core/constants/BeanstalkEth"; +} from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BEAN_USD_PRICE, WELL } from "./Constants"; import { setMockBeanPrice } from "../../../subgraph-core/tests/event-mocking/Price"; import { ONE_BD, ZERO_BD } from "../../../subgraph-core/utils/Decimals"; diff --git a/projects/subgraph-basin/tests/helpers/Liquidity.ts b/projects/subgraph-basin/tests/helpers/Liquidity.ts index d3235dece9..6b2ad41c3f 100644 --- a/projects/subgraph-basin/tests/helpers/Liquidity.ts +++ b/projects/subgraph-basin/tests/helpers/Liquidity.ts @@ -1,6 +1,6 @@ import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { Deposit, Withdraw } from "../../generated/schema"; -import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { handleAddLiquidity, handleRemoveLiquidity, handleRemoveLiquidityOneToken, handleSync } from "../../src/WellHandler"; import { BEAN_SWAP_AMOUNT, SWAP_ACCOUNT, WELL, WELL_LP_AMOUNT, WETH_SWAP_AMOUNT } from "./Constants"; import { createContractCallMocks } from "./Functions"; diff --git a/projects/subgraph-basin/tests/helpers/Swap.ts b/projects/subgraph-basin/tests/helpers/Swap.ts index c31e226eda..401e8a983c 100644 --- a/projects/subgraph-basin/tests/helpers/Swap.ts +++ b/projects/subgraph-basin/tests/helpers/Swap.ts @@ -1,5 +1,5 @@ import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { handleShift, handleSwap } from "../../src/WellHandler"; import { BEAN_SWAP_AMOUNT, SWAP_ACCOUNT, WELL, WETH_SWAP_AMOUNT } from "./Constants"; import { createContractCallMocks } from "./Functions"; diff --git a/projects/subgraph-bean/src/entities/Bean.ts b/projects/subgraph-bean/src/entities/Bean.ts index 8f9dd74815..aaa1cde662 100644 --- a/projects/subgraph-bean/src/entities/Bean.ts +++ b/projects/subgraph-bean/src/entities/Bean.ts @@ -1,5 +1,5 @@ import { BigInt, BigDecimal, Address } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20 } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20 } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { dayFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { Bean, BeanDailySnapshot, BeanHourlySnapshot } from "../../generated/schema"; diff --git a/projects/subgraph-bean/src/entities/Pool.ts b/projects/subgraph-bean/src/entities/Pool.ts index cbc3b57bb2..541938dc57 100644 --- a/projects/subgraph-bean/src/entities/Pool.ts +++ b/projects/subgraph-bean/src/entities/Pool.ts @@ -5,13 +5,14 @@ import { Pool, PoolDailySnapshot, PoolHourlySnapshot } from "../../generated/sch import { loadOrCreateToken } from "./Token"; import { emptyBigIntArray, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; -import { getProtocolToken } from "../utils/constants/Addresses"; import { toAddress, toBytesArray } from "../../../subgraph-core/utils/Bytes"; +import { getProtocolToken } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../utils/constants/Version"; export function loadOrCreatePool(poolAddress: Address, blockNumber: BigInt): Pool { let pool = Pool.load(poolAddress); if (pool == null) { - let beanAddress = getProtocolToken(blockNumber); + let beanAddress = getProtocolToken(v(), blockNumber); let bean = loadBean(beanAddress); pool = new Pool(poolAddress); diff --git a/projects/subgraph-bean/src/handlers/BeanWellHandler.ts b/projects/subgraph-bean/src/handlers/BeanWellHandler.ts index e4c773e9bc..f71ee6b328 100644 --- a/projects/subgraph-bean/src/handlers/BeanWellHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanWellHandler.ts @@ -5,8 +5,9 @@ import { loadOrCreatePool } from "../entities/Pool"; import { BeanstalkPrice_try_price, getPoolPrice } from "../utils/price/BeanstalkPrice"; import { getPoolLiquidityUSD, setPoolReserves, updatePoolPrice, updatePoolValues } from "../utils/Pool"; import { updateBeanAfterPoolSwap } from "../utils/Bean"; -import { getProtocolToken } from "../utils/constants/Addresses"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; +import { v } from "../utils/constants/Version"; +import { getProtocolToken } from "../../../subgraph-core/constants/RuntimeConstants"; export function handleAddLiquidity(event: AddLiquidity): void { handleLiquidityChange(event.address, event.params.tokenAmountsIn[0], event.params.tokenAmountsIn[1], false, event.block); @@ -17,7 +18,7 @@ export function handleRemoveLiquidity(event: RemoveLiquidity): void { } export function handleRemoveLiquidityOneToken(event: RemoveLiquidityOneToken): void { - const beanAddr = getProtocolToken(event.block.number); + const beanAddr = getProtocolToken(v(), event.block.number); handleLiquidityChange( event.address, event.params.tokenOut == beanAddr ? event.params.tokenAmountOut : ZERO_BI, @@ -113,7 +114,7 @@ function handleSwapEvent(poolAddress: Address, toToken: Address, amountIn: BigIn return; } - const beanAddr = getProtocolToken(block.number); + const beanAddr = getProtocolToken(v(), block.number); let startingLiquidity = getPoolLiquidityUSD(poolAddress, block); diff --git a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts index 88c1e8b87c..db56181cc0 100644 --- a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts @@ -5,9 +5,10 @@ import { loadBean } from "../entities/Bean"; import { WellOracle } from "../../generated/Bean-ABIs/BasinBip"; import { setRawWellReserves, setTwaLast } from "../utils/price/TwaOracle"; import { decodeCumulativeWellReserves, setWellTwa } from "../utils/price/WellPrice"; -import { getProtocolToken, isUnripe } from "../utils/constants/Addresses"; import { updateSeason } from "../utils/legacy/Beanstalk"; import { updatePoolPricesOnCross } from "../utils/Cross"; +import { getProtocolToken, isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../utils/constants/Version"; // Beanstalk 3 handler here, might not put this in the manifest yet - do not delete. export function handleSunrise(event: Sunrise): void { @@ -20,7 +21,7 @@ export function handleSunrise(event: Sunrise): void { // Assumption is that the whitelisted token corresponds to a pool lp. If not, this method will simply do nothing. export function handleDewhitelistToken(event: DewhitelistToken): void { - let beanToken = getProtocolToken(event.block.number); + let beanToken = getProtocolToken(v(), event.block.number); let bean = loadBean(beanToken); let index = bean.pools.indexOf(event.params.token); if (index >= 0) { @@ -49,18 +50,18 @@ export function handleWellOracle(event: WellOracle): void { // The result of fertilizer purchases will be included by the AddLiquidity event export function handleChop(event: Chop): void { - let beanToken = getProtocolToken(event.block.number); + let beanToken = getProtocolToken(v(), event.block.number); updateBeanSupplyPegPercent(beanToken, event.block.number); } export function handleConvert(event: Convert): void { - if (isUnripe(event.params.fromToken) && !isUnripe(event.params.toToken)) { - let beanToken = getProtocolToken(event.block.number); + if (isUnripe(v(), event.params.fromToken) && !isUnripe(v(), event.params.toToken)) { + let beanToken = getProtocolToken(v(), event.block.number); updateBeanSupplyPegPercent(beanToken, event.block.number); } } export function handleRewardMint(event: Reward): void { - let beanToken = getProtocolToken(event.block.number); + let beanToken = getProtocolToken(v(), event.block.number); updateBeanSupplyPegPercent(beanToken, event.block.number); } diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts index 72b16bc4a1..a71265c5f4 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts @@ -1,5 +1,5 @@ import { toAddress } from "../../../../subgraph-core/utils/Bytes"; -import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { CurvePrice } from "../../../generated/Bean-ABIs/CurvePrice"; import { Sunrise } from "../../../generated/Bean-ABIs/PreReplant"; @@ -7,7 +7,6 @@ import { MetapoolOracle } from "../../../generated/Bean-ABIs/Replanted"; import { loadBean } from "../../entities/Bean"; import { loadOrCreatePool } from "../../entities/Pool"; import { updateBeanTwa, updateBeanValues } from "../../utils/Bean"; -import { getProtocolToken } from "../../utils/constants/Addresses"; import { checkBeanCross, updatePoolPricesOnCross } from "../../utils/Cross"; import { updateSeason } from "../../utils/legacy/Beanstalk"; import { updatePoolPrice, updatePoolValues } from "../../utils/Pool"; @@ -15,12 +14,14 @@ import { calcCurveInst, setCurveTwa } from "../../utils/price/CurvePrice"; import { setTwaLast } from "../../utils/price/TwaOracle"; import { DeltaBPriceLiquidity } from "../../utils/price/Types"; import { calcUniswapV2Inst, setUniswapV2Twa } from "../../utils/price/UniswapPrice"; +import { getProtocolToken } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../../utils/constants/Version"; export function handleSunrise_v1(event: Sunrise): void { updateSeason(event.params.season.toI32(), event.block); // V1 logic below - let beanToken = getProtocolToken(event.block.number); + let beanToken = getProtocolToken(v(), event.block.number); let bean = loadBean(beanToken); let weightedPrice = ZERO_BD; @@ -55,7 +56,7 @@ export function handleSunrise_v2(event: Sunrise): void { updateSeason(event.params.season.toI32(), event.block); // V2 logic below - let beanToken = getProtocolToken(event.block.number); + let beanToken = getProtocolToken(v(), event.block.number); let bean = loadBean(beanToken); let oldBeanPrice = bean.price; diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts index b2c01bc520..1803aa7e7f 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyUniswapV2Handler.ts @@ -2,7 +2,7 @@ import { BigInt, ethereum, Address, log } from "@graphprotocol/graph-ts"; import { getLastBeanPrice, calcLiquidityWeightedBeanPrice, updateBeanSupplyPegPercent, updateBeanValues } from "../../utils/Bean"; import { Swap, Sync } from "../../../generated/Bean-ABIs/UniswapV2Pair"; import { loadOrCreateToken } from "../../entities/Token"; -import { BEAN_ERC20_V1, BEAN_WETH_V1, WETH } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20_V1, BEAN_WETH_V1, WETH } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadOrCreatePool } from "../../entities/Pool"; import { setPoolReserves, updatePoolPrice, updatePoolValues } from "../../utils/Pool"; diff --git a/projects/subgraph-bean/src/utils/Bean.ts b/projects/subgraph-bean/src/utils/Bean.ts index 2867fc7a6b..f4c9ddce6a 100644 --- a/projects/subgraph-bean/src/utils/Bean.ts +++ b/projects/subgraph-bean/src/utils/Bean.ts @@ -1,6 +1,6 @@ import { BigDecimal, BigInt, ethereum, Address } from "@graphprotocol/graph-ts"; import { Pool } from "../../generated/schema"; -import { BEAN_ERC20_V1, BEAN_WETH_V1 } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20_V1, BEAN_WETH_V1 } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { checkBeanCross } from "./Cross"; import { BeanstalkPrice_try_price, BeanstalkPriceResult } from "./price/BeanstalkPrice"; @@ -9,8 +9,9 @@ import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot import { loadOrCreatePool, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; import { externalUpdatePoolPrice as univ2_externalUpdatePoolPrice } from "../handlers/legacy/LegacyUniswapV2Handler"; import { updateBeanSupplyPegPercent_v1 } from "./legacy/Bean"; -import { getProtocolToken } from "./constants/Addresses"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; +import { getProtocolToken } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./constants/Version"; export function adjustSupply(beanToken: Address, amount: BigInt): void { let bean = loadBean(beanToken); @@ -174,7 +175,7 @@ export function updateInstDeltaB(token: Address, block: ethereum.Block): void { // Update Bean's TWA deltaB and price. Individual pools' values must be computed prior to calling this method. export function updateBeanTwa(block: ethereum.Block): void { - let beanAddress = getProtocolToken(block.number); + let beanAddress = getProtocolToken(v(), block.number); let bean = loadBean(beanAddress); let beanHourly = loadOrCreateBeanHourlySnapshot(beanAddress, block.timestamp, bean.lastSeason); let beanDaily = loadOrCreateBeanDailySnapshot(beanAddress, block.timestamp); diff --git a/projects/subgraph-bean/src/utils/Cross.ts b/projects/subgraph-bean/src/utils/Cross.ts index a1f6877831..afc9409cd4 100644 --- a/projects/subgraph-bean/src/utils/Cross.ts +++ b/projects/subgraph-bean/src/utils/Cross.ts @@ -1,13 +1,14 @@ import { BigDecimal, Address, ethereum, log } from "@graphprotocol/graph-ts"; import { ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEAN_ERC20_V1 } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20_V1 } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { loadOrCreatePool, loadOrCreatePoolDailySnapshot, loadOrCreatePoolHourlySnapshot } from "../entities/Pool"; import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../entities/Bean"; import { loadOrCreateBeanCross, loadOrCreatePoolCross } from "../entities/Cross"; import { BeanstalkPrice_try_price } from "./price/BeanstalkPrice"; import { updatePoolPrice, updatePoolValues } from "./Pool"; import { updateBeanValues } from "./Bean"; -import { getProtocolToken } from "./constants/Addresses"; +import { getProtocolToken } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./constants/Version"; export function checkPoolCross(pool: Address, oldPrice: BigDecimal, newPrice: BigDecimal, block: ethereum.Block): boolean { let poolInfo = loadOrCreatePool(pool, block.number); @@ -132,7 +133,7 @@ export function updatePoolPricesOnCross(priceOnlyOnCross: boolean, block: ethere // Price contract was unavailable briefly after well deployment return false; } - const beanToken = getProtocolToken(block.number); + const beanToken = getProtocolToken(v(), block.number); const bean = loadBean(beanToken); const prevPrice = bean.price; const newPrice = toDecimal(priceResult.value.price); diff --git a/projects/subgraph-bean/src/utils/LockedBeans.ts b/projects/subgraph-bean/src/utils/LockedBeans.ts index ecd06027b7..694ab419d0 100644 --- a/projects/subgraph-bean/src/utils/LockedBeans.ts +++ b/projects/subgraph-bean/src/utils/LockedBeans.ts @@ -4,17 +4,21 @@ import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { ERC20 } from "../../generated/Bean-ABIs/ERC20"; import { loadOrCreateTwaOracle } from "../entities/TwaOracle"; import { loadOrCreatePool } from "../entities/Pool"; -import { getVersionEntity } from "./constants/Version"; +import { getVersionEntity, v } from "./constants/Version"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; -import { getUnripeBeanAddr, getUnripeLpAddr } from "./constants/Addresses"; -import { getUnripeUnderlying, isGaugeDeployed } from "./constants/Milestone"; +import { + getUnripeBeanAddr, + getUnripeLpAddr, + getUnripeUnderlying, + isGaugeDeployed +} from "../../../subgraph-core/constants/RuntimeConstants"; export function calcLockedBeans(blockNumber: BigInt): BigInt { const protocol = toAddress(getVersionEntity().protocolAddress); - const underlyingLpPool = getUnripeUnderlying(getUnripeLpAddr(), blockNumber); + const underlyingLpPool = getUnripeUnderlying(v(), getUnripeLpAddr(v()), blockNumber); // If BIP45 is deployed - return the result from the contract - if (isGaugeDeployed(blockNumber)) { + if (isGaugeDeployed(v(), blockNumber)) { // If we are trying to calculate locked beans on the same block as the sunrise, use the values from the previous hour const twaOracle = loadOrCreateTwaOracle(underlyingLpPool); const twaReserves = @@ -40,8 +44,8 @@ export function calcLockedBeans(blockNumber: BigInt): BigInt { } const recapPaidPercent = new BigDecimal(recapPercentResult.value).div(BigDecimal.fromString("1000000")); - const lockedBeansUrBean = LibLockedUnderlying_getLockedUnderlying(protocol, getUnripeBeanAddr(), recapPaidPercent); - const lockedUnripeLp = LibLockedUnderlying_getLockedUnderlying(protocol, getUnripeLpAddr(), recapPaidPercent); + const lockedBeansUrBean = LibLockedUnderlying_getLockedUnderlying(protocol, getUnripeBeanAddr(v()), recapPaidPercent); + const lockedUnripeLp = LibLockedUnderlying_getLockedUnderlying(protocol, getUnripeLpAddr(v()), recapPaidPercent); const poolBeanReserves = loadOrCreatePool(underlyingLpPool, blockNumber).reserves[0]; const totalLpTokens = ERC20.bind(underlyingLpPool).totalSupply(); diff --git a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts index 453c23194e..7fd05e807a 100644 --- a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts +++ b/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts @@ -1,10 +1,11 @@ import { ethereum } from "@graphprotocol/graph-ts"; import { BEAN_INITIAL_VALUES } from "../../../cache-builder/results/BeanInit_arb"; import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../../entities/Bean"; -import { getProtocolToken } from "../constants/Addresses"; +import { getProtocolToken } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../constants/Version"; export function handleInitBeanEntity(block: ethereum.Block): void { - const token = getProtocolToken(block.number); + const token = getProtocolToken(v(), block.number); const bean = loadBean(token); bean.volume = BEAN_INITIAL_VALUES.volume; diff --git a/projects/subgraph-bean/src/utils/constants/Addresses.ts b/projects/subgraph-bean/src/utils/constants/Addresses.ts deleted file mode 100644 index defccd03cc..0000000000 --- a/projects/subgraph-bean/src/utils/constants/Addresses.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { BigInt, Address } from "@graphprotocol/graph-ts"; -import * as BeanstalkEth from "../../../../subgraph-core/constants/BeanstalkEth"; -import { getVersionEntity } from "./Version"; - -export function getProtocolToken(blockNumber: BigInt): Address { - const protocol = getVersionEntity().protocolAddress; - if (protocol == BeanstalkEth.BEANSTALK) { - if (blockNumber < BeanstalkEth.NEW_BEAN_TOKEN_BLOCK) { - return BeanstalkEth.BEAN_ERC20_V1; - } else { - return BeanstalkEth.BEAN_ERC20; - } - } - throw new Error("Unsupported protocol"); -} - -export function getUnripeBeanAddr(): Address { - const protocol = getVersionEntity().protocolAddress; - if (protocol == BeanstalkEth.BEANSTALK) { - return BeanstalkEth.UNRIPE_BEAN; - } - throw new Error("Unsupported protocol"); -} - -export function getUnripeLpAddr(): Address { - const protocol = getVersionEntity().protocolAddress; - if (protocol == BeanstalkEth.BEANSTALK) { - return BeanstalkEth.UNRIPE_LP; - } - throw new Error("Unsupported protocol"); -} - -export function isUnripe(token: Address): boolean { - const unripeTokens = [getUnripeBeanAddr(), getUnripeLpAddr()]; - for (let i = 0; i < unripeTokens.length; ++i) { - if (unripeTokens[i] == token) { - return true; - } - } - return false; -} diff --git a/projects/subgraph-bean/src/utils/constants/Milestone.ts b/projects/subgraph-bean/src/utils/constants/Milestone.ts deleted file mode 100644 index 21d5850f74..0000000000 --- a/projects/subgraph-bean/src/utils/constants/Milestone.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { BigInt, Address } from "@graphprotocol/graph-ts"; -import { - BEAN_3CRV, - BEAN_ERC20, - BEAN_WETH_CP2_WELL, - BEAN_WETH_UNRIPE_MIGRATION_BLOCK, - BEAN_WSTETH_CP2_WELL, - BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK, - BEANSTALK, - BEANSTALK_PRICE_1, - BEANSTALK_PRICE_2, - GAUGE_BIP45_BLOCK, - PRICE_2_BLOCK, - UNRIPE_BEAN, - UNRIPE_LP -} from "../../../../subgraph-core/constants/BeanstalkEth"; -import { getVersionEntity } from "./Version"; - -export function isGaugeDeployed(blockNumber: BigInt): boolean { - const protocol = getVersionEntity().protocolAddress; - if (protocol == BEANSTALK) { - return blockNumber >= GAUGE_BIP45_BLOCK; - } - throw new Error("Unsupported protocol"); -} - -export function getUnripeUnderlying(unripeToken: Address, blockNumber: BigInt): Address { - const protocol = getVersionEntity().protocolAddress; - if (protocol == BEANSTALK) { - if (unripeToken == UNRIPE_BEAN) { - return BEAN_ERC20; - } else if (unripeToken == UNRIPE_LP) { - if (blockNumber < BEAN_WETH_UNRIPE_MIGRATION_BLOCK) { - return BEAN_3CRV; - } else if (blockNumber < BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK) { - return BEAN_WETH_CP2_WELL; - } else { - return BEAN_WSTETH_CP2_WELL; - } - } - throw new Error("Unsupported unripe token"); - } - throw new Error("Unsupported protocol"); -} - -export function getBeanstalkPriceAddress(blockNumber: BigInt): Address { - const protocol = getVersionEntity().protocolAddress; - if (protocol == BEANSTALK) { - if (blockNumber < PRICE_2_BLOCK) { - return BEANSTALK_PRICE_1; - } else { - return BEANSTALK_PRICE_2; - } - } - throw new Error("Unsupported protocol"); -} diff --git a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts index a551dd528c..24aad21212 100644 --- a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts +++ b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts @@ -12,7 +12,7 @@ import { BEAN_WETH_CP2_WELL, BEAN_WSTETH_CP2_WELL, WSTETH -} from "../../../../subgraph-core/constants/BeanstalkEth"; +} from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; // Use this mapping to determine which tokens are in each pool. Pools may each follow a distinct interface, // so a view function shouldn't be used, and a new subgraph build is already required to track a newly whitelisted asset. diff --git a/projects/subgraph-bean/src/utils/constants/Version.ts b/projects/subgraph-bean/src/utils/constants/Version.ts index 3803d9655d..7fb2d922cf 100644 --- a/projects/subgraph-bean/src/utils/constants/Version.ts +++ b/projects/subgraph-bean/src/utils/constants/Version.ts @@ -1,6 +1,8 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../../generated/schema"; -import { BEANSTALK } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { VersionDto } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); @@ -35,3 +37,13 @@ function chainForBlockNumber(blockNumber: BigInt): string { } throw new Error("Unable to initialize chain for this block number"); } + +export function v(): VersionDto { + const versionEntity = Version.load("subgraph")!; + return { + subgraphName: versionEntity.subgraphName, + versionNumber: versionEntity.versionNumber, + protocolAddress: toAddress(versionEntity.protocolAddress), + chain: versionEntity.chain + }; +} diff --git a/projects/subgraph-bean/src/utils/legacy/Bean.ts b/projects/subgraph-bean/src/utils/legacy/Bean.ts index 152519a66b..291c1b7aad 100644 --- a/projects/subgraph-bean/src/utils/legacy/Bean.ts +++ b/projects/subgraph-bean/src/utils/legacy/Bean.ts @@ -1,5 +1,5 @@ import { BigInt, Address } from "@graphprotocol/graph-ts"; -import { BEAN_3CRV_V1, BEAN_LUSD_V1, BEAN_WETH_V1 } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_3CRV_V1, BEAN_LUSD_V1, BEAN_WETH_V1 } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal, ZERO_BD } from "../../../../subgraph-core/utils/Decimals"; import { Pool } from "../../../generated/schema"; import { loadBean } from "../../entities/Bean"; diff --git a/projects/subgraph-bean/src/utils/legacy/Beanstalk.ts b/projects/subgraph-bean/src/utils/legacy/Beanstalk.ts index a43129c7bc..c46f52d731 100644 --- a/projects/subgraph-bean/src/utils/legacy/Beanstalk.ts +++ b/projects/subgraph-bean/src/utils/legacy/Beanstalk.ts @@ -1,12 +1,13 @@ import { ethereum } from "@graphprotocol/graph-ts"; import { loadBean } from "../../entities/Bean"; import { updateBeanSeason } from "../Bean"; -import { getProtocolToken } from "../constants/Addresses"; import { updatePoolSeason } from "../Pool"; import { toAddress } from "../../../../subgraph-core/utils/Bytes"; +import { getProtocolToken } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../constants/Version"; export function updateSeason(season: i32, block: ethereum.Block): void { - let beanToken = getProtocolToken(block.number); + let beanToken = getProtocolToken(v(), block.number); updateBeanSeason(beanToken, block.timestamp, season); let bean = loadBean(beanToken); diff --git a/projects/subgraph-bean/src/utils/legacy/Curve.ts b/projects/subgraph-bean/src/utils/legacy/Curve.ts index 2a9a42261d..405e0ffdde 100644 --- a/projects/subgraph-bean/src/utils/legacy/Curve.ts +++ b/projects/subgraph-bean/src/utils/legacy/Curve.ts @@ -1,5 +1,5 @@ import { Address, BigInt, BigDecimal, ethereum } from "@graphprotocol/graph-ts"; -import { BEAN_3CRV_V1, BEAN_ERC20_V1, BEAN_LUSD_V1, CURVE_PRICE } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_3CRV_V1, BEAN_ERC20_V1, BEAN_LUSD_V1, CURVE_PRICE } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadOrCreatePool } from "../../entities/Pool"; import { manualTwa } from "../price/TwaOracle"; diff --git a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts index 2a24feb141..1052bb6fa2 100644 --- a/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts +++ b/projects/subgraph-bean/src/utils/price/BeanstalkPrice.ts @@ -8,8 +8,8 @@ import { import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadBean } from "../../entities/Bean"; import { toAddressArray } from "../../../../subgraph-core/utils/Bytes"; -import { getProtocolToken } from "../constants/Addresses"; -import { getBeanstalkPriceAddress } from "../constants/Milestone"; +import { getBeanstalkPriceAddress, getProtocolToken } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../constants/Version"; // Can't use the autogenerated one because the fields need to be updateable class PriceOverallStruct { @@ -106,7 +106,7 @@ export class BeanstalkPriceResult { // (1) Only including whitelisted tokens in the final price calculation and the prices list // (2) Which contract to call (in anticipation of new BeanstalkPrice contract deployments) export function BeanstalkPrice_try_price(blockNumber: BigInt): BeanstalkPriceResult { - const beanAddr = getProtocolToken(blockNumber); + const beanAddr = getProtocolToken(v(), blockNumber); let beanstalkPrice = getBeanstalkPrice(blockNumber); let beanPrice = beanstalkPrice.try_price(); @@ -143,5 +143,5 @@ export function getPoolPrice(priceResult: BeanstalkPriceResult, pool: Address): // Gets the BeanstalkPrice contract, bound to the appropriate instance of the contract. // Note: The caller still needs to check for reverts. export function getBeanstalkPrice(blockNumber: BigInt): BeanstalkPrice { - return BeanstalkPrice.bind(getBeanstalkPriceAddress(blockNumber)); + return BeanstalkPrice.bind(getBeanstalkPriceAddress(v(), blockNumber)); } diff --git a/projects/subgraph-bean/src/utils/price/CurvePrice.ts b/projects/subgraph-bean/src/utils/price/CurvePrice.ts index 5ac60e6e16..cbda13655e 100644 --- a/projects/subgraph-bean/src/utils/price/CurvePrice.ts +++ b/projects/subgraph-bean/src/utils/price/CurvePrice.ts @@ -9,7 +9,7 @@ import { CRV3_TOKEN, LUSD, LUSD_3POOL -} from "../../../../subgraph-core/constants/BeanstalkEth"; +} from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ERC20 } from "../../../generated/Bean-ABIs/ERC20"; import { DeltaBAndPrice, DeltaBPriceLiquidity, TWAType } from "./Types"; import { Pool } from "../../../generated/schema"; diff --git a/projects/subgraph-bean/src/utils/price/TwaOracle.ts b/projects/subgraph-bean/src/utils/price/TwaOracle.ts index 43fec10003..66c2cd2711 100644 --- a/projects/subgraph-bean/src/utils/price/TwaOracle.ts +++ b/projects/subgraph-bean/src/utils/price/TwaOracle.ts @@ -1,7 +1,7 @@ import { BigInt, Address, BigDecimal } from "@graphprotocol/graph-ts"; import { BI_10, ONE_BI, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { uniswapCumulativePrice } from "./UniswapPrice"; -import { WETH_USDC_PAIR } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { WETH_USDC_PAIR } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { curveCumulativePrices } from "./CurvePrice"; import { TWAType } from "./Types"; import { wellCumulativePrices, wellTwaReserves } from "./WellPrice"; diff --git a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts index 862c765f62..aa431685b2 100644 --- a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts +++ b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts @@ -1,6 +1,6 @@ import { Address, BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { BD_10, BI_10, ONE_BI, pow, sqrt, toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; -import { WETH, WETH_USDC_PAIR } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { WETH, WETH_USDC_PAIR } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { DeltaBAndPrice, DeltaBPriceLiquidity, TWAType } from "./Types"; import { setPoolTwa } from "../Pool"; import { getTWAPrices } from "./TwaOracle"; diff --git a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts index 6107c4ffcd..18ebc8910d 100644 --- a/projects/subgraph-bean/tests/BeanstalkPrice.test.ts +++ b/projects/subgraph-bean/tests/BeanstalkPrice.test.ts @@ -8,7 +8,7 @@ import { PRICE_1_BLOCK, PRICE_2_BLOCK, WETH -} from "../../subgraph-core/constants/BeanstalkEth"; +} from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { createDewhitelistTokenEvent } from "./event-mocking/Beanstalk"; import { setMockBeanPrice } from "../../subgraph-core/tests/event-mocking/Price"; import { BigInt } from "@graphprotocol/graph-ts"; diff --git a/projects/subgraph-bean/tests/Cross.test.ts b/projects/subgraph-bean/tests/Cross.test.ts index dc6e5e2ac6..6747c1f916 100644 --- a/projects/subgraph-bean/tests/Cross.test.ts +++ b/projects/subgraph-bean/tests/Cross.test.ts @@ -6,7 +6,13 @@ import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { mockPreReplantETHPrice, simpleMockPrice } from "../../subgraph-core/tests/event-mocking/Price"; -import { BEAN_3CRV_V1, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_CP2_WELL, BEAN_WETH_V1 } from "../../subgraph-core/constants/BeanstalkEth"; +import { + BEAN_3CRV_V1, + BEAN_ERC20, + BEAN_ERC20_V1, + BEAN_WETH_CP2_WELL, + BEAN_WETH_V1 +} from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BigDecimal_round, toDecimal, ZERO_BD } from "../../subgraph-core/utils/Decimals"; import { getPreReplantPriceETH, constantProductPrice, uniswapV2Reserves } from "../src/utils/price/UniswapPrice"; diff --git a/projects/subgraph-bean/tests/DeltaB.test.ts b/projects/subgraph-bean/tests/DeltaB.test.ts index 41b37186c6..fa3bd4da89 100644 --- a/projects/subgraph-bean/tests/DeltaB.test.ts +++ b/projects/subgraph-bean/tests/DeltaB.test.ts @@ -3,7 +3,7 @@ import { BigInt, Bytes, BigDecimal, log } from "@graphprotocol/graph-ts"; // import { log } from "matchstick-as/assembly/log"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { createMetapoolOracleEvent, createWellOracleEvent } from "./event-mocking/Beanstalk"; -import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, CRV3_POOL } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, CRV3_POOL } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { hourFromTimestamp } from "../../subgraph-core/utils/Dates"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { uniswapV2DeltaB } from "../src/utils/price/UniswapPrice"; diff --git a/projects/subgraph-bean/tests/Migration.test.ts b/projects/subgraph-bean/tests/Migration.test.ts index de8189e739..71a2393f7d 100644 --- a/projects/subgraph-bean/tests/Migration.test.ts +++ b/projects/subgraph-bean/tests/Migration.test.ts @@ -1,7 +1,7 @@ import { clearStore, beforeEach, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; import { handleInitBeanEntity } from "../src/utils/b3-migration/BeanInit"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; -import { BEAN_ERC20 } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20 } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BEAN_INITIAL_VALUES } from "../cache-builder/results/BeanInit_arb"; import { initL1Version } from "./entity-mocking/MockVersion"; diff --git a/projects/subgraph-bean/tests/Pool.test.ts b/projects/subgraph-bean/tests/Pool.test.ts index 6de53dd993..71839f9551 100644 --- a/projects/subgraph-bean/tests/Pool.test.ts +++ b/projects/subgraph-bean/tests/Pool.test.ts @@ -1,5 +1,12 @@ import { beforeEach, afterEach, clearStore, describe, assert, test } from "matchstick-as/assembly/index"; -import { BEAN_3CRV, BEAN_ERC20, BEAN_ERC20_V1, BEAN_WETH_V1, CRV3_TOKEN, WETH } from "../../subgraph-core/constants/BeanstalkEth"; +import { + BEAN_3CRV, + BEAN_ERC20, + BEAN_ERC20_V1, + BEAN_WETH_V1, + CRV3_TOKEN, + WETH +} from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BigInt, Address } from "@graphprotocol/graph-ts"; import { loadOrCreatePool } from "../src/entities/Pool"; import { toAddress } from "../../subgraph-core/utils/Bytes"; diff --git a/projects/subgraph-bean/tests/Whitelist.test.ts b/projects/subgraph-bean/tests/Whitelist.test.ts index 652ce70165..9ddc0e2f69 100644 --- a/projects/subgraph-bean/tests/Whitelist.test.ts +++ b/projects/subgraph-bean/tests/Whitelist.test.ts @@ -1,5 +1,10 @@ import { beforeEach, beforeAll, afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; -import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, BEAN_WETH_CP2_WELL_BLOCK } from "../../subgraph-core/constants/BeanstalkEth"; +import { + BEAN_3CRV, + BEAN_ERC20, + BEAN_WETH_CP2_WELL, + BEAN_WETH_CP2_WELL_BLOCK +} from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { createDewhitelistTokenEvent } from "./event-mocking/Beanstalk"; import { setWhitelistedPools } from "./entity-mocking/MockBean"; import { handleDewhitelistToken } from "../src/handlers/BeanstalkHandler"; diff --git a/projects/subgraph-bean/tests/call-mocking/Beanstalk.ts b/projects/subgraph-bean/tests/call-mocking/Beanstalk.ts index 0d6fb7794f..a3e477a330 100644 --- a/projects/subgraph-bean/tests/call-mocking/Beanstalk.ts +++ b/projects/subgraph-bean/tests/call-mocking/Beanstalk.ts @@ -1,6 +1,6 @@ import { BigDecimal, BigInt, ethereum, Address, Bytes } from "@graphprotocol/graph-ts"; import { createMockedFunction } from "matchstick-as/assembly/index"; -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; export function mockSeedGaugeLockedBeans(reserveBytes: Bytes, twaTimestamp: BigInt, lockedBeans: BigInt): void { createMockedFunction(BEANSTALK, "getLockedBeansFromTwaReserves", "getLockedBeansFromTwaReserves(bytes,uint40):(uint256)") diff --git a/projects/subgraph-bean/tests/entity-mocking/MockBean.ts b/projects/subgraph-bean/tests/entity-mocking/MockBean.ts index 97a79365e7..f3bc14b1e6 100644 --- a/projects/subgraph-bean/tests/entity-mocking/MockBean.ts +++ b/projects/subgraph-bean/tests/entity-mocking/MockBean.ts @@ -1,5 +1,5 @@ import { Address } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20 } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20 } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { loadBean } from "../../src/entities/Bean"; import { toBytesArray } from "../../../subgraph-core/utils/Bytes"; diff --git a/projects/subgraph-bean/tests/entity-mocking/MockPool.ts b/projects/subgraph-bean/tests/entity-mocking/MockPool.ts index cb6879cfab..ca47a481c4 100644 --- a/projects/subgraph-bean/tests/entity-mocking/MockPool.ts +++ b/projects/subgraph-bean/tests/entity-mocking/MockPool.ts @@ -1,6 +1,6 @@ import { BigInt, Address, BigDecimal } from "@graphprotocol/graph-ts"; import { mockPreReplantBeanEthPriceAndLiquidity } from "../../../subgraph-core/tests/event-mocking/Price"; -import { BEAN_WETH_V1, BEANSTALK_BLOCK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_WETH_V1, BEANSTALK_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { loadOrCreatePool } from "../../src/entities/Pool"; export function mockPoolPriceAndLiquidity(poolAddr: Address, price: BigDecimal, liquidityUSD: BigDecimal, blockNumber: BigInt): void { diff --git a/projects/subgraph-bean/tests/event-mocking/Curve.ts b/projects/subgraph-bean/tests/event-mocking/Curve.ts index 1ab27bb4ed..13a44d7e14 100644 --- a/projects/subgraph-bean/tests/event-mocking/Curve.ts +++ b/projects/subgraph-bean/tests/event-mocking/Curve.ts @@ -3,7 +3,7 @@ import { createMockedFunction } from "matchstick-as"; import { TokenExchangeUnderlying } from "../../generated/Bean-ABIs/Bean3CRV"; import { mockContractEvent } from "../../../subgraph-core/tests/event-mocking/Util"; -import { BEAN_3CRV_V1 } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_3CRV_V1 } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; export function mock_virtual_price(contract: Address, retval: BigInt): void { createMockedFunction(contract, "get_virtual_price", "get_virtual_price():(uint256)") diff --git a/projects/subgraph-bean/tests/l2sr.test.ts b/projects/subgraph-bean/tests/l2sr.test.ts index f195e8e9e3..ef678f29c0 100644 --- a/projects/subgraph-bean/tests/l2sr.test.ts +++ b/projects/subgraph-bean/tests/l2sr.test.ts @@ -9,7 +9,7 @@ import { GAUGE_BIP45_BLOCK, UNRIPE_BEAN, UNRIPE_LP -} from "../../subgraph-core/constants/BeanstalkEth"; +} from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { mockGetRecapPaidPercent, diff --git a/projects/subgraph-beanft/src/utils/Init.ts b/projects/subgraph-beanft/src/utils/Init.ts index 9557c066ec..888e6d7d69 100644 --- a/projects/subgraph-beanft/src/utils/Init.ts +++ b/projects/subgraph-beanft/src/utils/Init.ts @@ -1,6 +1,6 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../generated/schema"; -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); diff --git a/projects/subgraph-beanstalk/src/entities/Field.ts b/projects/subgraph-beanstalk/src/entities/Field.ts index 38feba1b4b..d239001211 100644 --- a/projects/subgraph-beanstalk/src/entities/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/Field.ts @@ -1,7 +1,7 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { Field, Plot } from "../../generated/schema"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; export function loadField(account: Address): Field { diff --git a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts index 68b4f1ad53..2dc5327713 100644 --- a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts +++ b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts @@ -2,7 +2,7 @@ import { Address, BigInt, Bytes, log } from "@graphprotocol/graph-ts"; import { loadField } from "./Field"; import { PodFill, PodListing, PodMarketplace, PodOrder } from "../../generated/schema"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; export function loadPodMarketplace(protocol: Address): PodMarketplace { let marketplace = PodMarketplace.load(protocol.toHexString()); diff --git a/projects/subgraph-beanstalk/src/entities/Silo.ts b/projects/subgraph-beanstalk/src/entities/Silo.ts index 4580d754d4..5addc97c52 100644 --- a/projects/subgraph-beanstalk/src/entities/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/Silo.ts @@ -9,7 +9,7 @@ import { TokenYield, UnripeToken } from "../../generated/schema"; -import { BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { getTokenDecimals, getUnripeUnderlying } from "../utils/Constants"; diff --git a/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts b/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts index 78a8097ab8..62c32bee7c 100644 --- a/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts @@ -1,6 +1,6 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Transfer } from "../../generated/Beanstalk-ABIs/ERC20"; -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; import { getTokenProtocol } from "../utils/Constants"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; diff --git a/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts b/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts index ecb9ee5b05..9ef189faa0 100644 --- a/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts @@ -1,5 +1,5 @@ import { BigInt, log } from "@graphprotocol/graph-ts"; -import { BEANSTALK_FARMS } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK_FARMS } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { loadField } from "../entities/Field"; import { harvest, plotTransfer, sow, temperatureChanged } from "../utils/Field"; import { Sow, Harvest, PlotTransfer, TemperatureChange } from "../../generated/Beanstalk-ABIs/SeedGauge"; diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index 1f5a96a141..87f79a6093 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -19,7 +19,7 @@ import { savePrevFarmerGerminatingEvent } from "../entities/Germinating"; import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEAN_WETH_CP2_WELL } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_WETH_CP2_WELL } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { Bytes4_emptyToNull } from "../../../subgraph-core/utils/Bytes"; import { setSiloHourlyCaseId, takeSiloSnapshots } from "../entities/snapshots/Silo"; import { loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index 8c24979637..4523480a92 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -1,6 +1,6 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { Reward, Soil, WellOracle, Sunrise, Incentivization, SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { BEANSTALK, GAUGE_BIP45_BLOCK, REPLANT_SEASON } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK, GAUGE_BIP45_BLOCK, REPLANT_SEASON } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal, ZERO_BD } from "../../../subgraph-core/utils/Decimals"; import { updateStalkWithCalls } from "../utils/legacy/LegacySilo"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts index ccfd7553d2..522c825149 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts @@ -1,5 +1,5 @@ import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; -import { CURVE_PRICE, REPLANT_SEASON } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { CURVE_PRICE, REPLANT_SEASON } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal } from "../../../../subgraph-core/utils/Decimals"; import { CurvePrice } from "../../../generated/Beanstalk-ABIs/CurvePrice"; import { SeasonSnapshot, Sunrise } from "../../../generated/Beanstalk-ABIs/PreReplant"; diff --git a/projects/subgraph-beanstalk/src/utils/Constants.ts b/projects/subgraph-beanstalk/src/utils/Constants.ts index ff62234732..28cc45579d 100644 --- a/projects/subgraph-beanstalk/src/utils/Constants.ts +++ b/projects/subgraph-beanstalk/src/utils/Constants.ts @@ -14,7 +14,7 @@ import { FERTILIZER, UNRIPE_BEAN, UNRIPE_LP -} from "../../../subgraph-core/constants/BeanstalkEth"; +} from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; export function getProtocolToken(protocol: Address): Address { if (protocol == BEANSTALK) { diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index 95ccd4b181..36e4df9119 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -1,7 +1,7 @@ import { Address, BigInt, BigDecimal, ethereum } from "@graphprotocol/graph-ts"; import { CurvePrice } from "../../generated/Beanstalk-ABIs/CurvePrice"; import { BeanstalkPrice_try_price } from "./contracts/BeanstalkPrice"; -import { CURVE_PRICE } from "../../../subgraph-core/constants/BeanstalkEth"; +import { CURVE_PRICE } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { setFieldHourlyCaseId, setHourlySoilSoldOut, takeFieldSnapshots } from "../entities/snapshots/Field"; import { getCurrentSeason, getHarvestableIndex, loadBeanstalk, loadFarmer, loadSeason } from "../entities/Beanstalk"; diff --git a/projects/subgraph-beanstalk/src/utils/Init.ts b/projects/subgraph-beanstalk/src/utils/Init.ts index 78b43bca47..13fb3dc682 100644 --- a/projects/subgraph-beanstalk/src/utils/Init.ts +++ b/projects/subgraph-beanstalk/src/utils/Init.ts @@ -1,6 +1,6 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../generated/schema"; -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); diff --git a/projects/subgraph-beanstalk/src/utils/Silo.ts b/projects/subgraph-beanstalk/src/utils/Silo.ts index d9db53b180..cf27e9bc62 100644 --- a/projects/subgraph-beanstalk/src/utils/Silo.ts +++ b/projects/subgraph-beanstalk/src/utils/Silo.ts @@ -3,7 +3,7 @@ import { takeSiloSnapshots } from "../entities/snapshots/Silo"; import { loadSilo, loadSiloAsset, loadSiloDeposit, loadWhitelistTokenSetting, updateDeposit } from "../entities/Silo"; import { takeSiloAssetSnapshots } from "../entities/snapshots/SiloAsset"; import { stemFromSeason } from "./contracts/SiloCalculations"; -import { GAUGE_BIP45_BLOCK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { GAUGE_BIP45_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { loadBeanstalk, loadFarmer } from "../entities/Beanstalk"; diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index d63187ed80..662e540ae4 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -15,7 +15,7 @@ import { getGerminatingBdvs } from "../entities/Germinating"; import { getCurrentSeason, getRewardMinted, loadBeanstalk } from "../entities/Beanstalk"; import { loadFertilizer, loadFertilizerYield } from "../entities/Fertilizer"; import { getProtocolFertilizer } from "./Constants"; -import { REPLANT_SEASON } from "../../../subgraph-core/constants/BeanstalkEth"; +import { REPLANT_SEASON } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; const ROLLING_24_WINDOW = 24; diff --git a/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts b/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts index 1297baf238..c0308b838e 100644 --- a/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts +++ b/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts @@ -5,7 +5,7 @@ import { BeanstalkPrice__priceResultPPsStruct, BeanstalkPrice__priceResultPStruct } from "../../../generated/Beanstalk-ABIs/BeanstalkPrice"; -import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadSilo } from "../../entities/Silo"; diff --git a/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts b/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts index 04c25865a0..81f5527198 100644 --- a/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts +++ b/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts @@ -1,5 +1,5 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; -import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10 } from "../../../../subgraph-core/utils/Decimals"; const STEM_START_SEASON = 14210; diff --git a/projects/subgraph-beanstalk/tests/Field.test.ts b/projects/subgraph-beanstalk/tests/Field.test.ts index 51af669ac2..e32eabb03b 100644 --- a/projects/subgraph-beanstalk/tests/Field.test.ts +++ b/projects/subgraph-beanstalk/tests/Field.test.ts @@ -1,7 +1,7 @@ import { afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; import { BigInt } from "@graphprotocol/graph-ts"; -import { BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { beans_BI as beans, podlineMil_BI as mil } from "../../subgraph-core/tests/Values"; import { assertFarmerHasPlot, assertFieldHas, sow } from "./utils/Field"; diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts index fab4e7c45c..14fdcabcb6 100644 --- a/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts +++ b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts @@ -2,7 +2,7 @@ import { BigInt, Bytes, log } from "@graphprotocol/graph-ts"; import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; import { beans_BI, podlineMil_BI } from "../../subgraph-core/tests/Values"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { assertMarketListingsState, assertMarketOrdersState, diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts index 7f0994b9d0..c227231ab6 100644 --- a/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts +++ b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts @@ -2,7 +2,7 @@ import { BigInt, Bytes, log } from "@graphprotocol/graph-ts"; import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; import { beans_BI, podlineMil_BI } from "../../subgraph-core/tests/Values"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { assertMarketListingsState, assertMarketOrdersState, diff --git a/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts b/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts index 238223d98a..017af4973e 100644 --- a/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts +++ b/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts @@ -4,7 +4,7 @@ import { beforeEach, afterEach, assert, clearStore, describe, test, createMocked import { log } from "matchstick-as/assembly/log"; import { BigInt, Bytes } from "@graphprotocol/graph-ts"; -import { BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { beans_BI as beans, podlineMil_BI } from "../../subgraph-core/tests/Values"; import { assertFarmerHasPlot, assertFieldHas, setHarvestable, sow, transferPlot } from "./utils/Field"; diff --git a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts index b7da66bf1b..50b0c33d2e 100644 --- a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts +++ b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts @@ -11,7 +11,7 @@ import { handleTotalGerminatingStalkChanged, handleTotalStalkChangedFromGermination } from "../src/handlers/GaugeHandler"; -import { BEAN_ERC20, BEANSTALK } from "../../subgraph-core/constants/BeanstalkEth"; +import { BEAN_ERC20, BEANSTALK } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { createBeanToMaxLpGpPerBdvRatioChangeEvent, createFarmerGerminatingStalkBalanceChangedEvent, diff --git a/projects/subgraph-beanstalk/tests/Silo.test.ts b/projects/subgraph-beanstalk/tests/Silo.test.ts index 04a6b498f4..e39df50f80 100644 --- a/projects/subgraph-beanstalk/tests/Silo.test.ts +++ b/projects/subgraph-beanstalk/tests/Silo.test.ts @@ -9,7 +9,7 @@ import { LUSD_3POOL, UNRIPE_BEAN, UNRIPE_LP -} from "../../subgraph-core/constants/BeanstalkEth"; +} from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { createAddDepositV2Event, createAddDepositV3Event, diff --git a/projects/subgraph-beanstalk/tests/Yield.test.ts b/projects/subgraph-beanstalk/tests/Yield.test.ts index 490e4f171b..0c02a5aec7 100644 --- a/projects/subgraph-beanstalk/tests/Yield.test.ts +++ b/projects/subgraph-beanstalk/tests/Yield.test.ts @@ -10,7 +10,7 @@ import { UNRIPE_BEAN, UNRIPE_LP, LUSD_3POOL -} from "../../subgraph-core/constants/BeanstalkEth"; +} from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { setSeason } from "./utils/Season"; import { calculateAPYPreGauge } from "../src/utils/legacy/LegacyYield"; import { calculateGaugeVAPYs, updateSiloVAPYs } from "../src/utils/Yield"; diff --git a/projects/subgraph-beanstalk/tests/utils/Field.ts b/projects/subgraph-beanstalk/tests/utils/Field.ts index 07779a6735..883722f967 100644 --- a/projects/subgraph-beanstalk/tests/utils/Field.ts +++ b/projects/subgraph-beanstalk/tests/utils/Field.ts @@ -5,7 +5,7 @@ import { handleHarvest, handlePlotTransfer, handleSow } from "../../src/handlers import { createIncentivizationEvent } from "../event-mocking/Season"; import { handleIncentive } from "../../src/handlers/SeasonHandler"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); diff --git a/projects/subgraph-beanstalk/tests/utils/Marketplace.ts b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts index 24336e4bea..7a3dacceda 100644 --- a/projects/subgraph-beanstalk/tests/utils/Marketplace.ts +++ b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts @@ -22,7 +22,7 @@ import { PodOrderCancelled, PodListingCancelled } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { transferPlot } from "./Field"; import { PodListingCreated as PodListingCreated_v1, diff --git a/projects/subgraph-beanstalk/tests/utils/Season.ts b/projects/subgraph-beanstalk/tests/utils/Season.ts index 4e57fda9ce..44a71bb635 100644 --- a/projects/subgraph-beanstalk/tests/utils/Season.ts +++ b/projects/subgraph-beanstalk/tests/utils/Season.ts @@ -1,4 +1,4 @@ -import { BEANSTALK } from "../../../subgraph-core/constants/BeanstalkEth"; +import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { loadBeanstalk } from "../../src/entities/Beanstalk"; export function setSeason(season: u32): void { diff --git a/projects/subgraph-core/constants/BeanstalkEth.ts b/projects/subgraph-core/constants/BeanstalkEth.ts index 8ce21ebd52..fc98d477fd 100644 --- a/projects/subgraph-core/constants/BeanstalkEth.ts +++ b/projects/subgraph-core/constants/BeanstalkEth.ts @@ -1,52 +1,75 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { + BEAN_3CRV, + BEAN_ERC20, + BEAN_ERC20_V1, + BEAN_WETH_CP2_WELL, + BEAN_WETH_UNRIPE_MIGRATION_BLOCK, + BEAN_WSTETH_CP2_WELL, + BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK, + BEANSTALK, + BEANSTALK_PRICE_1, + BEANSTALK_PRICE_2, + GAUGE_BIP45_BLOCK, + NEW_BEAN_TOKEN_BLOCK, + PRICE_2_BLOCK, + UNRIPE_BEAN, + UNRIPE_LP +} from "./raw/BeanstalkEthConstants"; -// Token Addresses -export const BEAN_ERC20_V1 = Address.fromString("0xDC59ac4FeFa32293A95889Dc396682858d52e5Db"); -export const BEAN_ERC20 = Address.fromString("0xBEA0000029AD1c77D3d5D23Ba2D8893dB9d1Efab"); -export const UNRIPE_BEAN = Address.fromString("0x1bea0050e63e05fbb5d8ba2f10cf5800b6224449"); -export const UNRIPE_LP = Address.fromString("0x1BEA3CcD22F4EBd3d37d731BA31Eeca95713716D"); -export const BEAN_3CRV = Address.fromString("0xc9C32cd16Bf7eFB85Ff14e0c8603cc90F6F2eE49"); -export const BEANSTALK_FARMS = Address.fromString("0x21de18b6a8f78ede6d16c50a167f6b222dc08df7"); -export const WETH = Address.fromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"); -export const LUSD = Address.fromString("0x5f98805A4E8be255a32880FDeC7F6728C6568bA0"); -export const WSTETH = Address.fromString("0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"); - -// Protocol Addresses -export const BEANSTALK = Address.fromString("0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5"); -export const FERTILIZER = Address.fromString("0x402c84De2Ce49aF88f5e2eF3710ff89bFED36cB6"); -export const AQUIFER = Address.fromString("0xBA51AAAA95aeEFc1292515b36D86C51dC7877773"); - -export const CURVE_PRICE = Address.fromString("0xA57289161FF18D67A68841922264B317170b0b81"); -export const BEANSTALK_PRICE_1 = Address.fromString("0xb01CE0008CaD90104651d6A84b6B11e182a9B62A"); -export const BEANSTALK_PRICE_2 = Address.fromString("0x4bed6cb142b7d474242d87f4796387deb9e1e1b4"); - -// LP Addresses -export const BEAN_3CRV_V1 = Address.fromString("0x3a70DfA7d2262988064A2D051dd47521E43c9BdD"); -export const CRV3_TOKEN = Address.fromString("0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490"); -export const CRV3_POOL = Address.fromString("0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7"); -export const BEAN_WETH_V1 = Address.fromString("0x87898263B6C5BABe34b4ec53F22d98430b91e371"); -export const WETH_USDC_PAIR = Address.fromString("0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc"); -export const BEAN_LUSD_V1 = Address.fromString("0xD652c40fBb3f06d6B58Cb9aa9CFF063eE63d465D"); -export const LUSD_3POOL = Address.fromString("0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA"); -export const BEAN_WETH_CP2_WELL = Address.fromString("0xBEA0e11282e2bB5893bEcE110cF199501e872bAd"); -export const BEAN_WSTETH_CP2_WELL = Address.fromString("0xBeA0000113B0d182f4064C86B71c315389E4715D"); - -export const CALCULATIONS_CURVE = Address.fromString("0x25BF7b72815476Dd515044F9650Bf79bAd0Df655"); - -export const REPLANT_SEASON = BigInt.fromU32(6075); - -// Milestone blocks -export const BEANSTALK_BLOCK = BigInt.fromU32(12974075); -export const EXPLOIT_BLOCK = BigInt.fromU32(14602790); -export const NEW_BEAN_TOKEN_BLOCK = BigInt.fromU32(15278082); -export const REPLANT_SUNRISE_BLOCK = BigInt.fromU32(15289934); -export const GAUGE_BIP45_BLOCK = BigInt.fromU32(19927634); - -export const BEAN_WETH_CP2_WELL_BLOCK = BigInt.fromU32(17978134); -export const BEAN_WSTETH_CP2_WELL_BLOCK = BigInt.fromU32(20264128); - -export const BEAN_WETH_UNRIPE_MIGRATION_BLOCK = BigInt.fromU32(18392690); -export const BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK = BigInt.fromU32(20389706); - -export const PRICE_1_BLOCK = BigInt.fromU32(17978222); -export const PRICE_2_BLOCK = BigInt.fromU32(20298142); +/// ADDRESSES /// + +export function getProtocolToken(blockNumber: BigInt): Address { + if (blockNumber < NEW_BEAN_TOKEN_BLOCK) { + return BEAN_ERC20_V1; + } else { + return BEAN_ERC20; + } +} + +export function getUnripeBeanAddr(): Address { + return UNRIPE_BEAN; +} + +export function getUnripeLpAddr(): Address { + return UNRIPE_LP; +} + +export function isUnripe(token: Address): boolean { + const unripeTokens = [getUnripeBeanAddr(), getUnripeLpAddr()]; + for (let i = 0; i < unripeTokens.length; ++i) { + if (unripeTokens[i] == token) { + return true; + } + } + return false; +} + +/// MILESTONE /// + +export function isGaugeDeployed(blockNumber: BigInt): boolean { + return blockNumber >= GAUGE_BIP45_BLOCK; +} + +export function getUnripeUnderlying(unripeToken: Address, blockNumber: BigInt): Address { + if (unripeToken == UNRIPE_BEAN) { + return BEAN_ERC20; + } else if (unripeToken == UNRIPE_LP) { + if (blockNumber < BEAN_WETH_UNRIPE_MIGRATION_BLOCK) { + return BEAN_3CRV; + } else if (blockNumber < BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK) { + return BEAN_WETH_CP2_WELL; + } else { + return BEAN_WSTETH_CP2_WELL; + } + } + throw new Error("Unsupported unripe token"); +} + +export function getBeanstalkPriceAddress(blockNumber: BigInt): Address { + if (blockNumber < PRICE_2_BLOCK) { + return BEANSTALK_PRICE_1; + } else { + return BEANSTALK_PRICE_2; + } +} diff --git a/projects/subgraph-core/constants/RuntimeConstants.ts b/projects/subgraph-core/constants/RuntimeConstants.ts new file mode 100644 index 0000000000..5241a6f00e --- /dev/null +++ b/projects/subgraph-core/constants/RuntimeConstants.ts @@ -0,0 +1,63 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { BEANSTALK } from "./raw/BeanstalkEthConstants"; +import * as BeanstalkEth from "./BeanstalkEth"; + +/// Used to determine the appropriate constants for subgraphs at runtime /// + +export class VersionDto { + subgraphName: string; + versionNumber: string; + protocolAddress: Address; + chain: string; +} + +export function getProtocolToken(v: VersionDto, blockNumber: BigInt): Address { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.getProtocolToken(blockNumber); + } + throw new Error("Unsupported protocol"); +} + +export function getUnripeBeanAddr(v: VersionDto): Address { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.getUnripeBeanAddr(); + } + throw new Error("Unsupported protocol"); +} + +export function getUnripeLpAddr(v: VersionDto): Address { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.getUnripeLpAddr(); + } + throw new Error("Unsupported protocol"); +} + +export function isUnripe(v: VersionDto, token: Address): boolean { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.isUnripe(token); + } + throw new Error("Unsupported protocol"); +} + +/// MILESTONE /// + +export function isGaugeDeployed(v: VersionDto, blockNumber: BigInt): boolean { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.isGaugeDeployed(blockNumber); + } + throw new Error("Unsupported protocol"); +} + +export function getUnripeUnderlying(v: VersionDto, unripeToken: Address, blockNumber: BigInt): Address { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.getUnripeUnderlying(unripeToken, blockNumber); + } + throw new Error("Unsupported protocol"); +} + +export function getBeanstalkPriceAddress(v: VersionDto, blockNumber: BigInt): Address { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.getBeanstalkPriceAddress(blockNumber); + } + throw new Error("Unsupported protocol"); +} diff --git a/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts new file mode 100644 index 0000000000..8ce21ebd52 --- /dev/null +++ b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts @@ -0,0 +1,52 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; + +// Token Addresses +export const BEAN_ERC20_V1 = Address.fromString("0xDC59ac4FeFa32293A95889Dc396682858d52e5Db"); +export const BEAN_ERC20 = Address.fromString("0xBEA0000029AD1c77D3d5D23Ba2D8893dB9d1Efab"); +export const UNRIPE_BEAN = Address.fromString("0x1bea0050e63e05fbb5d8ba2f10cf5800b6224449"); +export const UNRIPE_LP = Address.fromString("0x1BEA3CcD22F4EBd3d37d731BA31Eeca95713716D"); +export const BEAN_3CRV = Address.fromString("0xc9C32cd16Bf7eFB85Ff14e0c8603cc90F6F2eE49"); +export const BEANSTALK_FARMS = Address.fromString("0x21de18b6a8f78ede6d16c50a167f6b222dc08df7"); +export const WETH = Address.fromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"); +export const LUSD = Address.fromString("0x5f98805A4E8be255a32880FDeC7F6728C6568bA0"); +export const WSTETH = Address.fromString("0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"); + +// Protocol Addresses +export const BEANSTALK = Address.fromString("0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5"); +export const FERTILIZER = Address.fromString("0x402c84De2Ce49aF88f5e2eF3710ff89bFED36cB6"); +export const AQUIFER = Address.fromString("0xBA51AAAA95aeEFc1292515b36D86C51dC7877773"); + +export const CURVE_PRICE = Address.fromString("0xA57289161FF18D67A68841922264B317170b0b81"); +export const BEANSTALK_PRICE_1 = Address.fromString("0xb01CE0008CaD90104651d6A84b6B11e182a9B62A"); +export const BEANSTALK_PRICE_2 = Address.fromString("0x4bed6cb142b7d474242d87f4796387deb9e1e1b4"); + +// LP Addresses +export const BEAN_3CRV_V1 = Address.fromString("0x3a70DfA7d2262988064A2D051dd47521E43c9BdD"); +export const CRV3_TOKEN = Address.fromString("0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490"); +export const CRV3_POOL = Address.fromString("0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7"); +export const BEAN_WETH_V1 = Address.fromString("0x87898263B6C5BABe34b4ec53F22d98430b91e371"); +export const WETH_USDC_PAIR = Address.fromString("0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc"); +export const BEAN_LUSD_V1 = Address.fromString("0xD652c40fBb3f06d6B58Cb9aa9CFF063eE63d465D"); +export const LUSD_3POOL = Address.fromString("0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA"); +export const BEAN_WETH_CP2_WELL = Address.fromString("0xBEA0e11282e2bB5893bEcE110cF199501e872bAd"); +export const BEAN_WSTETH_CP2_WELL = Address.fromString("0xBeA0000113B0d182f4064C86B71c315389E4715D"); + +export const CALCULATIONS_CURVE = Address.fromString("0x25BF7b72815476Dd515044F9650Bf79bAd0Df655"); + +export const REPLANT_SEASON = BigInt.fromU32(6075); + +// Milestone blocks +export const BEANSTALK_BLOCK = BigInt.fromU32(12974075); +export const EXPLOIT_BLOCK = BigInt.fromU32(14602790); +export const NEW_BEAN_TOKEN_BLOCK = BigInt.fromU32(15278082); +export const REPLANT_SUNRISE_BLOCK = BigInt.fromU32(15289934); +export const GAUGE_BIP45_BLOCK = BigInt.fromU32(19927634); + +export const BEAN_WETH_CP2_WELL_BLOCK = BigInt.fromU32(17978134); +export const BEAN_WSTETH_CP2_WELL_BLOCK = BigInt.fromU32(20264128); + +export const BEAN_WETH_UNRIPE_MIGRATION_BLOCK = BigInt.fromU32(18392690); +export const BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK = BigInt.fromU32(20389706); + +export const PRICE_1_BLOCK = BigInt.fromU32(17978222); +export const PRICE_2_BLOCK = BigInt.fromU32(20298142); diff --git a/projects/subgraph-core/tests/event-mocking/Price.ts b/projects/subgraph-core/tests/event-mocking/Price.ts index 4aff720f35..051d6e77cf 100644 --- a/projects/subgraph-core/tests/event-mocking/Price.ts +++ b/projects/subgraph-core/tests/event-mocking/Price.ts @@ -9,7 +9,7 @@ import { CURVE_PRICE, WETH, WETH_USDC_PAIR -} from "../../constants/BeanstalkEth"; +} from "../../constants/raw/BeanstalkEthConstants"; import { BD_10, BI_10, pow, toDecimal, ZERO_BI } from "../../utils/Decimals"; // These 2 classes are analagous to structs used by BeanstalkPrice contract diff --git a/projects/subgraph-core/tests/event-mocking/Util.ts b/projects/subgraph-core/tests/event-mocking/Util.ts index 9e5a212fb7..4ebbd1007f 100644 --- a/projects/subgraph-core/tests/event-mocking/Util.ts +++ b/projects/subgraph-core/tests/event-mocking/Util.ts @@ -1,6 +1,6 @@ import { Address, ethereum } from "@graphprotocol/graph-ts"; import { newMockEvent } from "matchstick-as/assembly/index"; -import { BEANSTALK } from "../../constants/BeanstalkEth"; +import { BEANSTALK } from "../../constants/raw/BeanstalkEthConstants"; // Default mock to include beanstalk address export function mockBeanstalkEvent(): ethereum.Event { From 1ed4c38fa55de9b8e9bccef784dd83fe06b4f912 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:35:38 -0700 Subject: [PATCH 17/88] add v function to all subgraphs --- .../subgraph-basin/manifests/codegen-abis.yaml | 2 +- projects/subgraph-basin/manifests/ethereum.yaml | 2 +- .../src/utils/{Init.ts => constants/Version.ts} | 16 ++++++++++++++-- .../subgraph-beanft/manifests/codegen-abis.yaml | 2 +- projects/subgraph-beanft/manifests/ethereum.yaml | 2 +- .../src/utils/{Init.ts => constants/Version.ts} | 16 ++++++++++++++-- .../manifests/codegen-abis.yaml | 2 +- .../subgraph-beanstalk/manifests/ethereum.yaml | 2 +- .../subgraph-beanstalk/manifests/no-apy.yaml | 2 +- .../src/utils/{Init.ts => constants/Version.ts} | 16 ++++++++++++++-- 10 files changed, 49 insertions(+), 13 deletions(-) rename projects/subgraph-basin/src/utils/{Init.ts => constants/Version.ts} (65%) rename projects/subgraph-beanft/src/utils/{Init.ts => constants/Version.ts} (65%) rename projects/subgraph-beanstalk/src/utils/{Init.ts => constants/Version.ts} (65%) diff --git a/projects/subgraph-basin/manifests/codegen-abis.yaml b/projects/subgraph-basin/manifests/codegen-abis.yaml index fa6c273743..2c066381aa 100644 --- a/projects/subgraph-basin/manifests/codegen-abis.yaml +++ b/projects/subgraph-basin/manifests/codegen-abis.yaml @@ -37,7 +37,7 @@ dataSources: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts templates: - kind: ethereum/contract name: Well diff --git a/projects/subgraph-basin/manifests/ethereum.yaml b/projects/subgraph-basin/manifests/ethereum.yaml index 64b5112c0c..26dc082a30 100644 --- a/projects/subgraph-basin/manifests/ethereum.yaml +++ b/projects/subgraph-basin/manifests/ethereum.yaml @@ -26,7 +26,7 @@ dataSources: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts - kind: ethereum/contract name: Aquifer network: mainnet diff --git a/projects/subgraph-basin/src/utils/Init.ts b/projects/subgraph-basin/src/utils/constants/Version.ts similarity index 65% rename from projects/subgraph-basin/src/utils/Init.ts rename to projects/subgraph-basin/src/utils/constants/Version.ts index ff2bc21a39..34d9b2d16f 100644 --- a/projects/subgraph-basin/src/utils/Init.ts +++ b/projects/subgraph-basin/src/utils/constants/Version.ts @@ -1,6 +1,8 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; -import { Version } from "../../generated/schema"; -import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { Version } from "../../../generated/schema"; +import { BEANSTALK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { VersionDto } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); @@ -31,3 +33,13 @@ function chainForBlockNumber(blockNumber: BigInt): string { } throw new Error("Unable to initialize chain for this block number"); } + +export function v(): VersionDto { + const versionEntity = Version.load("subgraph")!; + return { + subgraphName: versionEntity.subgraphName, + versionNumber: versionEntity.versionNumber, + protocolAddress: toAddress(versionEntity.protocolAddress), + chain: versionEntity.chain + }; +} diff --git a/projects/subgraph-beanft/manifests/codegen-abis.yaml b/projects/subgraph-beanft/manifests/codegen-abis.yaml index 0cbc6ef2a0..0ab23b4a83 100644 --- a/projects/subgraph-beanft/manifests/codegen-abis.yaml +++ b/projects/subgraph-beanft/manifests/codegen-abis.yaml @@ -34,4 +34,4 @@ dataSources: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts diff --git a/projects/subgraph-beanft/manifests/ethereum.yaml b/projects/subgraph-beanft/manifests/ethereum.yaml index 2cc798c09b..7ad32490e5 100644 --- a/projects/subgraph-beanft/manifests/ethereum.yaml +++ b/projects/subgraph-beanft/manifests/ethereum.yaml @@ -26,7 +26,7 @@ dataSources: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts - kind: ethereum name: genesis network: mainnet diff --git a/projects/subgraph-beanft/src/utils/Init.ts b/projects/subgraph-beanft/src/utils/constants/Version.ts similarity index 65% rename from projects/subgraph-beanft/src/utils/Init.ts rename to projects/subgraph-beanft/src/utils/constants/Version.ts index 888e6d7d69..c41656425c 100644 --- a/projects/subgraph-beanft/src/utils/Init.ts +++ b/projects/subgraph-beanft/src/utils/constants/Version.ts @@ -1,6 +1,8 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; -import { Version } from "../../generated/schema"; -import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { Version } from "../../../generated/schema"; +import { BEANSTALK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { VersionDto } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); @@ -31,3 +33,13 @@ function chainForBlockNumber(blockNumber: BigInt): string { } throw new Error("Unable to initialize chain for this block number"); } + +export function v(): VersionDto { + const versionEntity = Version.load("subgraph")!; + return { + subgraphName: versionEntity.subgraphName, + versionNumber: versionEntity.versionNumber, + protocolAddress: toAddress(versionEntity.protocolAddress), + chain: versionEntity.chain + }; +} diff --git a/projects/subgraph-beanstalk/manifests/codegen-abis.yaml b/projects/subgraph-beanstalk/manifests/codegen-abis.yaml index 613d8aaefc..50d8408229 100644 --- a/projects/subgraph-beanstalk/manifests/codegen-abis.yaml +++ b/projects/subgraph-beanstalk/manifests/codegen-abis.yaml @@ -48,4 +48,4 @@ dataSources: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index 16b7b9fae1..fe83a5efa2 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -360,7 +360,7 @@ dataSources: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts ### # EXPLOIT ### diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index b3b188e95c..7d748a7887 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -27,7 +27,7 @@ dataSources: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts ### # SILO ### diff --git a/projects/subgraph-beanstalk/src/utils/Init.ts b/projects/subgraph-beanstalk/src/utils/constants/Version.ts similarity index 65% rename from projects/subgraph-beanstalk/src/utils/Init.ts rename to projects/subgraph-beanstalk/src/utils/constants/Version.ts index 13fb3dc682..21c97c97a6 100644 --- a/projects/subgraph-beanstalk/src/utils/Init.ts +++ b/projects/subgraph-beanstalk/src/utils/constants/Version.ts @@ -1,6 +1,8 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; -import { Version } from "../../generated/schema"; -import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { Version } from "../../../generated/schema"; +import { BEANSTALK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { VersionDto } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); @@ -31,3 +33,13 @@ function chainForBlockNumber(blockNumber: BigInt): string { } throw new Error("Unable to initialize chain for this block number"); } + +export function v(): VersionDto { + const versionEntity = Version.load("subgraph")!; + return { + subgraphName: versionEntity.subgraphName, + versionNumber: versionEntity.versionNumber, + protocolAddress: toAddress(versionEntity.protocolAddress), + chain: versionEntity.chain + }; +} From c98b4b2557b4bb9de1f1e5482472040c02926e77 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:51:56 -0700 Subject: [PATCH 18/88] add shared constants to beanstalk subgraph --- projects/subgraph-bean/src/entities/Bean.ts | 4 +- .../subgraph-bean/src/utils/LockedBeans.ts | 4 +- .../src/utils/constants/Version.ts | 4 - .../src/utils/price/UniswapPrice.ts | 4 +- .../src/entities/Beanstalk.ts | 7 +- .../src/entities/Fertilizer.ts | 4 +- .../subgraph-beanstalk/src/entities/Silo.ts | 7 +- .../src/handlers/BeanHandler.ts | 6 +- .../src/handlers/SeasonHandler.ts | 8 +- .../src/handlers/SiloHandler.ts | 7 +- projects/subgraph-beanstalk/src/utils/Barn.ts | 5 +- .../subgraph-beanstalk/src/utils/Constants.ts | 97 ------------------- .../subgraph-beanstalk/src/utils/Season.ts | 5 +- .../subgraph-beanstalk/src/utils/Yield.ts | 5 +- .../subgraph-beanstalk/tests/Field.test.ts | 6 +- .../tests/MarketplaceV1.test.ts | 3 + .../tests/MarketplaceV2.test.ts | 3 + .../tests/PlotTransfer.test.ts | 3 + .../tests/SeedGauge.test.ts | 8 +- .../subgraph-beanstalk/tests/Silo.test.ts | 6 +- .../subgraph-beanstalk/tests/Yield.test.ts | 6 +- .../tests/entity-mocking/MockVersion.ts | 7 ++ .../subgraph-core/constants/BeanstalkEth.ts | 33 +++++++ .../constants/RuntimeConstants.ts | 14 +++ 24 files changed, 119 insertions(+), 137 deletions(-) delete mode 100644 projects/subgraph-beanstalk/src/utils/Constants.ts create mode 100644 projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts diff --git a/projects/subgraph-bean/src/entities/Bean.ts b/projects/subgraph-bean/src/entities/Bean.ts index aaa1cde662..b054a92e5c 100644 --- a/projects/subgraph-bean/src/entities/Bean.ts +++ b/projects/subgraph-bean/src/entities/Bean.ts @@ -4,13 +4,13 @@ import { dayFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { Bean, BeanDailySnapshot, BeanHourlySnapshot } from "../../generated/schema"; import { getV1Crosses } from "../utils/Cross"; -import { getVersionEntity } from "../utils/constants/Version"; +import { v } from "../utils/constants/Version"; export function loadBean(token: Address): Bean { let bean = Bean.load(token); if (bean == null) { bean = new Bean(token); - const version = getVersionEntity(); + const version = v(); bean.chain = version.chain; bean.beanstalk = version.protocolAddress.toHexString(); diff --git a/projects/subgraph-bean/src/utils/LockedBeans.ts b/projects/subgraph-bean/src/utils/LockedBeans.ts index 694ab419d0..a11b32842d 100644 --- a/projects/subgraph-bean/src/utils/LockedBeans.ts +++ b/projects/subgraph-bean/src/utils/LockedBeans.ts @@ -4,7 +4,7 @@ import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { ERC20 } from "../../generated/Bean-ABIs/ERC20"; import { loadOrCreateTwaOracle } from "../entities/TwaOracle"; import { loadOrCreatePool } from "../entities/Pool"; -import { getVersionEntity, v } from "./constants/Version"; +import { v } from "./constants/Version"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; import { getUnripeBeanAddr, @@ -14,7 +14,7 @@ import { } from "../../../subgraph-core/constants/RuntimeConstants"; export function calcLockedBeans(blockNumber: BigInt): BigInt { - const protocol = toAddress(getVersionEntity().protocolAddress); + const protocol = toAddress(v().protocolAddress); const underlyingLpPool = getUnripeUnderlying(v(), getUnripeLpAddr(v()), blockNumber); // If BIP45 is deployed - return the result from the contract diff --git a/projects/subgraph-bean/src/utils/constants/Version.ts b/projects/subgraph-bean/src/utils/constants/Version.ts index 7fb2d922cf..b563e6af93 100644 --- a/projects/subgraph-bean/src/utils/constants/Version.ts +++ b/projects/subgraph-bean/src/utils/constants/Version.ts @@ -13,10 +13,6 @@ export function handleInitVersion(block: ethereum.Block): void { versionEntity.save(); } -export function getVersionEntity(): Version { - return Version.load("subgraph")!; -} - function subgraphNameForBlockNumber(blockNumber: BigInt): string { if (blockNumber == BigInt.fromU32(12974075)) { return "bean"; diff --git a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts index aa431685b2..21a6fc43ee 100644 --- a/projects/subgraph-bean/src/utils/price/UniswapPrice.ts +++ b/projects/subgraph-bean/src/utils/price/UniswapPrice.ts @@ -9,7 +9,7 @@ import { UniswapV2Pair } from "../../../generated/Bean-ABIs/UniswapV2Pair"; import { Pool } from "../../../generated/schema"; import { PreReplant } from "../../../generated/Bean-ABIs/PreReplant"; import { toAddress } from "../../../../subgraph-core/utils/Bytes"; -import { getVersionEntity } from "../constants/Version"; +import { v } from "../constants/Version"; export function updatePreReplantPriceETH(): BigDecimal { let token = loadOrCreateToken(WETH); @@ -99,7 +99,7 @@ export function uniswapCumulativePrice(pool: Address, tokenIndex: u32, timestamp } export function uniswapTwaDeltaBAndPrice(prices: BigInt[], blockNumber: BigInt): DeltaBAndPrice { - const protocol = toAddress(getVersionEntity().protocolAddress); + const protocol = toAddress(v().protocolAddress); let beanstalk = PreReplant.bind(protocol); let reserves: BigInt[]; // After BIP-9, reserves calculation changes diff --git a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts index e1de2691d8..0bc4a27af2 100644 --- a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts +++ b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts @@ -3,7 +3,8 @@ import { Beanstalk } from "../../generated/schema"; import { Farmer } from "../../generated/schema"; import { Season } from "../../generated/schema"; import { BI_MAX, ONE_BI, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { getProtocolFertilizer, getProtocolToken } from "../utils/Constants"; +import { getProtocolFertilizer, getProtocolToken } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../utils/constants/Version"; export function loadBeanstalk(protocol: Address): Beanstalk { let beanstalk = Beanstalk.load(protocol.toHexString()); @@ -11,8 +12,8 @@ export function loadBeanstalk(protocol: Address): Beanstalk { beanstalk = new Beanstalk(protocol.toHexString()); beanstalk.name = "Beanstalk"; // Pre-replant token currently would not be set - beanstalk.token = getProtocolToken(protocol).toHexString(); - const fert = getProtocolFertilizer(protocol); + beanstalk.token = getProtocolToken(v(), BI_MAX).toHexString(); + const fert = getProtocolFertilizer(v()); if (fert !== null) { beanstalk.fertilizer1155 = fert.toHexString(); } diff --git a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts index 25da09e4d4..5cf0e3c271 100644 --- a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts +++ b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts @@ -2,13 +2,13 @@ import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { Farmer, Fertilizer, FertilizerBalance, FertilizerToken, FertilizerYield } from "../../generated/schema"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { getFertilizerProtocol } from "../utils/Constants"; +import { v } from "../utils/constants/Version"; export function loadFertilizer(fertilizerAddress: Address): Fertilizer { let fertilizer = Fertilizer.load(fertilizerAddress.toHexString()); if (fertilizer == null) { fertilizer = new Fertilizer(fertilizerAddress.toHexString()); - fertilizer.beanstalk = getFertilizerProtocol(fertilizerAddress).toHexString(); + fertilizer.beanstalk = v().protocolAddress.toHexString(); fertilizer.supply = ZERO_BI; fertilizer.save(); } diff --git a/projects/subgraph-beanstalk/src/entities/Silo.ts b/projects/subgraph-beanstalk/src/entities/Silo.ts index 5addc97c52..2cd6b1ced1 100644 --- a/projects/subgraph-beanstalk/src/entities/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/Silo.ts @@ -11,7 +11,8 @@ import { } from "../../generated/schema"; import { BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { getTokenDecimals, getUnripeUnderlying } from "../utils/Constants"; +import { getTokenDecimals, getUnripeUnderlying } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../utils/constants/Version"; /* ===== Base Silo Entities ===== */ @@ -76,7 +77,7 @@ export function loadWhitelistTokenSetting(token: Address): WhitelistTokenSetting setting.stalkEarnedPerSeason = ZERO_BI; setting.stalkIssuedPerBdv = ZERO_BI; setting.milestoneSeason = 0; - setting.decimals = getTokenDecimals(token); + setting.decimals = getTokenDecimals(v(), token); setting.updatedAt = ZERO_BI; // Check token addresses and set replant seeds/stalk for Unripe due to event timing. @@ -98,7 +99,7 @@ export function loadUnripeToken(token: Address): UnripeToken { let unripe = UnripeToken.load(token); if (unripe == null) { unripe = new UnripeToken(token); - unripe.underlyingToken = getUnripeUnderlying(token, ZERO_BI); + unripe.underlyingToken = getUnripeUnderlying(v(), token, ZERO_BI); unripe.totalUnderlying = ZERO_BI; unripe.amountUnderlyingOne = ZERO_BI; unripe.bdvUnderlyingOne = ZERO_BI; diff --git a/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts b/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts index 62c32bee7c..392746236b 100644 --- a/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts @@ -2,14 +2,14 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Transfer } from "../../generated/Beanstalk-ABIs/ERC20"; import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; -import { getTokenProtocol } from "../utils/Constants"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; +import { v } from "../utils/constants/Version"; export function handleTransfer(event: Transfer): void { if (event.params.from == ADDRESS_ZERO || event.params.to == ADDRESS_ZERO) { - let beanstalk = loadBeanstalk(getTokenProtocol(event.address)); - let season = loadSeason(getTokenProtocol(event.address), BigInt.fromI32(beanstalk.lastSeason)); + let beanstalk = loadBeanstalk(v().protocolAddress); + let season = loadSeason(v().protocolAddress, BigInt.fromI32(beanstalk.lastSeason)); if (event.params.from == ADDRESS_ZERO) { season.deltaBeans = season.deltaBeans.plus(event.params.value); diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index 4523480a92..b790e9d394 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -13,8 +13,9 @@ import { loadField } from "../entities/Field"; import { updateBeanEMA } from "../utils/Yield"; import { updateExpiredPlots } from "../utils/Marketplace"; import { updateHarvestablePlots } from "../utils/Field"; -import { getProtocolToken } from "../utils/Constants"; import { sunrise } from "../utils/Season"; +import { getProtocolToken, isGaugeDeployed } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../utils/constants/Version"; export function handleSunrise(event: Sunrise): void { // (Legacy) Update any farmers that had silo transfers from the prior season. @@ -45,7 +46,7 @@ export function handleReward(event: Reward): void { updateDepositInSiloAsset( event.address, event.address, - getProtocolToken(event.address), + getProtocolToken(v(), event.block.number), event.params.toSilo, event.params.toSilo, event.block.timestamp @@ -55,8 +56,7 @@ export function handleReward(event: Reward): void { export function handleWellOracle(event: WellOracle): void { let season = loadSeason(event.address, event.params.season); season.deltaB = season.deltaB.plus(event.params.deltaB); - // TODO: something like isGaugeDeployed(v())? - if (event.block.number >= GAUGE_BIP45_BLOCK && season.price == ZERO_BD) { + if (isGaugeDeployed(v(), event.block.number) && season.price == ZERO_BD) { let beanstalkPrice = getBeanstalkPrice(event.block.number); let beanstalkQuery = beanstalkPrice.getConstantProductWell(event.params.well); season.price = toDecimal(beanstalkQuery.price); diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 2a2787c556..aa319d32d0 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -19,8 +19,9 @@ import { WhitelistToken } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { updateClaimedWithdraw } from "../utils/legacy/LegacySilo"; -import { getProtocolToken, isUnripe } from "../utils/Constants"; import { unripeChopped } from "../utils/Barn"; +import { getProtocolToken, isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../utils/constants/Version"; export function handleAddDeposit(event: AddDeposit): void { addDeposits({ @@ -62,7 +63,7 @@ export function handleRemoveDeposits(event: RemoveDeposits): void { } export function handleConvert(event: Convert): void { - if (isUnripe(event.params.fromToken) && !isUnripe(event.params.toToken)) { + if (isUnripe(v(), event.params.fromToken) && !isUnripe(v(), event.params.toToken)) { unripeChopped({ event, type: "convert", @@ -112,7 +113,7 @@ export function handlePlant(event: Plant): void { updateDepositInSiloAsset( event.address, event.address, - getProtocolToken(event.address), + getProtocolToken(v(), event.block.number), event.params.beans, event.params.beans, event.block.timestamp diff --git a/projects/subgraph-beanstalk/src/utils/Barn.ts b/projects/subgraph-beanstalk/src/utils/Barn.ts index a580dcda84..0d5188a194 100644 --- a/projects/subgraph-beanstalk/src/utils/Barn.ts +++ b/projects/subgraph-beanstalk/src/utils/Barn.ts @@ -5,10 +5,11 @@ import { loadFarmer } from "../entities/Beanstalk"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { loadUnripeToken, loadWhitelistTokenSetting } from "../entities/Silo"; import { takeUnripeTokenSnapshots } from "../entities/snapshots/UnripeToken"; -import { getUnripeUnderlying } from "./Constants"; import { BI_10, toDecimal } from "../../../subgraph-core/utils/Decimals"; import { getLatestBdv } from "../entities/snapshots/WhitelistTokenSetting"; import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; +import { getUnripeUnderlying } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./constants/Version"; class ChopParams { event: ethereum.Event; @@ -82,7 +83,7 @@ export function updateUnripeStats(unripe: Address, protocol: Address, block: eth unripeToken.recapPercent = toDecimal(beanstalk_call.getRecapFundedPercent(unripe)); // Further calculated values - unripeToken.underlyingToken = getUnripeUnderlying(unripe, block.number); + unripeToken.underlyingToken = getUnripeUnderlying(v(), unripe, block.number); const underlyingWhitelist = loadWhitelistTokenSetting(Address.fromBytes(unripeToken.underlyingToken)); const underlyingBdvOne = getLatestBdv(underlyingWhitelist); if (underlyingBdvOne !== null) { diff --git a/projects/subgraph-beanstalk/src/utils/Constants.ts b/projects/subgraph-beanstalk/src/utils/Constants.ts deleted file mode 100644 index 28cc45579d..0000000000 --- a/projects/subgraph-beanstalk/src/utils/Constants.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; -import { - BEAN_3CRV, - BEAN_3CRV_V1, - BEAN_ERC20, - BEAN_ERC20_V1, - BEAN_LUSD_V1, - BEAN_WETH_CP2_WELL, - BEAN_WETH_UNRIPE_MIGRATION_BLOCK, - BEAN_WETH_V1, - BEAN_WSTETH_CP2_WELL, - BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK, - BEANSTALK, - FERTILIZER, - UNRIPE_BEAN, - UNRIPE_LP -} from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; - -export function getProtocolToken(protocol: Address): Address { - if (protocol == BEANSTALK) { - return BEAN_ERC20; - } - throw new Error("Unsupported protocol"); -} - -export function getTokenProtocol(token: Address): Address { - if (token == BEAN_ERC20) { - return BEANSTALK; - } else if (token == BEAN_ERC20_V1) { - return BEANSTALK; - } - throw new Error("Unsupported protocol token"); -} - -export function getProtocolFertilizer(protocol: Address): Address | null { - if (protocol == BEANSTALK) { - return FERTILIZER; - } - throw new Error("Unsupported protocol"); -} - -export function getFertilizerProtocol(fertilizer: Address): Address { - if (fertilizer == FERTILIZER) { - return BEANSTALK; - } - throw new Error("Unsupported fertilizer"); -} - -export function getUnripeUnderlying(unripeToken: Address, blockNumber: BigInt): Address { - if (unripeToken == UNRIPE_BEAN) { - return BEAN_ERC20; - } else if (unripeToken == UNRIPE_LP) { - if (blockNumber < BEAN_WETH_UNRIPE_MIGRATION_BLOCK) { - return BEAN_3CRV; - } else if (blockNumber < BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK) { - return BEAN_WETH_CP2_WELL; - } else { - return BEAN_WSTETH_CP2_WELL; - } - } - throw new Error("Unsupported unripe token"); -} - -export function getTokenDecimals(token: Address): i32 { - if (token == BEAN_ERC20) { - return 6; - } else if (token == UNRIPE_BEAN) { - return 6; - } else if (token == UNRIPE_LP) { - return 6; - } else if (token == BEAN_3CRV) { - return 18; - } else if (token == BEAN_WETH_CP2_WELL) { - return 18; - } else if (token == BEAN_WSTETH_CP2_WELL) { - return 18; - } else if (token == BEAN_ERC20_V1) { - return 6; - } else if (token == BEAN_WETH_V1) { - return 18; - } else if (token == BEAN_3CRV_V1) { - return 18; - } else if (token == BEAN_LUSD_V1) { - return 18; - } - throw new Error("Unsupported token"); -} - -export function isUnripe(token: Address): boolean { - const unripeTokens = [UNRIPE_BEAN, UNRIPE_LP]; - for (let i = 0; i < unripeTokens.length; ++i) { - if (unripeTokens[i] == token) { - return true; - } - } - return false; -} diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index c8b2361836..22621157e5 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -11,8 +11,9 @@ import { loadField } from "../entities/Field"; import { setBdv, takeWhitelistTokenSettingSnapshots } from "../entities/snapshots/WhitelistTokenSetting"; import { WhitelistTokenSetting } from "../../generated/schema"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { isUnripe } from "./Constants"; import { updateUnripeStats } from "./Barn"; +import { isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./constants/Version"; export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block): void { let currentSeason = season.toI32(); @@ -56,7 +57,7 @@ export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block whitelistTokenSetting.save(); setTokenBdv(token, protocol, whitelistTokenSetting); - if (isUnripe(token)) { + if (isUnripe(v(), token)) { updateUnripeStats(token, protocol, block); } } diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index 662e540ae4..36abaa5cb3 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -14,9 +14,10 @@ import { calculateAPYPreGauge } from "./legacy/LegacyYield"; import { getGerminatingBdvs } from "../entities/Germinating"; import { getCurrentSeason, getRewardMinted, loadBeanstalk } from "../entities/Beanstalk"; import { loadFertilizer, loadFertilizerYield } from "../entities/Fertilizer"; -import { getProtocolFertilizer } from "./Constants"; import { REPLANT_SEASON } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { getProtocolFertilizer } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./constants/Version"; const ROLLING_24_WINDOW = 24; const ROLLING_7_DAY_WINDOW = 168; @@ -414,7 +415,7 @@ function updateGaugePoints(gaugePoints: f64, currentPercent: f64, optimalPercent } function updateFertAPY(protocol: Address, timestamp: BigInt, window: i32): void { - const fertAddress = getProtocolFertilizer(protocol); + const fertAddress = getProtocolFertilizer(v()); if (fertAddress === null) { return; } diff --git a/projects/subgraph-beanstalk/tests/Field.test.ts b/projects/subgraph-beanstalk/tests/Field.test.ts index e32eabb03b..c1d0593669 100644 --- a/projects/subgraph-beanstalk/tests/Field.test.ts +++ b/projects/subgraph-beanstalk/tests/Field.test.ts @@ -1,10 +1,11 @@ -import { afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; +import { afterEach, beforeEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; import { BigInt } from "@graphprotocol/graph-ts"; import { BEANSTALK } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { beans_BI as beans, podlineMil_BI as mil } from "../../subgraph-core/tests/Values"; import { assertFarmerHasPlot, assertFieldHas, sow } from "./utils/Field"; +import { initL1Version } from "./entity-mocking/MockVersion"; const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); @@ -15,6 +16,9 @@ const pods = beansSown.times(BigInt.fromI32(temperature)); // Begin tests describe("Field", () => { + beforeEach(() => { + initL1Version(); + }); afterEach(() => { clearStore(); }); diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts index 14fdcabcb6..5c54b6ccc6 100644 --- a/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts +++ b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts @@ -16,6 +16,7 @@ import { getPodFillId } from "./utils/Marketplace"; import { harvest, setHarvestable, sow } from "./utils/Field"; +import { initL1Version } from "./entity-mocking/MockVersion"; const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); const account2 = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8".toLowerCase(); @@ -34,6 +35,8 @@ const orderId = Bytes.fromHexString("0xabcd"); describe("Marketplace", () => { beforeEach(() => { + initL1Version(); + setHarvestable(currentHarvestable); sow(account, listingIndex, sowedBeans, sowedPods); }); diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts index c227231ab6..7d51c51e04 100644 --- a/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts +++ b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts @@ -15,6 +15,7 @@ import { getPodFillId } from "./utils/Marketplace"; import { harvest, setHarvestable, sow } from "./utils/Field"; +import { initL1Version } from "./entity-mocking/MockVersion"; const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); const account2 = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8".toLowerCase(); @@ -33,6 +34,8 @@ const orderId = Bytes.fromHexString("0xabcd"); describe("Marketplace", () => { beforeEach(() => { + initL1Version(); + setHarvestable(currentHarvestable); sow(account, listingIndex, sowedBeans, sowedPods); }); diff --git a/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts b/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts index 017af4973e..fde8cf3cdc 100644 --- a/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts +++ b/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts @@ -9,6 +9,7 @@ import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { beans_BI as beans, podlineMil_BI } from "../../subgraph-core/tests/Values"; import { assertFarmerHasPlot, assertFieldHas, setHarvestable, sow, transferPlot } from "./utils/Field"; import { createListing_v2, createOrder_v2, fillListing_v2, fillOrder_v2 } from "./utils/Marketplace"; +import { initL1Version } from "./entity-mocking/MockVersion"; const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); const account2 = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8".toLowerCase(); @@ -51,6 +52,8 @@ const initialPlots: Plot[] = [ // Begin tests describe("Field: Plot Transfer", () => { beforeEach(() => { + initL1Version(); + // Create two equally sized plots next to each other for (let i = 0; i < initialPlots.length; ++i) { sow(account, initialPlots[i].plotStart, initialPlots[i].beansSown, initialPlots[i].pods); diff --git a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts index 50b0c33d2e..02059ef95f 100644 --- a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts +++ b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts @@ -1,4 +1,4 @@ -import { afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; +import { afterEach, beforeEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; import { log } from "matchstick-as/assembly/log"; import { BigInt } from "@graphprotocol/graph-ts"; import { @@ -6,7 +6,6 @@ import { handleGaugePointChange, handleUpdateAverageStalkPerBdvPerSeason, handleFarmerGerminatingStalkBalanceChanged, - handleTotalGerminatingBalanceChanged, handleUpdateGaugeSettings, handleTotalGerminatingStalkChanged, handleTotalStalkChangedFromGermination @@ -16,7 +15,6 @@ import { createBeanToMaxLpGpPerBdvRatioChangeEvent, createFarmerGerminatingStalkBalanceChangedEvent, createGaugePointChangeEvent, - createTotalGerminatingBalanceChangedEvent, createTotalGerminatingStalkChangedEvent, createTotalStalkChangedFromGerminationEvent, createUpdateAverageStalkPerBdvPerSeasonEvent, @@ -31,12 +29,16 @@ import { dayFromTimestamp } from "../../subgraph-core/utils/Dates"; import { loadSilo } from "../src/entities/Silo"; import { handleWhitelistToken } from "../src/handlers/SiloHandler"; import { handleTemperatureChange } from "../src/handlers/FieldHandler"; +import { initL1Version } from "./entity-mocking/MockVersion"; const ANVIL_ADDR_1 = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); const ratioDecimals = BigInt.fromU32(10).pow(18); describe("Seed Gauge", () => { + beforeEach(() => { + initL1Version(); + }); afterEach(() => { log.debug("clearing the store", []); clearStore(); diff --git a/projects/subgraph-beanstalk/tests/Silo.test.ts b/projects/subgraph-beanstalk/tests/Silo.test.ts index e39df50f80..2ca0a4371b 100644 --- a/projects/subgraph-beanstalk/tests/Silo.test.ts +++ b/projects/subgraph-beanstalk/tests/Silo.test.ts @@ -1,5 +1,5 @@ import { BigInt } from "@graphprotocol/graph-ts"; -import { afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; +import { afterEach, beforeEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; import { BEAN_3CRV, BEAN_ERC20, @@ -31,8 +31,12 @@ import { } from "../src/handlers/legacy/LegacySiloHandler"; import { handleAddDeposit, handleDewhitelistToken, handleRemoveDeposit } from "../src/handlers/SiloHandler"; import { stemFromSeason } from "../src/utils/contracts/SiloCalculations"; +import { initL1Version } from "./entity-mocking/MockVersion"; describe("Silo Events", () => { + beforeEach(() => { + initL1Version(); + }); afterEach(() => { clearStore(); }); diff --git a/projects/subgraph-beanstalk/tests/Yield.test.ts b/projects/subgraph-beanstalk/tests/Yield.test.ts index 0c02a5aec7..bd78503f26 100644 --- a/projects/subgraph-beanstalk/tests/Yield.test.ts +++ b/projects/subgraph-beanstalk/tests/Yield.test.ts @@ -1,5 +1,5 @@ import { BigInt, BigDecimal, log, Bytes } from "@graphprotocol/graph-ts"; -import { assert, describe, test } from "matchstick-as/assembly/index"; +import { assert, beforeEach, describe, test } from "matchstick-as/assembly/index"; import { BigDecimal_isClose, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { loadSilo, loadSiloAsset, loadSiloYield, loadTokenYield, loadWhitelistTokenSetting } from "../src/entities/Silo"; import { @@ -14,8 +14,12 @@ import { import { setSeason } from "./utils/Season"; import { calculateAPYPreGauge } from "../src/utils/legacy/LegacyYield"; import { calculateGaugeVAPYs, updateSiloVAPYs } from "../src/utils/Yield"; +import { initL1Version } from "./entity-mocking/MockVersion"; describe("APY Calculations", () => { + beforeEach(() => { + initL1Version(); + }); describe("Pre-Gauge", () => { test("No Bean mints", () => { const apy = calculateAPYPreGauge( diff --git a/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts b/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts new file mode 100644 index 0000000000..bfc1a8a7dc --- /dev/null +++ b/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts @@ -0,0 +1,7 @@ +import { BigInt } from "@graphprotocol/graph-ts"; +import { handleInitVersion } from "../../src/utils/constants/Version"; +import { mockBlock } from "../../../subgraph-core/tests/event-mocking/Block"; + +export function initL1Version(): void { + handleInitVersion(mockBlock(BigInt.fromU32(12974075))); +} diff --git a/projects/subgraph-core/constants/BeanstalkEth.ts b/projects/subgraph-core/constants/BeanstalkEth.ts index fc98d477fd..134ea5c15d 100644 --- a/projects/subgraph-core/constants/BeanstalkEth.ts +++ b/projects/subgraph-core/constants/BeanstalkEth.ts @@ -1,15 +1,19 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { BEAN_3CRV, + BEAN_3CRV_V1, BEAN_ERC20, BEAN_ERC20_V1, + BEAN_LUSD_V1, BEAN_WETH_CP2_WELL, BEAN_WETH_UNRIPE_MIGRATION_BLOCK, + BEAN_WETH_V1, BEAN_WSTETH_CP2_WELL, BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK, BEANSTALK, BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, + FERTILIZER, GAUGE_BIP45_BLOCK, NEW_BEAN_TOKEN_BLOCK, PRICE_2_BLOCK, @@ -27,6 +31,10 @@ export function getProtocolToken(blockNumber: BigInt): Address { } } +export function getProtocolFertilizer(): Address { + return FERTILIZER; +} + export function getUnripeBeanAddr(): Address { return UNRIPE_BEAN; } @@ -45,6 +53,31 @@ export function isUnripe(token: Address): boolean { return false; } +export function getTokenDecimals(token: Address): i32 { + if (token == BEAN_ERC20) { + return 6; + } else if (token == UNRIPE_BEAN) { + return 6; + } else if (token == UNRIPE_LP) { + return 6; + } else if (token == BEAN_3CRV) { + return 18; + } else if (token == BEAN_WETH_CP2_WELL) { + return 18; + } else if (token == BEAN_WSTETH_CP2_WELL) { + return 18; + } else if (token == BEAN_ERC20_V1) { + return 6; + } else if (token == BEAN_WETH_V1) { + return 18; + } else if (token == BEAN_3CRV_V1) { + return 18; + } else if (token == BEAN_LUSD_V1) { + return 18; + } + throw new Error("Unsupported token"); +} + /// MILESTONE /// export function isGaugeDeployed(blockNumber: BigInt): boolean { diff --git a/projects/subgraph-core/constants/RuntimeConstants.ts b/projects/subgraph-core/constants/RuntimeConstants.ts index 5241a6f00e..49067bd006 100644 --- a/projects/subgraph-core/constants/RuntimeConstants.ts +++ b/projects/subgraph-core/constants/RuntimeConstants.ts @@ -18,6 +18,13 @@ export function getProtocolToken(v: VersionDto, blockNumber: BigInt): Address { throw new Error("Unsupported protocol"); } +export function getProtocolFertilizer(v: VersionDto): Address | null { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.getProtocolFertilizer(); + } + throw new Error("Unsupported protocol"); +} + export function getUnripeBeanAddr(v: VersionDto): Address { if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { return BeanstalkEth.getUnripeBeanAddr(); @@ -39,6 +46,13 @@ export function isUnripe(v: VersionDto, token: Address): boolean { throw new Error("Unsupported protocol"); } +export function getTokenDecimals(v: VersionDto, token: Address): i32 { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.getTokenDecimals(token); + } + throw new Error("Unsupported protocol"); +} + /// MILESTONE /// export function isGaugeDeployed(v: VersionDto, blockNumber: BigInt): boolean { From 40e21d78993944d7a4074e94eb70f614c7c650c1 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:51:13 -0700 Subject: [PATCH 19/88] remove unnecessary fields --- projects/subgraph-beanstalk/schema.graphql | 6 +- .../src/entities/Beanstalk.ts | 30 ++-- .../src/entities/PodMarketplace.ts | 18 +-- .../src/entities/snapshots/Field.ts | 18 +-- .../src/entities/snapshots/Marketplace.ts | 14 +- .../src/entities/snapshots/Silo.ts | 14 +- .../src/entities/snapshots/SiloAsset.ts | 14 +- .../src/entities/snapshots/UnripeToken.ts | 14 +- .../snapshots/WhitelistTokenSetting.ts | 18 +-- .../src/handlers/BeanHandler.ts | 10 +- .../src/handlers/FieldHandler.ts | 11 +- .../src/handlers/GaugeHandler.ts | 18 +-- .../src/handlers/SeasonHandler.ts | 24 +-- .../src/handlers/SiloHandler.ts | 12 +- .../handlers/legacy/LegacySeasonHandler.ts | 6 +- .../src/handlers/legacy/LegacySiloHandler.ts | 8 +- .../subgraph-beanstalk/src/utils/Field.ts | 137 ++++------------ .../src/utils/Marketplace.ts | 152 ++++-------------- .../subgraph-beanstalk/src/utils/Season.ts | 2 +- projects/subgraph-beanstalk/src/utils/Silo.ts | 58 +++---- .../subgraph-beanstalk/src/utils/Yield.ts | 10 +- .../src/utils/legacy/LegacyField.ts | 10 ++ .../src/utils/legacy/LegacySilo.ts | 14 +- .../tests/MarketplaceV1.test.ts | 105 ++++-------- .../tests/MarketplaceV2.test.ts | 83 +++------- .../subgraph-beanstalk/tests/utils/Season.ts | 3 +- 26 files changed, 265 insertions(+), 544 deletions(-) create mode 100644 projects/subgraph-beanstalk/src/utils/legacy/LegacyField.ts diff --git a/projects/subgraph-beanstalk/schema.graphql b/projects/subgraph-beanstalk/schema.graphql index d3bd6f59c7..fd8e0d9679 100644 --- a/projects/subgraph-beanstalk/schema.graphql +++ b/projects/subgraph-beanstalk/schema.graphql @@ -34,10 +34,8 @@ enum EmaWindow { } type Beanstalk @entity { - "Smart contract address of the protocol's main contract (Factory, Registry, etc) " + "'beanstalk'" id: ID! - "Name of the protocol, including version. e.g. Uniswap v3" - name: String! "Bean token address of the protocol" token: String! "Address of the fertilizer contract" @@ -713,7 +711,7 @@ type Plot @entity { } type PodMarketplace @entity { - "Contract address of beanstalk" + "Field id" id: ID! "Current season of the marketplace" season: Int! diff --git a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts index 0bc4a27af2..834e04a94a 100644 --- a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts +++ b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts @@ -6,11 +6,10 @@ import { BI_MAX, ONE_BI, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/D import { getProtocolFertilizer, getProtocolToken } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; -export function loadBeanstalk(protocol: Address): Beanstalk { - let beanstalk = Beanstalk.load(protocol.toHexString()); +export function loadBeanstalk(): Beanstalk { + let beanstalk = Beanstalk.load("beanstalk"); if (beanstalk == null) { - beanstalk = new Beanstalk(protocol.toHexString()); - beanstalk.name = "Beanstalk"; + beanstalk = new Beanstalk("beanstalk"); // Pre-replant token currently would not be set beanstalk.token = getProtocolToken(v(), BI_MAX).toHexString(); const fert = getProtocolFertilizer(v()); @@ -34,11 +33,11 @@ export function loadFarmer(account: Address): Farmer { return farmer; } -export function loadSeason(diamondAddress: Address, id: BigInt): Season { +export function loadSeason(id: BigInt): Season { let season = Season.load(id.toString()); if (season == null) { season = new Season(id.toString()); - season.beanstalk = diamondAddress.toHexString(); + season.beanstalk = "beanstalk"; season.season = id.toI32(); season.sunriseBlock = ZERO_BI; season.createdAt = ZERO_BI; @@ -52,27 +51,22 @@ export function loadSeason(diamondAddress: Address, id: BigInt): Season { season.harvestableIndex = ZERO_BI; season.save(); if (id > ZERO_BI) { - let lastSeason = loadSeason(diamondAddress, id.minus(ONE_BI)); + let lastSeason = loadSeason(id.minus(ONE_BI)); season.beans = lastSeason.beans; season.harvestableIndex = lastSeason.harvestableIndex; season.save(); } // Update beanstalk season - let beanstalk = loadBeanstalk(diamondAddress); + let beanstalk = loadBeanstalk(); beanstalk.lastSeason = season.season; beanstalk.save(); } return season; } -export function getBeanstalkToken(protocol: Address): Address { - let beanstalkEntity = loadBeanstalk(protocol); - return Address.fromString(beanstalkEntity.token); -} - -export function getCurrentSeason(protocol: Address): i32 { - let beanstalkEntity = loadBeanstalk(protocol); +export function getCurrentSeason(): i32 { + let beanstalkEntity = loadBeanstalk(); return beanstalkEntity.lastSeason; } @@ -85,8 +79,8 @@ export function getRewardMinted(season: i32): BigInt { return snapshot.rewardBeans; } -export function getHarvestableIndex(protocol: Address): BigInt { - let bs = loadBeanstalk(protocol); - let season = loadSeason(protocol, BigInt.fromI32(bs.lastSeason)); +export function getHarvestableIndex(): BigInt { + let bs = loadBeanstalk(); + let season = loadSeason(BigInt.fromI32(bs.lastSeason)); return season.harvestableIndex; } diff --git a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts index 2dc5327713..478c669938 100644 --- a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts +++ b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts @@ -1,15 +1,13 @@ import { Address, BigInt, Bytes, log } from "@graphprotocol/graph-ts"; -import { loadField } from "./Field"; import { PodFill, PodListing, PodMarketplace, PodOrder } from "../../generated/schema"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { getCurrentSeason } from "./Beanstalk"; -export function loadPodMarketplace(protocol: Address): PodMarketplace { - let marketplace = PodMarketplace.load(protocol.toHexString()); +export function loadPodMarketplace(): PodMarketplace { + let marketplace = PodMarketplace.load("0"); if (marketplace == null) { - let field = loadField(protocol); - marketplace = new PodMarketplace(protocol.toHexString()); - marketplace.season = field.season; + marketplace = new PodMarketplace("0"); + marketplace.season = getCurrentSeason(); marketplace.activeListings = []; marketplace.activeOrders = []; marketplace.listedPods = ZERO_BI; @@ -34,7 +32,7 @@ export function loadPodFill(protocol: Address, index: BigInt, hash: String): Pod let fill = PodFill.load(id); if (fill == null) { fill = new PodFill(id); - fill.podMarketplace = protocol.toHexString(); + fill.podMarketplace = "0"; fill.createdAt = ZERO_BI; fill.fromFarmer = ""; fill.toFarmer = ""; @@ -53,7 +51,7 @@ export function loadPodListing(account: Address, index: BigInt): PodListing { let listing = PodListing.load(id); if (listing == null) { listing = new PodListing(id); - listing.podMarketplace = BEANSTALK.toHexString(); + listing.podMarketplace = "0"; listing.historyID = ""; listing.plot = index.toString(); listing.farmer = account.toHexString(); @@ -117,7 +115,7 @@ export function loadPodOrder(orderID: Bytes): PodOrder { let order = PodOrder.load(orderID.toHexString()); if (order == null) { order = new PodOrder(orderID.toHexString()); - order.podMarketplace = BEANSTALK.toHexString(); + order.podMarketplace = "0"; order.historyID = ""; order.farmer = ""; order.createdAt = ZERO_BI; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts index d33671c2ed..0ed8c755df 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts @@ -1,13 +1,13 @@ -import { BigInt, Address, log } from "@graphprotocol/graph-ts"; +import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Field, FieldDailySnapshot, FieldHourlySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; -export function takeFieldSnapshots(field: Field, protocol: Address, timestamp: BigInt, blockNumber: BigInt): void { - const currentSeason = getCurrentSeason(protocol); +export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); - const hour = BigInt.fromI32(hourFromTimestamp(timestamp)); - const day = BigInt.fromI32(dayFromTimestamp(timestamp)); + const hour = BigInt.fromI32(hourFromTimestamp(block.timestamp)); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); // Load the snapshot for this season/day const hourlyId = field.id + "-" + currentSeason.toString(); @@ -78,7 +78,7 @@ export function takeFieldSnapshots(field: Field, protocol: Address, timestamp: B // Sets initial creation values hourly.issuedSoil = field.soil; hourly.deltaIssuedSoil = field.soil.minus(baseHourly.issuedSoil); - hourly.seasonBlock = blockNumber; + hourly.seasonBlock = block.number; hourly.soilSoldOut = false; } } else { @@ -97,11 +97,11 @@ export function takeFieldSnapshots(field: Field, protocol: Address, timestamp: B // Sets initial creation values hourly.issuedSoil = field.soil; hourly.deltaIssuedSoil = field.soil; - hourly.seasonBlock = blockNumber; + hourly.seasonBlock = block.number; hourly.soilSoldOut = false; } hourly.createdAt = hour; - hourly.updatedAt = timestamp; + hourly.updatedAt = block.timestamp; hourly.save(); // Repeat for daily snapshot. @@ -174,7 +174,7 @@ export function takeFieldSnapshots(field: Field, protocol: Address, timestamp: B daily.deltaIssuedSoil = field.soil; } daily.createdAt = day; - daily.updatedAt = timestamp; + daily.updatedAt = block.timestamp; daily.save(); field.lastHourlySnapshotSeason = currentSeason; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Marketplace.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Marketplace.ts index d3203079f3..4b99d34c7d 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Marketplace.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Marketplace.ts @@ -1,13 +1,13 @@ -import { BigInt, Address, log } from "@graphprotocol/graph-ts"; +import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { PodMarketplace, PodMarketplaceDailySnapshot, PodMarketplaceHourlySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; -export function takeMarketSnapshots(market: PodMarketplace, protocol: Address, timestamp: BigInt): void { - const currentSeason = getCurrentSeason(protocol); +export function takeMarketSnapshots(market: PodMarketplace, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); - const hour = BigInt.fromI32(hourFromTimestamp(timestamp)); - const day = BigInt.fromI32(dayFromTimestamp(timestamp)); + const hour = BigInt.fromI32(hourFromTimestamp(block.timestamp)); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); // Load the snapshot for this season/day const hourlyId = market.id + "-" + currentSeason.toString(); @@ -84,7 +84,7 @@ export function takeMarketSnapshots(market: PodMarketplace, protocol: Address, t hourly.deltaBeanVolume = hourly.beanVolume; } hourly.createdAt = hour; - hourly.updatedAt = timestamp; + hourly.updatedAt = block.timestamp; hourly.save(); // Repeat for daily snapshot. @@ -148,7 +148,7 @@ export function takeMarketSnapshots(market: PodMarketplace, protocol: Address, t daily.deltaBeanVolume = daily.beanVolume; } daily.createdAt = day; - daily.updatedAt = timestamp; + daily.updatedAt = block.timestamp; daily.save(); market.lastHourlySnapshotSeason = currentSeason; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts index a0d06279f9..b2bd119ad3 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts @@ -1,13 +1,13 @@ -import { BigInt, Address, log } from "@graphprotocol/graph-ts"; +import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Silo, SiloDailySnapshot, SiloHourlySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; -export function takeSiloSnapshots(silo: Silo, protocol: Address, timestamp: BigInt): void { - const currentSeason = getCurrentSeason(protocol); +export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); - const hour = BigInt.fromI32(hourFromTimestamp(timestamp)); - const day = BigInt.fromI32(dayFromTimestamp(timestamp)); + const hour = BigInt.fromI32(hourFromTimestamp(block.timestamp)); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); // Load the snapshot for this season/day const hourlyId = silo.id + "-" + currentSeason.toString(); @@ -74,7 +74,7 @@ export function takeSiloSnapshots(silo: Silo, protocol: Address, timestamp: BigI hourly.deltaActiveFarmers = hourly.activeFarmers; } hourly.createdAt = hour; - hourly.updatedAt = timestamp; + hourly.updatedAt = block.timestamp; hourly.save(); // Repeat for daily snapshot. @@ -126,7 +126,7 @@ export function takeSiloSnapshots(silo: Silo, protocol: Address, timestamp: BigI daily.deltaActiveFarmers = daily.activeFarmers; } daily.createdAt = day; - daily.updatedAt = timestamp; + daily.updatedAt = block.timestamp; daily.save(); silo.lastHourlySnapshotSeason = currentSeason; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/SiloAsset.ts b/projects/subgraph-beanstalk/src/entities/snapshots/SiloAsset.ts index e9f9e72d10..826f4c7191 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/SiloAsset.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/SiloAsset.ts @@ -1,13 +1,13 @@ -import { BigInt, Address, log } from "@graphprotocol/graph-ts"; +import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { SiloAsset, SiloAssetDailySnapshot, SiloAssetHourlySnapshot } from "../../../generated/schema"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; import { getCurrentSeason } from "../Beanstalk"; -export function takeSiloAssetSnapshots(siloAsset: SiloAsset, protocol: Address, timestamp: BigInt): void { - const currentSeason = getCurrentSeason(protocol); +export function takeSiloAssetSnapshots(siloAsset: SiloAsset, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); - const hour = BigInt.fromI32(hourFromTimestamp(timestamp)); - const day = BigInt.fromI32(dayFromTimestamp(timestamp)); + const hour = BigInt.fromI32(hourFromTimestamp(block.timestamp)); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); // Load the snapshot for this season/day const hourlyId = siloAsset.id + "-" + currentSeason.toString(); @@ -52,7 +52,7 @@ export function takeSiloAssetSnapshots(siloAsset: SiloAsset, protocol: Address, hourly.deltaFarmAmount = hourly.farmAmount; } hourly.createdAt = hour; - hourly.updatedAt = timestamp; + hourly.updatedAt = block.timestamp; hourly.save(); // Repeat for daily snapshot. @@ -84,7 +84,7 @@ export function takeSiloAssetSnapshots(siloAsset: SiloAsset, protocol: Address, daily.deltaFarmAmount = daily.farmAmount; } daily.createdAt = day; - daily.updatedAt = timestamp; + daily.updatedAt = block.timestamp; daily.save(); siloAsset.lastHourlySnapshotSeason = currentSeason; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/UnripeToken.ts b/projects/subgraph-beanstalk/src/entities/snapshots/UnripeToken.ts index 084599bc06..d9557f8f89 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/UnripeToken.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/UnripeToken.ts @@ -1,13 +1,13 @@ -import { BigInt, Address, log } from "@graphprotocol/graph-ts"; +import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { UnripeToken, UnripeTokenDailySnapshot, UnripeTokenHourlySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; -export function takeUnripeTokenSnapshots(unripeToken: UnripeToken, protocol: Address, timestamp: BigInt): void { - const currentSeason = getCurrentSeason(protocol); +export function takeUnripeTokenSnapshots(unripeToken: UnripeToken, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); - const hour = BigInt.fromI32(hourFromTimestamp(timestamp)); - const day = BigInt.fromI32(dayFromTimestamp(timestamp)); + const hour = BigInt.fromI32(hourFromTimestamp(block.timestamp)); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); // Load the snapshot for this season/day const hourlyId = unripeToken.id.toHexString() + "-" + currentSeason.toString(); @@ -80,7 +80,7 @@ export function takeUnripeTokenSnapshots(unripeToken: UnripeToken, protocol: Add hourly.deltaTotalChoppedBdvReceived = hourly.totalChoppedBdvReceived; } hourly.createdAt = hour; - hourly.updatedAt = timestamp; + hourly.updatedAt = block.timestamp; hourly.save(); // Repeat for daily snapshot. @@ -140,7 +140,7 @@ export function takeUnripeTokenSnapshots(unripeToken: UnripeToken, protocol: Add daily.deltaTotalChoppedBdvReceived = daily.totalChoppedBdvReceived; } daily.createdAt = day; - daily.updatedAt = timestamp; + daily.updatedAt = block.timestamp; daily.save(); unripeToken.lastHourlySnapshotSeason = currentSeason; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts b/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts index 2b08a6831e..68527b1596 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts @@ -1,17 +1,13 @@ -import { BigInt, Address, log } from "@graphprotocol/graph-ts"; +import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { WhitelistTokenSetting, WhitelistTokenHourlySnapshot, WhitelistTokenDailySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; -export function takeWhitelistTokenSettingSnapshots( - whitelistTokenSetting: WhitelistTokenSetting, - protocol: Address, - timestamp: BigInt -): void { - const currentSeason = getCurrentSeason(protocol); +export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: WhitelistTokenSetting, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); - const hour = BigInt.fromI32(hourFromTimestamp(timestamp)); - const day = BigInt.fromI32(dayFromTimestamp(timestamp)); + const hour = BigInt.fromI32(hourFromTimestamp(block.timestamp)); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); // Load the snapshot for this season/day const hourlyId = whitelistTokenSetting.id.toHexString() + "-" + currentSeason.toString(); @@ -83,7 +79,7 @@ export function takeWhitelistTokenSettingSnapshots( hourly.deltaOptimalPercentDepositedBdv = hourly.optimalPercentDepositedBdv; } hourly.createdAt = hour; - hourly.updatedAt = timestamp; + hourly.updatedAt = block.timestamp; hourly.save(); // Repeat for daily snapshot. @@ -138,7 +134,7 @@ export function takeWhitelistTokenSettingSnapshots( daily.deltaOptimalPercentDepositedBdv = daily.optimalPercentDepositedBdv; } daily.createdAt = day; - daily.updatedAt = timestamp; + daily.updatedAt = block.timestamp; daily.save(); whitelistTokenSetting.lastHourlySnapshotSeason = currentSeason; diff --git a/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts b/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts index 392746236b..2f4d2da386 100644 --- a/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/BeanHandler.ts @@ -1,15 +1,13 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Transfer } from "../../generated/Beanstalk-ABIs/ERC20"; -import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; -import { v } from "../utils/constants/Version"; export function handleTransfer(event: Transfer): void { if (event.params.from == ADDRESS_ZERO || event.params.to == ADDRESS_ZERO) { - let beanstalk = loadBeanstalk(v().protocolAddress); - let season = loadSeason(v().protocolAddress, BigInt.fromI32(beanstalk.lastSeason)); + let beanstalk = loadBeanstalk(); + let season = loadSeason(BigInt.fromI32(beanstalk.lastSeason)); if (event.params.from == ADDRESS_ZERO) { season.deltaBeans = season.deltaBeans.plus(event.params.value); @@ -23,8 +21,8 @@ export function handleTransfer(event: Transfer): void { } export function handleExploit(block: ethereum.Block): void { - let beanstalk = loadBeanstalk(BEANSTALK); - let season = loadSeason(BEANSTALK, BigInt.fromI32(beanstalk.lastSeason)); + let beanstalk = loadBeanstalk(); + let season = loadSeason(BigInt.fromI32(beanstalk.lastSeason)); season.deltaBeans = ZERO_BI; season.beans = ZERO_BI; season.price = BigDecimal.fromString("1.022"); diff --git a/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts b/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts index 9ef189faa0..c7bae4f985 100644 --- a/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts @@ -1,16 +1,9 @@ -import { BigInt, log } from "@graphprotocol/graph-ts"; -import { BEANSTALK_FARMS } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; -import { loadField } from "../entities/Field"; import { harvest, plotTransfer, sow, temperatureChanged } from "../utils/Field"; import { Sow, Harvest, PlotTransfer, TemperatureChange } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { legacySowAmount } from "../utils/legacy/LegacyField"; -// TODO: add legacy field for the part using beanstalk farms address export function handleSow(event: Sow): void { - let sownOverride: BigInt | null = null; - if (event.params.account == BEANSTALK_FARMS) { - let startingField = loadField(event.address); - sownOverride = startingField.soil; - } + let sownOverride = legacySowAmount(event.address, event.params.account); sow({ event, account: event.params.account, diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index 87f79a6093..e0cf5cc38f 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -37,7 +37,7 @@ export function handleBeanToMaxLpGpPerBdvRatioChange(event: BeanToMaxLpGpPerBdvR } else { silo.beanToMaxLpGpPerBdvRatio = silo.beanToMaxLpGpPerBdvRatio!.plus(event.params.absChange); } - takeSiloSnapshots(silo, event.address, event.block.timestamp); + takeSiloSnapshots(silo, event.block); setSiloHourlyCaseId(event.params.caseId, silo); silo.save(); } @@ -47,7 +47,7 @@ export function handleGaugePointChange(event: GaugePointChange): void { siloSettings.gaugePoints = event.params.gaugePoints; siloSettings.updatedAt = event.block.timestamp; - takeWhitelistTokenSettingSnapshots(siloSettings, event.address, event.block.timestamp); + takeWhitelistTokenSettingSnapshots(siloSettings, event.block); siloSettings.save(); } @@ -58,7 +58,7 @@ export function handleUpdateAverageStalkPerBdvPerSeason(event: UpdateAverageStal // In practice, seed values for non-gauge assets are negligible. // The correct approach is iterating whitelisted assets each season, multipying bdv and seeds silo.grownStalkPerSeason = silo.depositedBDV.times(event.params.newStalkPerBdvPerSeason); - takeSiloSnapshots(silo, event.address, event.block.timestamp); + takeSiloSnapshots(silo, event.block); silo.save(); // Individual asset grown stalk is set by the UpdatedStalkPerBdvPerSeason event. @@ -72,7 +72,7 @@ export function handleFarmerGerminatingStalkBalanceChanged(event: FarmerGerminat return; } - const currentSeason = getCurrentSeason(event.address); + const currentSeason = getCurrentSeason(); if (event.params.deltaGerminatingStalk > ZERO_BI) { // Germinating stalk is added. It is possible to begin germination in the prior season rather than the @@ -105,7 +105,7 @@ export function handleFarmerGerminatingStalkBalanceChanged(event: FarmerGerminat // into system stalk upon sunrise for season - 2. let systemSilo = loadSilo(event.address); systemSilo.stalk = systemSilo.stalk.plus(actualDeltaGerminatingStalk); - takeSiloSnapshots(systemSilo, event.address, event.block.timestamp); + takeSiloSnapshots(systemSilo, event.block); systemSilo.save(); } @@ -115,7 +115,7 @@ export function handleFarmerGerminatingStalkBalanceChanged(event: FarmerGerminat let farmerSilo = loadSilo(event.params.account); farmerSilo.germinatingStalk = farmerSilo.germinatingStalk.plus(event.params.deltaGerminatingStalk); - takeSiloSnapshots(farmerSilo, event.address, event.block.timestamp); + takeSiloSnapshots(farmerSilo, event.block); farmerSilo.save(); } @@ -177,14 +177,14 @@ export function handleTotalGerminatingStalkChanged(event: TotalGerminatingStalkC let silo = loadSilo(event.address); silo.germinatingStalk = silo.germinatingStalk.plus(event.params.deltaGerminatingStalk); - takeSiloSnapshots(silo, event.address, event.block.timestamp); + takeSiloSnapshots(silo, event.block); silo.save(); } // Germination completes, germinating stalk turns into stalk. // The removal of Germinating stalk would have already been handled from a separate emission export function handleTotalStalkChangedFromGermination(event: TotalStalkChangedFromGermination): void { - updateStalkBalances(event.address, event.address, event.params.deltaStalk, event.params.deltaRoots, event.block.timestamp); + updateStalkBalances(event.address, event.address, event.params.deltaStalk, event.params.deltaRoots, event.block); } // GAUGE CONFIGURATION SETTINGS // @@ -204,6 +204,6 @@ export function handleUpdateGaugeSettings(event: UpdateGaugeSettings): void { siloSettings.gaugePoints = BI_10.pow(20); } - takeWhitelistTokenSettingSnapshots(siloSettings, event.address, event.block.timestamp); + takeWhitelistTokenSettingSnapshots(siloSettings, event.block); siloSettings.save(); } diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index b790e9d394..c6b3d8c89d 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -1,6 +1,6 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { Reward, Soil, WellOracle, Sunrise, Incentivization, SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { BEANSTALK, GAUGE_BIP45_BLOCK, REPLANT_SEASON } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { REPLANT_SEASON } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal, ZERO_BD } from "../../../subgraph-core/utils/Decimals"; import { updateStalkWithCalls } from "../utils/legacy/LegacySilo"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; @@ -20,13 +20,13 @@ import { v } from "../utils/constants/Version"; export function handleSunrise(event: Sunrise): void { // (Legacy) Update any farmers that had silo transfers from the prior season. // This is intentionally done before beanstalk.lastSeason gets updated - updateStalkWithCalls(event.address, event.block.timestamp); + updateStalkWithCalls(event.address, event.block); sunrise(event.address, event.params.season, event.block); } export function handleReward(event: Reward): void { - let season = loadSeason(event.address, event.params.season); + let season = loadSeason(event.params.season); season.rewardBeans = event.params.toField.plus(event.params.toSilo).plus(event.params.toFertilizer); season.save(); @@ -40,7 +40,7 @@ export function handleReward(event: Reward): void { silo.plantableStalk = silo.plantableStalk.plus(newPlantableStalk); silo.depositedBDV = silo.depositedBDV.plus(event.params.toSilo); - takeSiloSnapshots(silo, event.address, event.block.timestamp); + takeSiloSnapshots(silo, event.block); silo.save(); updateDepositInSiloAsset( @@ -49,12 +49,12 @@ export function handleReward(event: Reward): void { getProtocolToken(v(), event.block.number), event.params.toSilo, event.params.toSilo, - event.block.timestamp + event.block ); } export function handleWellOracle(event: WellOracle): void { - let season = loadSeason(event.address, event.params.season); + let season = loadSeason(event.params.season); season.deltaB = season.deltaB.plus(event.params.deltaB); if (isGaugeDeployed(v(), event.block.number) && season.price == ZERO_BD) { let beanstalkPrice = getBeanstalkPrice(event.block.number); @@ -72,7 +72,7 @@ export function handleSoil(event: Soil): void { field.season = event.params.season.toI32(); field.soil = event.params.soil; - takeFieldSnapshots(field, event.address, event.block.timestamp, event.block.number); + takeFieldSnapshots(field, event.block); field.save(); if (event.params.season >= REPLANT_SEASON) { @@ -83,15 +83,15 @@ export function handleSoil(event: Soil): void { // This is the final function to be called during sunrise both pre and post replant export function handleIncentive(event: Incentivization): void { // Update market cap for season - let beanstalk = loadBeanstalk(event.address); - let beanstalk_contract = SeedGauge.bind(BEANSTALK); - let season = loadSeason(event.address, BigInt.fromI32(beanstalk.lastSeason)); + let beanstalk = loadBeanstalk(); + let beanstalk_contract = SeedGauge.bind(event.address); + let season = loadSeason(BigInt.fromI32(beanstalk.lastSeason)); season.marketCap = season.price.times(toDecimal(season.beans)); season.incentiveBeans = event.params.beans; season.harvestableIndex = beanstalk_contract.harvestableIndex(); season.save(); - updateExpiredPlots(event.address, season.harvestableIndex, event.block.timestamp); - updateHarvestablePlots(event.address, season.harvestableIndex, event.block.timestamp, event.block.number); + updateExpiredPlots(season.harvestableIndex, event.block); + updateHarvestablePlots(event.address, season.harvestableIndex, event.block); } diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index aa319d32d0..1d6bae3f8f 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -105,7 +105,7 @@ export function handlePlant(event: Plant): void { silo.plantableStalk = silo.plantableStalk.minus(newPlantableStalk); silo.depositedBDV = silo.depositedBDV.minus(event.params.beans); - takeSiloSnapshots(silo, event.address, event.block.timestamp); + takeSiloSnapshots(silo, event.block); silo.save(); // Remove the asset-only amount that got added in Reward event handler. @@ -116,7 +116,7 @@ export function handlePlant(event: Plant): void { getProtocolToken(v(), event.block.number), event.params.beans, event.params.beans, - event.block.timestamp + event.block ); } @@ -134,7 +134,7 @@ export function handleWhitelistToken(event: WhitelistToken): void { siloSettings.optimalPercentDepositedBdv = event.params.optimalPercentDepositedBdv; siloSettings.updatedAt = event.block.timestamp; - takeWhitelistTokenSettingSnapshots(siloSettings, event.address, event.block.timestamp); + takeWhitelistTokenSettingSnapshots(siloSettings, event.block); siloSettings.save(); } @@ -157,17 +157,17 @@ export function handleUpdatedStalkPerBdvPerSeason(event: UpdatedStalkPerBdvPerSe siloSettings.stalkEarnedPerSeason = event.params.stalkEarnedPerSeason; siloSettings.updatedAt = event.block.timestamp; - takeWhitelistTokenSettingSnapshots(siloSettings, event.address, event.block.timestamp); + takeWhitelistTokenSettingSnapshots(siloSettings, event.block); siloSettings.save(); } // Withdrawal is a legacy feature from replant, but these events are still present export function handleRemoveWithdrawal(event: RemoveWithdrawal): void { - updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.season, event.block.timestamp); + updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.season, event.block); } export function handleRemoveWithdrawals(event: RemoveWithdrawals): void { for (let i = 0; i < event.params.seasons.length; i++) { - updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.seasons[i], event.block.timestamp); + updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.seasons[i], event.block); } } diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts index 522c825149..3f687b31cf 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts @@ -17,7 +17,7 @@ export function handleReplantSunrise(event: Sunrise): void { // Replant oracle initialization if (event.params.season == REPLANT_SEASON) { - let seasonEntity = loadSeason(event.address, event.params.season); + let seasonEntity = loadSeason(event.params.season); seasonEntity.price = BigDecimal.fromString("1.07"); seasonEntity.save(); } @@ -27,14 +27,14 @@ export function handleReplantSunrise(event: Sunrise): void { // PreReplant -> Replanted export function handleSeasonSnapshot(event: SeasonSnapshot): void { - let season = loadSeason(event.address, event.params.season); + let season = loadSeason(event.params.season); season.price = toDecimal(event.params.price, 18); season.save(); } // Replanted -> SeedGauge export function handleMetapoolOracle(event: MetapoolOracle): void { - let season = loadSeason(event.address, event.params.season); + let season = loadSeason(event.params.season); // Attempt to pull from Beanstalk Price contract first let beanstalkQuery = BeanstalkPrice_try_price(event.address, event.block.number); if (beanstalkQuery.reverted) { diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index 75ced01685..a8cf5cc632 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -77,7 +77,7 @@ export function handleAddWithdrawal(event: AddWithdrawal): void { // Replant -> SiloV3 export function handleTransferDepositCall(call: TransferDepositCall): void { - let beanstalk = loadBeanstalk(call.to); + let beanstalk = loadBeanstalk(); let updateFarmers = beanstalk.farmersToUpdate; if (updateFarmers.indexOf(call.from.toHexString()) == -1) { updateFarmers.push(call.from.toHexString()); @@ -91,7 +91,7 @@ export function handleTransferDepositCall(call: TransferDepositCall): void { // Replant -> SiloV3 export function handleTransferDepositsCall(call: TransferDepositsCall): void { - let beanstalk = loadBeanstalk(call.to); + let beanstalk = loadBeanstalk(); let updateFarmers = beanstalk.farmersToUpdate; if (updateFarmers.indexOf(call.from.toHexString()) == -1) { updateFarmers.push(call.from.toHexString()); @@ -112,7 +112,7 @@ export function handleWhitelistToken_v2(event: WhitelistToken_v2): void { setting.stalkIssuedPerBdv = BigInt.fromString("10000000000"); setting.stalkEarnedPerSeason = event.params.stalk.times(BigInt.fromI32(1000000)); - takeWhitelistTokenSettingSnapshots(setting, event.address, event.block.timestamp); + takeWhitelistTokenSettingSnapshots(setting, event.block); setting.save(); } @@ -125,6 +125,6 @@ export function handleWhitelistToken_v3(event: WhitelistToken_v3): void { setting.stalkIssuedPerBdv = event.params.stalk.times(BigInt.fromI32(1_000_000)); setting.stalkEarnedPerSeason = event.params.stalkEarnedPerSeason; - takeWhitelistTokenSettingSnapshots(setting, event.address, event.block.timestamp); + takeWhitelistTokenSettingSnapshots(setting, event.block); setting.save(); } diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index 36e4df9119..eab9480ba7 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -45,18 +45,7 @@ export function sow(params: SowParams): void { const protocol = params.event.address; let sownBeans = params.beans; // Update Farmer Totals - updateFieldTotals( - protocol, - params.account, - ZERO_BI, - sownBeans, - params.pods, - ZERO_BI, - ZERO_BI, - ZERO_BI, - params.event.block.timestamp, - params.event.block.number - ); + updateFieldTotals(protocol, params.account, ZERO_BI, sownBeans, params.pods, ZERO_BI, ZERO_BI, ZERO_BI, params.event.block); let field = loadField(protocol); loadFarmer(params.account); @@ -79,55 +68,33 @@ export function sow(params: SowParams): void { plot.beansPerPod = params.beans.times(BI_10.pow(6)).div(plot.pods); plot.save(); - incrementSows(protocol, params.account, params.event.block.timestamp, params.event.block.number); + incrementSows(protocol, params.account, params.event.block); } export function harvest(params: HarvestParams): void { const protocol = params.event.address; - let beanstalk = loadBeanstalk(protocol); - let season = loadSeason(protocol, BigInt.fromI32(beanstalk.lastSeason)); + let beanstalk = loadBeanstalk(); + let season = loadSeason(BigInt.fromI32(beanstalk.lastSeason)); let remainingIndex = ZERO_BI; for (let i = 0; i < params.plots.length; i++) { // Plot should exist let plot = loadPlot(protocol, params.plots[i]); - expirePodListingIfExists(protocol, plot.farmer, plot.index, params.event.block.timestamp); + expirePodListingIfExists(plot.farmer, plot.index, params.event.block); let harvestablePods = season.harvestableIndex.minus(plot.index); if (harvestablePods >= plot.pods) { // Plot fully harvests - updateFieldTotals( - protocol, - params.account, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - plot.pods, - params.event.block.timestamp, - params.event.block.number - ); + updateFieldTotals(protocol, params.account, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, plot.pods, params.event.block); plot.harvestedPods = plot.pods; plot.fullyHarvested = true; plot.save(); } else { // Plot partially harvests - updateFieldTotals( - protocol, - params.account, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - harvestablePods, - params.event.block.timestamp, - params.event.block.number - ); + updateFieldTotals(protocol, params.account, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, harvestablePods, params.event.block); remainingIndex = plot.index.plus(harvestablePods); let remainingPods = plot.pods.minus(harvestablePods); @@ -170,7 +137,7 @@ export function harvest(params: HarvestParams): void { export function plotTransfer(params: PlotTransferParams): void { const protocol = params.event.address; - const currentHarvestable = getHarvestableIndex(protocol); + const currentHarvestable = getHarvestableIndex(); // Ensure both farmer entites exist loadFarmer(params.from); @@ -186,23 +153,10 @@ export function plotTransfer(params: PlotTransferParams): void { ZERO_BI.minus(params.amount), ZERO_BI, ZERO_BI, - params.event.block.timestamp, - params.event.block.number, - false - ); - updateFieldTotals( - protocol, - params.to, - ZERO_BI, - ZERO_BI, - ZERO_BI, - params.amount, - ZERO_BI, - ZERO_BI, - params.event.block.timestamp, - params.event.block.number, + params.event.block, false ); + updateFieldTotals(protocol, params.to, ZERO_BI, ZERO_BI, ZERO_BI, params.amount, ZERO_BI, ZERO_BI, params.event.block, false); let field = loadField(protocol); let sortedPlots = field.plotIndexes.sort(); @@ -384,23 +338,10 @@ export function plotTransfer(params: PlotTransferParams): void { ZERO_BI, ZERO_BI.minus(transferredHarvestable), ZERO_BI, - params.event.block.timestamp, - params.event.block.number, - false - ); - updateFieldTotals( - protocol, - params.to, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - transferredHarvestable, - ZERO_BI, - params.event.block.timestamp, - params.event.block.number, + params.event.block, false ); + updateFieldTotals(protocol, params.to, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, transferredHarvestable, ZERO_BI, params.event.block, false); } } @@ -411,12 +352,13 @@ export function temperatureChanged(params: TemperatureChangedParams): void { let field = loadField(protocol); field.temperature += params.absChange; - let seasonEntity = loadSeason(protocol, params.season); + let seasonEntity = loadSeason(params.season); let currentPrice = ZERO_BD; if (seasonEntity.price != ZERO_BD) { currentPrice = seasonEntity.price; } else { // Attempt to pull from Beanstalk Price contract first + // TODO: check whether protocol should be supplied here let beanstalkQuery = BeanstalkPrice_try_price(protocol, params.event.block.number); if (beanstalkQuery.reverted) { let curvePrice = CurvePrice.bind(CURVE_PRICE); @@ -428,7 +370,7 @@ export function temperatureChanged(params: TemperatureChangedParams): void { field.realRateOfReturn = ONE_BD.plus(BigDecimal.fromString((field.temperature / 100).toString())).div(currentPrice); - takeFieldSnapshots(field, protocol, params.event.block.timestamp, params.event.block.number); + takeFieldSnapshots(field, params.event.block); field.save(); // Set caseId on the hourly snapshot @@ -444,27 +386,15 @@ export function updateFieldTotals( transferredPods: BigInt, harvestablePods: BigInt, harvestedPods: BigInt, - timestamp: BigInt, - blockNumber: BigInt, + block: ethereum.Block, recurs: boolean = true ): void { if (recurs && account != protocol) { - updateFieldTotals( - protocol, - protocol, - soil, - sownBeans, - sownPods, - transferredPods, - harvestablePods, - harvestedPods, - timestamp, - blockNumber - ); + updateFieldTotals(protocol, protocol, soil, sownBeans, sownPods, transferredPods, harvestablePods, harvestedPods, block); } let field = loadField(account); - field.season = getCurrentSeason(protocol); + field.season = getCurrentSeason(); field.soil = field.soil.plus(soil).minus(sownBeans); field.sownBeans = field.sownBeans.plus(sownBeans); field.unharvestablePods = field.unharvestablePods.plus(sownPods).minus(harvestablePods).plus(transferredPods); @@ -472,16 +402,16 @@ export function updateFieldTotals( field.harvestedPods = field.harvestedPods.plus(harvestedPods); field.podIndex = field.podIndex.plus(sownPods); - takeFieldSnapshots(field, protocol, timestamp, blockNumber); + takeFieldSnapshots(field, block); field.save(); // Set extra info on the hourly snapshot if (field.soil == ZERO_BI) { - setHourlySoilSoldOut(blockNumber, field); + setHourlySoilSoldOut(block.number, field); } } -export function updateHarvestablePlots(protocol: Address, harvestableIndex: BigInt, timestamp: BigInt, blockNumber: BigInt): void { +export function updateHarvestablePlots(protocol: Address, harvestableIndex: BigInt, block: ethereum.Block): void { let field = loadField(protocol); let sortedIndexes = field.plotIndexes.sort(); @@ -503,42 +433,31 @@ export function updateHarvestablePlots(protocol: Address, harvestableIndex: BigI let deltaHarvestablePods = oldHarvestablePods == ZERO_BI ? plot.harvestablePods : plot.harvestablePods.minus(oldHarvestablePods); - updateFieldTotals( - protocol, - Address.fromString(plot.farmer), - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - deltaHarvestablePods, - ZERO_BI, - timestamp, - blockNumber - ); + updateFieldTotals(protocol, Address.fromString(plot.farmer), ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, deltaHarvestablePods, ZERO_BI, block); } } // Increment number of unique sowers (protocol only) -function incrementSowers(protocol: Address, timestamp: BigInt, blockNumber: BigInt): void { +function incrementSowers(protocol: Address, block: ethereum.Block): void { let field = loadField(protocol); field.numberOfSowers += 1; - takeFieldSnapshots(field, protocol, timestamp, blockNumber); + takeFieldSnapshots(field, block); field.save(); } // Increment total number of sows for either an account or the protocol -function incrementSows(protocol: Address, account: Address, timestamp: BigInt, blockNumber: BigInt, recurs: boolean = true): void { +function incrementSows(protocol: Address, account: Address, block: ethereum.Block, recurs: boolean = true): void { if (recurs && account != protocol) { - incrementSows(protocol, protocol, timestamp, blockNumber); + incrementSows(protocol, protocol, block); } let field = loadField(account); field.numberOfSows += 1; - takeFieldSnapshots(field, protocol, timestamp, blockNumber); + takeFieldSnapshots(field, block); field.save(); // Add to protocol numberOfSowers if this is the first time this account has sown if (account != protocol && field.numberOfSows == 0) { - incrementSowers(protocol, timestamp, blockNumber); + incrementSowers(protocol, block); } } diff --git a/projects/subgraph-beanstalk/src/utils/Marketplace.ts b/projects/subgraph-beanstalk/src/utils/Marketplace.ts index 70214835a6..71e2b098bf 100644 --- a/projects/subgraph-beanstalk/src/utils/Marketplace.ts +++ b/projects/subgraph-beanstalk/src/utils/Marketplace.ts @@ -126,22 +126,8 @@ export function podListingCreated(params: PodListingCreatedParams): void { plot.save(); /// Update market totals - updateActiveListings( - params.event.address, - MarketplaceAction.CREATED, - params.account.toHexString(), - listing.index, - listing.maxHarvestableIndex - ); - updateMarketListingBalances( - params.event.address, - params.event.address, - params.amount, - ZERO_BI, - ZERO_BI, - ZERO_BI, - params.event.block.timestamp - ); + updateActiveListings(MarketplaceAction.CREATED, params.account.toHexString(), listing.index, listing.maxHarvestableIndex); + updateMarketListingBalances(params.amount, ZERO_BI, ZERO_BI, ZERO_BI, params.event.block); /// Save raw event data let id = "podListingCreated-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); @@ -151,7 +137,7 @@ export function podListingCreated(params: PodListingCreatedParams): void { rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = listing.historyID; rawEvent.account = params.account.toHexString(); - rawEvent.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex(params.event.address)); + rawEvent.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex()); rawEvent.index = params.index; rawEvent.start = params.start; rawEvent.amount = params.amount; @@ -169,15 +155,7 @@ export function podListingCreated(params: PodListingCreatedParams): void { export function podListingFilled(params: MarketFillParams): void { let listing = loadPodListing(params.from, params.index); - updateMarketListingBalances( - params.event.address, - params.event.address, - ZERO_BI, - ZERO_BI, - params.amount, - params.costInBeans, - params.event.block.timestamp - ); + updateMarketListingBalances(ZERO_BI, ZERO_BI, params.amount, params.costInBeans, params.event.block); listing.filledAmount = params.amount; listing.remainingAmount = listing.remainingAmount.minus(params.amount); @@ -187,13 +165,7 @@ export function podListingFilled(params: MarketFillParams): void { let originalHistoryID = listing.historyID; if (listing.remainingAmount == ZERO_BI) { listing.status = "FILLED"; - updateActiveListings( - params.event.address, - MarketplaceAction.FILLED_FULL, - params.from.toHexString(), - listing.index, - listing.maxHarvestableIndex - ); + updateActiveListings(MarketplaceAction.FILLED_FULL, params.from.toHexString(), listing.index, listing.maxHarvestableIndex); } else { listing.status = "FILLED_PARTIAL"; @@ -217,15 +189,8 @@ export function podListingFilled(params: MarketFillParams): void { remainingListing.save(); // Process the partial fill on the prev listing, and the new listing + updateActiveListings(MarketplaceAction.FILLED_PARTIAL, params.from.toHexString(), listing.index, listing.maxHarvestableIndex); updateActiveListings( - params.event.address, - MarketplaceAction.FILLED_PARTIAL, - params.from.toHexString(), - listing.index, - listing.maxHarvestableIndex - ); - updateActiveListings( - params.event.address, MarketplaceAction.CREATED, params.from.toHexString(), remainingListing.index, @@ -239,7 +204,7 @@ export function podListingFilled(params: MarketFillParams): void { fill.fromFarmer = params.from.toHexString(); fill.toFarmer = params.to.toHexString(); fill.amount = params.amount; - fill.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex(params.event.address)); + fill.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex()); fill.index = params.index; fill.start = params.start; fill.costInBeans = params.costInBeans; @@ -272,22 +237,8 @@ export function podListingFilled(params: MarketFillParams): void { export function podListingCancelled(params: PodListingCancelledParams): void { let listing = PodListing.load(params.account.toHexString() + "-" + params.index.toString()); if (listing !== null && listing.status == "ACTIVE") { - updateActiveListings( - params.event.address, - MarketplaceAction.CANCELLED, - params.account.toHexString(), - listing.index, - listing.maxHarvestableIndex - ); - updateMarketListingBalances( - params.event.address, - params.event.address, - ZERO_BI, - listing.remainingAmount, - ZERO_BI, - ZERO_BI, - params.event.block.timestamp - ); + updateActiveListings(MarketplaceAction.CANCELLED, params.account.toHexString(), listing.index, listing.maxHarvestableIndex); + updateMarketListingBalances(ZERO_BI, listing.remainingAmount, ZERO_BI, ZERO_BI, params.event.block); listing.status = listing.filled == ZERO_BI ? "CANCELLED" : "CANCELLED_PARTIAL"; listing.updatedAt = params.event.block.timestamp; @@ -301,7 +252,7 @@ export function podListingCancelled(params: PodListingCancelledParams): void { rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = listing.historyID; rawEvent.account = params.account.toHexString(); - rawEvent.placeInLine = params.index.plus(listing.start).minus(getHarvestableIndex(params.event.address)); + rawEvent.placeInLine = params.index.plus(listing.start).minus(getHarvestableIndex()); rawEvent.index = params.index; rawEvent.blockNumber = params.event.block.number; rawEvent.createdAt = params.event.block.timestamp; @@ -334,16 +285,8 @@ export function podOrderCreated(params: PodOrderCreatedParams): void { order.fills = []; order.save(); - updateActiveOrders(params.event.address, MarketplaceAction.CREATED, order.id, order.maxPlaceInLine); - updateMarketOrderBalances( - params.event.address, - params.event.address, - params.beanAmount, - ZERO_BI, - ZERO_BI, - ZERO_BI, - params.event.block.timestamp - ); + updateActiveOrders(MarketplaceAction.CREATED, order.id, order.maxPlaceInLine); + updateMarketOrderBalances(params.beanAmount, ZERO_BI, ZERO_BI, ZERO_BI, params.event.block); // Save the raw event data let id = "podOrderCreated-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); @@ -382,7 +325,7 @@ export function podOrderFilled(params: MarketFillParams): void { fill.fromFarmer = params.from.toHexString(); fill.toFarmer = params.to.toHexString(); fill.amount = params.amount; - fill.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex(params.event.address)); + fill.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex()); fill.index = params.index; fill.start = params.start; fill.costInBeans = params.costInBeans; @@ -391,18 +334,10 @@ export function podOrderFilled(params: MarketFillParams): void { setBeansPerPodAfterFill(params.event, fill.index, fill.start, fill.amount, fill.costInBeans); if (order.status == "FILLED") { - updateActiveOrders(params.event.address, MarketplaceAction.FILLED_FULL, order.id, order.maxPlaceInLine); + updateActiveOrders(MarketplaceAction.FILLED_FULL, order.id, order.maxPlaceInLine); } - updateMarketOrderBalances( - params.event.address, - params.event.address, - ZERO_BI, - ZERO_BI, - params.amount, - params.costInBeans, - params.event.block.timestamp - ); + updateMarketOrderBalances(ZERO_BI, ZERO_BI, params.amount, params.costInBeans, params.event.block); // Save the raw event data let id = "podOrderFilled-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); @@ -413,7 +348,7 @@ export function podOrderFilled(params: MarketFillParams): void { rawEvent.historyID = order.historyID; rawEvent.fromFarmer = params.from.toHexString(); rawEvent.toFarmer = params.to.toHexString(); - rawEvent.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex(params.event.address)); + rawEvent.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex()); rawEvent.index = params.index; rawEvent.start = params.start; rawEvent.amount = params.amount; @@ -430,16 +365,8 @@ export function podOrderCancelled(params: PodOrderCancelledParams): void { order.updatedAt = params.event.block.timestamp; order.save(); - updateActiveOrders(params.event.address, MarketplaceAction.CANCELLED, order.id, order.maxPlaceInLine); - updateMarketOrderBalances( - params.event.address, - params.event.address, - ZERO_BI, - order.beanAmount.minus(order.beanAmountFilled), - ZERO_BI, - ZERO_BI, - params.event.block.timestamp - ); + updateActiveOrders(MarketplaceAction.CANCELLED, order.id, order.maxPlaceInLine); + updateMarketOrderBalances(ZERO_BI, order.beanAmount.minus(order.beanAmountFilled), ZERO_BI, ZERO_BI, params.event.block); // Save the raw event data let id = "podOrderCancelled-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); @@ -457,15 +384,13 @@ export function podOrderCancelled(params: PodOrderCancelledParams): void { } export function updateMarketListingBalances( - protocol: Address, - marketAddress: Address, newPodAmount: BigInt, cancelledPodAmount: BigInt, filledPodAmount: BigInt, filledBeanAmount: BigInt, - timestamp: BigInt + block: ethereum.Block ): void { - let market = loadPodMarketplace(marketAddress); + let market = loadPodMarketplace(); const netListingChange = newPodAmount.minus(cancelledPodAmount).minus(filledPodAmount); @@ -476,20 +401,18 @@ export function updateMarketListingBalances( market.podVolume = market.podVolume.plus(filledPodAmount); market.beanVolume = market.beanVolume.plus(filledBeanAmount); - takeMarketSnapshots(market, protocol, timestamp); + takeMarketSnapshots(market, block); market.save(); } export function updateMarketOrderBalances( - protocol: Address, - marketAddress: Address, newBeanAmount: BigInt, cancelledBeanAmount: BigInt, filledPodAmount: BigInt, filledBeanAmount: BigInt, - timestamp: BigInt + block: ethereum.Block ): void { - let market = loadPodMarketplace(marketAddress); + let market = loadPodMarketplace(); const netOrderChange = newBeanAmount.minus(cancelledBeanAmount).minus(filledBeanAmount); @@ -501,12 +424,12 @@ export function updateMarketOrderBalances( market.beanVolume = market.beanVolume.plus(filledBeanAmount); market.cancelledOrderBeans = market.cancelledOrderBeans.plus(cancelledBeanAmount); - takeMarketSnapshots(market, protocol, timestamp); + takeMarketSnapshots(market, block); market.save(); } -export function updateExpiredPlots(protocol: Address, harvestableIndex: BigInt, timestamp: BigInt): void { - let market = loadPodMarketplace(protocol); +export function updateExpiredPlots(harvestableIndex: BigInt, block: ethereum.Block): void { + let market = loadPodMarketplace(); let remainingListings = market.activeListings; // Cancel any pod marketplace listings beyond the index @@ -515,7 +438,7 @@ export function updateExpiredPlots(protocol: Address, harvestableIndex: BigInt, const maxHarvestableIndex = BigInt.fromString(destructured[2]); if (harvestableIndex > maxHarvestableIndex) { // This method updates the marketplace entity, so it will perform the splice. - expirePodListingIfExists(protocol, destructured[0], BigInt.fromString(destructured[1]), timestamp, i); + expirePodListingIfExists(destructured[0], BigInt.fromString(destructured[1]), block, i); // A similar splice is done here also to track the updated index on the underlying array. remainingListings.splice(i--, 1); } @@ -545,10 +468,9 @@ function setBeansPerPodAfterFill(event: ethereum.Event, plotIndex: BigInt, start } export function expirePodListingIfExists( - protocol: Address, farmer: string, listedPlotIndex: BigInt, - timestamp: BigInt, + block: ethereum.Block, activeListingIndex: i32 = -1 // If provided, avoids having to lookup the index ): void { let listing = PodListing.load(farmer + "-" + listedPlotIndex.toString()); @@ -558,7 +480,7 @@ export function expirePodListingIfExists( listing.status = "EXPIRED"; listing.save(); - let market = loadPodMarketplace(protocol); + let market = loadPodMarketplace(); if (activeListingIndex == -1) { // There should always be a matching entry in this list because it is verified that the listing is ACTIVE @@ -578,18 +500,12 @@ export function expirePodListingIfExists( activeListings.splice(activeListingIndex, 1); market.activeListings = activeListings; - takeMarketSnapshots(market, protocol, timestamp); + takeMarketSnapshots(market, block); market.save(); } -export function updateActiveListings( - protocol: Address, - action: MarketplaceAction, - farmer: string, - plotIndex: BigInt, - expiryIndex: BigInt -): void { - let market = loadPodMarketplace(protocol); +export function updateActiveListings(action: MarketplaceAction, farmer: string, plotIndex: BigInt, expiryIndex: BigInt): void { + let market = loadPodMarketplace(); let listings = market.activeListings; if (action == MarketplaceAction.CREATED) { @@ -607,8 +523,8 @@ export function updateActiveListings( market.save(); } -export function updateActiveOrders(protocol: Address, action: MarketplaceAction, orderId: string, maxPlaceInLine: BigInt): void { - let market = loadPodMarketplace(protocol); +export function updateActiveOrders(action: MarketplaceAction, orderId: string, maxPlaceInLine: BigInt): void { + let market = loadPodMarketplace(); let orders = market.activeOrders; if (action == MarketplaceAction.CREATED) { diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index 22621157e5..de3e497259 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -17,7 +17,7 @@ import { v } from "./constants/Version"; export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block): void { let currentSeason = season.toI32(); - let seasonEntity = loadSeason(protocol, season); + let seasonEntity = loadSeason(season); seasonEntity.sunriseBlock = block.number; seasonEntity.createdAt = block.timestamp; seasonEntity.save(); diff --git a/projects/subgraph-beanstalk/src/utils/Silo.ts b/projects/subgraph-beanstalk/src/utils/Silo.ts index cf27e9bc62..eba26c44aa 100644 --- a/projects/subgraph-beanstalk/src/utils/Silo.ts +++ b/projects/subgraph-beanstalk/src/utils/Silo.ts @@ -44,14 +44,7 @@ export function addDeposits(params: AddRemoveDepositsParams): void { // Ensure that a Farmer entity is set up for this account. loadFarmer(params.account); - updateDepositInSilo( - params.event.address, - params.account, - params.token, - params.amounts[i], - params.bdvs![i], - params.event.block.timestamp - ); + updateDepositInSilo(params.event.address, params.account, params.token, params.amounts[i], params.bdvs![i], params.event.block); } } @@ -75,14 +68,7 @@ export function removeDeposits(params: AddRemoveDepositsParams): void { } // Update protocol totals - updateDepositInSilo( - params.event.address, - params.account, - params.token, - params.amounts[i].neg(), - removedBdv.neg(), - params.event.block.timestamp - ); + updateDepositInSilo(params.event.address, params.account, params.token, params.amounts[i].neg(), removedBdv.neg(), params.event.block); } } @@ -92,21 +78,21 @@ export function updateDepositInSilo( token: Address, deltaAmount: BigInt, deltaBdv: BigInt, - timestamp: BigInt, + block: ethereum.Block, recurs: boolean = true ): void { if (recurs && account != protocol) { - updateDepositInSilo(protocol, protocol, token, deltaAmount, deltaBdv, timestamp); + updateDepositInSilo(protocol, protocol, token, deltaAmount, deltaBdv, block); } let silo = loadSilo(account); silo.depositedBDV = silo.depositedBDV.plus(deltaBdv); - const newSeedStalk = updateDepositInSiloAsset(protocol, account, token, deltaAmount, deltaBdv, timestamp, false); + const newSeedStalk = updateDepositInSiloAsset(protocol, account, token, deltaAmount, deltaBdv, block, false); // Individual farmer seeds cannot be directly tracked due to seed gauge if (account == protocol) { silo.grownStalkPerSeason = silo.grownStalkPerSeason.plus(newSeedStalk); } - takeSiloSnapshots(silo, protocol, timestamp); + takeSiloSnapshots(silo, block); silo.save(); } @@ -116,11 +102,11 @@ export function updateDepositInSiloAsset( token: Address, deltaAmount: BigInt, deltaBdv: BigInt, - timestamp: BigInt, + block: ethereum.Block, recurs: boolean = true ): BigInt { if (recurs && account != protocol) { - updateDepositInSiloAsset(protocol, protocol, token, deltaAmount, deltaBdv, timestamp); + updateDepositInSiloAsset(protocol, protocol, token, deltaAmount, deltaBdv, block); } let asset = loadSiloAsset(account, token); @@ -130,7 +116,7 @@ export function updateDepositInSiloAsset( asset.depositedBDV = asset.depositedBDV.plus(deltaBdv); asset.depositedAmount = asset.depositedAmount.plus(deltaAmount); - takeSiloAssetSnapshots(asset, protocol, timestamp); + takeSiloAssetSnapshots(asset, block); asset.save(); return newGrownStalk; @@ -141,15 +127,15 @@ export function addWithdrawToSiloAsset( account: Address, token: Address, deltaAmount: BigInt, - timestamp: BigInt, + block: ethereum.Block, recurs: boolean = true ): void { if (recurs && account != protocol) { - addWithdrawToSiloAsset(protocol, protocol, token, deltaAmount, timestamp); + addWithdrawToSiloAsset(protocol, protocol, token, deltaAmount, block); } let asset = loadSiloAsset(account, token); asset.withdrawnAmount = asset.withdrawnAmount.plus(deltaAmount); - takeSiloAssetSnapshots(asset, protocol, timestamp); + takeSiloAssetSnapshots(asset, block); asset.save(); } @@ -158,21 +144,21 @@ export function updateStalkBalances( account: Address, deltaStalk: BigInt, deltaRoots: BigInt, - timestamp: BigInt, + block: ethereum.Block, recurs: boolean = true ): void { if (recurs && account != protocol) { - updateStalkBalances(protocol, protocol, deltaStalk, deltaRoots, timestamp); + updateStalkBalances(protocol, protocol, deltaStalk, deltaRoots, block); } let silo = loadSilo(account); silo.stalk = silo.stalk.plus(deltaStalk); silo.roots = silo.roots.plus(deltaRoots); - takeSiloSnapshots(silo, protocol, timestamp); + takeSiloSnapshots(silo, block); // Add account to active list if needed if (account !== protocol) { - let beanstalk = loadBeanstalk(protocol); + let beanstalk = loadBeanstalk(); let farmerIndex = beanstalk.activeFarmers.indexOf(account.toHexString()); if (farmerIndex == -1) { let newFarmers = beanstalk.activeFarmers; @@ -191,12 +177,18 @@ export function updateStalkBalances( silo.save(); } -export function updateSeedsBalances(protocol: Address, account: Address, seeds: BigInt, timestamp: BigInt, recurs: boolean = true): void { +export function updateSeedsBalances( + protocol: Address, + account: Address, + seeds: BigInt, + block: ethereum.Block, + recurs: boolean = true +): void { if (recurs && account != protocol) { - updateSeedsBalances(protocol, protocol, seeds, timestamp); + updateSeedsBalances(protocol, protocol, seeds, block); } let silo = loadSilo(account); silo.seeds = silo.seeds.plus(seeds); - takeSiloSnapshots(silo, protocol, timestamp); + takeSiloSnapshots(silo, block); silo.save(); } diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index 36abaa5cb3..0796b31623 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -29,7 +29,7 @@ export function updateBeanEMA(protocol: Address, timestamp: BigInt): void { updateWindowEMA(protocol, timestamp, ROLLING_7_DAY_WINDOW); updateWindowEMA(protocol, timestamp, ROLLING_30_DAY_WINDOW); - if (getCurrentSeason(protocol) > 20_000) { + if (getCurrentSeason() > 20_000) { // Earlier values were set by cache updateSiloVAPYs(protocol, timestamp, ROLLING_24_WINDOW); updateSiloVAPYs(protocol, timestamp, ROLLING_7_DAY_WINDOW); @@ -42,7 +42,7 @@ export function updateBeanEMA(protocol: Address, timestamp: BigInt): void { } function updateWindowEMA(protocol: Address, timestamp: BigInt, window: i32): void { - const t = getCurrentSeason(protocol); + const t = getCurrentSeason(); let silo = loadSilo(protocol); let siloYield = loadSiloYield(t, window); @@ -87,7 +87,7 @@ function updateWindowEMA(protocol: Address, timestamp: BigInt, window: i32): voi } export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i32): void { - const beanstalk = loadBeanstalk(protocol); + const beanstalk = loadBeanstalk(); const t = beanstalk.lastSeason; let silo = loadSilo(protocol); let siloYield = loadSiloYield(t, window); @@ -202,7 +202,7 @@ export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i3 depositedBeanBdv, siloStalk, CATCH_UP_RATE, - BigInt.fromU32(getCurrentSeason(protocol)), + BigInt.fromU32(getCurrentSeason()), germinatingBeanBdv, germinatingGaugeLpBdv, germinatingNonGaugeBdv, @@ -420,7 +420,7 @@ function updateFertAPY(protocol: Address, timestamp: BigInt, window: i32): void return; } - const beanstalk = loadBeanstalk(protocol); + const beanstalk = loadBeanstalk(); const t = beanstalk.lastSeason; let siloYield = loadSiloYield(t, window); let fertilizerYield = loadFertilizerYield(t, window); diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacyField.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacyField.ts new file mode 100644 index 0000000000..e1c1794448 --- /dev/null +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacyField.ts @@ -0,0 +1,10 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { BEANSTALK_FARMS } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { loadField } from "../../entities/Field"; + +export function legacySowAmount(protocol: Address, sower: Address): BigInt | null { + if (sower == BEANSTALK_FARMS) { + return loadField(protocol).soil; + } + return null; +} diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts index 750fc0f99b..889ec5acfe 100644 --- a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts @@ -1,4 +1,4 @@ -import { Address, BigInt, log } from "@graphprotocol/graph-ts"; +import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { loadSilo, loadSiloAsset, loadSiloWithdraw } from "../../entities/Silo"; import { takeSiloAssetSnapshots } from "../../entities/snapshots/SiloAsset"; import { loadBeanstalk } from "../../entities/Beanstalk"; @@ -10,7 +10,7 @@ export function updateClaimedWithdraw( account: Address, token: Address, withdrawSeason: BigInt, - timestamp: BigInt + block: ethereum.Block ): void { let withdraw = loadSiloWithdraw(account, token, withdrawSeason.toI32()); withdraw.claimed = true; @@ -18,14 +18,14 @@ export function updateClaimedWithdraw( let asset = loadSiloAsset(account, token); asset.withdrawnAmount = asset.withdrawnAmount.minus(withdraw.amount); - takeSiloAssetSnapshots(asset, protocol, timestamp); + takeSiloAssetSnapshots(asset, block); asset.save(); } // Replanted -> SiloV3 // This should be run at sunrise for the previous season to update any farmers stalk/seed/roots balances from silo transfers. -export function updateStalkWithCalls(protocol: Address, timestamp: BigInt): void { - let beanstalk = loadBeanstalk(protocol); +export function updateStalkWithCalls(protocol: Address, block: ethereum.Block): void { + let beanstalk = loadBeanstalk(); let beanstalk_call = Replanted.bind(protocol); for (let i = 0; i < beanstalk.farmersToUpdate.length; i++) { @@ -36,10 +36,10 @@ export function updateStalkWithCalls(protocol: Address, timestamp: BigInt): void account, beanstalk_call.balanceOfStalk(account).minus(silo.stalk), beanstalk_call.balanceOfRoots(account).minus(silo.roots), - timestamp, + block, false ); - updateSeedsBalances(protocol, account, beanstalk_call.balanceOfSeeds(account).minus(silo.seeds), timestamp, false); + updateSeedsBalances(protocol, account, beanstalk_call.balanceOfSeeds(account).minus(silo.seeds), block, false); } beanstalk.farmersToUpdate = []; beanstalk.save(); diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts index 5c54b6ccc6..44ab6de5d8 100644 --- a/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts +++ b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts @@ -2,7 +2,6 @@ import { BigInt, Bytes, log } from "@graphprotocol/graph-ts"; import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; import { beans_BI, podlineMil_BI } from "../../subgraph-core/tests/Values"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { assertMarketListingsState, assertMarketOrdersState, @@ -49,7 +48,7 @@ describe("Marketplace", () => { test("Create a pod listing - full plot", () => { const event = createListing_v1(account, listingIndex, sowedPods, ZERO_BI, listingPricePerPod, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], sowedPods, sowedPods, @@ -65,7 +64,7 @@ describe("Marketplace", () => { sow(account, listing2Index, sowedBeans, sowedPods); const event2 = createListing_v1(account, listing2Index, sowedPods, ZERO_BI, listingPricePerPod, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [ account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString(), account + "-" + listing2Index.toString() + "-" + maxHarvestableIndex.toString() @@ -84,7 +83,7 @@ describe("Marketplace", () => { const listedPods = sowedPods.minus(listingStart); const event = createListing_v1(account, listingIndex, listedPods, listingStart, listingPricePerPod, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods, listedPods, @@ -100,7 +99,7 @@ describe("Marketplace", () => { const listedPods = sowedPods.minus(listingStart); const event = createListing_v1(account, listingIndex, listedPods, listingStart, listingPricePerPod, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods, listedPods, @@ -115,7 +114,7 @@ describe("Marketplace", () => { test("Create a pod order", () => { const event = createOrder_v1(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [event.params.id.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans, orderBeans, @@ -182,7 +181,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID, "filled", listedPods.toString()); assert.entityCount("PodListing", 1); - assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, ZERO_BI, listedPods, listedPods, filledBeans); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, ZERO_BI, listedPods, listedPods, filledBeans); }); test("Fill listing - partial, then full", () => { @@ -209,7 +208,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", derivedListingID, "filled", filledPods.toString()); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + newListingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods, remaining, @@ -233,17 +232,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID, "status", "FILLED_PARTIAL"); assert.fieldEquals("PodListing", listingID, "filled", filledPods.toString()); - assertMarketListingsState( - BEANSTALK.toHexString(), - [], - listedPods, - ZERO_BI, - ZERO_BI, - ZERO_BI, - listedPods, - listedPods, - filledBeans.plus(newFilledBeans) - ); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, ZERO_BI, listedPods, listedPods, filledBeans.plus(newFilledBeans)); }); test("Cancel listing - full", () => { @@ -253,17 +242,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID, "status", "CANCELLED"); assert.fieldEquals("PodListing", listingID, "remainingAmount", cancelledAmount.toString()); - assertMarketListingsState( - BEANSTALK.toHexString(), - [], - cancelledAmount, - ZERO_BI, - cancelledAmount, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI - ); + assertMarketListingsState("0", [], cancelledAmount, ZERO_BI, cancelledAmount, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI); }); test("Cancel listing - partial", () => { @@ -281,17 +260,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", newListingID, "status", "CANCELLED_PARTIAL"); assert.fieldEquals("PodListing", newListingID, "remainingAmount", remaining.toString()); - assertMarketListingsState( - BEANSTALK.toHexString(), - [], - listedPods, - ZERO_BI, - remaining, - ZERO_BI, - filledPods, - filledPods, - filledBeans - ); + assertMarketListingsState("0", [], listedPods, ZERO_BI, remaining, ZERO_BI, filledPods, filledPods, filledBeans); }); test("Recreate listing", () => { @@ -305,7 +274,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID + "-0", "filled", "0"); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods.times(BigInt.fromU32(2)), listedPods, @@ -337,7 +306,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", newListingID, "remainingAmount", newListingAmount.toString()); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + newListingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods.times(BigInt.fromU32(2)).plus(newListingAmount), newListingAmount, @@ -362,7 +331,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); assert.fieldEquals("PodListing", listingID, "remainingAmount", listedPods.toString()); - assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); // Test expiration after a partial sale setHarvestable(maxHarvestableIndex); @@ -384,7 +353,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", newListingID, "remainingAmount", listedPods.minus(filledPods).toString()); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [], listedPods.times(BigInt.fromU32(2)), ZERO_BI, @@ -409,7 +378,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); assert.fieldEquals("PodListing", listingID, "remainingAmount", listedPods.toString()); - assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); }); test("Cancel expired/nonexistent listing", () => { @@ -422,7 +391,7 @@ describe("Marketplace", () => { cancelListing(account, listingIndex); assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); - assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); }); }); @@ -442,17 +411,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", orderedPods.toString()); assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, event) + "]"); - assertMarketOrdersState( - BEANSTALK.toHexString(), - [], - orderBeans, - ZERO_BI, - orderBeans, - orderedPods, - ZERO_BI, - orderedPods, - orderBeans - ); + assertMarketOrdersState("0", [], orderBeans, ZERO_BI, orderBeans, orderedPods, ZERO_BI, orderedPods, orderBeans); }); test("Fill order - partial", () => { @@ -469,7 +428,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, event) + "]"); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [event.params.id.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans, orderBeans.minus(orderBeans1), @@ -496,17 +455,7 @@ describe("Marketplace", () => { "[" + getPodFillId(orderPlotIndex, event) + ", " + getPodFillId(newOrderPlotIndex, event2) + "]" ); - assertMarketOrdersState( - BEANSTALK.toHexString(), - [], - orderBeans, - ZERO_BI, - orderBeans, - orderedPods, - ZERO_BI, - orderedPods, - orderBeans - ); + assertMarketOrdersState("0", [], orderBeans, ZERO_BI, orderBeans, orderedPods, ZERO_BI, orderedPods, orderBeans); }); test("Cancel order - full", () => { @@ -517,7 +466,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", "0"); assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[]"); - assertMarketOrdersState(BEANSTALK.toHexString(), [], orderBeans, ZERO_BI, ZERO_BI, ZERO_BI, orderBeans, ZERO_BI, ZERO_BI); + assertMarketOrdersState("0", [], orderBeans, ZERO_BI, ZERO_BI, ZERO_BI, orderBeans, ZERO_BI, ZERO_BI); }); test("Cancel order - partial", () => { @@ -536,7 +485,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, fillEvent) + "]"); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [], orderBeans, ZERO_BI, @@ -555,7 +504,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodOrder", orderId.toHexString() + "-0", "fills", "[]"); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans.times(BigInt.fromU32(2)), orderBeans, @@ -584,7 +533,7 @@ describe("Marketplace", () => { // The same amount of beans were re-ordered, but fewer were cancelled assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans.times(BigInt.fromU32(3)), orderBeans, @@ -601,7 +550,7 @@ describe("Marketplace", () => { cancelOrder(account, nonexistent); assert.notInStore("PodOrder", nonexistent.toHexString()); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans, orderBeans, @@ -620,7 +569,7 @@ describe("Marketplace", () => { test("Create a pod listing - full plot", () => { const event = createListing_v1_1(account, listingIndex, sowedPods, ZERO_BI, listingPricePerPod, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], sowedPods, sowedPods, @@ -636,7 +585,7 @@ describe("Marketplace", () => { sow(account, listing2Index, sowedBeans, sowedPods); const event2 = createListing_v1_1(account, listing2Index, sowedPods, ZERO_BI, listingPricePerPod, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [ account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString(), account + "-" + listing2Index.toString() + "-" + maxHarvestableIndex.toString() @@ -655,7 +604,7 @@ describe("Marketplace", () => { const listedPods = sowedPods.minus(listingStart); const event = createListing_v1_1(account, listingIndex, listedPods, listingStart, listingPricePerPod, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods, listedPods, diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts index 7d51c51e04..7dfa85e9fd 100644 --- a/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts +++ b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts @@ -2,7 +2,6 @@ import { BigInt, Bytes, log } from "@graphprotocol/graph-ts"; import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; import { beans_BI, podlineMil_BI } from "../../subgraph-core/tests/Values"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { assertMarketListingsState, assertMarketOrdersState, @@ -48,7 +47,7 @@ describe("Marketplace", () => { test("Create a pod listing - full plot", () => { const event = createListing_v2(account, listingIndex, sowedPods, ZERO_BI, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], sowedPods, sowedPods, @@ -64,7 +63,7 @@ describe("Marketplace", () => { sow(account, listing2Index, sowedBeans, sowedPods); const event2 = createListing_v2(account, listing2Index, sowedPods, ZERO_BI, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [ account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString(), account + "-" + listing2Index.toString() + "-" + maxHarvestableIndex.toString() @@ -83,7 +82,7 @@ describe("Marketplace", () => { const listedPods = sowedPods.minus(listingStart); const event = createListing_v2(account, listingIndex, listedPods, listingStart, maxHarvestableIndex); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods, listedPods, @@ -98,7 +97,7 @@ describe("Marketplace", () => { test("Create a pod order", () => { const event = createOrder_v2(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [event.params.id.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans, orderBeans, @@ -165,7 +164,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID, "filled", listedPods.toString()); assert.entityCount("PodListing", 1); - assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, ZERO_BI, listedPods, listedPods, filledBeans); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, ZERO_BI, listedPods, listedPods, filledBeans); }); test("Fill listing - partial, then full", () => { @@ -192,7 +191,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", derivedListingID, "filled", filledPods.toString()); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + newListingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods, remaining, @@ -216,17 +215,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID, "status", "FILLED_PARTIAL"); assert.fieldEquals("PodListing", listingID, "filled", filledPods.toString()); - assertMarketListingsState( - BEANSTALK.toHexString(), - [], - listedPods, - ZERO_BI, - ZERO_BI, - ZERO_BI, - listedPods, - listedPods, - filledBeans.plus(newFilledBeans) - ); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, ZERO_BI, listedPods, listedPods, filledBeans.plus(newFilledBeans)); }); test("Cancel listing - partial", () => { @@ -244,17 +233,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", newListingID, "status", "CANCELLED_PARTIAL"); assert.fieldEquals("PodListing", newListingID, "remainingAmount", remaining.toString()); - assertMarketListingsState( - BEANSTALK.toHexString(), - [], - listedPods, - ZERO_BI, - remaining, - ZERO_BI, - filledPods, - filledPods, - filledBeans - ); + assertMarketListingsState("0", [], listedPods, ZERO_BI, remaining, ZERO_BI, filledPods, filledPods, filledBeans); }); test("Recreate listing", () => { @@ -268,7 +247,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID + "-0", "filled", "0"); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods.times(BigInt.fromU32(2)), listedPods, @@ -300,7 +279,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", newListingID, "remainingAmount", newListingAmount.toString()); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [account + "-" + newListingIndex.toString() + "-" + maxHarvestableIndex.toString()], listedPods.times(BigInt.fromU32(2)).plus(newListingAmount), newListingAmount, @@ -325,7 +304,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); assert.fieldEquals("PodListing", listingID, "remainingAmount", listedPods.toString()); - assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); // Test expiration after a partial sale setHarvestable(maxHarvestableIndex); @@ -347,7 +326,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", newListingID, "remainingAmount", listedPods.minus(filledPods).toString()); assertMarketListingsState( - BEANSTALK.toHexString(), + "0", [], listedPods.times(BigInt.fromU32(2)), ZERO_BI, @@ -372,7 +351,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); assert.fieldEquals("PodListing", listingID, "remainingAmount", listedPods.toString()); - assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); }); test("Cancel expired/nonexistent listing", () => { @@ -385,7 +364,7 @@ describe("Marketplace", () => { cancelListing(account, listingIndex); assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); - assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + assertMarketListingsState("0", [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); }); }); @@ -405,17 +384,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", orderedPods.toString()); assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, event) + "]"); - assertMarketOrdersState( - BEANSTALK.toHexString(), - [], - orderBeans, - ZERO_BI, - orderBeans, - orderedPods, - ZERO_BI, - orderedPods, - orderBeans - ); + assertMarketOrdersState("0", [], orderBeans, ZERO_BI, orderBeans, orderedPods, ZERO_BI, orderedPods, orderBeans); }); test("Fill order - partial", () => { @@ -432,7 +401,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, event) + "]"); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [event.params.id.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans, orderBeans.minus(orderBeans1), @@ -459,17 +428,7 @@ describe("Marketplace", () => { "[" + getPodFillId(orderPlotIndex, event) + ", " + getPodFillId(newOrderPlotIndex, event2) + "]" ); - assertMarketOrdersState( - BEANSTALK.toHexString(), - [], - orderBeans, - ZERO_BI, - orderBeans, - orderedPods, - ZERO_BI, - orderedPods, - orderBeans - ); + assertMarketOrdersState("0", [], orderBeans, ZERO_BI, orderBeans, orderedPods, ZERO_BI, orderedPods, orderBeans); }); test("Cancel order - partial", () => { @@ -488,7 +447,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, fillEvent) + "]"); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [], orderBeans, ZERO_BI, @@ -507,7 +466,7 @@ describe("Marketplace", () => { assert.fieldEquals("PodOrder", orderId.toHexString() + "-0", "fills", "[]"); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans.times(BigInt.fromU32(2)), orderBeans, @@ -536,7 +495,7 @@ describe("Marketplace", () => { // The same amount of beans were re-ordered, but fewer were cancelled assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans.times(BigInt.fromU32(3)), orderBeans, @@ -553,7 +512,7 @@ describe("Marketplace", () => { cancelOrder(account, nonexistent); assert.notInStore("PodOrder", nonexistent.toHexString()); assertMarketOrdersState( - BEANSTALK.toHexString(), + "0", [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], orderBeans, orderBeans, diff --git a/projects/subgraph-beanstalk/tests/utils/Season.ts b/projects/subgraph-beanstalk/tests/utils/Season.ts index 44a71bb635..b7115bf7ea 100644 --- a/projects/subgraph-beanstalk/tests/utils/Season.ts +++ b/projects/subgraph-beanstalk/tests/utils/Season.ts @@ -1,8 +1,7 @@ -import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { loadBeanstalk } from "../../src/entities/Beanstalk"; export function setSeason(season: u32): void { - let beanstalk = loadBeanstalk(BEANSTALK); + let beanstalk = loadBeanstalk(); beanstalk.lastSeason = season; beanstalk.save(); } From a47fa0b76ab2f63fddf8938f4f6d985fe24fa0ea Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:17:55 -0700 Subject: [PATCH 20/88] string -> bytes for address refactor --- projects/subgraph-beanstalk/schema.graphql | 54 +++++++++---------- .../src/entities/Beanstalk.ts | 11 ++-- .../src/entities/Fertilizer.ts | 8 +-- .../subgraph-beanstalk/src/entities/Field.ts | 16 +++--- .../src/entities/Germinating.ts | 2 +- .../src/entities/PodMarketplace.ts | 9 ++-- .../subgraph-beanstalk/src/entities/Silo.ts | 38 ++++++------- .../src/entities/snapshots/Field.ts | 12 ++--- .../src/entities/snapshots/Silo.ts | 10 ++-- .../src/handlers/GaugeHandler.ts | 9 +--- .../src/handlers/SeasonHandler.ts | 10 ++-- .../src/handlers/SiloHandler.ts | 6 +-- .../handlers/legacy/LegacySeasonHandler.ts | 2 +- .../src/handlers/legacy/LegacySiloHandler.ts | 18 +++---- .../subgraph-beanstalk/src/utils/Field.ts | 21 ++++---- .../src/utils/Marketplace.ts | 33 ++++++------ .../subgraph-beanstalk/src/utils/Season.ts | 15 +++--- projects/subgraph-beanstalk/src/utils/Silo.ts | 6 +-- .../subgraph-beanstalk/src/utils/Yield.ts | 11 ++-- .../src/utils/contracts/BeanstalkPrice.ts | 24 ++++----- .../src/utils/contracts/SiloCalculations.ts | 28 ---------- .../src/utils/legacy/LegacySilo.ts | 38 ++++++++++--- .../src/utils/legacy/LegacyWhitelist.ts | 27 ++++++++++ .../subgraph-beanstalk/tests/Silo.test.ts | 2 +- .../subgraph-beanstalk/tests/Yield.test.ts | 9 +--- .../subgraph-core/constants/BeanstalkEth.ts | 5 ++ .../constants/RuntimeConstants.ts | 7 +++ 27 files changed, 220 insertions(+), 211 deletions(-) delete mode 100644 projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts create mode 100644 projects/subgraph-beanstalk/src/utils/legacy/LegacyWhitelist.ts diff --git a/projects/subgraph-beanstalk/schema.graphql b/projects/subgraph-beanstalk/schema.graphql index fd8e0d9679..11cd10fc0e 100644 --- a/projects/subgraph-beanstalk/schema.graphql +++ b/projects/subgraph-beanstalk/schema.graphql @@ -37,9 +37,9 @@ type Beanstalk @entity { "'beanstalk'" id: ID! "Bean token address of the protocol" - token: String! + token: Bytes! "Address of the fertilizer contract" - fertilizer1155: String + fertilizer1155: Bytes "Season specific data" seasons: [Season!]! @derivedFrom(field: "beanstalk") "Silo level data" @@ -49,15 +49,15 @@ type Beanstalk @entity { "Last season called" lastSeason: Int! "Array of the addresses for all active farmers in the silo" - activeFarmers: [String!]! + activeFarmers: [Bytes!]! "Array of the addresses for all farmers that had silo transfers and need stalk/seeds/roots updated" - farmersToUpdate: [String!]! + farmersToUpdate: [Bytes!]! } type Season @entity { "Season Number" id: ID! - "Beanstalk Contract Address" + "'beanstalk'" beanstalk: Beanstalk! "Season number in Int form for sorting" season: Int! @@ -84,16 +84,16 @@ type Season @entity { } type Silo @entity { - "Address for the farmer or Beanstalk" - id: ID! - "Beanstalk diamond address" + "Address for the farmer or Beanstalk contract" + id: Bytes! + "'beanstalk'" beanstalk: Beanstalk! "Farmer address if applicable" farmer: Farmer "Tokens whitelisted for deposit within the silo" - whitelistedTokens: [String!]! + whitelistedTokens: [Bytes!]! "Tokens that have been removed from the silo deposit whitelist" - dewhitelistedTokens: [String!]! + dewhitelistedTokens: [Bytes!]! "Link to all silo assets currently associated with this silo" assets: [SiloAsset!]! @derivedFrom(field: "silo") "Current BDV of all deposited assets" @@ -222,7 +222,7 @@ type SiloAsset @entity { "Silo for this asset" silo: Silo! "Token address for this asset" - token: String! + token: Bytes! "Current Token amount of deposits" depositedAmount: BigInt! "Current BDV of deposits" @@ -309,7 +309,7 @@ type SiloYield @entity { "Bean EMA for season" beansPerSeasonEMA: BigDecimal! "Current whitelisted silo tokens" - whitelistedTokens: [String!]! + whitelistedTokens: [Bytes!]! "Current Bean (0) and Stalk (1) APY for each token." tokenAPYS: [TokenYield!]! @derivedFrom(field: "siloYield") "Unix timestamp of update" @@ -452,8 +452,8 @@ type WhitelistTokenDailySnapshot @entity { type Field @entity { "Contract address for this field or farmer" - id: ID! - "Contract address of beanstalk" + id: Bytes! + "'beanstalk'" beanstalk: Beanstalk! "Farmer address if applicable" farmer: Farmer @@ -609,7 +609,7 @@ type FieldDailySnapshot @entity { type Farmer @entity { "Address for the farmer" - id: ID! + id: Bytes! silo: Silo @derivedFrom(field: "farmer") deposits: [SiloDeposit!]! @derivedFrom(field: "farmer") withdraws: [SiloWithdraw!]! @derivedFrom(field: "farmer") @@ -629,7 +629,7 @@ type SiloDeposit @entity { "Farmer address" farmer: Farmer! "Token Address" - token: String! + token: Bytes! "Version of deposit. Options are season, v3, v3.1. `season` type includes those deposits which are calculated according to their silo v1 deposits pre-explout" depositVersion: String! "Season of deposit" @@ -660,7 +660,7 @@ type SiloWithdraw @entity { "Farmer address" farmer: Farmer! "Token address" - token: String! + token: Bytes! "Season withdrawal initiated" withdrawSeason: Int! "Season when withdrawal can be claimed" @@ -1146,7 +1146,7 @@ type PodFill @entity { "Associated order, if any" order: PodOrder "Account that is sending pods" - fromFarmer: String! # These are already referenced via the listing and order entities. + fromFarmer: Bytes! # These are already referenced via the listing and order entities. "Account that is receiving pods" toFarmer: Farmer! "Number of pods filled" @@ -1168,7 +1168,7 @@ type PodFill @entity { # Global Fertilizer state for tracking type Fertilizer @entity { "Token address for fert" - id: ID! + id: Bytes! "Address of parent beanstalk" beanstalk: String! "Total overall suppy of fert tokens" @@ -1321,9 +1321,9 @@ type PodListingFilled implements MarketplaceEvent @entity(immutable: true) { "Historical ID for joins" historyID: String! "Account selling pods" - fromFarmer: String! + fromFarmer: Bytes! "Account buying pods" - toFarmer: String! + toFarmer: Bytes! "Where these pods were in line when filled" placeInLine: BigInt! "Index of the plot transferred" @@ -1352,7 +1352,7 @@ type PodListingCancelled implements MarketplaceEvent @entity(immutable: true) { "Historical ID for joins" historyID: String! "Account cancelling listing" - account: String! + account: Bytes! "Where these pods were in line when cancelled" placeInLine: BigInt! "Index of plot listing being cancelled" @@ -1375,7 +1375,7 @@ type PodOrderCreated implements MarketplaceEvent @entity(immutable: true) { "Historical ID for joins" historyID: String! "Account creating the listing" - account: String! + account: Bytes! "ID of the pod order" orderId: String! """ @@ -1410,9 +1410,9 @@ type PodOrderFilled implements MarketplaceEvent @entity(immutable: true) { "Historical ID for joins" historyID: String! "Account selling pods" - fromFarmer: String! + fromFarmer: Bytes! "Account buying pods" - toFarmer: String! + toFarmer: Bytes! "Where these pods were in line when filled" placeInLine: BigInt! "Index of the plot transferred" @@ -1441,7 +1441,7 @@ type PodOrderCancelled implements MarketplaceEvent @entity(immutable: true) { "Historical ID for joins" historyID: String! "Account cancelling listing" - account: String! + account: Bytes! "ID of order cancelled" orderId: String! "Block number of this event" @@ -1455,7 +1455,7 @@ type Germinating @entity { "Address-(EVEN|ODD)" id: ID! "Address of the token or account which is germinating" - address: String! + address: Bytes! "EVEN or ODD" type: String! "True when the address is a farmer account" diff --git a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts index 834e04a94a..9a291de53a 100644 --- a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts +++ b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts @@ -11,11 +11,8 @@ export function loadBeanstalk(): Beanstalk { if (beanstalk == null) { beanstalk = new Beanstalk("beanstalk"); // Pre-replant token currently would not be set - beanstalk.token = getProtocolToken(v(), BI_MAX).toHexString(); - const fert = getProtocolFertilizer(v()); - if (fert !== null) { - beanstalk.fertilizer1155 = fert.toHexString(); - } + beanstalk.token = getProtocolToken(v(), BI_MAX); + beanstalk.fertilizer1155 = getProtocolFertilizer(v()); beanstalk.lastSeason = 1; beanstalk.activeFarmers = []; beanstalk.farmersToUpdate = []; @@ -25,9 +22,9 @@ export function loadBeanstalk(): Beanstalk { } export function loadFarmer(account: Address): Farmer { - let farmer = Farmer.load(account.toHexString()); + let farmer = Farmer.load(account); if (farmer == null) { - farmer = new Farmer(account.toHexString()); + farmer = new Farmer(account); farmer.save(); } return farmer; diff --git a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts index 5cf0e3c271..0d01c877c4 100644 --- a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts +++ b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts @@ -5,10 +5,10 @@ import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { v } from "../utils/constants/Version"; export function loadFertilizer(fertilizerAddress: Address): Fertilizer { - let fertilizer = Fertilizer.load(fertilizerAddress.toHexString()); + let fertilizer = Fertilizer.load(fertilizerAddress); if (fertilizer == null) { - fertilizer = new Fertilizer(fertilizerAddress.toHexString()); - fertilizer.beanstalk = v().protocolAddress.toHexString(); + fertilizer = new Fertilizer(fertilizerAddress); + fertilizer.beanstalk = "beanstalk"; fertilizer.supply = ZERO_BI; fertilizer.save(); } @@ -18,7 +18,7 @@ export function loadFertilizer(fertilizerAddress: Address): Fertilizer { export function loadFertilizerToken(fertilizer: Fertilizer, id: BigInt, blockNumber: BigInt): FertilizerToken { let fertilizerToken = FertilizerToken.load(id.toString()); if (fertilizerToken == null) { - const beanstalkContract = SeedGauge.bind(Address.fromString(fertilizer.beanstalk)); + const beanstalkContract = SeedGauge.bind(v().protocolAddress); fertilizerToken = new FertilizerToken(id.toString()); fertilizerToken.fertilizer = fertilizer.id; if (blockNumber.gt(BigInt.fromString("15278963"))) { diff --git a/projects/subgraph-beanstalk/src/entities/Field.ts b/projects/subgraph-beanstalk/src/entities/Field.ts index d239001211..1eb6a48c13 100644 --- a/projects/subgraph-beanstalk/src/entities/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/Field.ts @@ -1,16 +1,16 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { Field, Plot } from "../../generated/schema"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; +import { v } from "../utils/constants/Version"; export function loadField(account: Address): Field { - let field = Field.load(account.toHexString()); + let field = Field.load(account); if (field == null) { - field = new Field(account.toHexString()); - field.beanstalk = BEANSTALK.toHexString(); - if (account !== BEANSTALK) { - field.farmer = account.toHexString(); + field = new Field(account); + field.beanstalk = "beanstalk"; + if (account !== v().protocolAddress) { + field.farmer = account; } field.season = 1; field.temperature = 1; @@ -34,8 +34,8 @@ export function loadPlot(diamondAddress: Address, index: BigInt): Plot { let plot = Plot.load(index.toString()); if (plot == null) { plot = new Plot(index.toString()); - plot.field = diamondAddress.toHexString(); - plot.farmer = ADDRESS_ZERO.toHexString(); + plot.field = diamondAddress; + plot.farmer = ADDRESS_ZERO; plot.source = "SOW"; // Should be overwritten in case of a transfer creating a new plot plot.sourceHash = ""; plot.season = 0; diff --git a/projects/subgraph-beanstalk/src/entities/Germinating.ts b/projects/subgraph-beanstalk/src/entities/Germinating.ts index ddb2c0b490..46b8f62150 100644 --- a/projects/subgraph-beanstalk/src/entities/Germinating.ts +++ b/projects/subgraph-beanstalk/src/entities/Germinating.ts @@ -8,7 +8,7 @@ export function loadOrCreateGerminating(address: Address, season: i32, isFarmer: let germinating = Germinating.load(id); if (germinating == null) { germinating = new Germinating(id); - germinating.address = address.toHexString(); + germinating.address = address; germinating.type = type; germinating.isFarmer = isFarmer; germinating.season = season; diff --git a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts index 478c669938..599a56f821 100644 --- a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts +++ b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts @@ -2,6 +2,7 @@ import { Address, BigInt, Bytes, log } from "@graphprotocol/graph-ts"; import { PodFill, PodListing, PodMarketplace, PodOrder } from "../../generated/schema"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { getCurrentSeason } from "./Beanstalk"; +import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; export function loadPodMarketplace(): PodMarketplace { let marketplace = PodMarketplace.load("0"); @@ -34,8 +35,8 @@ export function loadPodFill(protocol: Address, index: BigInt, hash: String): Pod fill = new PodFill(id); fill.podMarketplace = "0"; fill.createdAt = ZERO_BI; - fill.fromFarmer = ""; - fill.toFarmer = ""; + fill.fromFarmer = ADDRESS_ZERO; + fill.toFarmer = ADDRESS_ZERO; fill.placeInLine = ZERO_BI; fill.amount = ZERO_BI; fill.index = ZERO_BI; @@ -54,7 +55,7 @@ export function loadPodListing(account: Address, index: BigInt): PodListing { listing.podMarketplace = "0"; listing.historyID = ""; listing.plot = index.toString(); - listing.farmer = account.toHexString(); + listing.farmer = account; listing.index = index; listing.start = ZERO_BI; listing.mode = 0; @@ -117,7 +118,7 @@ export function loadPodOrder(orderID: Bytes): PodOrder { order = new PodOrder(orderID.toHexString()); order.podMarketplace = "0"; order.historyID = ""; - order.farmer = ""; + order.farmer = ADDRESS_ZERO; order.createdAt = ZERO_BI; order.updatedAt = ZERO_BI; order.status = ""; diff --git a/projects/subgraph-beanstalk/src/entities/Silo.ts b/projects/subgraph-beanstalk/src/entities/Silo.ts index 2cd6b1ced1..02617b5dc2 100644 --- a/projects/subgraph-beanstalk/src/entities/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/Silo.ts @@ -9,20 +9,20 @@ import { TokenYield, UnripeToken } from "../../generated/schema"; -import { BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { getTokenDecimals, getUnripeUnderlying } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; +import { initLegacyUnripe } from "../utils/legacy/LegacyWhitelist"; /* ===== Base Silo Entities ===== */ export function loadSilo(account: Address): Silo { - let silo = Silo.load(account.toHexString()); + let silo = Silo.load(account); if (silo == null) { - silo = new Silo(account.toHexString()); - silo.beanstalk = BEANSTALK.toHexString(); - if (account !== BEANSTALK) { - silo.farmer = account.toHexString(); + silo = new Silo(account); + silo.beanstalk = "beanstalk"; + if (account !== v().protocolAddress) { + silo.farmer = account; } silo.whitelistedTokens = []; silo.dewhitelistedTokens = []; @@ -48,8 +48,8 @@ export function loadSiloAsset(account: Address, token: Address): SiloAsset { if (asset == null) { asset = new SiloAsset(id); - asset.silo = account.toHexString(); - asset.token = token.toHexString(); + asset.silo = account; + asset.token = token; asset.depositedBDV = ZERO_BI; asset.depositedAmount = ZERO_BI; asset.withdrawnAmount = ZERO_BI; @@ -64,7 +64,7 @@ export function loadSiloAsset(account: Address, token: Address): SiloAsset { export function addToSiloWhitelist(siloAddress: Address, token: Address): void { let silo = loadSilo(siloAddress); let currentList = silo.whitelistedTokens; - currentList.push(token.toHexString()); + currentList.push(token); silo.whitelistedTokens = currentList; silo.save(); } @@ -79,15 +79,7 @@ export function loadWhitelistTokenSetting(token: Address): WhitelistTokenSetting setting.milestoneSeason = 0; setting.decimals = getTokenDecimals(v(), token); setting.updatedAt = ZERO_BI; - - // Check token addresses and set replant seeds/stalk for Unripe due to event timing. - if (token == UNRIPE_BEAN) { - setting.stalkIssuedPerBdv = BigInt.fromString("10000000000"); - setting.stalkEarnedPerSeason = BigInt.fromI32(2000000); - } else if (token == UNRIPE_LP) { - setting.stalkIssuedPerBdv = BigInt.fromString("10000000000"); - setting.stalkEarnedPerSeason = BigInt.fromI32(4000000); - } + initLegacyUnripe(setting); setting.save(); } return setting as WhitelistTokenSetting; @@ -133,8 +125,8 @@ export function loadSiloDeposit(depositId: SiloDepositID): SiloDeposit { let deposit = SiloDeposit.load(id); if (deposit == null) { deposit = new SiloDeposit(id); - deposit.farmer = depositId.account.toHexString(); - deposit.token = depositId.token.toHexString(); + deposit.farmer = depositId.account; + deposit.token = depositId.token; deposit.depositVersion = depositId.depositVersion.toString(); if (depositId.season !== null) { deposit.season = depositId.season!.toU32(); @@ -178,8 +170,8 @@ export function loadSiloWithdraw(account: Address, token: Address, season: i32): let withdraw = SiloWithdraw.load(id); if (withdraw == null) { withdraw = new SiloWithdraw(id); - withdraw.farmer = account.toHexString(); - withdraw.token = token.toHexString(); + withdraw.farmer = account; + withdraw.token = token; withdraw.withdrawSeason = season; withdraw.claimableSeason = season + 1; withdraw.claimed = false; @@ -231,7 +223,7 @@ export function loadTokenYield(token: Address, season: i32, window: i32): TokenY return tokenYield as TokenYield; } -export function SiloAsset_findIndex_token(a: SiloAsset[], targetToken: string): i32 { +export function SiloAsset_findIndex_token(a: SiloAsset[], targetToken: Address): i32 { for (let j = 0; j < a.length; j++) { if (a[j].token == targetToken) { return j; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts index 0ed8c755df..2fa87b1cab 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts @@ -10,15 +10,15 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); // Load the snapshot for this season/day - const hourlyId = field.id + "-" + currentSeason.toString(); - const dailyId = field.id + "-" + day.toString(); + const hourlyId = field.id.toHexString() + "-" + currentSeason.toString(); + const dailyId = field.id.toHexString() + "-" + day.toString(); let baseHourly = FieldHourlySnapshot.load(hourlyId); let baseDaily = FieldDailySnapshot.load(dailyId); if (baseHourly == null && field.lastHourlySnapshotSeason !== 0) { - baseHourly = FieldHourlySnapshot.load(field.id + "-" + field.lastHourlySnapshotSeason.toString()); + baseHourly = FieldHourlySnapshot.load(field.id.toHexString() + "-" + field.lastHourlySnapshotSeason.toString()); } if (baseDaily == null && field.lastDailySnapshotDay !== null) { - baseDaily = FieldDailySnapshot.load(field.id + "-" + field.lastDailySnapshotDay!.toString()); + baseDaily = FieldDailySnapshot.load(field.id.toHexString() + "-" + field.lastDailySnapshotDay!.toString()); } const hourly = new FieldHourlySnapshot(hourlyId); const daily = new FieldDailySnapshot(dailyId); @@ -183,14 +183,14 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { // Set case id on hourly. Snapshot must have already been created. export function setFieldHourlyCaseId(caseId: BigInt, field: Field): void { - const hourly = FieldHourlySnapshot.load(field.id + "-" + field.lastHourlySnapshotSeason.toString())!; + const hourly = FieldHourlySnapshot.load(field.id.toHexString() + "-" + field.lastHourlySnapshotSeason.toString())!; hourly.caseId = caseId; hourly.save(); } // Set soil sold out info on the hourly. Snapshot must have already been created. export function setHourlySoilSoldOut(soldOutBlock: BigInt, field: Field): void { - const hourly = FieldHourlySnapshot.load(field.id + "-" + field.lastHourlySnapshotSeason.toString())!; + const hourly = FieldHourlySnapshot.load(field.id.toHexString() + "-" + field.lastHourlySnapshotSeason.toString())!; hourly.blocksToSoldOutSoil = soldOutBlock.minus(hourly.seasonBlock); hourly.soilSoldOut = true; hourly.save(); diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts index b2bd119ad3..8fc2a98c79 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts @@ -10,15 +10,15 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); // Load the snapshot for this season/day - const hourlyId = silo.id + "-" + currentSeason.toString(); - const dailyId = silo.id + "-" + day.toString(); + const hourlyId = silo.id.toHexString() + "-" + currentSeason.toString(); + const dailyId = silo.id.toHexString() + "-" + day.toString(); let baseHourly = SiloHourlySnapshot.load(hourlyId); let baseDaily = SiloDailySnapshot.load(dailyId); if (baseHourly == null && silo.lastHourlySnapshotSeason !== 0) { - baseHourly = SiloHourlySnapshot.load(silo.id + "-" + silo.lastHourlySnapshotSeason.toString()); + baseHourly = SiloHourlySnapshot.load(silo.id.toHexString() + "-" + silo.lastHourlySnapshotSeason.toString()); } if (baseDaily == null && silo.lastDailySnapshotDay !== null) { - baseDaily = SiloDailySnapshot.load(silo.id + "-" + silo.lastDailySnapshotDay!.toString()); + baseDaily = SiloDailySnapshot.load(silo.id.toHexString() + "-" + silo.lastDailySnapshotDay!.toString()); } const hourly = new SiloHourlySnapshot(hourlyId); const daily = new SiloDailySnapshot(dailyId); @@ -135,7 +135,7 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { // Set case id on hourly snapshot. Snapshot must have already been created. export function setSiloHourlyCaseId(caseId: BigInt, silo: Silo): void { - const hourly = SiloHourlySnapshot.load(silo.id + "-" + silo.lastHourlySnapshotSeason.toString())!; + const hourly = SiloHourlySnapshot.load(silo.id.toHexString() + "-" + silo.lastHourlySnapshotSeason.toString())!; hourly.caseId = caseId; hourly.save(); } diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index e0cf5cc38f..9c91575539 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -26,6 +26,7 @@ import { loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; import { takeWhitelistTokenSettingSnapshots } from "../entities/snapshots/WhitelistTokenSetting"; import { getCurrentSeason } from "../entities/Beanstalk"; import { updateStalkBalances } from "../utils/Silo"; +import { legacyInitGauge } from "../utils/legacy/LegacyWhitelist"; // SEED GAUGE SEASONAL ADJUSTMENTS // @@ -196,13 +197,7 @@ export function handleUpdateGaugeSettings(event: UpdateGaugeSettings): void { siloSettings.optimalPercentDepositedBdv = event.params.optimalPercentDepositedBdv; siloSettings.updatedAt = event.block.timestamp; - // On initial gauge deployment, there was no GaugePointChange event emitted. Need to initialize BEANETH here - if ( - event.params.token == BEAN_WETH_CP2_WELL && - event.transaction.hash.toHexString().toLowerCase() == "0x299a4b93b8d19f8587b648ce04e3f5e618ea461426bb2b2337993b5d6677f6a7" - ) { - siloSettings.gaugePoints = BI_10.pow(20); - } + legacyInitGauge(event, siloSettings); takeWhitelistTokenSettingSnapshots(siloSettings, event.block); siloSettings.save(); diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index c6b3d8c89d..94ac5ce6b3 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -1,6 +1,5 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { BigInt } from "@graphprotocol/graph-ts"; import { Reward, Soil, WellOracle, Sunrise, Incentivization, SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { REPLANT_SEASON } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal, ZERO_BD } from "../../../subgraph-core/utils/Decimals"; import { updateStalkWithCalls } from "../utils/legacy/LegacySilo"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; @@ -14,7 +13,7 @@ import { updateBeanEMA } from "../utils/Yield"; import { updateExpiredPlots } from "../utils/Marketplace"; import { updateHarvestablePlots } from "../utils/Field"; import { sunrise } from "../utils/Season"; -import { getProtocolToken, isGaugeDeployed } from "../../../subgraph-core/constants/RuntimeConstants"; +import { getProtocolToken, isGaugeDeployed, isReplanted } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; export function handleSunrise(event: Sunrise): void { @@ -65,9 +64,6 @@ export function handleWellOracle(event: WellOracle): void { } export function handleSoil(event: Soil): void { - // Replant sets the soil to the amount every season instead of adding new soil - // to an existing amount. - let field = loadField(event.address); field.season = event.params.season.toI32(); field.soil = event.params.soil; @@ -75,7 +71,7 @@ export function handleSoil(event: Soil): void { takeFieldSnapshots(field, event.block); field.save(); - if (event.params.season >= REPLANT_SEASON) { + if (isReplanted(v(), event.params.season)) { updateBeanEMA(event.address, event.block.timestamp); } } diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 1d6bae3f8f..42106d5a74 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -142,7 +142,7 @@ export function handleDewhitelistToken(event: DewhitelistToken): void { let silo = loadSilo(event.address); let currentWhitelist = silo.whitelistedTokens; let currentDewhitelist = silo.dewhitelistedTokens; - let index = currentWhitelist.indexOf(event.params.token.toHexString()); + let index = currentWhitelist.indexOf(event.params.token); if (index >= 0) { currentDewhitelist.push(currentWhitelist.splice(index, 1)[0]); silo.whitelistedTokens = currentWhitelist; @@ -163,11 +163,11 @@ export function handleUpdatedStalkPerBdvPerSeason(event: UpdatedStalkPerBdvPerSe // Withdrawal is a legacy feature from replant, but these events are still present export function handleRemoveWithdrawal(event: RemoveWithdrawal): void { - updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.season, event.block); + updateClaimedWithdraw(event.params.account, event.params.token, event.params.season, event.block); } export function handleRemoveWithdrawals(event: RemoveWithdrawals): void { for (let i = 0; i < event.params.seasons.length; i++) { - updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.seasons[i], event.block); + updateClaimedWithdraw(event.params.account, event.params.token, event.params.seasons[i], event.block); } } diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts index 3f687b31cf..fe8cf8d172 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts @@ -13,7 +13,7 @@ import { sunrise } from "../../utils/Season"; export function handleReplantSunrise(event: Sunrise): void { // Update any farmers that had silo transfers from the prior season. // This is intentionally done before beanstalk.lastSeason gets updated - updateStalkWithCalls(event.address, event.block.timestamp); + updateStalkWithCalls(event.address, event.block); // Replant oracle initialization if (event.params.season == REPLANT_SEASON) { diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index a8cf5cc632..8576719139 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -70,7 +70,7 @@ export function handleAddWithdrawal(event: AddWithdrawal): void { withdraw.createdAt = withdraw.createdAt == ZERO_BI ? event.block.timestamp : withdraw.createdAt; withdraw.save(); - addWithdrawToSiloAsset(event.address, event.params.account, event.params.token, event.params.amount, event.block.timestamp); + addWithdrawToSiloAsset(event.address, event.params.account, event.params.token, event.params.amount, event.block); } // Note: Legacy removals are still possible today, and are therefore not Legacy handlers. @@ -79,11 +79,11 @@ export function handleAddWithdrawal(event: AddWithdrawal): void { export function handleTransferDepositCall(call: TransferDepositCall): void { let beanstalk = loadBeanstalk(); let updateFarmers = beanstalk.farmersToUpdate; - if (updateFarmers.indexOf(call.from.toHexString()) == -1) { - updateFarmers.push(call.from.toHexString()); + if (updateFarmers.indexOf(call.from) == -1) { + updateFarmers.push(call.from); } - if (updateFarmers.indexOf(call.inputs.recipient.toHexString()) == -1) { - updateFarmers.push(call.inputs.recipient.toHexString()); + if (updateFarmers.indexOf(call.inputs.recipient) == -1) { + updateFarmers.push(call.inputs.recipient); } beanstalk.farmersToUpdate = updateFarmers; beanstalk.save(); @@ -93,11 +93,11 @@ export function handleTransferDepositCall(call: TransferDepositCall): void { export function handleTransferDepositsCall(call: TransferDepositsCall): void { let beanstalk = loadBeanstalk(); let updateFarmers = beanstalk.farmersToUpdate; - if (updateFarmers.indexOf(call.from.toHexString()) == -1) { - updateFarmers.push(call.from.toHexString()); + if (updateFarmers.indexOf(call.from) == -1) { + updateFarmers.push(call.from); } - if (updateFarmers.indexOf(call.inputs.recipient.toHexString()) == -1) { - updateFarmers.push(call.inputs.recipient.toHexString()); + if (updateFarmers.indexOf(call.inputs.recipient) == -1) { + updateFarmers.push(call.inputs.recipient); } beanstalk.farmersToUpdate = updateFarmers; beanstalk.save(); diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index eab9480ba7..d6b18aad4f 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -7,6 +7,7 @@ import { setFieldHourlyCaseId, setHourlySoilSoldOut, takeFieldSnapshots } from " import { getCurrentSeason, getHarvestableIndex, loadBeanstalk, loadFarmer, loadSeason } from "../entities/Beanstalk"; import { loadField, loadPlot } from "../entities/Field"; import { expirePodListingIfExists } from "./Marketplace"; +import { toAddress } from "../../../subgraph-core/utils/Bytes"; class SowParams { event: ethereum.Event; @@ -56,7 +57,7 @@ export function sow(params: SowParams): void { field.plotIndexes = newIndexes; field.save(); - plot.farmer = params.account.toHexString(); + plot.farmer = params.account; plot.source = "SOW"; plot.sourceHash = params.event.transaction.hash.toHexString(); plot.season = field.season; @@ -81,7 +82,7 @@ export function harvest(params: HarvestParams): void { // Plot should exist let plot = loadPlot(protocol, params.plots[i]); - expirePodListingIfExists(plot.farmer, plot.index, params.event.block); + expirePodListingIfExists(toAddress(plot.farmer), plot.index, params.event.block); let harvestablePods = season.harvestableIndex.minus(plot.index); @@ -209,7 +210,7 @@ export function plotTransfer(params: PlotTransferParams): void { sourcePlot.sourceHash = params.event.transaction.hash.toHexString(); sourcePlot.beansPerPod = sourcePlot.beansPerPod; } - sourcePlot.farmer = params.to.toHexString(); + sourcePlot.farmer = params.to; sourcePlot.updatedAt = params.event.block.timestamp; sourcePlot.updatedAtBlock = params.event.block.number; sourcePlot.save(); @@ -231,14 +232,14 @@ export function plotTransfer(params: PlotTransferParams): void { sourcePlot.sourceHash = params.event.transaction.hash.toHexString(); sourcePlot.beansPerPod = sourcePlot.beansPerPod; } - sourcePlot.farmer = params.to.toHexString(); + sourcePlot.farmer = params.to; sourcePlot.updatedAt = params.event.block.timestamp; sourcePlot.updatedAtBlock = params.event.block.number; sourcePlot.pods = params.amount; sourcePlot.harvestablePods = calcHarvestable(sourcePlot.index, sourcePlot.pods, currentHarvestable); sourcePlot.save(); - remainderPlot.farmer = params.from.toHexString(); + remainderPlot.farmer = params.from; remainderPlot.season = field.season; remainderPlot.creationHash = params.event.transaction.hash.toHexString(); remainderPlot.createdAt = params.event.block.timestamp; @@ -266,7 +267,7 @@ export function plotTransfer(params: PlotTransferParams): void { toPlot.sourceHash = params.event.transaction.hash.toHexString(); toPlot.beansPerPod = sourcePlot.beansPerPod; } - toPlot.farmer = params.to.toHexString(); + toPlot.farmer = params.to; toPlot.season = field.season; toPlot.creationHash = params.event.transaction.hash.toHexString(); toPlot.createdAt = params.event.block.timestamp; @@ -297,7 +298,7 @@ export function plotTransfer(params: PlotTransferParams): void { toPlot.sourceHash = params.event.transaction.hash.toHexString(); toPlot.beansPerPod = sourcePlot.beansPerPod; } - toPlot.farmer = params.to.toHexString(); + toPlot.farmer = params.to; toPlot.season = field.season; toPlot.creationHash = params.event.transaction.hash.toHexString(); toPlot.createdAt = params.event.block.timestamp; @@ -308,7 +309,7 @@ export function plotTransfer(params: PlotTransferParams): void { toPlot.harvestablePods = calcHarvestable(toPlot.index, toPlot.pods, currentHarvestable); toPlot.save(); - remainderPlot.farmer = params.from.toHexString(); + remainderPlot.farmer = params.from; remainderPlot.source = sourcePlot.source; remainderPlot.sourceHash = sourcePlot.sourceHash; remainderPlot.season = field.season; @@ -359,7 +360,7 @@ export function temperatureChanged(params: TemperatureChangedParams): void { } else { // Attempt to pull from Beanstalk Price contract first // TODO: check whether protocol should be supplied here - let beanstalkQuery = BeanstalkPrice_try_price(protocol, params.event.block.number); + let beanstalkQuery = BeanstalkPrice_try_price(params.event.block.number); if (beanstalkQuery.reverted) { let curvePrice = CurvePrice.bind(CURVE_PRICE); currentPrice = toDecimal(curvePrice.getCurve().price); @@ -433,7 +434,7 @@ export function updateHarvestablePlots(protocol: Address, harvestableIndex: BigI let deltaHarvestablePods = oldHarvestablePods == ZERO_BI ? plot.harvestablePods : plot.harvestablePods.minus(oldHarvestablePods); - updateFieldTotals(protocol, Address.fromString(plot.farmer), ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, deltaHarvestablePods, ZERO_BI, block); + updateFieldTotals(protocol, toAddress(plot.farmer), ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, deltaHarvestablePods, ZERO_BI, block); } } diff --git a/projects/subgraph-beanstalk/src/utils/Marketplace.ts b/projects/subgraph-beanstalk/src/utils/Marketplace.ts index 71e2b098bf..fb050609c2 100644 --- a/projects/subgraph-beanstalk/src/utils/Marketplace.ts +++ b/projects/subgraph-beanstalk/src/utils/Marketplace.ts @@ -17,6 +17,7 @@ import { } from "../../generated/schema"; import { getHarvestableIndex, loadFarmer } from "../entities/Beanstalk"; import { takeMarketSnapshots } from "../entities/snapshots/Marketplace"; +import { toAddress } from "../../../subgraph-core/utils/Bytes"; export enum MarketplaceAction { CREATED, @@ -169,7 +170,7 @@ export function podListingFilled(params: MarketFillParams): void { } else { listing.status = "FILLED_PARTIAL"; - let remainingListing = loadPodListing(Address.fromString(listing.farmer), listing.index.plus(params.amount).plus(listing.start)); + let remainingListing = loadPodListing(toAddress(listing.farmer), listing.index.plus(params.amount).plus(listing.start)); remainingListing.historyID = remainingListing.id + "-" + params.event.block.timestamp.toString() + "-" + params.event.logIndex.toString(); remainingListing.plot = listing.index.plus(params.amount).plus(listing.start).toString(); @@ -201,8 +202,8 @@ export function podListingFilled(params: MarketFillParams): void { let fill = loadPodFill(params.event.address, params.index, params.event.transaction.hash.toHexString()); fill.createdAt = params.event.block.timestamp; fill.listing = listing.id; - fill.fromFarmer = params.from.toHexString(); - fill.toFarmer = params.to.toHexString(); + fill.fromFarmer = params.from; + fill.toFarmer = params.to; fill.amount = params.amount; fill.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex()); fill.index = params.index; @@ -222,8 +223,8 @@ export function podListingFilled(params: MarketFillParams): void { rawEvent.logIndex = params.event.logIndex.toI32(); rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = originalHistoryID; - rawEvent.fromFarmer = params.from.toHexString(); - rawEvent.toFarmer = params.to.toHexString(); + rawEvent.fromFarmer = params.from; + rawEvent.toFarmer = params.to; rawEvent.placeInLine = fill.placeInLine; rawEvent.index = params.index; rawEvent.start = params.start; @@ -251,7 +252,7 @@ export function podListingCancelled(params: PodListingCancelledParams): void { rawEvent.logIndex = params.event.logIndex.toI32(); rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = listing.historyID; - rawEvent.account = params.account.toHexString(); + rawEvent.account = params.account; rawEvent.placeInLine = params.index.plus(listing.start).minus(getHarvestableIndex()); rawEvent.index = params.index; rawEvent.blockNumber = params.event.block.number; @@ -269,7 +270,7 @@ export function podOrderCreated(params: PodOrderCreatedParams): void { } order.historyID = order.id + "-" + params.event.block.timestamp.toString() + "-" + params.event.logIndex.toString(); - order.farmer = params.account.toHexString(); + order.farmer = params.account; order.createdAt = params.event.block.timestamp; order.updatedAt = params.event.block.timestamp; order.status = "ACTIVE"; @@ -295,7 +296,7 @@ export function podOrderCreated(params: PodOrderCreatedParams): void { rawEvent.logIndex = params.event.logIndex.toI32(); rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = order.historyID; - rawEvent.account = params.account.toHexString(); + rawEvent.account = params.account; rawEvent.orderId = params.id.toHexString(); rawEvent.amount = params.beanAmount; rawEvent.pricePerPod = params.pricePerPod; @@ -322,8 +323,8 @@ export function podOrderFilled(params: MarketFillParams): void { fill.createdAt = params.event.block.timestamp; fill.order = order.id; - fill.fromFarmer = params.from.toHexString(); - fill.toFarmer = params.to.toHexString(); + fill.fromFarmer = params.from; + fill.toFarmer = params.to; fill.amount = params.amount; fill.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex()); fill.index = params.index; @@ -346,8 +347,8 @@ export function podOrderFilled(params: MarketFillParams): void { rawEvent.logIndex = params.event.logIndex.toI32(); rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = order.historyID; - rawEvent.fromFarmer = params.from.toHexString(); - rawEvent.toFarmer = params.to.toHexString(); + rawEvent.fromFarmer = params.from; + rawEvent.toFarmer = params.to; rawEvent.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex()); rawEvent.index = params.index; rawEvent.start = params.start; @@ -375,7 +376,7 @@ export function podOrderCancelled(params: PodOrderCancelledParams): void { rawEvent.logIndex = params.event.logIndex.toI32(); rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = order.historyID; - rawEvent.account = params.account.toHexString(); + rawEvent.account = params.account; rawEvent.orderId = params.id.toHexString(); rawEvent.blockNumber = params.event.block.number; rawEvent.createdAt = params.event.block.timestamp; @@ -438,7 +439,7 @@ export function updateExpiredPlots(harvestableIndex: BigInt, block: ethereum.Blo const maxHarvestableIndex = BigInt.fromString(destructured[2]); if (harvestableIndex > maxHarvestableIndex) { // This method updates the marketplace entity, so it will perform the splice. - expirePodListingIfExists(destructured[0], BigInt.fromString(destructured[1]), block, i); + expirePodListingIfExists(Address.fromString(destructured[0]), BigInt.fromString(destructured[1]), block, i); // A similar splice is done here also to track the updated index on the underlying array. remainingListings.splice(i--, 1); } @@ -468,12 +469,12 @@ function setBeansPerPodAfterFill(event: ethereum.Event, plotIndex: BigInt, start } export function expirePodListingIfExists( - farmer: string, + farmer: Address, listedPlotIndex: BigInt, block: ethereum.Block, activeListingIndex: i32 = -1 // If provided, avoids having to lookup the index ): void { - let listing = PodListing.load(farmer + "-" + listedPlotIndex.toString()); + let listing = PodListing.load(farmer.toHexString() + "-" + listedPlotIndex.toString()); if (listing == null || listing.status != "ACTIVE") { return; } diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index de3e497259..56613ae386 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -14,6 +14,7 @@ import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { updateUnripeStats } from "./Barn"; import { isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; +import { toAddress } from "../../../subgraph-core/utils/Bytes"; export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block): void { let currentSeason = season.toI32(); @@ -29,31 +30,31 @@ export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block field.season = currentSeason; field.podRate = seasonEntity.beans == ZERO_BI ? ZERO_BD : toDecimal(field.unharvestablePods, 6).div(toDecimal(seasonEntity.beans, 6)); - takeFieldSnapshots(field, protocol, block.timestamp, block.number); + takeFieldSnapshots(field, block); field.save(); // Marketplace Season Update - let market = loadPodMarketplace(protocol); + let market = loadPodMarketplace(); market.season = currentSeason; - takeMarketSnapshots(market, protocol, block.timestamp); + takeMarketSnapshots(market, block); market.save(); // Create silo entities for the protocol let silo = loadSilo(protocol); - takeSiloSnapshots(silo, protocol, block.timestamp); + takeSiloSnapshots(silo, block); silo.save(); // Update all whitelisted/dewhitelisted token info const siloTokens = silo.whitelistedTokens.concat(silo.dewhitelistedTokens); for (let i = 0; i < siloTokens.length; i++) { - const token = Address.fromString(siloTokens[i]); + const token = toAddress(siloTokens[i]); let siloAsset = loadSiloAsset(protocol, token); - takeSiloAssetSnapshots(siloAsset, protocol, block.timestamp); + takeSiloAssetSnapshots(siloAsset, block); siloAsset.save(); let whitelistTokenSetting = loadWhitelistTokenSetting(token); - takeWhitelistTokenSettingSnapshots(whitelistTokenSetting, protocol, block.timestamp); + takeWhitelistTokenSettingSnapshots(whitelistTokenSetting, block); whitelistTokenSetting.save(); setTokenBdv(token, protocol, whitelistTokenSetting); diff --git a/projects/subgraph-beanstalk/src/utils/Silo.ts b/projects/subgraph-beanstalk/src/utils/Silo.ts index eba26c44aa..e2aa683763 100644 --- a/projects/subgraph-beanstalk/src/utils/Silo.ts +++ b/projects/subgraph-beanstalk/src/utils/Silo.ts @@ -2,10 +2,10 @@ import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { takeSiloSnapshots } from "../entities/snapshots/Silo"; import { loadSilo, loadSiloAsset, loadSiloDeposit, loadWhitelistTokenSetting, updateDeposit } from "../entities/Silo"; import { takeSiloAssetSnapshots } from "../entities/snapshots/SiloAsset"; -import { stemFromSeason } from "./contracts/SiloCalculations"; import { GAUGE_BIP45_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { loadBeanstalk, loadFarmer } from "../entities/Beanstalk"; +import { stemFromSeason } from "./legacy/LegacySilo"; class AddRemoveDepositsParams { event: ethereum.Event; @@ -159,10 +159,10 @@ export function updateStalkBalances( // Add account to active list if needed if (account !== protocol) { let beanstalk = loadBeanstalk(); - let farmerIndex = beanstalk.activeFarmers.indexOf(account.toHexString()); + let farmerIndex = beanstalk.activeFarmers.indexOf(account); if (farmerIndex == -1) { let newFarmers = beanstalk.activeFarmers; - newFarmers.push(account.toHexString()); + newFarmers.push(account); beanstalk.activeFarmers = newFarmers; beanstalk.save(); silo.activeFarmers += 1; diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index 0796b31623..bb9de150d9 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -18,6 +18,7 @@ import { REPLANT_SEASON } from "../../../subgraph-core/constants/raw/BeanstalkEt import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { getProtocolFertilizer } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; +import { toAddress } from "../../../subgraph-core/utils/Bytes"; const ROLLING_24_WINDOW = 24; const ROLLING_7_DAY_WINDOW = 168; @@ -99,7 +100,7 @@ export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i3 let gaugeSettings: Array = []; let isGaugeLive = false; for (let i = 0; i < siloYield.whitelistedTokens.length; ++i) { - let token = Address.fromString(siloYield.whitelistedTokens[i]); + let token = toAddress(siloYield.whitelistedTokens[i]); let tokenSetting = loadWhitelistTokenSetting(token); whitelistSettings.push(tokenSetting); @@ -115,7 +116,7 @@ export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i3 // Chooses which apy calculation to use if (!isGaugeLive) { - const beanGrownStalk = loadWhitelistTokenSetting(Address.fromString(beanstalk.token)).stalkEarnedPerSeason; + const beanGrownStalk = loadWhitelistTokenSetting(toAddress(beanstalk.token)).stalkEarnedPerSeason; for (let i = 0; i < whitelistSettings.length; ++i) { const tokenAPY = calculateAPYPreGauge( currentEMA, @@ -149,7 +150,7 @@ export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i3 const siloTokens = siloYield.whitelistedTokens.concat(silo.dewhitelistedTokens); const depositedAssets: SiloAsset[] = []; for (let i = 0; i < siloTokens.length; ++i) { - depositedAssets.push(loadSiloAsset(protocol, Address.fromString(siloTokens[i]))); + depositedAssets.push(loadSiloAsset(protocol, toAddress(siloTokens[i]))); } // .load() is not supported on graph-node v0.30.0. Instead the above derivation of depositedAssets is used @@ -157,7 +158,7 @@ export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i3 for (let i = 0; i < whitelistSettings.length; ++i) { // Get the total deposited bdv of this asset. Remove whitelsited assets from the list as they are encountered - const depositedIndex = SiloAsset_findIndex_token(depositedAssets, whitelistSettings[i].id.toHexString()); + const depositedIndex = SiloAsset_findIndex_token(depositedAssets, toAddress(whitelistSettings[i].id)); const depositedAsset = depositedAssets.splice(depositedIndex, 1)[0]; const depositedBdv = toDecimal(depositedAsset.depositedBDV); @@ -171,7 +172,7 @@ export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i3 germinatingGaugeLpBdv.push(germinating); staticSeeds.push(null); } else { - if (whitelistSettings[i].id == Address.fromString(beanstalk.token)) { + if (whitelistSettings[i].id == toAddress(beanstalk.token)) { tokens.push(-1); depositedBeanBdv = depositedBdv; germinatingBeanBdv = germinating; diff --git a/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts b/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts index c0308b838e..1468735122 100644 --- a/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts +++ b/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts @@ -8,6 +8,9 @@ import { import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadSilo } from "../../entities/Silo"; +import { getBeanstalkPriceAddress } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../constants/Version"; +import { toAddressArray } from "../../../../subgraph-core/utils/Bytes"; // Can't use the autogenerated one because the fields need to be updateable class PriceOverallStruct { @@ -53,13 +56,13 @@ export class BeanstalkPriceResult { private _value: PriceOverallStruct | null = null; private _dewhitelistedPools: Array = []; - constructor(value: BeanstalkPrice__priceResultPStruct | null, whitelistedPools: string[]) { + constructor(value: BeanstalkPrice__priceResultPStruct | null, whitelistedPools: Address[]) { if (value !== null) { this._value = new PriceOverallStruct(value); let poolsCount = this._value!.ps.length; let dewhitelistCount = 0; for (let i = 0; i < this._value!.ps.length; ++i) { - const index = whitelistedPools.indexOf(this._value!.ps[i].pool.toHexString()); + const index = whitelistedPools.indexOf(this._value!.ps[i].pool); if (index == -1) { // The pool was dewhitelisted this._dewhitelistedPools.push(this._value!.ps.splice(i--, 1)[0]); @@ -103,7 +106,7 @@ export class BeanstalkPriceResult { // Wrapper for BeanstalkPrice contract that handles a few things: // (1) Only including whitelisted tokens in the final price calculation and the prices list // (2) Which contract to call (in anticipation of new BeanstalkPrice contract deployments) -export function BeanstalkPrice_try_price(beanstalkAddr: Address, blockNumber: BigInt): BeanstalkPriceResult { +export function BeanstalkPrice_try_price(blockNumber: BigInt): BeanstalkPriceResult { let beanstalkPrice = getBeanstalkPrice(blockNumber); let beanPrice = beanstalkPrice.try_price(); @@ -111,11 +114,11 @@ export function BeanstalkPrice_try_price(beanstalkAddr: Address, blockNumber: Bi return new BeanstalkPriceResult(null, []); } - let silo = loadSilo(beanstalkAddr); + let silo = loadSilo(v().protocolAddress); // changetype is necessary as there are identical responses from different generated contract objects. // If the response structure changes in the future, this will need to be revisited. - return new BeanstalkPriceResult(changetype(beanPrice.value), silo.whitelistedTokens); + return new BeanstalkPriceResult(changetype(beanPrice.value), toAddressArray(silo.whitelistedTokens)); } // Extracts the pool price from the larger result @@ -135,14 +138,7 @@ export function getPoolPrice(priceResult: BeanstalkPriceResult, pool: Address): } // Gets the BeanstalkPrice contract, bound to the appropriate instance of the contract. -// Note: Will bind to PRICE_1 even if that contract has not been deployed yet -// Thus the caller still needs to check for reverts. +// Note: The caller still needs to check for reverts. export function getBeanstalkPrice(blockNumber: BigInt): BeanstalkPrice { - let contractAddress: Address; - if (blockNumber < PRICE_2_BLOCK) { - contractAddress = BEANSTALK_PRICE_1; - } else { - contractAddress = BEANSTALK_PRICE_2; - } - return BeanstalkPrice.bind(contractAddress); + return BeanstalkPrice.bind(getBeanstalkPriceAddress(v(), blockNumber)); } diff --git a/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts b/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts deleted file mode 100644 index 81f5527198..0000000000 --- a/projects/subgraph-beanstalk/src/utils/contracts/SiloCalculations.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; -import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; -import { BI_10 } from "../../../../subgraph-core/utils/Decimals"; - -const STEM_START_SEASON = 14210; - -export function stemFromSeason(season: i32, token: Address): BigInt { - return seasonToV3Stem(season, STEM_START_SEASON, getLegacySeedsPerToken(token)); -} - -// Equivalent to LibLegacyTokenSilo.seasonToStem -function seasonToV3Stem(season: i32, stemStartSeason: i32, seedsPerBdv: i32): BigInt { - return BigInt.fromI32(season - stemStartSeason).times(BigInt.fromI32(seedsPerBdv).times(BI_10.pow(6))); -} - -// Equivalent to LibLegacyTokenSilo.getLegacySeedsPerToken -function getLegacySeedsPerToken(token: Address): i32 { - if (token == BEAN_ERC20) { - return 2; - } else if (token == UNRIPE_BEAN) { - return 2; - } else if (token == UNRIPE_LP) { - return 4; - } else if (token == BEAN_3CRV) { - return 4; - } - return 0; -} diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts index 889ec5acfe..8908ce5e43 100644 --- a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts @@ -4,14 +4,11 @@ import { takeSiloAssetSnapshots } from "../../entities/snapshots/SiloAsset"; import { loadBeanstalk } from "../../entities/Beanstalk"; import { updateSeedsBalances, updateStalkBalances } from "../Silo"; import { Replanted } from "../../../generated/Beanstalk-ABIs/Replanted"; +import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { BI_10 } from "../../../../subgraph-core/utils/Decimals"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; -export function updateClaimedWithdraw( - protocol: Address, - account: Address, - token: Address, - withdrawSeason: BigInt, - block: ethereum.Block -): void { +export function updateClaimedWithdraw(account: Address, token: Address, withdrawSeason: BigInt, block: ethereum.Block): void { let withdraw = loadSiloWithdraw(account, token, withdrawSeason.toI32()); withdraw.claimed = true; withdraw.save(); @@ -29,7 +26,7 @@ export function updateStalkWithCalls(protocol: Address, block: ethereum.Block): let beanstalk_call = Replanted.bind(protocol); for (let i = 0; i < beanstalk.farmersToUpdate.length; i++) { - let account = Address.fromString(beanstalk.farmersToUpdate[i]); + let account = toAddress(beanstalk.farmersToUpdate[i]); let silo = loadSilo(account); updateStalkBalances( protocol, @@ -44,3 +41,28 @@ export function updateStalkWithCalls(protocol: Address, block: ethereum.Block): beanstalk.farmersToUpdate = []; beanstalk.save(); } + +const STEM_START_SEASON = 14210; + +export function stemFromSeason(season: i32, token: Address): BigInt { + return seasonToV3Stem(season, STEM_START_SEASON, getLegacySeedsPerToken(token)); +} + +// Equivalent to LibLegacyTokenSilo.seasonToStem +function seasonToV3Stem(season: i32, stemStartSeason: i32, seedsPerBdv: i32): BigInt { + return BigInt.fromI32(season - stemStartSeason).times(BigInt.fromI32(seedsPerBdv).times(BI_10.pow(6))); +} + +// Equivalent to LibLegacyTokenSilo.getLegacySeedsPerToken +function getLegacySeedsPerToken(token: Address): i32 { + if (token == BEAN_ERC20) { + return 2; + } else if (token == UNRIPE_BEAN) { + return 2; + } else if (token == UNRIPE_LP) { + return 4; + } else if (token == BEAN_3CRV) { + return 4; + } + return 0; +} diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacyWhitelist.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacyWhitelist.ts new file mode 100644 index 0000000000..793326b8b0 --- /dev/null +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacyWhitelist.ts @@ -0,0 +1,27 @@ +import { BigInt } from "@graphprotocol/graph-ts"; +import { BEAN_WETH_CP2_WELL, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; +import { WhitelistTokenSetting } from "../../../generated/schema"; +import { BI_10 } from "../../../../subgraph-core/utils/Decimals"; +import { UpdateGaugeSettings } from "../../../generated/Beanstalk-ABIs/SeedGauge"; + +export function initLegacyUnripe(setting: WhitelistTokenSetting): void { + const token = toAddress(setting.id); + if (token == UNRIPE_BEAN) { + setting.stalkIssuedPerBdv = BigInt.fromString("10000000000"); + setting.stalkEarnedPerSeason = BigInt.fromI32(2000000); + } else if (token == UNRIPE_LP) { + setting.stalkIssuedPerBdv = BigInt.fromString("10000000000"); + setting.stalkEarnedPerSeason = BigInt.fromI32(4000000); + } +} + +export function legacyInitGauge(event: UpdateGaugeSettings, setting: WhitelistTokenSetting): void { + // On initial gauge deployment, there was no GaugePointChange event emitted. Need to initialize BEANETH here + if ( + event.params.token == BEAN_WETH_CP2_WELL && + event.transaction.hash.toHexString().toLowerCase() == "0x299a4b93b8d19f8587b648ce04e3f5e618ea461426bb2b2337993b5d6677f6a7" + ) { + setting.gaugePoints = BI_10.pow(20); + } +} diff --git a/projects/subgraph-beanstalk/tests/Silo.test.ts b/projects/subgraph-beanstalk/tests/Silo.test.ts index 2ca0a4371b..87fc1542ca 100644 --- a/projects/subgraph-beanstalk/tests/Silo.test.ts +++ b/projects/subgraph-beanstalk/tests/Silo.test.ts @@ -30,8 +30,8 @@ import { handleWhitelistToken_v3 } from "../src/handlers/legacy/LegacySiloHandler"; import { handleAddDeposit, handleDewhitelistToken, handleRemoveDeposit } from "../src/handlers/SiloHandler"; -import { stemFromSeason } from "../src/utils/contracts/SiloCalculations"; import { initL1Version } from "./entity-mocking/MockVersion"; +import { stemFromSeason } from "../src/utils/legacy/LegacySilo"; describe("Silo Events", () => { beforeEach(() => { diff --git a/projects/subgraph-beanstalk/tests/Yield.test.ts b/projects/subgraph-beanstalk/tests/Yield.test.ts index bd78503f26..f953917e81 100644 --- a/projects/subgraph-beanstalk/tests/Yield.test.ts +++ b/projects/subgraph-beanstalk/tests/Yield.test.ts @@ -152,13 +152,8 @@ describe("APY Calculations", () => { let silo = loadSilo(BEANSTALK); silo.stalk = BigInt.fromString("1615408790000000000"); silo.beanToMaxLpGpPerBdvRatio = BigInt.fromString("33000000000000000000"); - silo.whitelistedTokens = [ - BEAN_ERC20.toHexString(), - BEAN_WETH_CP2_WELL.toHexString(), - UNRIPE_BEAN.toHexString(), - UNRIPE_LP.toHexString() - ]; - silo.dewhitelistedTokens = [BEAN_3CRV.toHexString()]; + silo.whitelistedTokens = [BEAN_ERC20, BEAN_WETH_CP2_WELL, UNRIPE_BEAN, UNRIPE_LP]; + silo.dewhitelistedTokens = [BEAN_3CRV]; silo.save(); setSeason(20000); diff --git a/projects/subgraph-core/constants/BeanstalkEth.ts b/projects/subgraph-core/constants/BeanstalkEth.ts index 134ea5c15d..ae226afef8 100644 --- a/projects/subgraph-core/constants/BeanstalkEth.ts +++ b/projects/subgraph-core/constants/BeanstalkEth.ts @@ -17,6 +17,7 @@ import { GAUGE_BIP45_BLOCK, NEW_BEAN_TOKEN_BLOCK, PRICE_2_BLOCK, + REPLANT_SEASON, UNRIPE_BEAN, UNRIPE_LP } from "./raw/BeanstalkEthConstants"; @@ -80,6 +81,10 @@ export function getTokenDecimals(token: Address): i32 { /// MILESTONE /// +export function isReplanted(blockNumber: BigInt): boolean { + return blockNumber >= REPLANT_SEASON; +} + export function isGaugeDeployed(blockNumber: BigInt): boolean { return blockNumber >= GAUGE_BIP45_BLOCK; } diff --git a/projects/subgraph-core/constants/RuntimeConstants.ts b/projects/subgraph-core/constants/RuntimeConstants.ts index 49067bd006..04dd3e9b82 100644 --- a/projects/subgraph-core/constants/RuntimeConstants.ts +++ b/projects/subgraph-core/constants/RuntimeConstants.ts @@ -55,6 +55,13 @@ export function getTokenDecimals(v: VersionDto, token: Address): i32 { /// MILESTONE /// +export function isReplanted(v: VersionDto, blockNumber: BigInt): boolean { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.isReplanted(blockNumber); + } + throw new Error("Unsupported protocol"); +} + export function isGaugeDeployed(v: VersionDto, blockNumber: BigInt): boolean { if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { return BeanstalkEth.isGaugeDeployed(blockNumber); From 02ed6e3ebef9a099349d05d83c58d363acebe3e1 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:23:28 -0700 Subject: [PATCH 21/88] misc refactor fixes --- .../src/handlers/FarmHandler.ts | 10 ++--- .../src/handlers/SiloHandler.ts | 4 +- .../src/handlers/legacy/LegacyFieldHandler.ts | 42 ++----------------- .../handlers/legacy/LegacySeasonHandler.ts | 2 +- projects/subgraph-beanstalk/src/utils/Barn.ts | 4 +- .../subgraph-beanstalk/src/utils/Field.ts | 1 - 6 files changed, 14 insertions(+), 49 deletions(-) diff --git a/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts b/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts index 16d443c2e8..30a8123fdb 100644 --- a/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts @@ -1,4 +1,4 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { InternalBalanceChanged } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { takeSiloAssetSnapshots } from "../entities/snapshots/SiloAsset"; import { loadSiloAsset } from "../entities/Silo"; @@ -6,7 +6,7 @@ import { loadFarmer } from "../entities/Beanstalk"; export function handleInternalBalanceChanged(event: InternalBalanceChanged): void { loadFarmer(event.params.user); - updateFarmTotals(event.address, event.params.user, event.params.token, event.params.delta, event.block.timestamp); + updateFarmTotals(event.address, event.params.user, event.params.token, event.params.delta, event.block); } function updateFarmTotals( @@ -14,14 +14,14 @@ function updateFarmTotals( account: Address, token: Address, deltaAmount: BigInt, - timestamp: BigInt, + block: ethereum.Block, recursive: boolean = true ): void { if (recursive && account != protocol) { - updateFarmTotals(protocol, protocol, token, deltaAmount, timestamp); + updateFarmTotals(protocol, protocol, token, deltaAmount, block); } let asset = loadSiloAsset(account, token); asset.farmAmount = asset.farmAmount.plus(deltaAmount); - takeSiloAssetSnapshots(asset, protocol, timestamp); + takeSiloAssetSnapshots(asset, block); asset.save(); } diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 42106d5a74..13205a85ce 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -81,7 +81,7 @@ export function handleStalkBalanceChanged(event: StalkBalanceChanged): void { return; } - updateStalkBalances(event.address, event.params.account, event.params.delta, event.params.deltaRoots, event.block.timestamp); + updateStalkBalances(event.address, event.params.account, event.params.delta, event.params.deltaRoots, event.block); } export function handleSeedsBalanceChanged(event: SeedsBalanceChanged): void { @@ -90,7 +90,7 @@ export function handleSeedsBalanceChanged(event: SeedsBalanceChanged): void { return; } - updateSeedsBalances(event.address, event.params.account, event.params.delta, event.block.timestamp); + updateSeedsBalances(event.address, event.params.account, event.params.delta, event.block); } export function handlePlant(event: Plant): void { diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFieldHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFieldHandler.ts index f2d969a43c..c007a22c12 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFieldHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFieldHandler.ts @@ -14,50 +14,17 @@ export function handleWeatherChange(event: WeatherChange): void { // PreReplant -> Replanted export function handleSupplyIncrease(event: SupplyIncrease): void { - updateFieldTotals( - event.address, - event.address, - event.params.newSoil, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - event.block.timestamp, - event.block.number - ); + updateFieldTotals(event.address, event.address, event.params.newSoil, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, event.block); } // PreReplant -> Replanted export function handleSupplyDecrease(event: SupplyDecrease): void { - updateFieldTotals( - event.address, - event.address, - event.params.newSoil, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - event.block.timestamp, - event.block.number - ); + updateFieldTotals(event.address, event.address, event.params.newSoil, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, event.block); } // PreReplant -> Replanted export function handleSupplyNeutral(event: SupplyNeutral): void { - updateFieldTotals( - event.address, - event.address, - event.params.newSoil, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - event.block.timestamp, - event.block.number - ); + updateFieldTotals(event.address, event.address, event.params.newSoil, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, event.block); } // PreReplant -> Replanted @@ -72,7 +39,6 @@ export function handleFundFundraiser(event: FundFundraiser): void { ZERO_BI, ZERO_BI, ZERO_BI, - event.block.timestamp, - event.block.number + event.block ); } diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts index fe8cf8d172..aa28e50c8c 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts @@ -36,7 +36,7 @@ export function handleSeasonSnapshot(event: SeasonSnapshot): void { export function handleMetapoolOracle(event: MetapoolOracle): void { let season = loadSeason(event.params.season); // Attempt to pull from Beanstalk Price contract first - let beanstalkQuery = BeanstalkPrice_try_price(event.address, event.block.number); + let beanstalkQuery = BeanstalkPrice_try_price(event.block.number); if (beanstalkQuery.reverted) { let curvePrice = CurvePrice.bind(CURVE_PRICE); season.price = toDecimal(curvePrice.getCurve().price); diff --git a/projects/subgraph-beanstalk/src/utils/Barn.ts b/projects/subgraph-beanstalk/src/utils/Barn.ts index 0d5188a194..c52fb10cac 100644 --- a/projects/subgraph-beanstalk/src/utils/Barn.ts +++ b/projects/subgraph-beanstalk/src/utils/Barn.ts @@ -50,7 +50,7 @@ export function unripeChopped(params: ChopParams): void { let id = params.type + "-" + params.event.transaction.hash.toHexString() + "-" + params.event.transactionLogIndex.toString(); let chop = new ChopEntity(id); - chop.farmer = params.account.toHexString(); + chop.farmer = params.account; chop.unripeToken = unripe.id; chop.unripeAmount = params.unripeAmount; chop.unripeBdv = params.unripeAmount.times(unripeBdvOne).div(BI_10.pow(unripeWhitelist.decimals)); @@ -91,6 +91,6 @@ export function updateUnripeStats(unripe: Address, protocol: Address, block: eth unripeToken.choppableBdvOne = unripeToken.choppableAmountOne.times(underlyingBdvOne).div(BI_10.pow(underlyingWhitelist.decimals)); } - takeUnripeTokenSnapshots(unripeToken, protocol, block.timestamp); + takeUnripeTokenSnapshots(unripeToken, block); unripeToken.save(); } diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index d6b18aad4f..ad22ff6c2b 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -359,7 +359,6 @@ export function temperatureChanged(params: TemperatureChangedParams): void { currentPrice = seasonEntity.price; } else { // Attempt to pull from Beanstalk Price contract first - // TODO: check whether protocol should be supplied here let beanstalkQuery = BeanstalkPrice_try_price(params.event.block.number); if (beanstalkQuery.reverted) { let curvePrice = CurvePrice.bind(CURVE_PRICE); From 46e1f407531802395f1edcc1ea2381bfe2e58b52 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:58:50 -0700 Subject: [PATCH 22/88] finish constants refactor --- .../src/handlers/GaugeHandler.ts | 3 +-- .../src/handlers/legacy/LegacySeasonHandler.ts | 14 +++----------- projects/subgraph-beanstalk/src/utils/Field.ts | 13 ++----------- projects/subgraph-beanstalk/src/utils/Silo.ts | 7 ++++--- projects/subgraph-beanstalk/src/utils/Yield.ts | 9 +++++---- .../src/utils/contracts/BeanstalkPrice.ts | 14 +++++++++++++- projects/subgraph-core/constants/BeanstalkEth.ts | 5 ++++- .../subgraph-core/constants/RuntimeConstants.ts | 7 +++++++ 8 files changed, 39 insertions(+), 33 deletions(-) diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index 9c91575539..aa12ccc9c3 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -18,8 +18,7 @@ import { loadOrCreateGerminating, savePrevFarmerGerminatingEvent } from "../entities/Germinating"; -import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { BEAN_WETH_CP2_WELL } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { Bytes4_emptyToNull } from "../../../subgraph-core/utils/Bytes"; import { setSiloHourlyCaseId, takeSiloSnapshots } from "../entities/snapshots/Silo"; import { loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts index aa28e50c8c..d692e9cd53 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts @@ -1,10 +1,9 @@ import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; -import { CURVE_PRICE, REPLANT_SEASON } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { REPLANT_SEASON } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal } from "../../../../subgraph-core/utils/Decimals"; -import { CurvePrice } from "../../../generated/Beanstalk-ABIs/CurvePrice"; import { SeasonSnapshot, Sunrise } from "../../../generated/Beanstalk-ABIs/PreReplant"; import { MetapoolOracle } from "../../../generated/Beanstalk-ABIs/Replanted"; -import { BeanstalkPrice_try_price } from "../../utils/contracts/BeanstalkPrice"; +import { BeanstalkPrice_priceOnly } from "../../utils/contracts/BeanstalkPrice"; import { loadSeason } from "../../entities/Beanstalk"; import { updateStalkWithCalls } from "../../utils/legacy/LegacySilo"; import { sunrise } from "../../utils/Season"; @@ -35,14 +34,7 @@ export function handleSeasonSnapshot(event: SeasonSnapshot): void { // Replanted -> SeedGauge export function handleMetapoolOracle(event: MetapoolOracle): void { let season = loadSeason(event.params.season); - // Attempt to pull from Beanstalk Price contract first - let beanstalkQuery = BeanstalkPrice_try_price(event.block.number); - if (beanstalkQuery.reverted) { - let curvePrice = CurvePrice.bind(CURVE_PRICE); - season.price = toDecimal(curvePrice.getCurve().price); - } else { - season.price = toDecimal(beanstalkQuery.value.price); - } + season.price = toDecimal(BeanstalkPrice_priceOnly(event.block.number)); season.deltaB = event.params.deltaB; season.save(); } diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index ad22ff6c2b..ecfd6346df 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -1,7 +1,5 @@ import { Address, BigInt, BigDecimal, ethereum } from "@graphprotocol/graph-ts"; -import { CurvePrice } from "../../generated/Beanstalk-ABIs/CurvePrice"; -import { BeanstalkPrice_try_price } from "./contracts/BeanstalkPrice"; -import { CURVE_PRICE } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { BeanstalkPrice_priceOnly } from "./contracts/BeanstalkPrice"; import { BI_10, ONE_BD, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { setFieldHourlyCaseId, setHourlySoilSoldOut, takeFieldSnapshots } from "../entities/snapshots/Field"; import { getCurrentSeason, getHarvestableIndex, loadBeanstalk, loadFarmer, loadSeason } from "../entities/Beanstalk"; @@ -358,14 +356,7 @@ export function temperatureChanged(params: TemperatureChangedParams): void { if (seasonEntity.price != ZERO_BD) { currentPrice = seasonEntity.price; } else { - // Attempt to pull from Beanstalk Price contract first - let beanstalkQuery = BeanstalkPrice_try_price(params.event.block.number); - if (beanstalkQuery.reverted) { - let curvePrice = CurvePrice.bind(CURVE_PRICE); - currentPrice = toDecimal(curvePrice.getCurve().price); - } else { - currentPrice = toDecimal(beanstalkQuery.value.price); - } + currentPrice = toDecimal(BeanstalkPrice_priceOnly(params.event.block.number)); } field.realRateOfReturn = ONE_BD.plus(BigDecimal.fromString((field.temperature / 100).toString())).div(currentPrice); diff --git a/projects/subgraph-beanstalk/src/utils/Silo.ts b/projects/subgraph-beanstalk/src/utils/Silo.ts index e2aa683763..696d4cfd12 100644 --- a/projects/subgraph-beanstalk/src/utils/Silo.ts +++ b/projects/subgraph-beanstalk/src/utils/Silo.ts @@ -2,10 +2,11 @@ import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { takeSiloSnapshots } from "../entities/snapshots/Silo"; import { loadSilo, loadSiloAsset, loadSiloDeposit, loadWhitelistTokenSetting, updateDeposit } from "../entities/Silo"; import { takeSiloAssetSnapshots } from "../entities/snapshots/SiloAsset"; -import { GAUGE_BIP45_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { loadBeanstalk, loadFarmer } from "../entities/Beanstalk"; import { stemFromSeason } from "./legacy/LegacySilo"; +import { isGaugeDeployed } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./constants/Version"; class AddRemoveDepositsParams { event: ethereum.Event; @@ -34,8 +35,8 @@ export function addDeposits(params: AddRemoveDepositsParams): void { // Fill stem according to legacy conversion deposit.stemV31 = stemFromSeason(params.seasons![i].toI32(), params.token); } else { - deposit.depositVersion = params.event.block.number > GAUGE_BIP45_BLOCK ? "v3.1" : "v3"; - deposit.stemV31 = params.event.block.number > GAUGE_BIP45_BLOCK ? deposit.stem! : deposit.stem!.times(BI_10.pow(6)); + deposit.depositVersion = isGaugeDeployed(v(), params.event.block.number) ? "v3.1" : "v3"; + deposit.stemV31 = isGaugeDeployed(v(), params.event.block.number) ? deposit.stem! : deposit.stem!.times(BI_10.pow(6)); } deposit = updateDeposit(deposit, params.amounts[i], params.bdvs![i], params.event)!; diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index bb9de150d9..79fdf5c8df 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -14,9 +14,8 @@ import { calculateAPYPreGauge } from "./legacy/LegacyYield"; import { getGerminatingBdvs } from "../entities/Germinating"; import { getCurrentSeason, getRewardMinted, loadBeanstalk } from "../entities/Beanstalk"; import { loadFertilizer, loadFertilizerYield } from "../entities/Fertilizer"; -import { REPLANT_SEASON } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { getProtocolFertilizer } from "../../../subgraph-core/constants/RuntimeConstants"; +import { getProtocolFertilizer, minEMASeason } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; @@ -43,6 +42,8 @@ export function updateBeanEMA(protocol: Address, timestamp: BigInt): void { } function updateWindowEMA(protocol: Address, timestamp: BigInt, window: i32): void { + const minStartSeason = minEMASeason(v()); + const t = getCurrentSeason(); let silo = loadSilo(protocol); let siloYield = loadSiloYield(t, window); @@ -56,7 +57,7 @@ function updateWindowEMA(protocol: Address, timestamp: BigInt, window: i32): voi // When less then window data points are available, // smooth over whatever is available. Otherwise use the full window. - siloYield.u = t - 6074 < window ? t - 6074 : window; + siloYield.u = t - (minStartSeason - 1) < window ? t - (minStartSeason - 1) : window; siloYield.whitelistedTokens = silo.whitelistedTokens; // Calculate the current beta value @@ -68,7 +69,7 @@ function updateWindowEMA(protocol: Address, timestamp: BigInt, window: i32): voi if (siloYield.u < window) { // Recalculate EMA from initial season since beta has changed - for (let i = REPLANT_SEASON.toI32(); i <= t; i++) { + for (let i = minStartSeason; i <= t; i++) { let rewardMint = getRewardMinted(i); currentEMA = toDecimal(rewardMint).minus(priorEMA).times(siloYield.beta).plus(priorEMA); priorEMA = currentEMA; diff --git a/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts b/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts index 1468735122..79802f4a49 100644 --- a/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts +++ b/projects/subgraph-beanstalk/src/utils/contracts/BeanstalkPrice.ts @@ -5,12 +5,13 @@ import { BeanstalkPrice__priceResultPPsStruct, BeanstalkPrice__priceResultPStruct } from "../../../generated/Beanstalk-ABIs/BeanstalkPrice"; -import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { loadSilo } from "../../entities/Silo"; import { getBeanstalkPriceAddress } from "../../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../constants/Version"; import { toAddressArray } from "../../../../subgraph-core/utils/Bytes"; +import { CurvePrice } from "../../../generated/Beanstalk-ABIs/CurvePrice"; +import { CURVE_PRICE } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; // Can't use the autogenerated one because the fields need to be updateable class PriceOverallStruct { @@ -137,6 +138,17 @@ export function getPoolPrice(priceResult: BeanstalkPriceResult, pool: Address): return null; } +// Currently there are no circumstances in which these calls can revert. +// This may need to be revisited if more past analytics are added. +export function BeanstalkPrice_priceOnly(blockNumber: BigInt): BigInt { + let beanstalkQuery = BeanstalkPrice_try_price(blockNumber); + if (!beanstalkQuery.reverted) { + return beanstalkQuery.value.price; + } else { + return CurvePrice.bind(CURVE_PRICE).getCurve().price; + } +} + // Gets the BeanstalkPrice contract, bound to the appropriate instance of the contract. // Note: The caller still needs to check for reverts. export function getBeanstalkPrice(blockNumber: BigInt): BeanstalkPrice { diff --git a/projects/subgraph-core/constants/BeanstalkEth.ts b/projects/subgraph-core/constants/BeanstalkEth.ts index ae226afef8..6d450709af 100644 --- a/projects/subgraph-core/constants/BeanstalkEth.ts +++ b/projects/subgraph-core/constants/BeanstalkEth.ts @@ -10,7 +10,6 @@ import { BEAN_WETH_V1, BEAN_WSTETH_CP2_WELL, BEAN_WSTETH_UNRIPE_MIGRATION_BLOCK, - BEANSTALK, BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, FERTILIZER, @@ -111,3 +110,7 @@ export function getBeanstalkPriceAddress(blockNumber: BigInt): Address { return BEANSTALK_PRICE_2; } } + +export function minEMASeason(): i32 { + return REPLANT_SEASON.toI32(); +} diff --git a/projects/subgraph-core/constants/RuntimeConstants.ts b/projects/subgraph-core/constants/RuntimeConstants.ts index 04dd3e9b82..3c0cc697db 100644 --- a/projects/subgraph-core/constants/RuntimeConstants.ts +++ b/projects/subgraph-core/constants/RuntimeConstants.ts @@ -82,3 +82,10 @@ export function getBeanstalkPriceAddress(v: VersionDto, blockNumber: BigInt): Ad } throw new Error("Unsupported protocol"); } + +export function minEMASeason(v: VersionDto): i32 { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.minEMASeason(); + } + throw new Error("Unsupported protocol"); +} From f69bf89b910b20bf4611e0886741e3da66c2c52a Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Tue, 10 Sep 2024 12:10:07 -0700 Subject: [PATCH 23/88] increment version to 3.0.0 --- projects/subgraph-basin/src/utils/constants/Version.ts | 2 +- projects/subgraph-beanstalk/src/utils/constants/Version.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/subgraph-basin/src/utils/constants/Version.ts b/projects/subgraph-basin/src/utils/constants/Version.ts index 34d9b2d16f..202461cd99 100644 --- a/projects/subgraph-basin/src/utils/constants/Version.ts +++ b/projects/subgraph-basin/src/utils/constants/Version.ts @@ -6,7 +6,7 @@ import { toAddress } from "../../../../subgraph-core/utils/Bytes"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); - versionEntity.versionNumber = "2.2.2"; + versionEntity.versionNumber = "3.0.0"; versionEntity.subgraphName = subgraphNameForBlockNumber(block.number); versionEntity.protocolAddress = protocolForBlockNumber(block.number); versionEntity.chain = chainForBlockNumber(block.number); diff --git a/projects/subgraph-beanstalk/src/utils/constants/Version.ts b/projects/subgraph-beanstalk/src/utils/constants/Version.ts index 21c97c97a6..48dd38bd52 100644 --- a/projects/subgraph-beanstalk/src/utils/constants/Version.ts +++ b/projects/subgraph-beanstalk/src/utils/constants/Version.ts @@ -6,7 +6,7 @@ import { toAddress } from "../../../../subgraph-core/utils/Bytes"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); - versionEntity.versionNumber = "2.4.1"; + versionEntity.versionNumber = "3.0.0"; versionEntity.subgraphName = subgraphNameForBlockNumber(block.number); versionEntity.protocolAddress = protocolForBlockNumber(block.number); versionEntity.chain = chainForBlockNumber(block.number); From c9028c34580a5fc4efed496e84efc976ab9e9701 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Tue, 10 Sep 2024 22:31:59 -0700 Subject: [PATCH 24/88] change string to bytes --- projects/subgraph-beanstalk/schema.graphql | 44 +++++++------------ .../subgraph-beanstalk/src/entities/Field.ts | 4 +- .../src/entities/PodMarketplace.ts | 4 +- .../subgraph-beanstalk/src/entities/Silo.ts | 2 +- projects/subgraph-beanstalk/src/utils/Barn.ts | 2 +- .../subgraph-beanstalk/src/utils/Field.ts | 30 ++++++------- .../src/utils/Marketplace.ts | 28 +++++------- 7 files changed, 47 insertions(+), 67 deletions(-) diff --git a/projects/subgraph-beanstalk/schema.graphql b/projects/subgraph-beanstalk/schema.graphql index 11cd10fc0e..5dceba48fa 100644 --- a/projects/subgraph-beanstalk/schema.graphql +++ b/projects/subgraph-beanstalk/schema.graphql @@ -643,7 +643,7 @@ type SiloDeposit @entity { "Original deposited BDV" depositedBDV: BigInt! "Transaction hashes pertaining to this deposit" - hashes: [String!]! + hashes: [Bytes!]! "Block of first deposit" createdBlock: BigInt! "Block when last updated" @@ -683,13 +683,13 @@ type Plot @entity { "Transaction source for this plot. Not the same as creationHash which can include plots splitting from transfer or harvest without the owner changing" source: PlotSource! "Transaction hash corresponding to source" - sourceHash: String! + sourceHash: Bytes! "Associated plot listing" listing: PodListing "Season when created" season: Int! "Transaction hash of when this plot entity was created" - creationHash: String! + creationHash: Bytes! "Timestamp of creation" createdAt: BigInt! "Timestamp when updated" @@ -1013,7 +1013,7 @@ type PodListing @entity { updatedAt: BigInt! "Transaction hash when this PodListing entity was created." - creationHash: String! + creationHash: Bytes! } type PodOrder @entity { @@ -1131,7 +1131,7 @@ type PodOrder @entity { updatedAt: BigInt! "Transaction hash when this PodOrder entity was created." - creationHash: String! + creationHash: Bytes! } type PodFill @entity { @@ -1169,7 +1169,7 @@ type PodFill @entity { type Fertilizer @entity { "Token address for fert" id: Bytes! - "Address of parent beanstalk" + "'beanstalk'" beanstalk: String! "Total overall suppy of fert tokens" supply: BigInt! @@ -1232,11 +1232,9 @@ interface MarketplaceEvent { "{ Event type }-{ Transaction hash }-{ Log index }" id: ID! "Transaction hash of the transaction that emitted this event" - hash: String! + hash: Bytes! "Event log index. For transactions that don't emit event, create arbitrary index starting from 0" logIndex: Int! - "The protocol this transaction belongs to" - protocol: Beanstalk! "Block number of this event" blockNumber: BigInt! "Timestamp of this event" @@ -1263,7 +1261,7 @@ type Chop @entity(immutable: true) { "The effective chop rate for this chop" chopRate: BigDecimal! "Transaction hash of the transaction that emitted this event" - hash: String! + hash: Bytes! "The block number of this event" blockNumber: BigInt! "Timestamp of this chop" @@ -1274,15 +1272,13 @@ type PodListingCreated implements MarketplaceEvent @entity(immutable: true) { "podListingCreated-{ Transaction hash }-{ Log index }" id: ID! "Transaction hash of the transaction that emitted this event" - hash: String! + hash: Bytes! "Event log index. For transactions that don't emit event, create arbitrary index starting from 0" logIndex: Int! - "The protocol this transaction belongs to" - protocol: Beanstalk! "Historical ID for joins" historyID: String! "Account creating the listing" - account: String! + account: Bytes! "Where these pods were in line when listed" placeInLine: BigInt! "Index of the plot listed" @@ -1313,11 +1309,9 @@ type PodListingFilled implements MarketplaceEvent @entity(immutable: true) { "podListingFilled-{ Transaction hash }-{ Log index }" id: ID! "Transaction hash of the transaction that emitted this event" - hash: String! + hash: Bytes! "Event log index. For transactions that don't emit event, create arbitrary index starting from 0" logIndex: Int! - "The protocol this transaction belongs to" - protocol: Beanstalk! "Historical ID for joins" historyID: String! "Account selling pods" @@ -1344,11 +1338,9 @@ type PodListingCancelled implements MarketplaceEvent @entity(immutable: true) { "seedChange-{ Transaction hash }-{ Log index }" id: ID! "Transaction hash of the transaction that emitted this event" - hash: String! + hash: Bytes! "Event log index. For transactions that don't emit event, create arbitrary index starting from 0" logIndex: Int! - "The protocol this transaction belongs to" - protocol: Beanstalk! "Historical ID for joins" historyID: String! "Account cancelling listing" @@ -1367,11 +1359,9 @@ type PodOrderCreated implements MarketplaceEvent @entity(immutable: true) { "podOrderCreated-{ Transaction hash }-{ Log index }" id: ID! "Transaction hash of the transaction that emitted this event" - hash: String! + hash: Bytes! "Event log index. For transactions that don't emit event, create arbitrary index starting from 0" logIndex: Int! - "The protocol this transaction belongs to" - protocol: Beanstalk! "Historical ID for joins" historyID: String! "Account creating the listing" @@ -1402,11 +1392,9 @@ type PodOrderFilled implements MarketplaceEvent @entity(immutable: true) { "podOrderFilled-{ Transaction hash }-{ Log index }" id: ID! "Transaction hash of the transaction that emitted this event" - hash: String! + hash: Bytes! "Event log index. For transactions that don't emit event, create arbitrary index starting from 0" logIndex: Int! - "The protocol this transaction belongs to" - protocol: Beanstalk! "Historical ID for joins" historyID: String! "Account selling pods" @@ -1433,11 +1421,9 @@ type PodOrderCancelled implements MarketplaceEvent @entity(immutable: true) { "podOrderCancelled-{ Transaction hash }-{ Log index }" id: ID! "Transaction hash of the transaction that emitted this event" - hash: String! + hash: Bytes! "Event log index. For transactions that don't emit event, create arbitrary index starting from 0" logIndex: Int! - "The protocol this transaction belongs to" - protocol: Beanstalk! "Historical ID for joins" historyID: String! "Account cancelling listing" diff --git a/projects/subgraph-beanstalk/src/entities/Field.ts b/projects/subgraph-beanstalk/src/entities/Field.ts index 1eb6a48c13..4ffd0c6182 100644 --- a/projects/subgraph-beanstalk/src/entities/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/Field.ts @@ -37,9 +37,9 @@ export function loadPlot(diamondAddress: Address, index: BigInt): Plot { plot.field = diamondAddress; plot.farmer = ADDRESS_ZERO; plot.source = "SOW"; // Should be overwritten in case of a transfer creating a new plot - plot.sourceHash = ""; + plot.sourceHash = ADDRESS_ZERO; plot.season = 0; - plot.creationHash = ""; + plot.creationHash = ADDRESS_ZERO; plot.createdAt = ZERO_BI; plot.updatedAt = ZERO_BI; plot.updatedAtBlock = ZERO_BI; diff --git a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts index 599a56f821..3ef4c3d7eb 100644 --- a/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts +++ b/projects/subgraph-beanstalk/src/entities/PodMarketplace.ts @@ -70,7 +70,7 @@ export function loadPodListing(account: Address, index: BigInt): PodListing { listing.filledAmount = ZERO_BI; listing.status = "ACTIVE"; listing.createdAt = ZERO_BI; - listing.creationHash = ""; + listing.creationHash = ADDRESS_ZERO; listing.updatedAt = ZERO_BI; listing.save(); } @@ -128,7 +128,7 @@ export function loadPodOrder(orderID: Bytes): PodOrder { order.minFillAmount = ZERO_BI; order.maxPlaceInLine = ZERO_BI; order.pricePerPod = 0; - order.creationHash = ""; + order.creationHash = ADDRESS_ZERO; order.fills = []; order.save(); } diff --git a/projects/subgraph-beanstalk/src/entities/Silo.ts b/projects/subgraph-beanstalk/src/entities/Silo.ts index 02617b5dc2..6c8ba4908a 100644 --- a/projects/subgraph-beanstalk/src/entities/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/Silo.ts @@ -154,7 +154,7 @@ export function updateDeposit(deposit: SiloDeposit, deltaAmount: BigInt, deltaBd } deposit.depositedBDV = deposit.depositedBDV.plus(deltaBdv); let depositHashes = deposit.hashes; - depositHashes.push(event.transaction.hash.toHexString()); + depositHashes.push(event.transaction.hash); deposit.hashes = depositHashes; deposit.createdBlock = deposit.createdBlock == ZERO_BI ? event.block.number : deposit.createdBlock; deposit.createdAt = deposit.createdAt == ZERO_BI ? event.block.timestamp : deposit.createdAt; diff --git a/projects/subgraph-beanstalk/src/utils/Barn.ts b/projects/subgraph-beanstalk/src/utils/Barn.ts index c52fb10cac..6502c3daf6 100644 --- a/projects/subgraph-beanstalk/src/utils/Barn.ts +++ b/projects/subgraph-beanstalk/src/utils/Barn.ts @@ -58,7 +58,7 @@ export function unripeChopped(params: ChopParams): void { chop.underlyingAmount = params.underlyingAmount; chop.underlyingBdv = params.underlyingAmount.times(underlyingBdvOne).div(BI_10.pow(underlyingWhitelist.decimals)); chop.chopRate = unripe.chopRate; - chop.hash = params.event.transaction.hash.toHexString(); + chop.hash = params.event.transaction.hash; chop.blockNumber = params.event.block.number; chop.createdAt = params.event.block.timestamp; chop.save(); diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index ecfd6346df..9acdd572c5 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -57,9 +57,9 @@ export function sow(params: SowParams): void { plot.farmer = params.account; plot.source = "SOW"; - plot.sourceHash = params.event.transaction.hash.toHexString(); + plot.sourceHash = params.event.transaction.hash; plot.season = field.season; - plot.creationHash = params.event.transaction.hash.toHexString(); + plot.creationHash = params.event.transaction.hash; plot.createdAt = params.event.block.timestamp; plot.updatedAt = params.event.block.timestamp; plot.updatedAtBlock = params.event.block.number; @@ -103,7 +103,7 @@ export function harvest(params: HarvestParams): void { remainingPlot.source = plot.source; remainingPlot.sourceHash = plot.sourceHash; remainingPlot.season = beanstalk.lastSeason; - remainingPlot.creationHash = params.event.transaction.hash.toHexString(); + remainingPlot.creationHash = params.event.transaction.hash; remainingPlot.createdAt = params.event.block.timestamp; remainingPlot.updatedAt = params.event.block.timestamp; remainingPlot.updatedAtBlock = params.event.block.number; @@ -202,10 +202,10 @@ export function plotTransfer(params: PlotTransferParams): void { // Actually transfer the plots if (sourcePlot.pods == params.amount) { // Sending full plot - const isMarket = sourcePlot.source == "MARKET" && sourcePlot.sourceHash == params.event.transaction.hash.toHexString(); + const isMarket = sourcePlot.source == "MARKET" && sourcePlot.sourceHash == params.event.transaction.hash; if (!isMarket) { sourcePlot.source = "TRANSFER"; - sourcePlot.sourceHash = params.event.transaction.hash.toHexString(); + sourcePlot.sourceHash = params.event.transaction.hash; sourcePlot.beansPerPod = sourcePlot.beansPerPod; } sourcePlot.farmer = params.to; @@ -219,7 +219,7 @@ export function plotTransfer(params: PlotTransferParams): void { let remainderPlot = loadPlot(protocol, remainderIndex); sortedPlots.push(remainderIndex); - const isMarket = sourcePlot.source == "MARKET" && sourcePlot.sourceHash == params.event.transaction.hash.toHexString(); + const isMarket = sourcePlot.source == "MARKET" && sourcePlot.sourceHash == params.event.transaction.hash; if (!isMarket) { // When sending the start of the plot via market, these cannot be derived from sourcePlot. remainderPlot.source = sourcePlot.source; @@ -227,7 +227,7 @@ export function plotTransfer(params: PlotTransferParams): void { remainderPlot.beansPerPod = sourcePlot.beansPerPod; sourcePlot.source = "TRANSFER"; - sourcePlot.sourceHash = params.event.transaction.hash.toHexString(); + sourcePlot.sourceHash = params.event.transaction.hash; sourcePlot.beansPerPod = sourcePlot.beansPerPod; } sourcePlot.farmer = params.to; @@ -239,7 +239,7 @@ export function plotTransfer(params: PlotTransferParams): void { remainderPlot.farmer = params.from; remainderPlot.season = field.season; - remainderPlot.creationHash = params.event.transaction.hash.toHexString(); + remainderPlot.creationHash = params.event.transaction.hash; remainderPlot.createdAt = params.event.block.timestamp; remainderPlot.updatedAt = params.event.block.timestamp; remainderPlot.updatedAtBlock = params.event.block.number; @@ -259,15 +259,15 @@ export function plotTransfer(params: PlotTransferParams): void { sourcePlot.harvestablePods = calcHarvestable(sourcePlot.index, sourcePlot.pods, currentHarvestable); sourcePlot.save(); - const isMarket = toPlot.source == "MARKET" && toPlot.sourceHash == params.event.transaction.hash.toHexString(); + const isMarket = toPlot.source == "MARKET" && toPlot.sourceHash == params.event.transaction.hash; if (!isMarket) { toPlot.source = "TRANSFER"; - toPlot.sourceHash = params.event.transaction.hash.toHexString(); + toPlot.sourceHash = params.event.transaction.hash; toPlot.beansPerPod = sourcePlot.beansPerPod; } toPlot.farmer = params.to; toPlot.season = field.season; - toPlot.creationHash = params.event.transaction.hash.toHexString(); + toPlot.creationHash = params.event.transaction.hash; toPlot.createdAt = params.event.block.timestamp; toPlot.updatedAt = params.event.block.timestamp; toPlot.updatedAtBlock = params.event.block.number; @@ -290,15 +290,15 @@ export function plotTransfer(params: PlotTransferParams): void { sourcePlot.harvestablePods = calcHarvestable(sourcePlot.index, sourcePlot.pods, currentHarvestable); sourcePlot.save(); - const isMarket = toPlot.source == "MARKET" && toPlot.sourceHash == params.event.transaction.hash.toHexString(); + const isMarket = toPlot.source == "MARKET" && toPlot.sourceHash == params.event.transaction.hash; if (!isMarket) { toPlot.source = "TRANSFER"; - toPlot.sourceHash = params.event.transaction.hash.toHexString(); + toPlot.sourceHash = params.event.transaction.hash; toPlot.beansPerPod = sourcePlot.beansPerPod; } toPlot.farmer = params.to; toPlot.season = field.season; - toPlot.creationHash = params.event.transaction.hash.toHexString(); + toPlot.creationHash = params.event.transaction.hash; toPlot.createdAt = params.event.block.timestamp; toPlot.updatedAt = params.event.block.timestamp; toPlot.updatedAtBlock = params.event.block.number; @@ -311,7 +311,7 @@ export function plotTransfer(params: PlotTransferParams): void { remainderPlot.source = sourcePlot.source; remainderPlot.sourceHash = sourcePlot.sourceHash; remainderPlot.season = field.season; - remainderPlot.creationHash = params.event.transaction.hash.toHexString(); + remainderPlot.creationHash = params.event.transaction.hash; remainderPlot.createdAt = params.event.block.timestamp; remainderPlot.updatedAt = params.event.block.timestamp; remainderPlot.updatedAtBlock = params.event.block.number; diff --git a/projects/subgraph-beanstalk/src/utils/Marketplace.ts b/projects/subgraph-beanstalk/src/utils/Marketplace.ts index fb050609c2..c9f184e41c 100644 --- a/projects/subgraph-beanstalk/src/utils/Marketplace.ts +++ b/projects/subgraph-beanstalk/src/utils/Marketplace.ts @@ -118,7 +118,7 @@ export function podListingCreated(params: PodListingCreatedParams): void { listing.status = "ACTIVE"; listing.createdAt = params.event.block.timestamp; listing.updatedAt = params.event.block.timestamp; - listing.creationHash = params.event.transaction.hash.toHexString(); + listing.creationHash = params.event.transaction.hash; listing.save(); @@ -133,11 +133,10 @@ export function podListingCreated(params: PodListingCreatedParams): void { /// Save raw event data let id = "podListingCreated-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodListingCreatedEvent(id); - rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.hash = params.event.transaction.hash; rawEvent.logIndex = params.event.logIndex.toI32(); - rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = listing.historyID; - rawEvent.account = params.account.toHexString(); + rawEvent.account = params.account; rawEvent.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex()); rawEvent.index = params.index; rawEvent.start = params.start; @@ -185,7 +184,7 @@ export function podListingFilled(params: MarketFillParams): void { remainingListing.pricePerPod = listing.pricePerPod; remainingListing.maxHarvestableIndex = listing.maxHarvestableIndex; remainingListing.mode = listing.mode; - remainingListing.creationHash = params.event.transaction.hash.toHexString(); + remainingListing.creationHash = params.event.transaction.hash; remainingListing.minFillAmount = listing.minFillAmount; remainingListing.save(); @@ -219,9 +218,8 @@ export function podListingFilled(params: MarketFillParams): void { // Save the raw event data let id = "podListingFilled-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodListingFilledEvent(id); - rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.hash = params.event.transaction.hash; rawEvent.logIndex = params.event.logIndex.toI32(); - rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = originalHistoryID; rawEvent.fromFarmer = params.from; rawEvent.toFarmer = params.to; @@ -248,9 +246,8 @@ export function podListingCancelled(params: PodListingCancelledParams): void { // Save the raw event data let id = "podListingCancelled-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodListingCancelledEvent(id); - rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.hash = params.event.transaction.hash; rawEvent.logIndex = params.event.logIndex.toI32(); - rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = listing.historyID; rawEvent.account = params.account; rawEvent.placeInLine = params.index.plus(listing.start).minus(getHarvestableIndex()); @@ -282,7 +279,7 @@ export function podOrderCreated(params: PodOrderCreatedParams): void { order.pricePerPod = params.pricePerPod; order.pricingFunction = params.pricingFunction; order.pricingType = params.pricingType; - order.creationHash = params.event.transaction.hash.toHexString(); + order.creationHash = params.event.transaction.hash; order.fills = []; order.save(); @@ -292,9 +289,8 @@ export function podOrderCreated(params: PodOrderCreatedParams): void { // Save the raw event data let id = "podOrderCreated-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodOrderCreatedEvent(id); - rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.hash = params.event.transaction.hash; rawEvent.logIndex = params.event.logIndex.toI32(); - rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = order.historyID; rawEvent.account = params.account; rawEvent.orderId = params.id.toHexString(); @@ -343,9 +339,8 @@ export function podOrderFilled(params: MarketFillParams): void { // Save the raw event data let id = "podOrderFilled-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodOrderFilledEvent(id); - rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.hash = params.event.transaction.hash; rawEvent.logIndex = params.event.logIndex.toI32(); - rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = order.historyID; rawEvent.fromFarmer = params.from; rawEvent.toFarmer = params.to; @@ -372,9 +367,8 @@ export function podOrderCancelled(params: PodOrderCancelledParams): void { // Save the raw event data let id = "podOrderCancelled-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodOrderCancelledEvent(id); - rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.hash = params.event.transaction.hash; rawEvent.logIndex = params.event.logIndex.toI32(); - rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = order.historyID; rawEvent.account = params.account; rawEvent.orderId = params.id.toHexString(); @@ -464,7 +458,7 @@ function setBeansPerPodAfterFill(event: ethereum.Event, plotIndex: BigInt, start // Update source/cost per pod of the sold plot fillPlot.beansPerPod = costInBeans.times(BI_10.pow(6)).div(length); fillPlot.source = "MARKET"; - fillPlot.sourceHash = event.transaction.hash.toHexString(); + fillPlot.sourceHash = event.transaction.hash; fillPlot.save(); } From 5380b785fbdf680d06dd604052d781551442398e Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Tue, 10 Sep 2024 22:41:29 -0700 Subject: [PATCH 25/88] extract stalk decimal constant --- projects/subgraph-beanstalk/src/utils/Season.ts | 2 +- projects/subgraph-beanstalk/src/utils/Yield.ts | 5 ++--- .../subgraph-beanstalk/src/utils/legacy/LegacyYield.ts | 4 +++- projects/subgraph-core/constants/BeanstalkEth.ts | 4 ++++ projects/subgraph-core/constants/RuntimeConstants.ts | 7 +++++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index 56613ae386..bfa93faff3 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -28,7 +28,7 @@ export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block // -- Field level totals field.season = currentSeason; - field.podRate = seasonEntity.beans == ZERO_BI ? ZERO_BD : toDecimal(field.unharvestablePods, 6).div(toDecimal(seasonEntity.beans, 6)); + field.podRate = seasonEntity.beans == ZERO_BI ? ZERO_BD : toDecimal(field.unharvestablePods).div(toDecimal(seasonEntity.beans)); takeFieldSnapshots(field, block); field.save(); diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index 79fdf5c8df..8e38465f51 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -15,7 +15,7 @@ import { getGerminatingBdvs } from "../entities/Germinating"; import { getCurrentSeason, getRewardMinted, loadBeanstalk } from "../entities/Beanstalk"; import { loadFertilizer, loadFertilizerYield } from "../entities/Fertilizer"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { getProtocolFertilizer, minEMASeason } from "../../../subgraph-core/constants/RuntimeConstants"; +import { getProtocolFertilizer, minEMASeason, stalkDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; @@ -138,8 +138,7 @@ export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i3 let depositedBeanBdv = ZERO_BD; let initialR = toDecimal(silo.beanToMaxLpGpPerBdvRatio!, 20); - // Stalk has 10 decimals - let siloStalk = toDecimal(silo.stalk, 10); + let siloStalk = toDecimal(silo.stalk, stalkDecimals(v())); let germinatingBeanBdv: BigDecimal[] = []; let germinatingGaugeLpBdv: BigDecimal[][] = []; diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacyYield.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacyYield.ts index 041fbc8931..64b8aca2f7 100644 --- a/projects/subgraph-beanstalk/src/utils/legacy/LegacyYield.ts +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacyYield.ts @@ -1,5 +1,7 @@ import { BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; import { toDecimal } from "../../../../subgraph-core/utils/Decimals"; +import { stalkDecimals } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../constants/Version"; /** * @param n An estimate of number of Beans minted to the Silo per Season on average @@ -17,7 +19,7 @@ export function calculateAPYPreGauge( // Initialize sequence const beansPerSeason: f64 = parseFloat(n.toString()); let C: f64 = parseFloat(toDecimal(seeds).toString()); // Init: Total Seeds - let K: f64 = parseFloat(toDecimal(stalk, 10).toString()); // Init: Total Stalk + let K: f64 = parseFloat(toDecimal(stalk, stalkDecimals(v())).toString()); // Init: Total Stalk let b: f64 = parseFloat(seedsPerBDV.div(seedsPerBeanBDV).toString()); // Init: User BDV let k: f64 = 1; // Init: User Stalk diff --git a/projects/subgraph-core/constants/BeanstalkEth.ts b/projects/subgraph-core/constants/BeanstalkEth.ts index 6d450709af..ebf308e75b 100644 --- a/projects/subgraph-core/constants/BeanstalkEth.ts +++ b/projects/subgraph-core/constants/BeanstalkEth.ts @@ -114,3 +114,7 @@ export function getBeanstalkPriceAddress(blockNumber: BigInt): Address { export function minEMASeason(): i32 { return REPLANT_SEASON.toI32(); } + +export function stalkDecimals(): i32 { + return 10; +} diff --git a/projects/subgraph-core/constants/RuntimeConstants.ts b/projects/subgraph-core/constants/RuntimeConstants.ts index 3c0cc697db..7448369448 100644 --- a/projects/subgraph-core/constants/RuntimeConstants.ts +++ b/projects/subgraph-core/constants/RuntimeConstants.ts @@ -89,3 +89,10 @@ export function minEMASeason(v: VersionDto): i32 { } throw new Error("Unsupported protocol"); } + +export function stalkDecimals(v: VersionDto): i32 { + if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + return BeanstalkEth.stalkDecimals(); + } + throw new Error("Unsupported protocol"); +} From 3fd0222a16ceef5b94308a7cddc1bb0f4ae3a882 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Tue, 10 Sep 2024 23:41:21 -0700 Subject: [PATCH 26/88] carry over export for beanstalk subgraph --- .../subgraph-bean/cache-builder/beanstalk3.js | 2 +- .../{BeanInit_arb.ts => B3Migration_arb.ts} | 0 .../b3-migration/{BeanInit.ts => Init.ts} | 4 +- .../subgraph-bean/tests/Migration.test.ts | 8 +- projects/subgraph-beanstalk/README.md | 2 + .../cache-builder/beanstalk3.js | 108 ++++++++++++++++++ .../cache-builder/results/B3Migration_arb.ts | 63 ++++++++++ projects/subgraph-beanstalk/package.json | 1 + .../src/utils/b3-migration/Init.ts | 5 + .../tests/Migration.test.ts | 74 ++++++++++++ 10 files changed, 261 insertions(+), 6 deletions(-) rename projects/subgraph-bean/cache-builder/results/{BeanInit_arb.ts => B3Migration_arb.ts} (100%) rename projects/subgraph-bean/src/utils/b3-migration/{BeanInit.ts => Init.ts} (93%) create mode 100644 projects/subgraph-beanstalk/cache-builder/beanstalk3.js create mode 100644 projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts create mode 100644 projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts create mode 100644 projects/subgraph-beanstalk/tests/Migration.test.ts diff --git a/projects/subgraph-bean/cache-builder/beanstalk3.js b/projects/subgraph-bean/cache-builder/beanstalk3.js index ba795f4b7e..93a486836c 100644 --- a/projects/subgraph-bean/cache-builder/beanstalk3.js +++ b/projects/subgraph-bean/cache-builder/beanstalk3.js @@ -17,7 +17,7 @@ const subgraph = new GraphQLClient(url); } `); - const outFile = `${__dirname}/results/BeanInit_arb.ts`; + const outFile = `${__dirname}/results/B3Migration_arb.ts`; await fs.promises.writeFile( outFile, `/* This is a generated file */ diff --git a/projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts b/projects/subgraph-bean/cache-builder/results/B3Migration_arb.ts similarity index 100% rename from projects/subgraph-bean/cache-builder/results/BeanInit_arb.ts rename to projects/subgraph-bean/cache-builder/results/B3Migration_arb.ts diff --git a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts b/projects/subgraph-bean/src/utils/b3-migration/Init.ts similarity index 93% rename from projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts rename to projects/subgraph-bean/src/utils/b3-migration/Init.ts index 7fd05e807a..e9bbbc20c8 100644 --- a/projects/subgraph-bean/src/utils/b3-migration/BeanInit.ts +++ b/projects/subgraph-bean/src/utils/b3-migration/Init.ts @@ -1,10 +1,10 @@ import { ethereum } from "@graphprotocol/graph-ts"; -import { BEAN_INITIAL_VALUES } from "../../../cache-builder/results/BeanInit_arb"; +import { BEAN_INITIAL_VALUES } from "../../../cache-builder/results/B3Migration_arb"; import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot } from "../../entities/Bean"; import { getProtocolToken } from "../../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../constants/Version"; -export function handleInitBeanEntity(block: ethereum.Block): void { +export function handleMigration(block: ethereum.Block): void { const token = getProtocolToken(v(), block.number); const bean = loadBean(token); diff --git a/projects/subgraph-bean/tests/Migration.test.ts b/projects/subgraph-bean/tests/Migration.test.ts index 71a2393f7d..d613bdde2b 100644 --- a/projects/subgraph-bean/tests/Migration.test.ts +++ b/projects/subgraph-bean/tests/Migration.test.ts @@ -1,20 +1,22 @@ import { clearStore, beforeEach, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; -import { handleInitBeanEntity } from "../src/utils/b3-migration/BeanInit"; +import { handleMigration } from "../src/utils/b3-migration/Init"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { BEAN_ERC20 } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; -import { BEAN_INITIAL_VALUES } from "../cache-builder/results/BeanInit_arb"; +import { BEAN_INITIAL_VALUES } from "../cache-builder/results/B3Migration_arb"; import { initL1Version } from "./entity-mocking/MockVersion"; describe("Beanstalk 3 Migration", () => { beforeEach(() => { + // NOTE: it may be more appropriate to init l2 version, but this shouldnt affect the tests + // (aside from having to use L1 addresses in this test) initL1Version(); + handleMigration(mockBlock()); }); afterEach(() => { clearStore(); }); test("Bean entity initialization", () => { - handleInitBeanEntity(mockBlock()); assert.fieldEquals("Bean", BEAN_ERC20.toHexString(), "volume", BEAN_INITIAL_VALUES.volume.toString()); assert.fieldEquals("Bean", BEAN_ERC20.toHexString(), "crosses", BEAN_INITIAL_VALUES.crosses.toString()); assert.fieldEquals( diff --git a/projects/subgraph-beanstalk/README.md b/projects/subgraph-beanstalk/README.md index 183cdba415..616c8cb808 100644 --- a/projects/subgraph-beanstalk/README.md +++ b/projects/subgraph-beanstalk/README.md @@ -28,6 +28,8 @@ To test with Docker, the first time you will need to run `yarn run graph test -d When using graph cli commands, you will often need to specify which manifest file should be used. This is necessary to support multiple chains in the same codebase. The commands which need it will be evident - as they will fail when unable to find a `subgraph.yaml` file. In those commands, include `./manifest/${chain}.yaml` as the final argument to the command. See scripts inside `package.json` for examples. +It may be necessary to run `yarn build-cache` prior to a new deployment build. This updates historical cached values, particularly as it pertains to the L1 -> L2 migration. It will be necessary to re-run these scripts if updates to the L1 subgraph are made that need to have some values carried to the L2 subgraph. Note that it may not always be appropriate to run every script in the corresponding `cache-builder` directory, use with caution. + ### Development # Handler organization strategy diff --git a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js new file mode 100644 index 0000000000..8ed0b4cacd --- /dev/null +++ b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js @@ -0,0 +1,108 @@ +const { GraphQLClient, gql } = require("graphql-request"); +const fs = require("fs"); + +const url = "https://graph.bean.money/beanstalk_eth"; +const subgraph = new GraphQLClient(url); + +// NOTE: once latest subgraph is deployed, will need to update beanstalk/marketplace ids in this query. +(async () => { + const l1Values = await subgraph.request(gql` + { + beanstalk(id: "0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5") { + lastSeason + } + field(id: "0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5") { + numberOfSowers + numberOfSows + sownBeans + harvestedPods + } + podMarketplace(id: "0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5") { + filledListedPods + expiredListedPods + cancelledListedPods + filledOrderBeans + filledOrderedPods + cancelledOrderBeans + podVolume + beanVolume + } + unripeTokens { + id + totalChoppedAmount + totalChoppedBdv + totalChoppedBdvReceived + } + } + `); + + const outFile = `${__dirname}/results/B3Migration_arb.ts`; + await fs.promises.writeFile( + outFile, + `/* This is a generated file */ + + import { BigInt, Address } from "@graphprotocol/graph-ts"; + + class FieldInitialValues { + numberOfSowers: i32; + numberOfSows: i32; + sownBeans: BigInt; + harvestedPods: BigInt; + } + + class PodMarketplaceInitialValues { + filledListedPods: BigInt; + expiredListedPods: BigInt; + cancelledListedPods: BigInt; + filledOrderBeans: BigInt; + filledOrderedPods: BigInt; + cancelledOrderBeans: BigInt; + podVolume: BigInt; + beanVolume: BigInt; + } + + class UnripeTokenInitialValues { + token: Address; + totalChoppedAmount: BigInt; + totalChoppedBdv: BigInt; + totalChoppedBdvReceived: BigInt; + } + + export const SEASON_INITIAL = ${l1Values.beanstalk.lastSeason}; + + export const FIELD_INITIAL_VALUES: FieldInitialValues = { + numberOfSowers: ${l1Values.field.numberOfSowers}, + numberOfSows: ${l1Values.field.numberOfSows}, + sownBeans: BigInt.fromString('${l1Values.field.sownBeans}'), + harvestedPods: BigInt.fromString('${l1Values.field.harvestedPods}') + }; + + export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { + filledListedPods: BigInt.fromString('${l1Values.podMarketplace.filledListedPods}'), + expiredListedPods: BigInt.fromString('${l1Values.podMarketplace.expiredListedPods}'), + cancelledListedPods: BigInt.fromString('${l1Values.podMarketplace.cancelledListedPods}'), + filledOrderBeans: BigInt.fromString('${l1Values.podMarketplace.filledOrderBeans}'), + filledOrderedPods: BigInt.fromString('${l1Values.podMarketplace.filledOrderedPods}'), + cancelledOrderBeans: BigInt.fromString('${l1Values.podMarketplace.cancelledOrderBeans}'), + podVolume: BigInt.fromString('${l1Values.podMarketplace.podVolume}'), + beanVolume: BigInt.fromString('${l1Values.podMarketplace.beanVolume}') + }; + + export const UNRIPE_TOKENS_INITIAL_VALUES: UnripeTokenInitialValues[] = [ + { + token: Address.fromString('${l1Values.unripeTokens[0].id}'), + totalChoppedAmount: BigInt.fromString('${l1Values.unripeTokens[0].totalChoppedAmount}'), + totalChoppedBdv: BigInt.fromString('${l1Values.unripeTokens[0].totalChoppedBdv}'), + totalChoppedBdvReceived: BigInt.fromString('${l1Values.unripeTokens[0].totalChoppedBdvReceived}') + }, + { + token: Address.fromString('${l1Values.unripeTokens[1].id}'), + totalChoppedAmount: BigInt.fromString('${l1Values.unripeTokens[1].totalChoppedAmount}'), + totalChoppedBdv: BigInt.fromString('${l1Values.unripeTokens[1].totalChoppedBdv}'), + totalChoppedBdvReceived: BigInt.fromString('${l1Values.unripeTokens[1].totalChoppedBdvReceived}') + } + ]; + ` + ); + console.log(`Wrote beanstalk 3 initial values to ${outFile}`); +})(); diff --git a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts new file mode 100644 index 0000000000..13923252a9 --- /dev/null +++ b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts @@ -0,0 +1,63 @@ +/* This is a generated file */ + +import { BigInt, Address } from "@graphprotocol/graph-ts"; + +class FieldInitialValues { + numberOfSowers: i32; + numberOfSows: i32; + sownBeans: BigInt; + harvestedPods: BigInt; +} + +class PodMarketplaceInitialValues { + filledListedPods: BigInt; + expiredListedPods: BigInt; + cancelledListedPods: BigInt; + filledOrderBeans: BigInt; + filledOrderedPods: BigInt; + cancelledOrderBeans: BigInt; + podVolume: BigInt; + beanVolume: BigInt; +} + +class UnripeTokenInitialValues { + token: Address; + totalChoppedAmount: BigInt; + totalChoppedBdv: BigInt; + totalChoppedBdvReceived: BigInt; +} + +export const SEASON_INITIAL = 24472; + +export const FIELD_INITIAL_VALUES: FieldInitialValues = { + numberOfSowers: 0, + numberOfSows: 19160, + sownBeans: BigInt.fromString("33592460691690"), + harvestedPods: BigInt.fromString("61126608133951") +}; + +export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { + filledListedPods: BigInt.fromString("49222911145993"), + expiredListedPods: BigInt.fromString("7065428228776"), + cancelledListedPods: BigInt.fromString("60134193309316"), + filledOrderBeans: BigInt.fromString("762556935865"), + filledOrderedPods: BigInt.fromString("14851692494599"), + cancelledOrderBeans: BigInt.fromString("1308742101463"), + podVolume: BigInt.fromString("64074603640592"), + beanVolume: BigInt.fromString("6508703985303") +}; + +export const UNRIPE_TOKENS_INITIAL_VALUES: UnripeTokenInitialValues[] = [ + { + token: Address.fromString("0x1bea0050e63e05fbb5d8ba2f10cf5800b6224449"), + totalChoppedAmount: BigInt.fromString("24665725897573"), + totalChoppedBdv: BigInt.fromString("5882168812974"), + totalChoppedBdvReceived: BigInt.fromString("1334001323440") + }, + { + token: Address.fromString("0x1bea3ccd22f4ebd3d37d731ba31eeca95713716d"), + totalChoppedAmount: BigInt.fromString("7250545162321"), + totalChoppedBdv: BigInt.fromString("2529372423798"), + totalChoppedBdvReceived: BigInt.fromString("508153566375") + } +]; diff --git a/projects/subgraph-beanstalk/package.json b/projects/subgraph-beanstalk/package.json index b21639c4dc..6a16eb5e26 100644 --- a/projects/subgraph-beanstalk/package.json +++ b/projects/subgraph-beanstalk/package.json @@ -13,6 +13,7 @@ "test": "graph test", "testd": "docker run -it --rm --mount type=bind,source=\"$(pwd)\"/matchstick-docker.yaml,target=/matchstick/matchstick.yaml --mount type=bind,source=\"$(pwd)\"/../../,target=/matchstick/repo-mounted/ matchstick", "testd-named": "../subgraph-core/tests/scripts/docker-run-named.sh", + "build-cache": "sh -c 'for file in ./cache-builder/*.js; do node \"$file\"; done'", "create-local": "echo Using manifest at ./manifests/$1.yaml && graph create --node http://127.0.0.1:8020/ beanstalk_$1", "remove-local": "echo Using manifest at ./manifests/$1.yaml && graph remove --node http://127.0.0.1:8020/ beanstalk_$1", "deploy-local": "echo Using manifest at ./manifests/$1.yaml && yarn codegen && graph deploy --node http://127.0.0.1:8020/ --ipfs http://127.0.0.1:5001 beanstalk_$1 ./manifests/$1.yaml" diff --git a/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts new file mode 100644 index 0000000000..2222b2134e --- /dev/null +++ b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts @@ -0,0 +1,5 @@ +import { ethereum } from "@graphprotocol/graph-ts"; +import { getProtocolToken } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "../constants/Version"; + +export function handleMigration(block: ethereum.Block): void {} diff --git a/projects/subgraph-beanstalk/tests/Migration.test.ts b/projects/subgraph-beanstalk/tests/Migration.test.ts new file mode 100644 index 0000000000..bf1855d43f --- /dev/null +++ b/projects/subgraph-beanstalk/tests/Migration.test.ts @@ -0,0 +1,74 @@ +import { clearStore, beforeEach, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; +import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; +import { initL1Version } from "./entity-mocking/MockVersion"; +import { handleMigration } from "../src/utils/b3-migration/Init"; +import { BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { + FIELD_INITIAL_VALUES, + POD_MARKETPLACE_INITIAL_VALUES, + SEASON_INITIAL, + UNRIPE_TOKENS_INITIAL_VALUES +} from "../cache-builder/results/B3Migration_arb"; + +describe("Beanstalk 3 Migration", () => { + beforeEach(() => { + // NOTE: it may be more appropriate to init l2 version, but this shouldnt affect the tests + // (aside from having to use L1 addresses in this test) + initL1Version(); + handleMigration(mockBlock()); + }); + afterEach(() => { + clearStore(); + }); + + test("Field entity initialization", () => { + assert.fieldEquals("Field", BEANSTALK.toHexString(), "numberOfSowers", FIELD_INITIAL_VALUES.numberOfSowers.toString()); + assert.fieldEquals("Field", BEANSTALK.toHexString(), "sownBeans", FIELD_INITIAL_VALUES.sownBeans.toString()); + assert.fieldEquals( + "FieldHourlySnapshot", + BEANSTALK.toHexString() + "-" + SEASON_INITIAL.toString(), + "sownBeans", + FIELD_INITIAL_VALUES.sownBeans.toString() + ); + assert.fieldEquals("FieldHourlySnapshot", BEANSTALK.toHexString() + "-" + SEASON_INITIAL.toString(), "deltaSownBeans", "0"); + }); + + test("PodMarketplace entity initialization", () => { + assert.fieldEquals("PodMarketplace", "0", "filledListedPods", POD_MARKETPLACE_INITIAL_VALUES.filledListedPods.toString()); + assert.fieldEquals("PodMarketplace", "0", "beanVolume", POD_MARKETPLACE_INITIAL_VALUES.beanVolume.toString()); + assert.fieldEquals( + "PodMarketplaceHourlySnapshot", + "0-" + SEASON_INITIAL.toString(), + "beanVolume", + POD_MARKETPLACE_INITIAL_VALUES.beanVolume.toString() + ); + assert.fieldEquals("PodMarketplaceHourlySnapshot", BEANSTALK.toHexString() + "-" + SEASON_INITIAL.toString(), "deltaBeanVolume", "0"); + }); + + test("UnripeTokens entity initialization", () => { + assert.fieldEquals( + "UnripeToken", + UNRIPE_BEAN.toHexString(), + "totalChoppedAmount", + UNRIPE_TOKENS_INITIAL_VALUES[0].totalChoppedAmount.toString() + ); + assert.fieldEquals( + "UnripeToken", + UNRIPE_LP.toHexString(), + "totalChoppedBdvReceived", + UNRIPE_TOKENS_INITIAL_VALUES[1].totalChoppedBdvReceived.toString() + ); + assert.fieldEquals( + "UnripeTokenHourlySnapshot", + UNRIPE_BEAN.toHexString() + "-" + SEASON_INITIAL.toString(), + "totalChoppedBdvReceived", + UNRIPE_TOKENS_INITIAL_VALUES[0].totalChoppedBdvReceived.toString() + ); + assert.fieldEquals( + "UnripeTokenHourlySnapshot", + UNRIPE_BEAN.toHexString() + "-" + SEASON_INITIAL.toString(), + "deltaTotalChoppedBdvReceived", + "0" + ); + }); +}); From 60abb482d4b0335a82417452651e79da496eed80 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 11:59:38 -0700 Subject: [PATCH 27/88] separate init and pre-unpause b3 init --- .../src/utils/b3-migration/Init.ts | 5 +- .../subgraph-bean/tests/Migration.test.ts | 4 +- .../cache-builder/beanstalk3.js | 13 +++-- .../cache-builder/results/B3Migration_arb.ts | 14 ++--- .../src/entities/Beanstalk.ts | 3 +- .../src/utils/b3-migration/Init.ts | 58 ++++++++++++++++++- .../tests/Migration.test.ts | 7 ++- 7 files changed, 82 insertions(+), 22 deletions(-) diff --git a/projects/subgraph-bean/src/utils/b3-migration/Init.ts b/projects/subgraph-bean/src/utils/b3-migration/Init.ts index e9bbbc20c8..f9c67f2f05 100644 --- a/projects/subgraph-bean/src/utils/b3-migration/Init.ts +++ b/projects/subgraph-bean/src/utils/b3-migration/Init.ts @@ -4,7 +4,8 @@ import { loadBean, loadOrCreateBeanDailySnapshot, loadOrCreateBeanHourlySnapshot import { getProtocolToken } from "../../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../constants/Version"; -export function handleMigration(block: ethereum.Block): void { +// Carries over cumulative data from L1 -> L2 subgraph. See cache-builder/beanstalk3.js for the input source. +export function init(block: ethereum.Block): void { const token = getProtocolToken(v(), block.number); const bean = loadBean(token); @@ -16,7 +17,7 @@ export function handleMigration(block: ethereum.Block): void { bean.save(); // No need to initialize supply/price etc as those will be initialized when liquidity is added. - // Direct assignment for snapshots is preferable as to avoid large deltas + // Direct assignment for snapshots is required as to avoid large deltas const beanHourly = loadOrCreateBeanHourlySnapshot(token, block.timestamp, bean.lastSeason); beanHourly.volume = bean.volume; beanHourly.volumeUSD = bean.volumeUSD; diff --git a/projects/subgraph-bean/tests/Migration.test.ts b/projects/subgraph-bean/tests/Migration.test.ts index d613bdde2b..de75b2253e 100644 --- a/projects/subgraph-bean/tests/Migration.test.ts +++ b/projects/subgraph-bean/tests/Migration.test.ts @@ -1,5 +1,5 @@ import { clearStore, beforeEach, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; -import { handleMigration } from "../src/utils/b3-migration/Init"; +import { init } from "../src/utils/b3-migration/Init"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { BEAN_ERC20 } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BEAN_INITIAL_VALUES } from "../cache-builder/results/B3Migration_arb"; @@ -10,7 +10,7 @@ describe("Beanstalk 3 Migration", () => { // NOTE: it may be more appropriate to init l2 version, but this shouldnt affect the tests // (aside from having to use L1 addresses in this test) initL1Version(); - handleMigration(mockBlock()); + init(mockBlock()); }); afterEach(() => { clearStore(); diff --git a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js index 8ed0b4cacd..892eba7ce7 100644 --- a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js +++ b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js @@ -4,6 +4,11 @@ const fs = require("fs"); const url = "https://graph.bean.money/beanstalk_eth"; const subgraph = new GraphQLClient(url); +const tokenMap = { + "0x1bea0050e63e05fbb5d8ba2f10cf5800b6224449": "urbean", + "0x1bea3ccd22f4ebd3d37d731ba31eeca95713716d": "urlp" +}; + // NOTE: once latest subgraph is deployed, will need to update beanstalk/marketplace ids in this query. (async () => { const l1Values = await subgraph.request(gql` @@ -41,7 +46,7 @@ const subgraph = new GraphQLClient(url); outFile, `/* This is a generated file */ - import { BigInt, Address } from "@graphprotocol/graph-ts"; + import { BigInt } from "@graphprotocol/graph-ts"; class FieldInitialValues { numberOfSowers: i32; @@ -62,7 +67,7 @@ const subgraph = new GraphQLClient(url); } class UnripeTokenInitialValues { - token: Address; + tokenType: string; totalChoppedAmount: BigInt; totalChoppedBdv: BigInt; totalChoppedBdvReceived: BigInt; @@ -90,13 +95,13 @@ const subgraph = new GraphQLClient(url); export const UNRIPE_TOKENS_INITIAL_VALUES: UnripeTokenInitialValues[] = [ { - token: Address.fromString('${l1Values.unripeTokens[0].id}'), + tokenType: '${tokenMap[l1Values.unripeTokens[0].id]}', totalChoppedAmount: BigInt.fromString('${l1Values.unripeTokens[0].totalChoppedAmount}'), totalChoppedBdv: BigInt.fromString('${l1Values.unripeTokens[0].totalChoppedBdv}'), totalChoppedBdvReceived: BigInt.fromString('${l1Values.unripeTokens[0].totalChoppedBdvReceived}') }, { - token: Address.fromString('${l1Values.unripeTokens[1].id}'), + tokenType: '${tokenMap[l1Values.unripeTokens[1].id]}', totalChoppedAmount: BigInt.fromString('${l1Values.unripeTokens[1].totalChoppedAmount}'), totalChoppedBdv: BigInt.fromString('${l1Values.unripeTokens[1].totalChoppedBdv}'), totalChoppedBdvReceived: BigInt.fromString('${l1Values.unripeTokens[1].totalChoppedBdvReceived}') diff --git a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts index 13923252a9..7475e2ba67 100644 --- a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts +++ b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts @@ -1,6 +1,6 @@ /* This is a generated file */ -import { BigInt, Address } from "@graphprotocol/graph-ts"; +import { BigInt } from "@graphprotocol/graph-ts"; class FieldInitialValues { numberOfSowers: i32; @@ -21,18 +21,18 @@ class PodMarketplaceInitialValues { } class UnripeTokenInitialValues { - token: Address; + tokenType: string; totalChoppedAmount: BigInt; totalChoppedBdv: BigInt; totalChoppedBdvReceived: BigInt; } -export const SEASON_INITIAL = 24472; +export const SEASON_INITIAL = 24484; export const FIELD_INITIAL_VALUES: FieldInitialValues = { numberOfSowers: 0, - numberOfSows: 19160, - sownBeans: BigInt.fromString("33592460691690"), + numberOfSows: 19172, + sownBeans: BigInt.fromString("33592460721984"), harvestedPods: BigInt.fromString("61126608133951") }; @@ -49,13 +49,13 @@ export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { export const UNRIPE_TOKENS_INITIAL_VALUES: UnripeTokenInitialValues[] = [ { - token: Address.fromString("0x1bea0050e63e05fbb5d8ba2f10cf5800b6224449"), + tokenType: "urbean", totalChoppedAmount: BigInt.fromString("24665725897573"), totalChoppedBdv: BigInt.fromString("5882168812974"), totalChoppedBdvReceived: BigInt.fromString("1334001323440") }, { - token: Address.fromString("0x1bea3ccd22f4ebd3d37d731ba31eeca95713716d"), + tokenType: "urlp", totalChoppedAmount: BigInt.fromString("7250545162321"), totalChoppedBdv: BigInt.fromString("2529372423798"), totalChoppedBdvReceived: BigInt.fromString("508153566375") diff --git a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts index 9a291de53a..53dfeb9188 100644 --- a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts +++ b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts @@ -63,8 +63,7 @@ export function loadSeason(id: BigInt): Season { } export function getCurrentSeason(): i32 { - let beanstalkEntity = loadBeanstalk(); - return beanstalkEntity.lastSeason; + return loadBeanstalk().lastSeason; } // Returns the number of reward beans minted for the requested season diff --git a/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts index 2222b2134e..5f733c2cba 100644 --- a/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts +++ b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts @@ -1,5 +1,59 @@ import { ethereum } from "@graphprotocol/graph-ts"; -import { getProtocolToken } from "../../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../constants/Version"; +import { loadField } from "../../entities/Field"; +import { + FIELD_INITIAL_VALUES, + POD_MARKETPLACE_INITIAL_VALUES, + SEASON_INITIAL, + UNRIPE_TOKENS_INITIAL_VALUES +} from "../../../cache-builder/results/B3Migration_arb"; +import { takeFieldSnapshots } from "../../entities/snapshots/Field"; +import { loadPodMarketplace } from "../../entities/PodMarketplace"; +import { takeMarketSnapshots } from "../../entities/snapshots/Marketplace"; +import { loadUnripeToken } from "../../entities/Silo"; +import { getUnripeBeanAddr, getUnripeLpAddr } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { takeUnripeTokenSnapshots } from "../../entities/snapshots/UnripeToken"; +import { loadBeanstalk } from "../../entities/Beanstalk"; -export function handleMigration(block: ethereum.Block): void {} +export function init(block: ethereum.Block): void { + let beanstalk = loadBeanstalk(); + beanstalk.lastSeason = SEASON_INITIAL; + beanstalk.save(); +} + +// Carries over cumulative data from L1 -> L2 subgraph. See cache-builder/beanstalk3.js for the input source. +// This function should be executed after all of the Migration events are handled, at which point +// the snapshots will be set with nonsensical deltas. The strategy is to take all of those snapshots, +// and then zero-out all of the deltas here. +export function preUnpause(block: ethereum.Block): void { + let field = loadField(v().protocolAddress); + field.numberOfSowers = FIELD_INITIAL_VALUES.numberOfSowers; + field.numberOfSows = FIELD_INITIAL_VALUES.numberOfSows; + field.sownBeans = FIELD_INITIAL_VALUES.sownBeans; + field.harvestedPods = FIELD_INITIAL_VALUES.harvestedPods; + takeFieldSnapshots(field, block); + field.save(); + + let podMarketplace = loadPodMarketplace(); + podMarketplace.filledListedPods = POD_MARKETPLACE_INITIAL_VALUES.filledListedPods; + podMarketplace.expiredListedPods = POD_MARKETPLACE_INITIAL_VALUES.expiredListedPods; + podMarketplace.cancelledListedPods = POD_MARKETPLACE_INITIAL_VALUES.cancelledListedPods; + podMarketplace.filledOrderBeans = POD_MARKETPLACE_INITIAL_VALUES.filledOrderBeans; + podMarketplace.filledOrderedPods = POD_MARKETPLACE_INITIAL_VALUES.filledOrderedPods; + podMarketplace.cancelledOrderBeans = POD_MARKETPLACE_INITIAL_VALUES.cancelledOrderBeans; + podMarketplace.podVolume = POD_MARKETPLACE_INITIAL_VALUES.podVolume; + podMarketplace.beanVolume = POD_MARKETPLACE_INITIAL_VALUES.beanVolume; + takeMarketSnapshots(podMarketplace, block); + podMarketplace.save(); + + for (let i = 0; i < UNRIPE_TOKENS_INITIAL_VALUES.length; ++i) { + let unripe = loadUnripeToken(UNRIPE_TOKENS_INITIAL_VALUES[i].tokenType === "urbean" ? getUnripeBeanAddr(v()) : getUnripeLpAddr(v())); + unripe.totalChoppedAmount = UNRIPE_TOKENS_INITIAL_VALUES[i].totalChoppedAmount; + unripe.totalChoppedBdv = UNRIPE_TOKENS_INITIAL_VALUES[i].totalChoppedBdv; + unripe.totalChoppedBdvReceived = UNRIPE_TOKENS_INITIAL_VALUES[i].totalChoppedBdvReceived; + takeUnripeTokenSnapshots(unripe, block); + unripe.save(); + } + + // Zero out all deltas for all snapshots +} diff --git a/projects/subgraph-beanstalk/tests/Migration.test.ts b/projects/subgraph-beanstalk/tests/Migration.test.ts index bf1855d43f..1618db3b8a 100644 --- a/projects/subgraph-beanstalk/tests/Migration.test.ts +++ b/projects/subgraph-beanstalk/tests/Migration.test.ts @@ -1,7 +1,7 @@ import { clearStore, beforeEach, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { initL1Version } from "./entity-mocking/MockVersion"; -import { handleMigration } from "../src/utils/b3-migration/Init"; +import { init, preUnpause } from "../src/utils/b3-migration/Init"; import { BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { FIELD_INITIAL_VALUES, @@ -15,7 +15,8 @@ describe("Beanstalk 3 Migration", () => { // NOTE: it may be more appropriate to init l2 version, but this shouldnt affect the tests // (aside from having to use L1 addresses in this test) initL1Version(); - handleMigration(mockBlock()); + init(mockBlock()); + preUnpause(mockBlock()); }); afterEach(() => { clearStore(); @@ -42,7 +43,7 @@ describe("Beanstalk 3 Migration", () => { "beanVolume", POD_MARKETPLACE_INITIAL_VALUES.beanVolume.toString() ); - assert.fieldEquals("PodMarketplaceHourlySnapshot", BEANSTALK.toHexString() + "-" + SEASON_INITIAL.toString(), "deltaBeanVolume", "0"); + assert.fieldEquals("PodMarketplaceHourlySnapshot", "0-" + SEASON_INITIAL.toString(), "deltaBeanVolume", "0"); }); test("UnripeTokens entity initialization", () => { From c62460a09d9ed17cb95754958a2fed8132b9118a Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:53:26 -0700 Subject: [PATCH 28/88] clear deltas on pre-unpause --- .../src/entities/snapshots/Field.ts | 38 +++++++++++++++++++ .../src/entities/snapshots/Marketplace.ts | 38 +++++++++++++++++++ .../src/entities/snapshots/Silo.ts | 30 +++++++++++++++ .../src/entities/snapshots/SiloAsset.ts | 22 +++++++++++ .../src/entities/snapshots/UnripeToken.ts | 36 ++++++++++++++++++ .../snapshots/WhitelistTokenSetting.ts | 28 ++++++++++++++ .../src/utils/b3-migration/Init.ts | 23 ++++++++--- 7 files changed, 209 insertions(+), 6 deletions(-) diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts index 2fa87b1cab..7c00352d4d 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts @@ -2,6 +2,7 @@ import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Field, FieldDailySnapshot, FieldHourlySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; +import { ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { const currentSeason = getCurrentSeason(); @@ -181,6 +182,43 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { field.lastDailySnapshotDay = day; } +export function clearFieldDeltas(field: Field, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); + const hourly = FieldHourlySnapshot.load(field.id.toHexString() + "-" + currentSeason.toString()); + const daily = FieldDailySnapshot.load(field.id.toHexString() + "-" + day.toString()); + if (hourly != null) { + hourly.deltaTemperature = 0; + hourly.deltaRealRateOfReturn = ZERO_BD; + hourly.deltaNumberOfSowers = 0; + hourly.deltaNumberOfSows = 0; + hourly.deltaSownBeans = ZERO_BI; + hourly.deltaUnharvestablePods = ZERO_BI; + hourly.deltaHarvestablePods = ZERO_BI; + hourly.deltaHarvestedPods = ZERO_BI; + hourly.deltaSoil = ZERO_BI; + hourly.deltaPodIndex = ZERO_BI; + hourly.deltaPodRate = ZERO_BD; + hourly.deltaIssuedSoil = ZERO_BI; + hourly.save(); + } + if (daily != null) { + daily.deltaTemperature = 0; + daily.deltaRealRateOfReturn = ZERO_BD; + daily.deltaNumberOfSowers = 0; + daily.deltaNumberOfSows = 0; + daily.deltaSownBeans = ZERO_BI; + daily.deltaUnharvestablePods = ZERO_BI; + daily.deltaHarvestablePods = ZERO_BI; + daily.deltaHarvestedPods = ZERO_BI; + daily.deltaSoil = ZERO_BI; + daily.deltaPodIndex = ZERO_BI; + daily.deltaPodRate = ZERO_BD; + daily.deltaIssuedSoil = ZERO_BI; + daily.save(); + } +} + // Set case id on hourly. Snapshot must have already been created. export function setFieldHourlyCaseId(caseId: BigInt, field: Field): void { const hourly = FieldHourlySnapshot.load(field.id.toHexString() + "-" + field.lastHourlySnapshotSeason.toString())!; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Marketplace.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Marketplace.ts index 4b99d34c7d..e05b75709a 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Marketplace.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Marketplace.ts @@ -2,6 +2,7 @@ import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { PodMarketplace, PodMarketplaceDailySnapshot, PodMarketplaceHourlySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; +import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; export function takeMarketSnapshots(market: PodMarketplace, block: ethereum.Block): void { const currentSeason = getCurrentSeason(); @@ -154,3 +155,40 @@ export function takeMarketSnapshots(market: PodMarketplace, block: ethereum.Bloc market.lastHourlySnapshotSeason = currentSeason; market.lastDailySnapshotDay = day; } + +export function clearMarketDeltas(market: PodMarketplace, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); + const hourly = PodMarketplaceHourlySnapshot.load(market.id + "-" + currentSeason.toString()); + const daily = PodMarketplaceDailySnapshot.load(market.id + "-" + day.toString()); + if (hourly != null) { + hourly.deltaListedPods = ZERO_BI; + hourly.deltaAvailableListedPods = ZERO_BI; + hourly.deltaFilledListedPods = ZERO_BI; + hourly.deltaExpiredListedPods = ZERO_BI; + hourly.deltaCancelledListedPods = ZERO_BI; + hourly.deltaOrderBeans = ZERO_BI; + hourly.deltaAvailableOrderBeans = ZERO_BI; + hourly.deltaFilledOrderBeans = ZERO_BI; + hourly.deltaFilledOrderedPods = ZERO_BI; + hourly.deltaCancelledOrderBeans = ZERO_BI; + hourly.deltaPodVolume = ZERO_BI; + hourly.deltaBeanVolume = ZERO_BI; + hourly.save(); + } + if (daily != null) { + daily.deltaListedPods = ZERO_BI; + daily.deltaAvailableListedPods = ZERO_BI; + daily.deltaFilledListedPods = ZERO_BI; + daily.deltaExpiredListedPods = ZERO_BI; + daily.deltaCancelledListedPods = ZERO_BI; + daily.deltaOrderBeans = ZERO_BI; + daily.deltaAvailableOrderBeans = ZERO_BI; + daily.deltaFilledOrderBeans = ZERO_BI; + daily.deltaFilledOrderedPods = ZERO_BI; + daily.deltaCancelledOrderBeans = ZERO_BI; + daily.deltaPodVolume = ZERO_BI; + daily.deltaBeanVolume = ZERO_BI; + daily.save(); + } +} diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts index 8fc2a98c79..5aa4f306cd 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts @@ -2,6 +2,7 @@ import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Silo, SiloDailySnapshot, SiloHourlySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; +import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { const currentSeason = getCurrentSeason(); @@ -133,6 +134,35 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { silo.lastDailySnapshotDay = day; } +export function clearSiloDeltas(silo: Silo, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); + const hourly = SiloHourlySnapshot.load(silo.id.toHexString() + "-" + currentSeason.toString()); + const daily = SiloDailySnapshot.load(silo.id.toHexString() + "-" + day.toString()); + if (hourly != null) { + hourly.deltaDepositedBDV = ZERO_BI; + hourly.deltaStalk = ZERO_BI; + hourly.deltaPlantableStalk = ZERO_BI; + hourly.deltaSeeds = ZERO_BI; + hourly.deltaRoots = ZERO_BI; + hourly.deltaGerminatingStalk = ZERO_BI; + hourly.deltaBeanMints = ZERO_BI; + hourly.deltaActiveFarmers = 0; + hourly.save(); + } + if (daily != null) { + daily.deltaDepositedBDV = ZERO_BI; + daily.deltaStalk = ZERO_BI; + daily.deltaPlantableStalk = ZERO_BI; + daily.deltaSeeds = ZERO_BI; + daily.deltaRoots = ZERO_BI; + daily.deltaGerminatingStalk = ZERO_BI; + daily.deltaBeanMints = ZERO_BI; + daily.deltaActiveFarmers = 0; + daily.save(); + } +} + // Set case id on hourly snapshot. Snapshot must have already been created. export function setSiloHourlyCaseId(caseId: BigInt, silo: Silo): void { const hourly = SiloHourlySnapshot.load(silo.id.toHexString() + "-" + silo.lastHourlySnapshotSeason.toString())!; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/SiloAsset.ts b/projects/subgraph-beanstalk/src/entities/snapshots/SiloAsset.ts index 826f4c7191..6b49b2aca1 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/SiloAsset.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/SiloAsset.ts @@ -2,6 +2,7 @@ import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { SiloAsset, SiloAssetDailySnapshot, SiloAssetHourlySnapshot } from "../../../generated/schema"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; import { getCurrentSeason } from "../Beanstalk"; +import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; export function takeSiloAssetSnapshots(siloAsset: SiloAsset, block: ethereum.Block): void { const currentSeason = getCurrentSeason(); @@ -90,3 +91,24 @@ export function takeSiloAssetSnapshots(siloAsset: SiloAsset, block: ethereum.Blo siloAsset.lastHourlySnapshotSeason = currentSeason; siloAsset.lastDailySnapshotDay = day; } + +export function clearSiloAssetDeltas(siloAsset: SiloAsset, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); + const hourly = SiloAssetHourlySnapshot.load(siloAsset.id + "-" + currentSeason.toString()); + const daily = SiloAssetDailySnapshot.load(siloAsset.id + "-" + day.toString()); + if (hourly != null) { + hourly.deltaDepositedAmount = ZERO_BI; + hourly.deltaDepositedBDV = ZERO_BI; + hourly.deltaWithdrawnAmount = ZERO_BI; + hourly.deltaFarmAmount = ZERO_BI; + hourly.save(); + } + if (daily != null) { + daily.deltaDepositedAmount = ZERO_BI; + daily.deltaDepositedBDV = ZERO_BI; + daily.deltaWithdrawnAmount = ZERO_BI; + daily.deltaFarmAmount = ZERO_BI; + daily.save(); + } +} diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/UnripeToken.ts b/projects/subgraph-beanstalk/src/entities/snapshots/UnripeToken.ts index d9557f8f89..b5097b854f 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/UnripeToken.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/UnripeToken.ts @@ -2,6 +2,7 @@ import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { UnripeToken, UnripeTokenDailySnapshot, UnripeTokenHourlySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; +import { ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; export function takeUnripeTokenSnapshots(unripeToken: UnripeToken, block: ethereum.Block): void { const currentSeason = getCurrentSeason(); @@ -146,3 +147,38 @@ export function takeUnripeTokenSnapshots(unripeToken: UnripeToken, block: ethere unripeToken.lastHourlySnapshotSeason = currentSeason; unripeToken.lastDailySnapshotDay = day; } + +export function clearUnripeTokenDeltas(unripeToken: UnripeToken, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); + const hourly = UnripeTokenHourlySnapshot.load(unripeToken.id.toHexString() + "-" + currentSeason.toString()); + const daily = UnripeTokenDailySnapshot.load(unripeToken.id.toHexString() + "-" + day.toString()); + if (hourly) { + hourly.deltaUnderlyingToken = false; + hourly.deltaTotalUnderlying = ZERO_BI; + hourly.deltaAmountUnderlyingOne = ZERO_BI; + hourly.deltaBdvUnderlyingOne = ZERO_BI; + hourly.deltaChoppableAmountOne = ZERO_BI; + hourly.deltaChoppableBdvOne = ZERO_BI; + hourly.deltaChopRate = ZERO_BD; + hourly.deltaRecapPercent = ZERO_BD; + hourly.deltaTotalChoppedAmount = ZERO_BI; + hourly.deltaTotalChoppedBdv = ZERO_BI; + hourly.deltaTotalChoppedBdvReceived = ZERO_BI; + hourly.save(); + } + if (daily) { + daily.deltaUnderlyingToken = false; + daily.deltaTotalUnderlying = ZERO_BI; + daily.deltaAmountUnderlyingOne = ZERO_BI; + daily.deltaBdvUnderlyingOne = ZERO_BI; + daily.deltaChoppableAmountOne = ZERO_BI; + daily.deltaChoppableBdvOne = ZERO_BI; + daily.deltaChopRate = ZERO_BD; + daily.deltaRecapPercent = ZERO_BD; + daily.deltaTotalChoppedAmount = ZERO_BI; + daily.deltaTotalChoppedBdv = ZERO_BI; + daily.deltaTotalChoppedBdvReceived = ZERO_BI; + daily.save(); + } +} diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts b/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts index 68527b1596..4bf7d329f6 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts @@ -2,6 +2,7 @@ import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { WhitelistTokenSetting, WhitelistTokenHourlySnapshot, WhitelistTokenDailySnapshot } from "../../../generated/schema"; import { getCurrentSeason } from "../Beanstalk"; import { dayFromTimestamp, hourFromTimestamp } from "../../../../subgraph-core/utils/Dates"; +import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: WhitelistTokenSetting, block: ethereum.Block): void { const currentSeason = getCurrentSeason(); @@ -141,6 +142,33 @@ export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: Whitel whitelistTokenSetting.lastDailySnapshotDay = day; } +export function clearWhitelistTokenSettingDeltas(whitelistTokenSetting: WhitelistTokenSetting, block: ethereum.Block): void { + const currentSeason = getCurrentSeason(); + const day = BigInt.fromI32(dayFromTimestamp(block.timestamp)); + const hourly = WhitelistTokenHourlySnapshot.load(whitelistTokenSetting.id.toHexString() + "-" + currentSeason.toString()); + const daily = WhitelistTokenDailySnapshot.load(whitelistTokenSetting.id.toHexString() + "-" + day.toString()); + if (hourly != null) { + hourly.deltaStalkEarnedPerSeason = ZERO_BI; + hourly.deltaStalkIssuedPerBdv = ZERO_BI; + hourly.deltaMilestoneSeason = 0; + hourly.deltaGaugePoints = ZERO_BI; + if (hourly.deltaOptimalPercentDepositedBdv != null) { + hourly.deltaOptimalPercentDepositedBdv = ZERO_BI; + } + hourly.save(); + } + if (daily != null) { + daily.deltaStalkEarnedPerSeason = ZERO_BI; + daily.deltaStalkIssuedPerBdv = ZERO_BI; + daily.deltaMilestoneSeason = 0; + daily.deltaGaugePoints = ZERO_BI; + if (daily.deltaOptimalPercentDepositedBdv != null) { + daily.deltaOptimalPercentDepositedBdv = ZERO_BI; + } + daily.save(); + } +} + // Set bdv on hourly and daily. Snapshots must have already been created. export function setBdv(bdv: BigInt, whitelistTokenSetting: WhitelistTokenSetting): void { const hourly = WhitelistTokenHourlySnapshot.load( diff --git a/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts index 5f733c2cba..b21c5aee22 100644 --- a/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts +++ b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts @@ -7,13 +7,17 @@ import { SEASON_INITIAL, UNRIPE_TOKENS_INITIAL_VALUES } from "../../../cache-builder/results/B3Migration_arb"; -import { takeFieldSnapshots } from "../../entities/snapshots/Field"; +import { clearFieldDeltas, takeFieldSnapshots } from "../../entities/snapshots/Field"; import { loadPodMarketplace } from "../../entities/PodMarketplace"; -import { takeMarketSnapshots } from "../../entities/snapshots/Marketplace"; -import { loadUnripeToken } from "../../entities/Silo"; -import { getUnripeBeanAddr, getUnripeLpAddr } from "../../../../subgraph-core/constants/RuntimeConstants"; -import { takeUnripeTokenSnapshots } from "../../entities/snapshots/UnripeToken"; +import { clearMarketDeltas, takeMarketSnapshots } from "../../entities/snapshots/Marketplace"; +import { loadSilo, loadSiloAsset, loadUnripeToken, loadWhitelistTokenSetting } from "../../entities/Silo"; +import { getUnripeBeanAddr, getUnripeLpAddr, isUnripe } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { clearUnripeTokenDeltas, takeUnripeTokenSnapshots } from "../../entities/snapshots/UnripeToken"; import { loadBeanstalk } from "../../entities/Beanstalk"; +import { clearSiloDeltas } from "../../entities/snapshots/Silo"; +import { clearSiloAssetDeltas } from "../../entities/snapshots/SiloAsset"; +import { clearWhitelistTokenSettingDeltas } from "../../entities/snapshots/WhitelistTokenSetting"; +import { toAddress } from "../../../../subgraph-core/utils/Bytes"; export function init(block: ethereum.Block): void { let beanstalk = loadBeanstalk(); @@ -53,7 +57,14 @@ export function preUnpause(block: ethereum.Block): void { unripe.totalChoppedBdvReceived = UNRIPE_TOKENS_INITIAL_VALUES[i].totalChoppedBdvReceived; takeUnripeTokenSnapshots(unripe, block); unripe.save(); + + clearUnripeTokenDeltas(unripe, block); } - // Zero out all deltas for all snapshots + // Zero out all deltas for all snapshots. Unripe cleared above + clearFieldDeltas(field, block); + clearMarketDeltas(podMarketplace, block); + const silo = loadSilo(v().protocolAddress); + clearSiloDeltas(silo, block); + // No need to clear silo assets/whitelisted tokens, since all of these are technically new to the silo } From 24533c6f9e416bd9a10e6d833f6c82b3ec33a266 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 17:29:44 -0700 Subject: [PATCH 29/88] marketplace, silo legacy events --- .../manifests/arbitrum.yaml | 303 ++++++++++++++++++ .../manifests/codegen-abis.yaml | 2 + .../subgraph-beanstalk/manifests/no-apy.yaml | 4 +- .../src/handlers/MarketplaceHandler.ts | 35 +- .../src/handlers/SiloHandler.ts | 20 -- ...ndler.ts => LegacyMarketplaceV1Handler.ts} | 2 +- .../legacy/LegacyMarketplaceV2Handler.ts | 77 +++++ .../src/handlers/legacy/LegacySiloHandler.ts | 28 ++ .../src/utils/Marketplace.ts | 4 +- projects/subgraph-beanstalk/src/utils/Silo.ts | 16 - .../src/utils/legacy/LegacySilo.ts | 19 +- 11 files changed, 450 insertions(+), 60 deletions(-) create mode 100644 projects/subgraph-beanstalk/manifests/arbitrum.yaml rename projects/subgraph-beanstalk/src/handlers/legacy/{LegacyMarketplaceHandler.ts => LegacyMarketplaceV1Handler.ts} (97%) create mode 100644 projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV2Handler.ts diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml new file mode 100644 index 0000000000..f62a8bd837 --- /dev/null +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -0,0 +1,303 @@ +specVersion: 0.0.9 +schema: + file: ../schema.graphql +dataSources: + ### + # INITIALIZATION + ### + - kind: ethereum/contract + name: Version + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 1 # TODO: set this to the contract deployment block + endBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Version + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + blockHandlers: + - handler: handleInitVersion + filter: + kind: once + file: ../src/utils/constants/Version.ts + ### + # SILO + ### + - kind: ethereum/contract + name: Silo + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Silo + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: AddDeposit(indexed address,indexed address,int96,uint256,uint256) + handler: handleAddDeposit + - event: RemoveDeposit(indexed address,indexed address,int96,uint256,uint256) + handler: handleRemoveDeposit + - event: RemoveDeposits(indexed address,indexed address,int96[],uint256[],uint256,uint256[]) + handler: handleRemoveDeposits + - event: Convert(indexed address,address,address,uint256,uint256) + handler: handleConvert + - event: StalkBalanceChanged(indexed address,int256,int256) + handler: handleStalkBalanceChanged + - event: Plant(indexed address,uint256) + handler: handlePlant + - event: WhitelistToken(indexed address,bytes4,uint32,uint256,uint128,uint64) + handler: handleWhitelistToken + - event: DewhitelistToken(indexed address) + handler: handleDewhitelistToken + - event: UpdatedStalkPerBdvPerSeason(indexed address,uint32,uint32) + handler: handleUpdatedStalkPerBdvPerSeason + file: ../src/handlers/SiloHandler.ts + ### + # SEED GAUGE + ### + - kind: ethereum/contract + name: SeedGauge + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - SeedGauge + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + eventHandlers: + - event: BeanToMaxLpGpPerBdvRatioChange(indexed uint256,uint256,int80) + handler: handleBeanToMaxLpGpPerBdvRatioChange + - event: GaugePointChange(indexed uint256,indexed address,uint256) + handler: handleGaugePointChange + - event: UpdateAverageStalkPerBdvPerSeason(uint256) + handler: handleUpdateAverageStalkPerBdvPerSeason + - event: FarmerGerminatingStalkBalanceChanged(indexed address,int256,uint8) + handler: handleFarmerGerminatingStalkBalanceChanged + - event: TotalGerminatingBalanceChanged(uint256,indexed address,int256,int256) + handler: handleTotalGerminatingBalanceChanged + - event: TotalGerminatingStalkChanged(uint256,int256) + handler: handleTotalGerminatingStalkChanged + - event: TotalStalkChangedFromGermination(int256,int256) + handler: handleTotalStalkChangedFromGermination + # TODO: need replacement for UpdateGaugeSettings, which was deleted in BIP50 + file: ../src/handlers/GaugeHandler.ts + ### + # FIELD + ### + - kind: ethereum/contract + name: Field + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Field + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + # TODO: see if this can be removed + - name: CurvePrice + file: ../../subgraph-core/abis/CurvePrice.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + eventHandlers: + - event: Sow(indexed address,uint256,uint256,uint256,uint256) + handler: handleSow + - event: Harvest(indexed address,uint256,uint256[],uint256) + handler: handleHarvest + - event: PlotTransfer(indexed address,indexed address,uint256,indexed uint256,uint256) + handler: handlePlotTransfer + - event: TemperatureChange(indexed uint256,uint256,int8,uint256) + handler: handleTemperatureChange + file: ../src/handlers/FieldHandler.ts + ### + # MARKETPLACE + ### + - kind: ethereum/contract + name: Marketplace + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - PodMarketplace + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: PodListingCreated(indexed address,uint256,uint256,uint256,uint256,uint24,uint256,uint256,uint8) + handler: handlePodListingCreated + - event: PodListingFilled(indexed address,indexed address,uint256,uint256,uint256,uint256,uint256) + handler: handlePodListingFilled + - event: PodOrderCreated(indexed address,bytes32,uint256,uint256,uint24,uint256,uint256) + handler: handlePodOrderCreated + - event: PodOrderFilled(indexed address,indexed address,bytes32,uint256,uint256,uint256,uint256,uint256) + handler: handlePodOrderFilled + - event: PodListingCancelled(indexed address,uint256,uint256) + handler: handlePodListingCancelled + - event: PodOrderCancelled(indexed address,bytes32) + handler: handlePodOrderCancelled + file: ../src/handlers/MarketplaceHandler.ts + ### + # FERTILIZER + ### + - kind: ethereum/contract + name: Fertilizer-1155 + network: arbitrum-one + source: + address: "0x2D5E484Dd7D43dFE32BF1Ed9fE6517b64F13Ea51" + abi: Fertilizer + startBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Fertilizer + abis: + - name: Fertilizer + file: ../../subgraph-core/abis/Fertilizer.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) + handler: handleTransferBatch + - event: TransferSingle(indexed address,indexed address,indexed address,uint256,uint256) + handler: handleTransferSingle + file: ../src/handlers/BarnHandler.ts + - kind: ethereum/contract + name: Fertilizer-Beanstalk + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Chop + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: Chop(indexed address,indexed address,uint256,uint256) + handler: handleChop + - event: ChangeUnderlying(indexed address,int256) + handler: handleChangeUnderlying + file: ../src/handlers/BarnHandler.ts + ### + # SEASON + ### + - kind: ethereum/contract + name: Season + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Season + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + eventHandlers: + # TODO: need replacement for Reward, which was deleted in BIP50 + - event: WellOracle(indexed uint32,address,int256,bytes) + handler: handleWellOracle + - event: Soil(indexed uint32,uint256) + handler: handleSoil + - event: Incentivization(indexed address,uint256) + handler: handleIncentive + file: ../src/handlers/SeasonHandler.ts + ### + # BEAN ERC20 + ### + - kind: ethereum/contract + name: Bean-Replanted + network: arbitrum-one + source: + address: "0xBEA0005B8599265D41256905A9B3073D397812E4" + abi: ERC20 + startBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Season + abis: + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + eventHandlers: + - event: Transfer(indexed address,indexed address,uint256) + handler: handleTransfer + file: ../src/handlers/BeanHandler.ts + ### + # FARM BALANCE + ### + - kind: ethereum/contract + name: Farm + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 1 # TODO: set this to the contract deployment block + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - SiloAsset + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: InternalBalanceChanged(indexed address,indexed address,int256) + handler: handleInternalBalanceChanged + file: ../src/handlers/FarmHandler.ts +# features: +# - grafting +# graft: +# base: QmUqT47H7o3gcZ2mHRJf2J5hpitWDYxsMmacGeuvo1wKU7 +# block: 19927630 diff --git a/projects/subgraph-beanstalk/manifests/codegen-abis.yaml b/projects/subgraph-beanstalk/manifests/codegen-abis.yaml index 50d8408229..5292fc93c5 100644 --- a/projects/subgraph-beanstalk/manifests/codegen-abis.yaml +++ b/projects/subgraph-beanstalk/manifests/codegen-abis.yaml @@ -34,6 +34,8 @@ dataSources: file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP37.json - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - name: CurvePrice diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index 7d748a7887..8f41a94493 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -316,7 +316,7 @@ dataSources: # Both signatures are required to recognize all events. - event: PodListingCancelled(indexed address,indexed uint256) handler: handlePodListingCancelled_indexed - file: ../src/handlers/legacy/LegacyMarketplaceHandler.ts + file: ../src/handlers/legacy/LegacyMarketplaceV1Handler.ts - kind: ethereum/contract name: LegacyMarketplace-Replanted-SeedGauge network: mainnet @@ -337,7 +337,7 @@ dataSources: eventHandlers: - event: PodListingCreated(indexed address,uint256,uint256,uint256,uint24,uint256,uint8) handler: handlePodListingCreated_v1_1 - file: ../src/handlers/legacy/LegacyMarketplaceHandler.ts + file: ../src/handlers/legacy/LegacyMarketplaceV1Handler.ts ### # FERTILIZER ### diff --git a/projects/subgraph-beanstalk/src/handlers/MarketplaceHandler.ts b/projects/subgraph-beanstalk/src/handlers/MarketplaceHandler.ts index 380b46fe3c..8cacfb5139 100644 --- a/projects/subgraph-beanstalk/src/handlers/MarketplaceHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/MarketplaceHandler.ts @@ -1,4 +1,3 @@ -import { Address, BigInt, Bytes, ethereum, log } from "@graphprotocol/graph-ts"; import { PodListingCreated, PodListingFilled, @@ -6,7 +5,7 @@ import { PodOrderFilled, PodListingCancelled, PodOrderCancelled -} from "../../generated/Beanstalk-ABIs/SeedGauge"; +} from "../../generated/Beanstalk-ABIs/Reseed"; import { podListingCancelled, podListingCreated, @@ -19,28 +18,28 @@ import { export function handlePodListingCreated(event: PodListingCreated): void { podListingCreated({ event: event, - account: event.params.account, + account: event.params.lister, index: event.params.index, start: event.params.start, - amount: event.params.amount, + amount: event.params.podAmount, pricePerPod: event.params.pricePerPod, maxHarvestableIndex: event.params.maxHarvestableIndex, mode: event.params.mode, minFillAmount: event.params.minFillAmount, - pricingFunction: event.params.pricingFunction, - pricingType: event.params.pricingType + pricingFunction: null, + pricingType: 0 }); } export function handlePodListingFilled(event: PodListingFilled): void { podListingFilled({ event: event, - from: event.params.from, - to: event.params.to, + from: event.params.lister, + to: event.params.filler, id: null, index: event.params.index, start: event.params.start, - amount: event.params.amount, + amount: event.params.podAmount, costInBeans: event.params.costInBeans }); } @@ -48,26 +47,26 @@ export function handlePodListingFilled(event: PodListingFilled): void { export function handlePodOrderCreated(event: PodOrderCreated): void { podOrderCreated({ event: event, - account: event.params.account, + account: event.params.orderer, id: event.params.id, - beanAmount: event.params.amount, + beanAmount: event.params.beanAmount, pricePerPod: event.params.pricePerPod, maxPlaceInLine: event.params.maxPlaceInLine, minFillAmount: event.params.minFillAmount, - pricingFunction: event.params.pricingFunction, - pricingType: event.params.priceType + pricingFunction: null, + pricingType: 0 }); } export function handlePodOrderFilled(event: PodOrderFilled): void { podOrderFilled({ event: event, - from: event.params.from, - to: event.params.to, + from: event.params.filler, + to: event.params.orderer, id: event.params.id, index: event.params.index, start: event.params.start, - amount: event.params.amount, + amount: event.params.podAmount, costInBeans: event.params.costInBeans }); } @@ -75,7 +74,7 @@ export function handlePodOrderFilled(event: PodOrderFilled): void { export function handlePodListingCancelled(event: PodListingCancelled): void { podListingCancelled({ event, - account: event.params.account, + account: event.params.lister, index: event.params.index }); } @@ -83,7 +82,7 @@ export function handlePodListingCancelled(event: PodListingCancelled): void { export function handlePodOrderCancelled(event: PodOrderCancelled): void { podOrderCancelled({ event, - account: event.params.account, + account: event.params.orderer, id: event.params.id }); } diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 13205a85ce..209b424c6f 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -84,15 +84,6 @@ export function handleStalkBalanceChanged(event: StalkBalanceChanged): void { updateStalkBalances(event.address, event.params.account, event.params.delta, event.params.deltaRoots, event.block); } -export function handleSeedsBalanceChanged(event: SeedsBalanceChanged): void { - // Exclude BIP-24 emission of missed past events - if (event.transaction.hash.toHexString() == "0xa89638aeb0d6c4afb4f367ea7a806a4c8b3b2a6eeac773e8cc4eda10bfa804fc") { - return; - } - - updateSeedsBalances(event.address, event.params.account, event.params.delta, event.block); -} - export function handlePlant(event: Plant): void { // This removes the plantable stalk for planted beans. // Actual stalk credit for the farmer will be handled under the StalkBalanceChanged event. @@ -160,14 +151,3 @@ export function handleUpdatedStalkPerBdvPerSeason(event: UpdatedStalkPerBdvPerSe takeWhitelistTokenSettingSnapshots(siloSettings, event.block); siloSettings.save(); } - -// Withdrawal is a legacy feature from replant, but these events are still present -export function handleRemoveWithdrawal(event: RemoveWithdrawal): void { - updateClaimedWithdraw(event.params.account, event.params.token, event.params.season, event.block); -} - -export function handleRemoveWithdrawals(event: RemoveWithdrawals): void { - for (let i = 0; i < event.params.seasons.length; i++) { - updateClaimedWithdraw(event.params.account, event.params.token, event.params.seasons[i], event.block); - } -} diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV1Handler.ts similarity index 97% rename from projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceHandler.ts rename to projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV1Handler.ts index a14326439b..740e6c4d9e 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV1Handler.ts @@ -1,4 +1,4 @@ -import { Address, BigInt, Bytes, ethereum, log } from "@graphprotocol/graph-ts"; +import { BigInt, log } from "@graphprotocol/graph-ts"; import { PodListingCreated as PodListingCreated_v1, PodListingFilled as PodListingFilled_v1, diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV2Handler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV2Handler.ts new file mode 100644 index 0000000000..c57c4c4026 --- /dev/null +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV2Handler.ts @@ -0,0 +1,77 @@ +import { + PodListingCreated as PodListingCreated_v2, + PodListingFilled as PodListingFilled_v2, + PodOrderCreated as PodOrderCreated_v2, + PodOrderFilled as PodOrderFilled_v2, + PodListingCancelled as PodListingCancelled_v2 +} from "../../../generated/Beanstalk-ABIs/MarketV2"; +import { podListingCancelled, podListingCreated, podListingFilled, podOrderCreated, podOrderFilled } from "../../utils/Marketplace"; + +// MarketV2 -> Reseed +export function handlePodListingCreated_v2(event: PodListingCreated_v2): void { + podListingCreated({ + event: event, + account: event.params.account, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + pricePerPod: event.params.pricePerPod, + maxHarvestableIndex: event.params.maxHarvestableIndex, + mode: event.params.mode, + minFillAmount: event.params.minFillAmount, + pricingFunction: event.params.pricingFunction, + pricingType: event.params.pricingType + }); +} + +// MarketV2 -> Reseed +export function handlePodListingFilled_v2(event: PodListingFilled_v2): void { + podListingFilled({ + event: event, + from: event.params.from, + to: event.params.to, + id: null, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + costInBeans: event.params.costInBeans + }); +} + +// MarketV2 -> Reseed +export function handlePodOrderCreated_v2(event: PodOrderCreated_v2): void { + podOrderCreated({ + event: event, + account: event.params.account, + id: event.params.id, + beanAmount: event.params.amount, + pricePerPod: event.params.pricePerPod, + maxPlaceInLine: event.params.maxPlaceInLine, + minFillAmount: event.params.minFillAmount, + pricingFunction: event.params.pricingFunction, + pricingType: event.params.priceType + }); +} + +// MarketV2 -> Reseed +export function handlePodOrderFilled_v2(event: PodOrderFilled_v2): void { + podOrderFilled({ + event: event, + from: event.params.from, + to: event.params.to, + id: event.params.id, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + costInBeans: event.params.costInBeans + }); +} + +// Replanted -> Reseed +export function handlePodListingCancelled_v2(event: PodListingCancelled_v2): void { + podListingCancelled({ + event, + account: event.params.account, + index: event.params.index + }); +} diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index 8576719139..0c0535494a 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -14,6 +14,8 @@ import { addToSiloWhitelist, loadSiloWithdraw, loadWhitelistTokenSetting } from import { addDeposits, addWithdrawToSiloAsset, removeDeposits } from "../../utils/Silo"; import { takeWhitelistTokenSettingSnapshots } from "../../entities/snapshots/WhitelistTokenSetting"; import { WhitelistToken as WhitelistToken_v3 } from "../../../generated/Beanstalk-ABIs/SiloV3"; +import { RemoveWithdrawal, RemoveWithdrawals, SeedsBalanceChanged } from "../../../generated/Beanstalk-ABIs/SeedGauge"; +import { updateClaimedWithdraw, updateSeedsBalances } from "../../utils/legacy/LegacySilo"; // Note: No silo v1 (pre-replant) handlers have been developed. @@ -128,3 +130,29 @@ export function handleWhitelistToken_v3(event: WhitelistToken_v3): void { takeWhitelistTokenSettingSnapshots(setting, event.block); setting.save(); } + +// TODO: whitelist v4 + +// Replanted -> Reseed +// Legacy feature since silo v3, but the event was still present until the reseed // +export function handleSeedsBalanceChanged(event: SeedsBalanceChanged): void { + // Exclude BIP-24 emission of missed past events + if (event.transaction.hash.toHexString() == "0xa89638aeb0d6c4afb4f367ea7a806a4c8b3b2a6eeac773e8cc4eda10bfa804fc") { + return; + } + + updateSeedsBalances(event.address, event.params.account, event.params.delta, event.block); +} + +/// Withdrawal is a legacy feature from replant, but these events were still present until the reseed /// +// Replanted -> Reseed +export function handleRemoveWithdrawal(event: RemoveWithdrawal): void { + updateClaimedWithdraw(event.params.account, event.params.token, event.params.season, event.block); +} + +// Replanted -> Reseed +export function handleRemoveWithdrawals(event: RemoveWithdrawals): void { + for (let i = 0; i < event.params.seasons.length; i++) { + updateClaimedWithdraw(event.params.account, event.params.token, event.params.seasons[i], event.block); + } +} diff --git a/projects/subgraph-beanstalk/src/utils/Marketplace.ts b/projects/subgraph-beanstalk/src/utils/Marketplace.ts index c9f184e41c..3196a15773 100644 --- a/projects/subgraph-beanstalk/src/utils/Marketplace.ts +++ b/projects/subgraph-beanstalk/src/utils/Marketplace.ts @@ -39,7 +39,7 @@ class PodListingCreatedParams { // v2 minFillAmount: BigInt; // for v1, always 0 pricingFunction: Bytes | null; - pricingType: i32; // for v1, always 0 + pricingType: i32; // for v1 or v3, always 0 } class PodListingCancelledParams { @@ -58,7 +58,7 @@ class PodOrderCreatedParams { // v2 minFillAmount: BigInt; // for v1, always 0 pricingFunction: Bytes | null; - pricingType: i32; // for v1, always 0 + pricingType: i32; // for v1 or v3, always 0 } class PodOrderCancelledParams { diff --git a/projects/subgraph-beanstalk/src/utils/Silo.ts b/projects/subgraph-beanstalk/src/utils/Silo.ts index 696d4cfd12..4560929151 100644 --- a/projects/subgraph-beanstalk/src/utils/Silo.ts +++ b/projects/subgraph-beanstalk/src/utils/Silo.ts @@ -177,19 +177,3 @@ export function updateStalkBalances( } silo.save(); } - -export function updateSeedsBalances( - protocol: Address, - account: Address, - seeds: BigInt, - block: ethereum.Block, - recurs: boolean = true -): void { - if (recurs && account != protocol) { - updateSeedsBalances(protocol, protocol, seeds, block); - } - let silo = loadSilo(account); - silo.seeds = silo.seeds.plus(seeds); - takeSiloSnapshots(silo, block); - silo.save(); -} diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts index 8908ce5e43..56ad30dbd1 100644 --- a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts @@ -2,11 +2,12 @@ import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { loadSilo, loadSiloAsset, loadSiloWithdraw } from "../../entities/Silo"; import { takeSiloAssetSnapshots } from "../../entities/snapshots/SiloAsset"; import { loadBeanstalk } from "../../entities/Beanstalk"; -import { updateSeedsBalances, updateStalkBalances } from "../Silo"; +import { updateStalkBalances } from "../Silo"; import { Replanted } from "../../../generated/Beanstalk-ABIs/Replanted"; import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10 } from "../../../../subgraph-core/utils/Decimals"; import { toAddress } from "../../../../subgraph-core/utils/Bytes"; +import { takeSiloSnapshots } from "../../entities/snapshots/Silo"; export function updateClaimedWithdraw(account: Address, token: Address, withdrawSeason: BigInt, block: ethereum.Block): void { let withdraw = loadSiloWithdraw(account, token, withdrawSeason.toI32()); @@ -42,6 +43,22 @@ export function updateStalkWithCalls(protocol: Address, block: ethereum.Block): beanstalk.save(); } +export function updateSeedsBalances( + protocol: Address, + account: Address, + seeds: BigInt, + block: ethereum.Block, + recurs: boolean = true +): void { + if (recurs && account != protocol) { + updateSeedsBalances(protocol, protocol, seeds, block); + } + let silo = loadSilo(account); + silo.seeds = silo.seeds.plus(seeds); + takeSiloSnapshots(silo, block); + silo.save(); +} + const STEM_START_SEASON = 14210; export function stemFromSeason(season: i32, token: Address): BigInt { From 32b75c01e026ab4d8f2b794fb3f4026a058872a4 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 17:56:11 -0700 Subject: [PATCH 30/88] reward event replacement --- .../manifests/ethereum.yaml | 4 +- .../src/handlers/SeasonHandler.ts | 40 +- .../src/handlers/SiloHandler.ts | 31 +- .../handlers/legacy/LegacySeasonHandler.ts | 12 +- .../src/handlers/legacy/LegacySiloHandler.ts | 24 +- .../subgraph-beanstalk/src/utils/Season.ts | 19 +- projects/subgraph-beanstalk/src/utils/Silo.ts | 1 + .../src/utils/legacy/LegacySilo.ts | 1 + .../tests/utils/Marketplace.ts | 2 +- .../abis/Beanstalk/Beanstalk-BIP50.json | 11490 ++++++++++++++++ 10 files changed, 11562 insertions(+), 62 deletions(-) create mode 100644 projects/subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index fe83a5efa2..c262cc8135 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -674,7 +674,7 @@ dataSources: # Both signatures are required to recognize all events. - event: PodListingCancelled(indexed address,indexed uint256) handler: handlePodListingCancelled_indexed - file: ../src/handlers/legacy/LegacyMarketplaceHandler.ts + file: ../src/handlers/legacy/LegacyMarketplaceV1Handler.ts - kind: ethereum/contract name: LegacyMarketplace-Replanted-SeedGauge network: mainnet @@ -695,7 +695,7 @@ dataSources: eventHandlers: - event: PodListingCreated(indexed address,uint256,uint256,uint256,uint24,uint256,uint8) handler: handlePodListingCreated_v1_1 - file: ../src/handlers/legacy/LegacyMarketplaceHandler.ts + file: ../src/handlers/legacy/LegacyMarketplaceV1Handler.ts ### # FERTILIZER ### diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index 94ac5ce6b3..e5b14e70a2 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -3,18 +3,16 @@ import { Reward, Soil, WellOracle, Sunrise, Incentivization, SeedGauge } from ". import { toDecimal, ZERO_BD } from "../../../subgraph-core/utils/Decimals"; import { updateStalkWithCalls } from "../utils/legacy/LegacySilo"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; -import { loadSilo } from "../entities/Silo"; -import { takeSiloSnapshots } from "../entities/snapshots/Silo"; -import { updateDepositInSiloAsset } from "../utils/Silo"; import { getBeanstalkPrice } from "../utils/contracts/BeanstalkPrice"; import { takeFieldSnapshots } from "../entities/snapshots/Field"; import { loadField } from "../entities/Field"; import { updateBeanEMA } from "../utils/Yield"; import { updateExpiredPlots } from "../utils/Marketplace"; import { updateHarvestablePlots } from "../utils/Field"; -import { sunrise } from "../utils/Season"; -import { getProtocolToken, isGaugeDeployed, isReplanted } from "../../../subgraph-core/constants/RuntimeConstants"; +import { siloReceipt, sunrise } from "../utils/Season"; +import { isGaugeDeployed, isReplanted } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; +import { Receipt, Shipped } from "../../generated/Beanstalk-ABIs/Reseed"; export function handleSunrise(event: Sunrise): void { // (Legacy) Update any farmers that had silo transfers from the prior season. @@ -24,32 +22,18 @@ export function handleSunrise(event: Sunrise): void { sunrise(event.address, event.params.season, event.block); } -export function handleReward(event: Reward): void { +// Overall reward mint +export function handleShipped(event: Shipped): void { let season = loadSeason(event.params.season); - season.rewardBeans = event.params.toField.plus(event.params.toSilo).plus(event.params.toFertilizer); + season.rewardBeans = event.params.shipmentAmount; season.save(); +} - // Add to total Silo Bean mints - - let silo = loadSilo(event.address); - let newPlantableStalk = event.params.toSilo.times(BigInt.fromI32(10000)); // Stalk has 10 decimals - - silo.beanMints = silo.beanMints.plus(event.params.toSilo); - silo.stalk = silo.stalk.plus(newPlantableStalk); - silo.plantableStalk = silo.plantableStalk.plus(newPlantableStalk); - silo.depositedBDV = silo.depositedBDV.plus(event.params.toSilo); - - takeSiloSnapshots(silo, event.block); - silo.save(); - - updateDepositInSiloAsset( - event.address, - event.address, - getProtocolToken(v(), event.block.number), - event.params.toSilo, - event.params.toSilo, - event.block - ); +// Reward mint to each shipment +export function handleReceipt(event: Receipt): void { + if (event.params.recipient == 1) { + siloReceipt(event.params.receivedAmount, event.block); + } } export function handleWellOracle(event: WellOracle): void { diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 209b424c6f..74eadd8384 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -1,9 +1,8 @@ import { BigInt, log } from "@graphprotocol/graph-ts"; -import { addDeposits, removeDeposits, updateDepositInSiloAsset, updateSeedsBalances, updateStalkBalances } from "../utils/Silo"; -import { addToSiloWhitelist, loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; +import { addDeposits, removeDeposits, updateDepositInSiloAsset, updateStalkBalances } from "../utils/Silo"; +import { loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; import { takeSiloSnapshots } from "../entities/snapshots/Silo"; import { takeWhitelistTokenSettingSnapshots } from "../entities/snapshots/WhitelistTokenSetting"; -import { Bytes4_emptyToNull } from "../../../subgraph-core/utils/Bytes"; import { AddDeposit, Convert, @@ -11,14 +10,9 @@ import { Plant, RemoveDeposit, RemoveDeposits, - RemoveWithdrawal, - RemoveWithdrawals, - SeedsBalanceChanged, StalkBalanceChanged, - UpdatedStalkPerBdvPerSeason, - WhitelistToken + UpdatedStalkPerBdvPerSeason } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { updateClaimedWithdraw } from "../utils/legacy/LegacySilo"; import { unripeChopped } from "../utils/Barn"; import { getProtocolToken, isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; @@ -89,6 +83,7 @@ export function handlePlant(event: Plant): void { // Actual stalk credit for the farmer will be handled under the StalkBalanceChanged event. let silo = loadSilo(event.address); + // FIXME stalk decimals let newPlantableStalk = event.params.beans.times(BigInt.fromI32(10000)); // Subtract stalk since it was already added in Reward, and is about to get re-added in StalkBalanceChanged. @@ -111,24 +106,6 @@ export function handlePlant(event: Plant): void { ); } -export function handleWhitelistToken(event: WhitelistToken): void { - addToSiloWhitelist(event.address, event.params.token); - - let siloSettings = loadWhitelistTokenSetting(event.params.token); - - siloSettings.selector = event.params.selector; - siloSettings.stalkEarnedPerSeason = event.params.stalkEarnedPerSeason; - siloSettings.stalkIssuedPerBdv = event.params.stalkIssuedPerBdv; - siloSettings.gaugePoints = event.params.gaugePoints; - siloSettings.gpSelector = Bytes4_emptyToNull(event.params.gpSelector); - siloSettings.lwSelector = Bytes4_emptyToNull(event.params.lwSelector); - siloSettings.optimalPercentDepositedBdv = event.params.optimalPercentDepositedBdv; - siloSettings.updatedAt = event.block.timestamp; - - takeWhitelistTokenSettingSnapshots(siloSettings, event.block); - siloSettings.save(); -} - export function handleDewhitelistToken(event: DewhitelistToken): void { let silo = loadSilo(event.address); let currentWhitelist = silo.whitelistedTokens; diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts index d692e9cd53..871dea8cfa 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts @@ -6,7 +6,8 @@ import { MetapoolOracle } from "../../../generated/Beanstalk-ABIs/Replanted"; import { BeanstalkPrice_priceOnly } from "../../utils/contracts/BeanstalkPrice"; import { loadSeason } from "../../entities/Beanstalk"; import { updateStalkWithCalls } from "../../utils/legacy/LegacySilo"; -import { sunrise } from "../../utils/Season"; +import { siloReceipt, sunrise } from "../../utils/Season"; +import { Reward } from "../../../generated/Beanstalk-ABIs/SeedGauge"; // Replanted -> SiloV3 export function handleReplantSunrise(event: Sunrise): void { @@ -38,3 +39,12 @@ export function handleMetapoolOracle(event: MetapoolOracle): void { season.deltaB = event.params.deltaB; season.save(); } + +// Replanted -> SeedGauge +export function handleReward(event: Reward): void { + let season = loadSeason(event.params.season); + season.rewardBeans = event.params.toField.plus(event.params.toSilo).plus(event.params.toFertilizer); + season.save(); + + siloReceipt(event.params.toSilo, event.block); +} diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index 0c0535494a..b2632b1cf3 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -14,8 +14,9 @@ import { addToSiloWhitelist, loadSiloWithdraw, loadWhitelistTokenSetting } from import { addDeposits, addWithdrawToSiloAsset, removeDeposits } from "../../utils/Silo"; import { takeWhitelistTokenSettingSnapshots } from "../../entities/snapshots/WhitelistTokenSetting"; import { WhitelistToken as WhitelistToken_v3 } from "../../../generated/Beanstalk-ABIs/SiloV3"; -import { RemoveWithdrawal, RemoveWithdrawals, SeedsBalanceChanged } from "../../../generated/Beanstalk-ABIs/SeedGauge"; +import { RemoveWithdrawal, RemoveWithdrawals, SeedsBalanceChanged, WhitelistToken } from "../../../generated/Beanstalk-ABIs/SeedGauge"; import { updateClaimedWithdraw, updateSeedsBalances } from "../../utils/legacy/LegacySilo"; +import { Bytes4_emptyToNull } from "../../../../subgraph-core/utils/Bytes"; // Note: No silo v1 (pre-replant) handlers have been developed. @@ -111,6 +112,7 @@ export function handleWhitelistToken_v2(event: WhitelistToken_v2): void { let setting = loadWhitelistTokenSetting(event.params.token); setting.selector = event.params.selector; + // FIXME stalk decimals setting.stalkIssuedPerBdv = BigInt.fromString("10000000000"); setting.stalkEarnedPerSeason = event.params.stalk.times(BigInt.fromI32(1000000)); @@ -124,6 +126,7 @@ export function handleWhitelistToken_v3(event: WhitelistToken_v3): void { let setting = loadWhitelistTokenSetting(event.params.token); setting.selector = event.params.selector; + // FIXME stalk decimals setting.stalkIssuedPerBdv = event.params.stalk.times(BigInt.fromI32(1_000_000)); setting.stalkEarnedPerSeason = event.params.stalkEarnedPerSeason; @@ -131,7 +134,24 @@ export function handleWhitelistToken_v3(event: WhitelistToken_v3): void { setting.save(); } -// TODO: whitelist v4 +// SeedGauge -> Reseed +export function handleWhitelistToken(event: WhitelistToken): void { + addToSiloWhitelist(event.address, event.params.token); + + let siloSettings = loadWhitelistTokenSetting(event.params.token); + + siloSettings.selector = event.params.selector; + siloSettings.stalkEarnedPerSeason = event.params.stalkEarnedPerSeason; + siloSettings.stalkIssuedPerBdv = event.params.stalkIssuedPerBdv; + siloSettings.gaugePoints = event.params.gaugePoints; + siloSettings.gpSelector = Bytes4_emptyToNull(event.params.gpSelector); + siloSettings.lwSelector = Bytes4_emptyToNull(event.params.lwSelector); + siloSettings.optimalPercentDepositedBdv = event.params.optimalPercentDepositedBdv; + siloSettings.updatedAt = event.block.timestamp; + + takeWhitelistTokenSettingSnapshots(siloSettings, event.block); + siloSettings.save(); +} // Replanted -> Reseed // Legacy feature since silo v3, but the event was still present until the reseed // diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index bfa93faff3..7daa7aea3c 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -12,9 +12,10 @@ import { setBdv, takeWhitelistTokenSettingSnapshots } from "../entities/snapshot import { WhitelistTokenSetting } from "../../generated/schema"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { updateUnripeStats } from "./Barn"; -import { isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; +import { getProtocolToken, isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; +import { updateDepositInSiloAsset } from "./Silo"; export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block): void { let currentSeason = season.toI32(); @@ -64,6 +65,22 @@ export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block } } +export function siloReceipt(amount: BigInt, block: ethereum.Block): void { + let silo = loadSilo(v().protocolAddress); + // FIXME stalk decimals + let newPlantableStalk = amount.times(BigInt.fromI32(10000)); // Stalk has 10 decimals + + silo.beanMints = silo.beanMints.plus(amount); + silo.stalk = silo.stalk.plus(newPlantableStalk); + silo.plantableStalk = silo.plantableStalk.plus(newPlantableStalk); + silo.depositedBDV = silo.depositedBDV.plus(amount); + + takeSiloSnapshots(silo, block); + silo.save(); + + updateDepositInSiloAsset(v().protocolAddress, v().protocolAddress, getProtocolToken(v(), block.number), amount, amount, block); +} + function setTokenBdv(token: Address, protocol: Address, whitelistTokenSetting: WhitelistTokenSetting): void { // Get bdv if the bdv function is available onchain (not available prior to BIP-16) const beanstalk_call = SeedGauge.bind(protocol); diff --git a/projects/subgraph-beanstalk/src/utils/Silo.ts b/projects/subgraph-beanstalk/src/utils/Silo.ts index 4560929151..6f3d83e691 100644 --- a/projects/subgraph-beanstalk/src/utils/Silo.ts +++ b/projects/subgraph-beanstalk/src/utils/Silo.ts @@ -112,6 +112,7 @@ export function updateDepositInSiloAsset( let asset = loadSiloAsset(account, token); let tokenSettings = loadWhitelistTokenSetting(token); + // FIXME stalk decimals let newGrownStalk = deltaBdv.times(tokenSettings.stalkEarnedPerSeason).div(BigInt.fromI32(1000000)); asset.depositedBDV = asset.depositedBDV.plus(deltaBdv); diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts index 56ad30dbd1..1e97e225b7 100644 --- a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts @@ -67,6 +67,7 @@ export function stemFromSeason(season: i32, token: Address): BigInt { // Equivalent to LibLegacyTokenSilo.seasonToStem function seasonToV3Stem(season: i32, stemStartSeason: i32, seedsPerBdv: i32): BigInt { + // FIXME stalk decimals return BigInt.fromI32(season - stemStartSeason).times(BigInt.fromI32(seedsPerBdv).times(BI_10.pow(6))); } diff --git a/projects/subgraph-beanstalk/tests/utils/Marketplace.ts b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts index 7a3dacceda..9577be5d43 100644 --- a/projects/subgraph-beanstalk/tests/utils/Marketplace.ts +++ b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts @@ -37,7 +37,7 @@ import { handlePodListingFilled_v1, handlePodOrderCreated_v1, handlePodOrderFilled_v1 -} from "../../src/handlers/legacy/LegacyMarketplaceHandler"; +} from "../../src/handlers/legacy/LegacyMarketplaceV1Handler"; import { handlePodListingCancelled, handlePodListingCreated, diff --git a/projects/subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json b/projects/subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json new file mode 100644 index 0000000000..f38c9fb054 --- /dev/null +++ b/projects/subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json @@ -0,0 +1,11490 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "SafeCastOverflowedUintToInt", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "unripeToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "underlyingToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "merkleRoot", + "type": "bytes32" + } + ], + "name": "AddUnripeToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "underlying", + "type": "int256" + } + ], + "name": "ChangeUnderlying", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "underlying", + "type": "uint256" + } + ], + "name": "Chop", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "delta", + "type": "int256" + } + ], + "name": "InternalBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Pick", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "underlyingToken", + "type": "address" + } + ], + "name": "SwitchUnderlyingToken", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "addMigratedUnderlying", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "underlyingToken", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "addUnripeToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfPenalizedUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "underlying", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "underlying", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.From", + "name": "fromMode", + "type": "uint8" + }, + { + "internalType": "enum LibTransfer.To", + "name": "toMode", + "type": "uint8" + } + ], + "name": "chop", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "getLockedBeans", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "cumulativeReserves", + "type": "bytes" + }, + { + "internalType": "uint40", + "name": "timestamp", + "type": "uint40" + } + ], + "name": "getLockedBeansFromTwaReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLockedBeansUnderlyingUnripeBean", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLockedBeansUnderlyingUnripeLP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "getPenalizedUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "redeem", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + } + ], + "name": "getPenalty", + "outputs": [ + { + "internalType": "uint256", + "name": "penalty", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + } + ], + "name": "getPercentPenalty", + "outputs": [ + { + "internalType": "uint256", + "name": "penalty", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + } + ], + "name": "getRecapFundedPercent", + "outputs": [ + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRecapPaidPercent", + "outputs": [ + { + "internalType": "uint256", + "name": "percent", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRecapitalized", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + } + ], + "name": "getTotalUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "underlying", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "getUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "underlyingAmount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + } + ], + "name": "getUnderlyingPerUnripeToken", + "outputs": [ + { + "internalType": "uint256", + "name": "underlyingPerToken", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + } + ], + "name": "getUnderlyingToken", + "outputs": [ + { + "internalType": "address", + "name": "underlyingToken", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + } + ], + "name": "isUnripe", + "outputs": [ + { + "internalType": "bool", + "name": "unripe", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "unripeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "newUnderlyingToken", + "type": "address" + } + ], + "name": "switchUnderlyingToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "bits", + "type": "uint8" + }, + { + "internalType": "int256", + "name": "value", + "type": "int256" + } + ], + "name": "SafeCastOverflowedIntDowncast", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "bits", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "SafeCastOverflowedUintDowncast", + "type": "error" + }, + { + "inputs": [], + "name": "T", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint128", + "name": "id", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "bpf", + "type": "uint128" + } + ], + "name": "SetFertilizer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "address", + "name": "barnRaiseToken", + "type": "address" + } + ], + "name": "_getMintFertilizerOut", + "outputs": [ + { + "internalType": "uint256", + "name": "fertilizerAmountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "accounts", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + } + ], + "name": "balanceOfBatchFertilizer", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "lastBpf", + "type": "uint128" + } + ], + "internalType": "struct IFertilizer.Balance[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + } + ], + "name": "balanceOfFertilized", + "outputs": [ + { + "internalType": "uint256", + "name": "beans", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "balanceOfFertilizer", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "lastBpf", + "type": "uint128" + } + ], + "internalType": "struct IFertilizer.Balance", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + } + ], + "name": "balanceOfUnfertilized", + "outputs": [ + { + "internalType": "uint256", + "name": "beans", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "beansPerFertilizer", + "outputs": [ + { + "internalType": "uint128", + "name": "bpf", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "beginBarnRaiseMigration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "claimFertilized", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "getActiveFertilizer", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBarnRaiseToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBarnRaiseWell", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentHumidity", + "outputs": [ + { + "internalType": "uint128", + "name": "humidity", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getEndBpf", + "outputs": [ + { + "internalType": "uint128", + "name": "endBpf", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "id", + "type": "uint128" + } + ], + "name": "getFertilizer", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFertilizers", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "endBpf", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + } + ], + "internalType": "struct FertilizerFacet.Supply[]", + "name": "fertilizers", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFirst", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_s", + "type": "uint128" + } + ], + "name": "getHumidity", + "outputs": [ + { + "internalType": "uint128", + "name": "humidity", + "type": "uint128" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getLast", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + } + ], + "name": "getMintFertilizerOut", + "outputs": [ + { + "internalType": "uint256", + "name": "fertilizerAmountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "id", + "type": "uint128" + } + ], + "name": "getNext", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalRecapDollarsNeeded", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isFertilizing", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "leftoverBeans", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minFertilizerOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minLPTokensOut", + "type": "uint256" + } + ], + "name": "mintFertilizer", + "outputs": [ + { + "internalType": "uint256", + "name": "fertilizerAmountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "payFertilizer", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "remainingRecapitalization", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rinsableSprouts", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rinsedSprouts", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalFertilizedBeans", + "outputs": [ + { + "internalType": "uint256", + "name": "beans", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalFertilizerBeans", + "outputs": [ + { + "internalType": "uint256", + "name": "beans", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalUnfertilizedBeans", + "outputs": [ + { + "internalType": "uint256", + "name": "beans", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "Pause", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timePassed", + "type": "uint256" + } + ], + "name": "Unpause", + "type": "event" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "claimOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "owner_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ownerCandidate", + "outputs": [ + { + "internalType": "address", + "name": "ownerCandidate_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + } + ], + "name": "facetAddress", + "outputs": [ + { + "internalType": "address", + "name": "facetAddress_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facetAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "facetAddresses_", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facet", + "type": "address" + } + ], + "name": "facetFunctionSelectors", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "facetFunctionSelectors_", + "type": "bytes4[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facets", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondLoupe.Facet[]", + "name": "facets_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "diamondCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "ECDSAInvalidSignature", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "ECDSAInvalidSignatureLength", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "ECDSAInvalidSignatureS", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "blueprintHash", + "type": "bytes32" + } + ], + "name": "CancelBlueprint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "publisher", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bytes32[]", + "name": "operatorPasteInstrs", + "type": "bytes32[]" + }, + { + "internalType": "uint256", + "name": "maxNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "internalType": "struct LibTractor.Blueprint", + "name": "blueprint", + "type": "tuple" + }, + { + "internalType": "bytes32", + "name": "blueprintHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct LibTractor.Requisition", + "name": "requisition", + "type": "tuple" + } + ], + "name": "PublishRequisition", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "blueprintHash", + "type": "bytes32" + } + ], + "name": "Tractor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "version", + "type": "string" + } + ], + "name": "TractorVersionSet", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "publisher", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bytes32[]", + "name": "operatorPasteInstrs", + "type": "bytes32[]" + }, + { + "internalType": "uint256", + "name": "maxNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "internalType": "struct LibTractor.Blueprint", + "name": "blueprint", + "type": "tuple" + }, + { + "internalType": "bytes32", + "name": "blueprintHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct LibTractor.Requisition", + "name": "requisition", + "type": "tuple" + } + ], + "name": "cancelBlueprint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "publisher", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bytes32[]", + "name": "operatorPasteInstrs", + "type": "bytes32[]" + }, + { + "internalType": "uint256", + "name": "maxNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "internalType": "struct LibTractor.Blueprint", + "name": "blueprint", + "type": "tuple" + } + ], + "name": "getBlueprintHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "blueprintHash", + "type": "bytes32" + } + ], + "name": "getBlueprintNonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "counterId", + "type": "bytes32" + } + ], + "name": "getCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "counterId", + "type": "bytes32" + } + ], + "name": "getPublisherCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTractorVersion", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "publisher", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bytes32[]", + "name": "operatorPasteInstrs", + "type": "bytes32[]" + }, + { + "internalType": "uint256", + "name": "maxNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "internalType": "struct LibTractor.Blueprint", + "name": "blueprint", + "type": "tuple" + }, + { + "internalType": "bytes32", + "name": "blueprintHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct LibTractor.Requisition", + "name": "requisition", + "type": "tuple" + } + ], + "name": "publishRequisition", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "publisher", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bytes32[]", + "name": "operatorPasteInstrs", + "type": "bytes32[]" + }, + { + "internalType": "uint256", + "name": "maxNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "internalType": "struct LibTractor.Blueprint", + "name": "blueprint", + "type": "tuple" + }, + { + "internalType": "bytes32", + "name": "blueprintHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct LibTractor.Requisition", + "name": "requisition", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "operatorData", + "type": "bytes" + } + ], + "name": "tractor", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "counterId", + "type": "bytes32" + }, + { + "internalType": "enum LibTractor.CounterUpdateType", + "name": "updateType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "updatePublisherCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "version", + "type": "string" + } + ], + "name": "updateTractorVersion", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC1155", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "batchTransferERC1155", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Permit", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permitERC20", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC4494", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "sig", + "type": "bytes" + } + ], + "name": "permitERC721", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC1155", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferERC1155", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "transferERC721", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokenApproval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "enum LibTransfer.From", + "name": "fromMode", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "enum LibTransfer.To", + "name": "toMode", + "type": "uint8" + } + ], + "name": "TokenTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approveToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseTokenAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "getAllBalance", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "internalBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "externalBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBalance", + "type": "uint256" + } + ], + "internalType": "struct TokenFacet.Balance", + "name": "b", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "getAllBalances", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "internalBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "externalBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBalance", + "type": "uint256" + } + ], + "internalType": "struct TokenFacet.Balance[]", + "name": "balances", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "getBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "getBalances", + "outputs": [ + { + "internalType": "uint256[]", + "name": "balances", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "getExternalBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "getExternalBalances", + "outputs": [ + { + "internalType": "uint256[]", + "name": "balances", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "getInternalBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "getInternalBalances", + "outputs": [ + { + "internalType": "uint256[]", + "name": "balances", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseTokenAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC1155BatchReceived", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC1155Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permitToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "tokenAllowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tokenPermitDomainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "tokenPermitNonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.To", + "name": "toMode", + "type": "uint8" + } + ], + "name": "transferInternalTokenFrom", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.From", + "name": "fromMode", + "type": "uint8" + }, + { + "internalType": "enum LibTransfer.To", + "name": "toMode", + "type": "uint8" + } + ], + "name": "transferToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.From", + "name": "mode", + "type": "uint8" + } + ], + "name": "unwrapEth", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "wrapEth", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "clipboard", + "type": "bytes" + } + ], + "internalType": "struct AdvancedFarmCall[]", + "name": "data", + "type": "tuple[]" + } + ], + "name": "advancedFarm", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "farm", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "clipboard", + "type": "bytes" + } + ], + "internalType": "struct AdvancedPipeCall[]", + "name": "pipes", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "advancedPipe", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct PipeCall", + "name": "p", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "etherPipe", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct PipeCall[]", + "name": "pipes", + "type": "tuple[]" + } + ], + "name": "multiPipe", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct PipeCall", + "name": "p", + "type": "tuple" + } + ], + "name": "pipe", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct PipeCall", + "name": "p", + "type": "tuple" + } + ], + "name": "readPipe", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "prod1", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "denominator", + "type": "uint256" + } + ], + "name": "PRBMath__MulDivOverflow", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "ActiveFieldSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "FieldAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "plots", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "beans", + "type": "uint256" + } + ], + "name": "Harvest", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "lister", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "PodListingCancelled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "beans", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "pods", + "type": "uint256" + } + ], + "name": "Sow", + "type": "event" + }, + { + "inputs": [], + "name": "activeField", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "addField", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "balanceOfPods", + "outputs": [ + { + "internalType": "uint256", + "name": "pods", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "fieldCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "getPlotIndexesFromAccount", + "outputs": [ + { + "internalType": "uint256[]", + "name": "plotIndexes", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "getPlotsFromAccount", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pods", + "type": "uint256" + } + ], + "internalType": "struct FieldFacet.Plot[]", + "name": "plots", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "plots", + "type": "uint256[]" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "harvest", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "harvestableIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "isHarvesting", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxTemperature", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "plot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "podIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "remainingPods", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "_temperature", + "type": "uint32" + } + ], + "name": "setActiveField", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "beans", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minTemperature", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.From", + "name": "mode", + "type": "uint8" + } + ], + "name": "sow", + "outputs": [ + { + "internalType": "uint256", + "name": "pods", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "beans", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minTemperature", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minSoil", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.From", + "name": "mode", + "type": "uint8" + } + ], + "name": "sowWithMin", + "outputs": [ + { + "internalType": "uint256", + "name": "pods", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "temperature", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "totalHarvestable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalHarvestableForActiveField", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "totalHarvested", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "totalPods", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSoil", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "totalUnharvestable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "PlotTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "PodApproval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "lister", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "podAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "maxHarvestableIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "PodListingCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "filler", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "lister", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "podAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "costInBeans", + "type": "uint256" + } + ], + "name": "PodListingFilled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "orderer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "name": "PodOrderCancelled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "orderer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "beanAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "maxPlaceInLine", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + } + ], + "name": "PodOrderCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "filler", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "orderer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "podAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "costInBeans", + "type": "uint256" + } + ], + "name": "PodOrderFilled", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "allowancePods", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approvePods", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "cancelPodListing", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "orderer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "internalType": "uint256", + "name": "maxPlaceInLine", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + } + ], + "internalType": "struct Order.PodOrder", + "name": "podOrder", + "type": "tuple" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "cancelPodOrder", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "lister", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podAmount", + "type": "uint256" + }, + { + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "internalType": "uint256", + "name": "maxHarvestableIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "internalType": "struct Listing.PodListing", + "name": "podListing", + "type": "tuple" + } + ], + "name": "createPodListing", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "orderer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "internalType": "uint256", + "name": "maxPlaceInLine", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + } + ], + "internalType": "struct Order.PodOrder", + "name": "podOrder", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "beanAmount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.From", + "name": "mode", + "type": "uint8" + } + ], + "name": "createPodOrder", + "outputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "lister", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podAmount", + "type": "uint256" + }, + { + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "internalType": "uint256", + "name": "maxHarvestableIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "internalType": "struct Listing.PodListing", + "name": "podListing", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "beanAmount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.From", + "name": "mode", + "type": "uint8" + } + ], + "name": "fillPodListing", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "orderer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "internalType": "uint256", + "name": "maxPlaceInLine", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + } + ], + "internalType": "struct Order.PodOrder", + "name": "podOrder", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "fillPodOrder", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "orderer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "internalType": "uint256", + "name": "maxPlaceInLine", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + } + ], + "internalType": "struct Order.PodOrder", + "name": "podOrder", + "type": "tuple" + } + ], + "name": "getOrderId", + "outputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getPodListing", + "outputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "name": "getPodOrder", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "end", + "type": "uint256" + } + ], + "name": "transferPlot", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "starts", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "ends", + "type": "uint256[]" + } + ], + "name": "transferPlots", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int96", + "name": "stem", + "type": "int96" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bdv", + "type": "uint256" + } + ], + "name": "AddDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + } + ], + "name": "Convert", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "delta", + "type": "int256" + }, + { + "indexed": false, + "internalType": "enum GerminationSide", + "name": "germ", + "type": "uint8" + } + ], + "name": "FarmerGerminatingStalkBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int96[]", + "name": "stems", + "type": "int96[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "bdvs", + "type": "uint256[]" + } + ], + "name": "RemoveDeposits", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "delta", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "deltaRoots", + "type": "int256" + } + ], + "name": "StalkBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "germinationSeason", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "deltaAmount", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "deltaBdv", + "type": "int256" + } + ], + "name": "TotalGerminatingBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "germinationSeason", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "deltaGerminatingStalk", + "type": "int256" + } + ], + "name": "TotalGerminatingStalkChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "TransferBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "depositId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TransferSingle", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "int96[]", + "name": "stems", + "type": "int96[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "clipboard", + "type": "bytes" + } + ], + "internalType": "struct AdvancedFarmCall[]", + "name": "advancedFarmCalls", + "type": "tuple[]" + } + ], + "name": "pipelineConvert", + "outputs": [ + { + "internalType": "int96", + "name": "toStem", + "type": "int96" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fromBdv", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toBdv", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int96", + "name": "stem", + "type": "int96" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bdv", + "type": "uint256" + } + ], + "name": "RemoveDeposit", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "int96[]", + "name": "stems", + "type": "int96[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "balanceOfRevitalizedStalk", + "outputs": [ + { + "internalType": "uint256", + "name": "stalk", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96", + "name": "stem", + "type": "int96" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "enrootDeposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96[]", + "name": "stems", + "type": "int96[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "enrootDeposits", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "int256", + "name": "beforeInputTokenDeltaB", + "type": "int256" + }, + { + "internalType": "int256", + "name": "afterInputTokenDeltaB", + "type": "int256" + }, + { + "internalType": "int256", + "name": "beforeOutputTokenDeltaB", + "type": "int256" + }, + { + "internalType": "int256", + "name": "afterOutputTokenDeltaB", + "type": "int256" + }, + { + "internalType": "int256", + "name": "beforeOverallDeltaB", + "type": "int256" + }, + { + "internalType": "int256", + "name": "afterOverallDeltaB", + "type": "int256" + } + ], + "internalType": "struct LibConvert.DeltaBStorage", + "name": "dbs", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "bdvConverted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "overallConvertCapacity", + "type": "uint256" + }, + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "name": "calculateStalkPenalty", + "outputs": [ + { + "internalType": "uint256", + "name": "stalkPenaltyBdv", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "overallConvertCapacityUsed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputTokenAmountUsed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputTokenAmountUsed", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "cappedReservesDeltaB", + "outputs": [ + { + "internalType": "int256", + "name": "deltaB", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "name": "getAmountOut", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + } + ], + "name": "getMaxAmountIn", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOverallConvertCapacity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "getWellConvertCapacity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "overallCappedDeltaB", + "outputs": [ + { + "internalType": "int256", + "name": "deltaB", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "overallCurrentDeltaB", + "outputs": [ + { + "internalType": "int256", + "name": "deltaB", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "beforeLpTokenSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "afterLpTokenSupply", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "deltaB", + "type": "int256" + } + ], + "name": "scaledDeltaB", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "convertData", + "type": "bytes" + }, + { + "internalType": "int96[]", + "name": "stems", + "type": "int96[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "convert", + "outputs": [ + { + "internalType": "int96", + "name": "toStem", + "type": "int96" + }, + { + "internalType": "uint256", + "name": "fromAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fromBdv", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toBdv", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "beanToBDV", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "unripeBeanToBDV", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "unripeLPToBDV", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "wellBdv", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "DepositApproval", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approveDeposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseDepositAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "depositAllowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "depositPermitDomainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "depositPermitNonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseDepositAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "internalType": "address", + "name": "_operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permitDeposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permitDeposits", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelistedLp", + "type": "bool" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelistedWell", + "type": "bool" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isSoppable", + "type": "bool" + } + ], + "name": "AddWhitelistStatus", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "DewhitelistToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelistedLp", + "type": "bool" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isWhitelistedWell", + "type": "bool" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isSoppable", + "type": "bool" + } + ], + "name": "UpdateWhitelistStatus", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "maxBeanMaxLpGpPerBdvRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minBeanMaxLpGpPerBdvRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetSeasonsToCatchUp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podRateLowerBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podRateOptimal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podRateUpperBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deltaPodDemandLowerBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deltaPodDemandUpperBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lpToSupplyRatioUpperBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lpToSupplyRatioOptimal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lpToSupplyRatioLowerBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "excessivePriceThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "soilCoefficientHigh", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "soilCoefficientLow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseReward", + "type": "uint256" + } + ], + "indexed": false, + "internalType": "struct EvaluationParameters", + "name": "", + "type": "tuple" + } + ], + "name": "UpdatedEvaluationParameters", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct Implementation", + "name": "gaugePointImplementation", + "type": "tuple" + } + ], + "name": "UpdatedGaugePointImplementationForToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct Implementation", + "name": "liquidityWeightImplementation", + "type": "tuple" + } + ], + "name": "UpdatedLiqudityWeightImplementationForToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "optimalPercentDepositedBdv", + "type": "uint64" + } + ], + "name": "UpdatedOptimalPercentDepositedBdvForToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct Implementation", + "name": "oracleImplementation", + "type": "tuple" + } + ], + "name": "UpdatedOracleImplementationForToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "stalkEarnedPerSeason", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "season", + "type": "uint32" + } + ], + "name": "UpdatedStalkPerBdvPerSeason", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "stalkEarnedPerSeason", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stalkIssuedPerBdv", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "gaugePoints", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "optimalPercentDepositedBdv", + "type": "uint64" + } + ], + "name": "WhitelistToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct Implementation", + "name": "gpImplementation", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct Implementation", + "name": "lwImplementation", + "type": "tuple" + } + ], + "name": "WhitelistTokenImplementations", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "dewhitelistToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getGaugePointImplementationForToken", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getLiquidityWeightImplementationForToken", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getOracleImplementationForToken", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSiloTokens", + "outputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getWhitelistStatus", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isWhitelistedLp", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isWhitelistedWell", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isSoppable", + "type": "bool" + } + ], + "internalType": "struct WhitelistStatus", + "name": "_whitelistStatuses", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWhitelistStatuses", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "bool", + "name": "isWhitelisted", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isWhitelistedLp", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isWhitelistedWell", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isSoppable", + "type": "bool" + } + ], + "internalType": "struct WhitelistStatus[]", + "name": "_whitelistStatuses", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWhitelistedLpTokens", + "outputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWhitelistedTokens", + "outputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWhitelistedWellLpTokens", + "outputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint64", + "name": "optimalPercentDepositedBdv", + "type": "uint64" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "gpImplementation", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "lwImplementation", + "type": "tuple" + } + ], + "name": "updateGaugeForToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "impl", + "type": "tuple" + } + ], + "name": "updateGaugePointImplementationForToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "impl", + "type": "tuple" + } + ], + "name": "updateLiqudityWeightImplementationForToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "impl", + "type": "tuple" + } + ], + "name": "updateOracleImplementationForToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "maxBeanMaxLpGpPerBdvRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minBeanMaxLpGpPerBdvRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetSeasonsToCatchUp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podRateLowerBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podRateOptimal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podRateUpperBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deltaPodDemandLowerBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deltaPodDemandUpperBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lpToSupplyRatioUpperBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lpToSupplyRatioOptimal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lpToSupplyRatioLowerBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "excessivePriceThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "soilCoefficientHigh", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "soilCoefficientLow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseReward", + "type": "uint256" + } + ], + "internalType": "struct EvaluationParameters", + "name": "updatedSeedGaugeSettings", + "type": "tuple" + } + ], + "name": "updateSeedGaugeSettings", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint32", + "name": "stalkEarnedPerSeason", + "type": "uint32" + } + ], + "name": "updateStalkPerBdvPerSeasonForToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "uint48", + "name": "stalkIssuedPerBdv", + "type": "uint48" + }, + { + "internalType": "uint32", + "name": "stalkEarnedPerSeason", + "type": "uint32" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "uint128", + "name": "gaugePoints", + "type": "uint128" + }, + { + "internalType": "uint64", + "name": "optimalPercentDepositedBdv", + "type": "uint64" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "oracleImplementation", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "gaugePointImplementation", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "liquidityWeightImplementation", + "type": "tuple" + } + ], + "name": "whitelistToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "depositId", + "type": "uint256" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "accounts", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "depositIds", + "type": "uint256[]" + } + ], + "name": "balanceOfBatch", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "balanceOfDepositedBdv", + "outputs": [ + { + "internalType": "uint256", + "name": "depositedBdv", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfEarnedBeans", + "outputs": [ + { + "internalType": "uint256", + "name": "beans", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfEarnedStalk", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfFinishedGerminatingStalkAndRoots", + "outputs": [ + { + "internalType": "uint256", + "name": "gStalk", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "gRoots", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfGerminatingStalk", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "balanceOfGrownStalk", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "balanceOfGrownStalkMultiple", + "outputs": [ + { + "internalType": "uint256[]", + "name": "grownStalks", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfPlantableSeeds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "balanceOfPlenty", + "outputs": [ + { + "internalType": "uint256", + "name": "plenty", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfRainRoots", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfRoots", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfSop", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "lastRain", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "lastSop", + "type": "uint32" + }, + { + "internalType": "uint256", + "name": "roots", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "well", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "plentyPerRoot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "plenty", + "type": "uint256" + }, + { + "internalType": "bytes32[4]", + "name": "_buffer", + "type": "bytes32[4]" + } + ], + "internalType": "struct PerWellPlenty", + "name": "wellsPlenty", + "type": "tuple" + } + ], + "internalType": "struct SiloGettersFacet.FarmerSops[]", + "name": "farmerSops", + "type": "tuple[]" + } + ], + "internalType": "struct SiloGettersFacet.AccountSeasonOfPlenty", + "name": "sop", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfStalk", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfYoungAndMatureGerminatingStalk", + "outputs": [ + { + "internalType": "uint256", + "name": "matureGerminatingStalk", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "youngGerminatingStalk", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "bdv", + "outputs": [ + { + "internalType": "uint256", + "name": "_bdv", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "bdvs", + "outputs": [ + { + "internalType": "uint256", + "name": "_bdv", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "grownStalk", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bdvOfDeposit", + "type": "uint256" + } + ], + "name": "calculateStemForTokenFromGrownStalk", + "outputs": [ + { + "internalType": "int96", + "name": "stem", + "type": "int96" + }, + { + "internalType": "enum GerminationSide", + "name": "germ", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "getBeanIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBeanstalkTokens", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "bean", + "type": "address" + }, + { + "internalType": "address", + "name": "fertilizer", + "type": "address" + }, + { + "internalType": "address", + "name": "urBean", + "type": "address" + }, + { + "internalType": "address", + "name": "urLp", + "type": "address" + } + ], + "internalType": "struct Tokens", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96", + "name": "stem", + "type": "int96" + } + ], + "name": "getDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96", + "name": "stem", + "type": "int96" + } + ], + "name": "getDepositId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getDepositsForAccount", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "depositIds", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bdv", + "type": "uint128" + } + ], + "internalType": "struct Deposit[]", + "name": "tokenDeposits", + "type": "tuple[]" + } + ], + "internalType": "struct SiloGettersFacet.TokenDepositId[]", + "name": "deposits", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getEvenGerminating", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "season", + "type": "uint32" + } + ], + "name": "getGerminatingRootsForSeason", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "season", + "type": "uint32" + } + ], + "name": "getGerminatingStalkAndRootsForSeason", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "season", + "type": "uint32" + } + ], + "name": "getGerminatingStalkForSeason", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getGerminatingStem", + "outputs": [ + { + "internalType": "int96", + "name": "germinatingStem", + "type": "int96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "getGerminatingStems", + "outputs": [ + { + "internalType": "int96[]", + "name": "germinatingStems", + "type": "int96[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getGerminatingTotalDeposited", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getGerminatingTotalDepositedBdv", + "outputs": [ + { + "internalType": "uint256", + "name": "_bdv", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "depositId", + "type": "uint256" + } + ], + "name": "getIndexForDepositId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getLastMowedStem", + "outputs": [ + { + "internalType": "int96", + "name": "lastStem", + "type": "int96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "getMowStatus", + "outputs": [ + { + "components": [ + { + "internalType": "int96", + "name": "lastStem", + "type": "int96" + }, + { + "internalType": "uint128", + "name": "bdv", + "type": "uint128" + } + ], + "internalType": "struct MowStatus[]", + "name": "mowStatuses", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "getNonBeanTokenAndIndexFromWell", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getOddGerminating", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStemTips", + "outputs": [ + { + "internalType": "int96[]", + "name": "_stemTips", + "type": "int96[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getTokenDepositIdsForAccount", + "outputs": [ + { + "internalType": "uint256[]", + "name": "depositIds", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getTokenDepositsForAccount", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "depositIds", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bdv", + "type": "uint128" + } + ], + "internalType": "struct Deposit[]", + "name": "tokenDeposits", + "type": "tuple[]" + } + ], + "internalType": "struct SiloGettersFacet.TokenDepositId", + "name": "deposits", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getTotalDeposited", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getTotalDepositedBdv", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getTotalGerminatingAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getTotalGerminatingBdv", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalGerminatingStalk", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalSiloDeposited", + "outputs": [ + { + "internalType": "uint256[]", + "name": "depositedAmounts", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalSiloDepositedBdv", + "outputs": [ + { + "internalType": "uint256[]", + "name": "depositedBdvs", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getYoungAndMatureGerminatingTotalStalk", + "outputs": [ + { + "internalType": "uint256", + "name": "matureGerminatingStalk", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "youngGerminatingStalk", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96", + "name": "stem", + "type": "int96" + } + ], + "name": "grownStalkForDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "grownStalk", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastSeasonOfPlenty", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "lastUpdate", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "stalkEarnedPerSeason", + "outputs": [ + { + "internalType": "uint256[]", + "name": "stalkEarnedPerSeasons", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stemStartSeason", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "stemTipForToken", + "outputs": [ + { + "internalType": "int96", + "name": "_stemTip", + "type": "int96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "tokenSettings", + "outputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "uint32", + "name": "stalkEarnedPerSeason", + "type": "uint32" + }, + { + "internalType": "uint48", + "name": "stalkIssuedPerBdv", + "type": "uint48" + }, + { + "internalType": "uint32", + "name": "milestoneSeason", + "type": "uint32" + }, + { + "internalType": "int96", + "name": "milestoneStem", + "type": "int96" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "int24", + "name": "deltaStalkEarnedPerSeason", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "gaugePoints", + "type": "uint128" + }, + { + "internalType": "uint64", + "name": "optimalPercentDepositedBdv", + "type": "uint64" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "gaugePointImplementation", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "internalType": "bytes1", + "name": "encodeType", + "type": "bytes1" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Implementation", + "name": "liquidityWeightImplementation", + "type": "tuple" + } + ], + "internalType": "struct AssetSettings", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalEarnedBeans", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRainRoots", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRoots", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalStalk", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.From", + "name": "mode", + "type": "uint8" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_bdv", + "type": "uint256" + }, + { + "internalType": "int96", + "name": "stem", + "type": "int96" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "depositIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "safeBatchTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "depositId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96", + "name": "stem", + "type": "int96" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "_bdv", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96[]", + "name": "stem", + "type": "int96[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "transferDeposits", + "outputs": [ + { + "internalType": "uint256[]", + "name": "bdvs", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96", + "name": "stem", + "type": "int96" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "withdrawDeposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96[]", + "name": "stems", + "type": "int96[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "withdrawDeposits", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "plenty", + "type": "uint256" + } + ], + "name": "ClaimPlenty", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "beans", + "type": "uint256" + } + ], + "name": "Plant", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "enum LibTransfer.To", + "name": "toMode", + "type": "uint8" + } + ], + "name": "claimAllPlenty", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + }, + { + "internalType": "enum LibTransfer.To", + "name": "toMode", + "type": "uint8" + } + ], + "name": "claimPlenty", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "mow", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "mowMultiple", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "plant", + "outputs": [ + { + "internalType": "uint256", + "name": "beans", + "type": "uint256" + }, + { + "internalType": "int96", + "name": "stem", + "type": "int96" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "beans", + "type": "uint256" + } + ], + "name": "Incentivization", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "secondsLate", + "type": "uint256" + } + ], + "name": "determineReward", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "int256", + "name": "deltaStalk", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "deltaRoots", + "type": "int256" + } + ], + "name": "TotalStalkChangedFromGermination", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "season", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "address", + "name": "well", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "deltaB", + "type": "int256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "cumulativeReserves", + "type": "bytes" + } + ], + "name": "WellOracle", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "check", + "outputs": [ + { + "internalType": "int256", + "name": "deltaB", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "RemoveWhitelistStatus", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "season", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "gaugePoints", + "type": "uint256" + } + ], + "name": "GaugePointChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newStalkPerBdvPerSeason", + "type": "uint256" + } + ], + "name": "UpdateAverageStalkPerBdvPerSeason", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "enum ShipmentRecipient", + "name": "recipient", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "receivedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "Receipt", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "season", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shipmentAmount", + "type": "uint256" + } + ], + "name": "Shipped", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "shipmentAmounts", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "points", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cap", + "type": "uint256" + } + ], + "internalType": "struct ShipmentPlan[]", + "name": "shipmentPlans", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "totalPoints", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "beansToShip", + "type": "uint256" + } + ], + "name": "getBeansFromPoints", + "outputs": [], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "planContract", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "planSelector", + "type": "bytes4" + }, + { + "internalType": "enum ShipmentRecipient", + "name": "recipient", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct ShipmentRoute[]", + "name": "shipmentRoutes", + "type": "tuple[]" + } + ], + "name": "getShipmentPlans", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "points", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "cap", + "type": "uint256" + } + ], + "internalType": "struct ShipmentPlan[]", + "name": "shipmentPlans", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "totalPoints", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getTokenUsdPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "lookback", + "type": "uint256" + } + ], + "name": "getTokenUsdPriceFromExternal", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenUsd", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "lookback", + "type": "uint256" + } + ], + "name": "getTokenUsdTwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getUsdTokenPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "lookback", + "type": "uint256" + } + ], + "name": "getUsdTokenPriceFromExternal", + "outputs": [ + { + "internalType": "uint256", + "name": "usdToken", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "lookback", + "type": "uint256" + } + ], + "name": "getUsdTokenTwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "maxWeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "noWeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "abovePeg", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "percentOfDepositedBdv", + "type": "uint256" + } + ], + "name": "calcGaugePointsWithParams", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "pools", + "type": "address[]" + } + ], + "name": "cumulativeCurrentDeltaB", + "outputs": [ + { + "internalType": "int256", + "name": "deltaB", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "caseId", + "type": "uint256" + } + ], + "name": "getAbsBeanToMaxLpRatioChangeFromCaseId", + "outputs": [ + { + "internalType": "uint80", + "name": "ml", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "caseId", + "type": "uint256" + } + ], + "name": "getAbsTemperatureChangeFromCaseId", + "outputs": [ + { + "internalType": "int8", + "name": "t", + "type": "int8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAverageGrownStalkPerBdv", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAverageGrownStalkPerBdvPerSeason", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBeanGaugePointsPerBdv", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBeanToMaxLpGpPerBdvRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBeanToMaxLpGpPerBdvRatioScaled", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "caseId", + "type": "uint256" + } + ], + "name": "getCaseData", + "outputs": [ + { + "internalType": "bytes32", + "name": "casesData", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCases", + "outputs": [ + { + "internalType": "bytes32[144]", + "name": "cases", + "type": "bytes32[144]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "caseId", + "type": "uint256" + } + ], + "name": "getChangeFromCaseId", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + }, + { + "internalType": "int8", + "name": "", + "type": "int8" + }, + { + "internalType": "uint80", + "name": "", + "type": "uint80" + }, + { + "internalType": "int80", + "name": "", + "type": "int80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDeltaPodDemand", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDeltaPodDemandLowerBound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDeltaPodDemandUpperBound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getExcessivePriceThreshold", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getGaugePoints", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getGaugePointsPerBdvForToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "getGaugePointsPerBdvForWell", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getGaugePointsWithParams", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getGrownStalkIssuedPerGp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getGrownStalkIssuedPerSeason", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLargestGpPerBdv", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLargestLiqWell", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLiquidityToSupplyRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLpToSupplyRatioLowerBound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLpToSupplyRatioOptimal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLpToSupplyRatioUpperBound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaxBeanMaxLpGpPerBdvRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMinBeanMaxLpGpPerBdvRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "getPodRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPodRateLowerBound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPodRateOptimal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPodRateUpperBound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "caseId", + "type": "uint256" + } + ], + "name": "getRelBeanToMaxLpRatioChangeFromCaseId", + "outputs": [ + { + "internalType": "int80", + "name": "l", + "type": "int80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "caseId", + "type": "uint256" + } + ], + "name": "getRelTemperatureChangeFromCaseId", + "outputs": [ + { + "internalType": "uint32", + "name": "mt", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSeasonStruct", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "current", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "lastSop", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "withdrawSeasons", + "type": "uint8" + }, + { + "internalType": "uint32", + "name": "lastSopSeason", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "rainStart", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "raining", + "type": "bool" + }, + { + "internalType": "bool", + "name": "fertilizing", + "type": "bool" + }, + { + "internalType": "uint32", + "name": "sunriseBlock", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "abovePeg", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "stemStartSeason", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "stemScaleSeason", + "type": "uint16" + }, + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "period", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32[8]", + "name": "_buffer", + "type": "bytes32[8]" + } + ], + "internalType": "struct Season", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSeasonTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSeedGauge", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "averageGrownStalkPerBdvPerSeason", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "beanToMaxLpGpPerBdvRatio", + "type": "uint128" + }, + { + "internalType": "bytes32[4]", + "name": "_buffer", + "type": "bytes32[4]" + } + ], + "internalType": "struct SeedGauge", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSeedGaugeSetting", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "maxBeanMaxLpGpPerBdvRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minBeanMaxLpGpPerBdvRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetSeasonsToCatchUp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podRateLowerBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podRateOptimal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "podRateUpperBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deltaPodDemandLowerBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deltaPodDemandUpperBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lpToSupplyRatioUpperBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lpToSupplyRatioOptimal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lpToSupplyRatioLowerBound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "excessivePriceThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "soilCoefficientHigh", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "soilCoefficientLow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseReward", + "type": "uint256" + } + ], + "internalType": "struct EvaluationParameters", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTargetSeasonsToCatchUp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalBdv", + "outputs": [ + { + "internalType": "uint256", + "name": "totalBdv", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalUsdLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "totalLiquidity", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalWeightedUsdLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "totalWeightedLiquidity", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "getTwaLiquidityForWell", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "getWeightedTwaLiquidityForWell", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWellsByDeltaB", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "well", + "type": "address" + }, + { + "internalType": "int256", + "name": "deltaB", + "type": "int256" + } + ], + "internalType": "struct LibFlood.WellDeltaB[]", + "name": "wellDeltaBs", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "totalPositiveDeltaB", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalNegativeDeltaB", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positiveDeltaBCount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_season", + "type": "uint32" + }, + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "plentyPerRoot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "poolCurrentDeltaB", + "outputs": [ + { + "internalType": "int256", + "name": "deltaB", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "poolDeltaB", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rain", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pods", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "roots", + "type": "uint256" + }, + { + "internalType": "bytes32[4]", + "name": "_buffer", + "type": "bytes32[4]" + } + ], + "internalType": "struct Rain", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "season", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "sunriseBlock", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "time", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "current", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "lastSop", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "withdrawSeasons", + "type": "uint8" + }, + { + "internalType": "uint32", + "name": "lastSopSeason", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "rainStart", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "raining", + "type": "bool" + }, + { + "internalType": "bool", + "name": "fertilizing", + "type": "bool" + }, + { + "internalType": "uint32", + "name": "sunriseBlock", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "abovePeg", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "stemStartSeason", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "stemScaleSeason", + "type": "uint16" + }, + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "period", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32[8]", + "name": "_buffer", + "type": "bytes32[8]" + } + ], + "internalType": "struct Season", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalDeltaB", + "outputs": [ + { + "internalType": "int256", + "name": "deltaB", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "weather", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "lastDeltaSoil", + "type": "uint128" + }, + { + "internalType": "uint32", + "name": "lastSowTime", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "thisSowTime", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "temp", + "type": "uint32" + }, + { + "internalType": "bytes32[4]", + "name": "_buffer", + "type": "bytes32[4]" + } + ], + "internalType": "struct Weather", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "well", + "type": "address" + } + ], + "name": "wellOracleSnapshot", + "outputs": [ + { + "internalType": "bytes", + "name": "snapshot", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "season", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "caseId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int80", + "name": "absChange", + "type": "int80" + } + ], + "name": "BeanToMaxLpGpPerBdvRatioChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "toField", + "type": "uint256" + } + ], + "name": "SeasonOfPlentyField", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "season", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "well", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "SeasonOfPlentyWell", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "planContract", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "planSelector", + "type": "bytes4" + }, + { + "internalType": "enum ShipmentRecipient", + "name": "recipient", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct ShipmentRoute[]", + "name": "newShipmentRoutes", + "type": "tuple[]" + } + ], + "name": "ShipmentRoutesSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "season", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "soil", + "type": "uint256" + } + ], + "name": "Soil", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "season", + "type": "uint256" + } + ], + "name": "Sunrise", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "season", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "caseId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int8", + "name": "absChange", + "type": "int8" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + } + ], + "name": "TemperatureChange", + "type": "event" + }, + { + "inputs": [], + "name": "getShipmentRoutes", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "planContract", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "planSelector", + "type": "bytes4" + }, + { + "internalType": "enum ShipmentRecipient", + "name": "recipient", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct ShipmentRoute[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "gm", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "seasonTime", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "planContract", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "planSelector", + "type": "bytes4" + }, + { + "internalType": "enum ShipmentRecipient", + "name": "recipient", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct ShipmentRoute[]", + "name": "shipmentRoutes", + "type": "tuple[]" + } + ], + "name": "setShipmentRoutes", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sunrise", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "currentGaugePoints", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "optimalPercentDepositedBdv", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "percentOfDepositedBdv", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "defaultGaugePointFunction", + "outputs": [ + { + "internalType": "uint256", + "name": "newGaugePoints", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "optimalPercentBdv", + "type": "uint256" + } + ], + "name": "getExtremelyFarAbove", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "optimalPercentBdv", + "type": "uint256" + } + ], + "name": "getExtremelyFarBelow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "optimalPercentBdv", + "type": "uint256" + } + ], + "name": "getRelativelyFarAbove", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "optimalPercentBdv", + "type": "uint256" + } + ], + "name": "getRelativelyFarBelow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "StringsInsufficientHexLength", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "_uri", + "type": "string" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + } + ], + "name": "URI", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "int96", + "name": "stem", + "type": "int96" + }, + { + "internalType": "int96", + "name": "stemTip", + "type": "int96" + } + ], + "name": "imageURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositId", + "type": "uint256" + } + ], + "name": "uri", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "ticketId", + "type": "uint256" + } + ], + "name": "RetryableTicketCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "reciever", + "type": "address" + }, + { + "internalType": "address", + "name": "L2Beanstalk", + "type": "address" + }, + { + "internalType": "uint256", + "name": "maxSubmissionCost", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "gasPriceBid", + "type": "uint256" + } + ], + "name": "approveL2Reciever", + "outputs": [ + { + "internalType": "uint256", + "name": "ticketID", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "reciever", + "type": "address" + }, + { + "internalType": "address", + "name": "L2Beanstalk", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.To", + "name": "toMode", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "maxSubmissionCost", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "gasPriceBid", + "type": "uint256" + } + ], + "name": "migrateL2Beans", + "outputs": [ + { + "internalType": "uint256", + "name": "ticketID", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "reciever", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "enum LibTransfer.To", + "name": "toMode", + "type": "uint8" + } + ], + "name": "L1BeansMigrated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "reciever", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "depositIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "bdvs", + "type": "uint256[]" + } + ], + "name": "L1DepositsMigrated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "reciever", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fertIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint128[]", + "name": "amounts", + "type": "uint128[]" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "lastBpf", + "type": "uint128" + } + ], + "name": "L1FertilizerMigrated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "reciever", + "type": "address" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "L1InternalBalancesMigrated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "reciever", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "index", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "pods", + "type": "uint256[]" + } + ], + "name": "L1PlotsMigrated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "reciever", + "type": "address" + } + ], + "name": "RecieverApproved", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "reciever", + "type": "address" + } + ], + "name": "approveReciever", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getDepositMerkleRoot", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getFertilizerMerkleRoot", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getInternalBalanceMerkleRoot", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getPlotMerkleRoot", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "getReciever", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "depositIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "bdvs", + "type": "uint256[]" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "issueDeposits", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "fertIds", + "type": "uint256[]" + }, + { + "internalType": "uint128[]", + "name": "amounts", + "type": "uint128[]" + }, + { + "internalType": "uint128", + "name": "lastBpf", + "type": "uint128" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "issueFertilizer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "issueInternalBalances", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "index", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "pods", + "type": "uint256[]" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "issuePlots", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "reciever", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "enum LibTransfer.To", + "name": "toMode", + "type": "uint8" + } + ], + "name": "recieveL1Beans", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "depositIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "bdvs", + "type": "uint256[]" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "verifyDepositMerkleProof", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "fertIds", + "type": "uint256[]" + }, + { + "internalType": "uint128[]", + "name": "amounts", + "type": "uint128[]" + }, + { + "internalType": "uint128", + "name": "lastBpf", + "type": "uint128" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "verifyFertilizerMerkleProof", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "verifyInternalBalanceMerkleProof", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "index", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "verifyPlotMerkleProof", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + } +] From 4762926bcdc6a76d15ea0d3bf735543f05763340 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:01:11 -0700 Subject: [PATCH 31/88] legacy updategaugesettings --- .../src/handlers/GaugeHandler.ts | 11 ++--------- .../src/handlers/legacy/LegacyGaugeHandler.ts | 19 +++++++++++++++++++ .../src/handlers/legacy/LegacySiloHandler.ts | 2 +- .../tests/SeedGauge.test.ts | 1 - 4 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index aa12ccc9c3..b5981de18a 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -4,7 +4,6 @@ import { UpdateAverageStalkPerBdvPerSeason, FarmerGerminatingStalkBalanceChanged, TotalGerminatingBalanceChanged, - UpdateGaugeSettings, TotalGerminatingStalkChanged, TotalStalkChangedFromGermination, SeedGauge @@ -19,13 +18,12 @@ import { savePrevFarmerGerminatingEvent } from "../entities/Germinating"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { Bytes4_emptyToNull } from "../../../subgraph-core/utils/Bytes"; import { setSiloHourlyCaseId, takeSiloSnapshots } from "../entities/snapshots/Silo"; import { loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; import { takeWhitelistTokenSettingSnapshots } from "../entities/snapshots/WhitelistTokenSetting"; import { getCurrentSeason } from "../entities/Beanstalk"; import { updateStalkBalances } from "../utils/Silo"; -import { legacyInitGauge } from "../utils/legacy/LegacyWhitelist"; +import { UpdatedOptimalPercentDepositedBdvForToken } from "../../generated/Beanstalk-ABIs/Reseed"; // SEED GAUGE SEASONAL ADJUSTMENTS // @@ -189,15 +187,10 @@ export function handleTotalStalkChangedFromGermination(event: TotalStalkChangedF // GAUGE CONFIGURATION SETTINGS // -export function handleUpdateGaugeSettings(event: UpdateGaugeSettings): void { +export function handleUpdatedOptimalPercentDepositedBdvForToken(event: UpdatedOptimalPercentDepositedBdvForToken): void { let siloSettings = loadWhitelistTokenSetting(event.params.token); - siloSettings.gpSelector = Bytes4_emptyToNull(event.params.gpSelector); - siloSettings.lwSelector = Bytes4_emptyToNull(event.params.lwSelector); siloSettings.optimalPercentDepositedBdv = event.params.optimalPercentDepositedBdv; siloSettings.updatedAt = event.block.timestamp; - - legacyInitGauge(event, siloSettings); - takeWhitelistTokenSettingSnapshots(siloSettings, event.block); siloSettings.save(); } diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts new file mode 100644 index 0000000000..fa28f4c207 --- /dev/null +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts @@ -0,0 +1,19 @@ +import { Bytes4_emptyToNull } from "../../../../subgraph-core/utils/Bytes"; +import { UpdateGaugeSettings } from "../../../generated/Beanstalk-ABIs/SeedGauge"; +import { loadWhitelistTokenSetting } from "../../entities/Silo"; +import { takeWhitelistTokenSettingSnapshots } from "../../entities/snapshots/WhitelistTokenSetting"; +import { legacyInitGauge } from "../../utils/legacy/LegacyWhitelist"; + +// SeedGauge -> Reseed +export function handleUpdateGaugeSettings(event: UpdateGaugeSettings): void { + let siloSettings = loadWhitelistTokenSetting(event.params.token); + siloSettings.gpSelector = Bytes4_emptyToNull(event.params.gpSelector); + siloSettings.lwSelector = Bytes4_emptyToNull(event.params.lwSelector); + siloSettings.optimalPercentDepositedBdv = event.params.optimalPercentDepositedBdv; + siloSettings.updatedAt = event.block.timestamp; + + legacyInitGauge(event, siloSettings); + + takeWhitelistTokenSettingSnapshots(siloSettings, event.block); + siloSettings.save(); +} diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index b2632b1cf3..517d0366ae 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -135,7 +135,7 @@ export function handleWhitelistToken_v3(event: WhitelistToken_v3): void { } // SeedGauge -> Reseed -export function handleWhitelistToken(event: WhitelistToken): void { +export function handleWhitelistToken_v4(event: WhitelistToken): void { addToSiloWhitelist(event.address, event.params.token); let siloSettings = loadWhitelistTokenSetting(event.params.token); diff --git a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts index 02059ef95f..3a8711ed8f 100644 --- a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts +++ b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts @@ -27,7 +27,6 @@ import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { setSeason } from "./utils/Season"; import { dayFromTimestamp } from "../../subgraph-core/utils/Dates"; import { loadSilo } from "../src/entities/Silo"; -import { handleWhitelistToken } from "../src/handlers/SiloHandler"; import { handleTemperatureChange } from "../src/handlers/FieldHandler"; import { initL1Version } from "./entity-mocking/MockVersion"; From 325d262fff274e1a8819bae85d9b0b1e4ff2fafd Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:04:49 -0700 Subject: [PATCH 32/88] fieldid to field events --- .../manifests/ethereum.yaml | 1 + .../src/handlers/FieldHandler.ts | 6 +- .../src/handlers/legacy/LegacyFieldHandler.ts | 55 ++++++++++++++++++- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index c262cc8135..ae404cdcc2 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -575,6 +575,7 @@ dataSources: handler: handlePlotTransfer - event: TemperatureChange(indexed uint256,uint256,int8) handler: handleTemperatureChange + # TODO: point to legacy file: ../src/handlers/FieldHandler.ts - kind: ethereum/contract name: LegacyField-PreReplant-SeedGauge diff --git a/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts b/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts index c7bae4f985..8d820bf00a 100644 --- a/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/FieldHandler.ts @@ -1,5 +1,5 @@ import { harvest, plotTransfer, sow, temperatureChanged } from "../utils/Field"; -import { Sow, Harvest, PlotTransfer, TemperatureChange } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { Sow, Harvest, PlotTransfer, TemperatureChange } from "../../generated/Beanstalk-ABIs/Reseed"; import { legacySowAmount } from "../utils/legacy/LegacyField"; export function handleSow(event: Sow): void { @@ -30,8 +30,8 @@ export function handlePlotTransfer(event: PlotTransfer): void { from: event.params.from, to: event.params.to, fieldId: null, - index: event.params.id, - amount: event.params.pods + index: event.params.index, + amount: event.params.amount }); } diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFieldHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFieldHandler.ts index c007a22c12..1be4c09e0c 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFieldHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFieldHandler.ts @@ -1,6 +1,13 @@ import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { WeatherChange, SupplyIncrease, SupplyDecrease, SupplyNeutral, FundFundraiser } from "../../../generated/Beanstalk-ABIs/PreReplant"; -import { temperatureChanged, updateFieldTotals } from "../../utils/Field"; +import { + Harvest as Harvest_v1, + PlotTransfer as PlotTransfer_v1, + Sow as Sow_v1, + TemperatureChange as TemperatureChange_v1 +} from "../../../generated/Beanstalk-ABIs/SeedGauge"; +import { harvest, plotTransfer, sow, temperatureChanged, updateFieldTotals } from "../../utils/Field"; +import { legacySowAmount } from "../../utils/legacy/LegacyField"; // PreReplant -> SeedGauge export function handleWeatherChange(event: WeatherChange): void { @@ -42,3 +49,49 @@ export function handleFundFundraiser(event: FundFundraiser): void { event.block ); } + +// PreReplant -> Reseed +export function handleSow_v1(event: Sow_v1): void { + let sownOverride = legacySowAmount(event.address, event.params.account); + sow({ + event, + account: event.params.account, + fieldId: null, + index: event.params.index, + beans: sownOverride !== null ? sownOverride : event.params.beans, + pods: event.params.pods + }); +} + +// PreReplant -> Reseed +export function handleHarvest_v1(event: Harvest_v1): void { + harvest({ + event, + account: event.params.account, + fieldId: null, + plots: event.params.plots, + beans: event.params.beans + }); +} + +// PreReplant -> Reseed +export function handlePlotTransfer_v1(event: PlotTransfer_v1): void { + plotTransfer({ + event, + from: event.params.from, + to: event.params.to, + fieldId: null, + index: event.params.id, + amount: event.params.pods + }); +} + +// SeedGauge -> Reseed +export function handleTemperatureChange_v1(event: TemperatureChange_v1): void { + temperatureChanged({ + event, + season: event.params.season, + caseId: event.params.caseId, + absChange: event.params.absChange + }); +} From cb49737fc9bbd27938b9f0c82703b15f3b86dc88 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:21:58 -0700 Subject: [PATCH 33/88] Update ethereum manifests --- .../manifests/ethereum.yaml | 125 +++++++++++--- .../subgraph-beanstalk/manifests/no-apy.yaml | 162 ++++++++++++++---- 2 files changed, 231 insertions(+), 56 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index ae404cdcc2..bbe456b073 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -416,20 +416,12 @@ dataSources: handler: handleConvert - event: StalkBalanceChanged(indexed address,int256,int256) handler: handleStalkBalanceChanged - - event: SeedsBalanceChanged(indexed address,int256) - handler: handleSeedsBalanceChanged - event: Plant(indexed address,uint256) handler: handlePlant - - event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64) - handler: handleWhitelistToken - event: DewhitelistToken(indexed address) handler: handleDewhitelistToken - event: UpdatedStalkPerBdvPerSeason(indexed address,uint32,uint32) handler: handleUpdatedStalkPerBdvPerSeason - - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) - handler: handleRemoveWithdrawal - - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) - handler: handleRemoveWithdrawals file: ../src/handlers/SiloHandler.ts - kind: ethereum/contract name: LegacySilo-Replanted-SeedGauge @@ -504,6 +496,32 @@ dataSources: - event: WhitelistToken(indexed address,bytes4,uint32,uint256) handler: handleWhitelistToken_v3 file: ../src/handlers/legacy/LegacySiloHandler.ts + - kind: ethereum/contract + name: LegacySilo-SeedGauge-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 19927634 # SeedGauge + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Silo + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + eventHandlers: + - event: SeedsBalanceChanged(indexed address,int256) + handler: handleSeedsBalanceChanged + - event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64) + handler: handleWhitelistToken + - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) + handler: handleRemoveWithdrawal + - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) + handler: handleRemoveWithdrawals + file: ../src/handlers/legacy/LegacySiloHandler.ts ### # SEED GAUGE ### @@ -540,9 +558,29 @@ dataSources: handler: handleTotalGerminatingStalkChanged - event: TotalStalkChangedFromGermination(int256,int256) handler: handleTotalStalkChangedFromGermination + file: ../src/handlers/GaugeHandler.ts + - kind: ethereum/contract + name: LegacySeedGauge-SeedGauge-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 19628074 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - SeedGauge + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + eventHandlers: - event: UpdateGaugeSettings(indexed address,bytes4,bytes4,uint64) handler: handleUpdateGaugeSettings - file: ../src/handlers/GaugeHandler.ts + file: ../src/handlers/legacy/LegacyGaugeHandler.ts ### # FIELD ### @@ -568,15 +606,14 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: - event: Sow(indexed address,uint256,uint256,uint256) - handler: handleSow + handler: handleSow_v1 - event: Harvest(indexed address,uint256[],uint256) - handler: handleHarvest + handler: handleHarvest_v1 - event: PlotTransfer(indexed address,indexed address,indexed uint256,uint256) - handler: handlePlotTransfer + handler: handlePlotTransfer_v1 - event: TemperatureChange(indexed uint256,uint256,int8) - handler: handleTemperatureChange - # TODO: point to legacy - file: ../src/handlers/FieldHandler.ts + handler: handleTemperatureChange_v1 + file: ../src/handlers/legacy/LegacyFieldHandler.ts - kind: ethereum/contract name: LegacyField-PreReplant-SeedGauge network: mainnet @@ -616,6 +653,26 @@ dataSources: - kind: ethereum/contract name: Marketplace network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 14148509 # BIP-11 Pod Marketplace + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - PodMarketplace + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + eventHandlers: + - event: PodOrderCancelled(indexed address,bytes32) + handler: handlePodOrderCancelled + file: ../src/handlers/MarketplaceHandler.ts + - kind: ethereum/contract + name: LegacyMarketplace-PreReplant-Reseed + network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge @@ -631,20 +688,16 @@ dataSources: file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: PodListingCreated(indexed address,uint256,uint256,uint256,uint24,uint256,uint256,bytes,uint8,uint8) - handler: handlePodListingCreated + handler: handlePodListingCreated_v2 - event: PodListingFilled(indexed address,indexed address,uint256,uint256,uint256,uint256) - handler: handlePodListingFilled + handler: handlePodListingFilled_v2 - event: PodOrderCreated(indexed address,bytes32,uint256,uint24,uint256,uint256,bytes,uint8) - handler: handlePodOrderCreated + handler: handlePodOrderCreated_v2 - event: PodOrderFilled(indexed address,indexed address,bytes32,uint256,uint256,uint256,uint256) - handler: handlePodOrderFilled - # NOT a duplicate, this signature does not have an indexed uint256. - # Both signatures are required to recognize all events. + handler: handlePodOrderFilled_v2 - event: PodListingCancelled(indexed address,uint256) - handler: handlePodListingCancelled - - event: PodOrderCancelled(indexed address,bytes32) - handler: handlePodOrderCancelled - file: ../src/handlers/MarketplaceHandler.ts + handler: handlePodListingCancelled_v2 + file: ../src/handlers/legacy/LegacyMarketplaceV2Handler.ts - kind: ethereum/contract name: LegacyMarketplace-PreReplant-SeedGauge network: mainnet @@ -768,8 +821,6 @@ dataSources: - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: - - event: Reward(indexed uint32,uint256,uint256,uint256) - handler: handleReward - event: WellOracle(indexed uint32,address,int256,bytes) handler: handleWellOracle - event: Soil(indexed uint32,uint256) @@ -887,6 +938,26 @@ dataSources: - event: Sunrise(indexed uint256) handler: handleSunrise file: ../src/handlers/SeasonHandler.ts + - kind: ethereum/contract + name: LegacySeason-PreReplant-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 12974075 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Season + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + eventHandlers: + - event: Reward(indexed uint32,uint256,uint256,uint256) + handler: handleReward + file: ../src/handlers/legacy/LegacySeasonHandler.ts ### # BEAN ERC20 ### diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index 8f41a94493..babc3a25cb 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -29,6 +29,31 @@ dataSources: kind: once file: ../src/utils/constants/Version.ts ### + # EXPLOIT + ### + - kind: ethereum/contract + name: Exploit + network: mainnet + source: + address: "0xDC59ac4FeFa32293A95889Dc396682858d52e5Db" + abi: ERC20 + startBlock: 14602789 # Exploit + endBlock: 14602789 # Exploit + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Version + abis: + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + blockHandlers: + - handler: handleExploit + filter: + kind: once + file: ../src/handlers/BeanHandler.ts + ### # SILO ### - kind: ethereum/contract @@ -58,20 +83,12 @@ dataSources: handler: handleConvert - event: StalkBalanceChanged(indexed address,int256,int256) handler: handleStalkBalanceChanged - - event: SeedsBalanceChanged(indexed address,int256) - handler: handleSeedsBalanceChanged - event: Plant(indexed address,uint256) handler: handlePlant - - event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64) - handler: handleWhitelistToken - event: DewhitelistToken(indexed address) handler: handleDewhitelistToken - event: UpdatedStalkPerBdvPerSeason(indexed address,uint32,uint32) handler: handleUpdatedStalkPerBdvPerSeason - - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) - handler: handleRemoveWithdrawal - - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) - handler: handleRemoveWithdrawals file: ../src/handlers/SiloHandler.ts - kind: ethereum/contract name: LegacySilo-Replanted-SeedGauge @@ -146,6 +163,32 @@ dataSources: - event: WhitelistToken(indexed address,bytes4,uint32,uint256) handler: handleWhitelistToken_v3 file: ../src/handlers/legacy/LegacySiloHandler.ts + - kind: ethereum/contract + name: LegacySilo-SeedGauge-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 19927634 # SeedGauge + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Silo + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + eventHandlers: + - event: SeedsBalanceChanged(indexed address,int256) + handler: handleSeedsBalanceChanged + - event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64) + handler: handleWhitelistToken + - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) + handler: handleRemoveWithdrawal + - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) + handler: handleRemoveWithdrawals + file: ../src/handlers/legacy/LegacySiloHandler.ts ### # SEED GAUGE ### @@ -182,9 +225,29 @@ dataSources: handler: handleTotalGerminatingStalkChanged - event: TotalStalkChangedFromGermination(int256,int256) handler: handleTotalStalkChangedFromGermination + file: ../src/handlers/GaugeHandler.ts + - kind: ethereum/contract + name: LegacySeedGauge-SeedGauge-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 19628074 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - SeedGauge + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + eventHandlers: - event: UpdateGaugeSettings(indexed address,bytes4,bytes4,uint64) handler: handleUpdateGaugeSettings - file: ../src/handlers/GaugeHandler.ts + file: ../src/handlers/legacy/LegacyGaugeHandler.ts ### # FIELD ### @@ -210,14 +273,14 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: - event: Sow(indexed address,uint256,uint256,uint256) - handler: handleSow + handler: handleSow_v1 - event: Harvest(indexed address,uint256[],uint256) - handler: handleHarvest + handler: handleHarvest_v1 - event: PlotTransfer(indexed address,indexed address,indexed uint256,uint256) - handler: handlePlotTransfer + handler: handlePlotTransfer_v1 - event: TemperatureChange(indexed uint256,uint256,int8) - handler: handleTemperatureChange - file: ../src/handlers/FieldHandler.ts + handler: handleTemperatureChange_v1 + file: ../src/handlers/legacy/LegacyFieldHandler.ts - kind: ethereum/contract name: LegacyField-PreReplant-SeedGauge network: mainnet @@ -257,6 +320,26 @@ dataSources: - kind: ethereum/contract name: Marketplace network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 14148509 # BIP-11 Pod Marketplace + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - PodMarketplace + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + eventHandlers: + - event: PodOrderCancelled(indexed address,bytes32) + handler: handlePodOrderCancelled + file: ../src/handlers/MarketplaceHandler.ts + - kind: ethereum/contract + name: LegacyMarketplace-PreReplant-Reseed + network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge @@ -272,20 +355,16 @@ dataSources: file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: PodListingCreated(indexed address,uint256,uint256,uint256,uint24,uint256,uint256,bytes,uint8,uint8) - handler: handlePodListingCreated + handler: handlePodListingCreated_v2 - event: PodListingFilled(indexed address,indexed address,uint256,uint256,uint256,uint256) - handler: handlePodListingFilled + handler: handlePodListingFilled_v2 - event: PodOrderCreated(indexed address,bytes32,uint256,uint24,uint256,uint256,bytes,uint8) - handler: handlePodOrderCreated + handler: handlePodOrderCreated_v2 - event: PodOrderFilled(indexed address,indexed address,bytes32,uint256,uint256,uint256,uint256) - handler: handlePodOrderFilled - # NOT a duplicate, this signature does not have an indexed uint256. - # Both signatures are required to recognize all events. + handler: handlePodOrderFilled_v2 - event: PodListingCancelled(indexed address,uint256) - handler: handlePodListingCancelled - - event: PodOrderCancelled(indexed address,bytes32) - handler: handlePodOrderCancelled - file: ../src/handlers/MarketplaceHandler.ts + handler: handlePodListingCancelled_v2 + file: ../src/handlers/legacy/LegacyMarketplaceV2Handler.ts - kind: ethereum/contract name: LegacyMarketplace-PreReplant-SeedGauge network: mainnet @@ -409,8 +488,6 @@ dataSources: - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: - - event: Reward(indexed uint32,uint256,uint256,uint256) - handler: handleReward - event: WellOracle(indexed uint32,address,int256,bytes) handler: handleWellOracle - event: Soil(indexed uint32,uint256) @@ -469,7 +546,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: PreReplant + abi: SeedGauge startBlock: 12974075 endBlock: 15277986 # Replanted mapping: @@ -479,8 +556,8 @@ dataSources: entities: - Season abis: - - name: PreReplant - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: Sunrise(indexed uint256) handler: handleSunrise @@ -502,6 +579,8 @@ dataSources: abis: - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: Sunrise(indexed uint256) handler: handleReplantSunrise @@ -526,6 +605,26 @@ dataSources: - event: Sunrise(indexed uint256) handler: handleSunrise file: ../src/handlers/SeasonHandler.ts + - kind: ethereum/contract + name: LegacySeason-PreReplant-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 12974075 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Season + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + eventHandlers: + - event: Reward(indexed uint32,uint256,uint256,uint256) + handler: handleReward + file: ../src/handlers/legacy/LegacySeasonHandler.ts ### # BEAN ERC20 ### @@ -593,3 +692,8 @@ dataSources: - event: InternalBalanceChanged(indexed address,indexed address,int256) handler: handleInternalBalanceChanged file: ../src/handlers/FarmHandler.ts +# features: +# - grafting +# graft: +# base: QmUqT47H7o3gcZ2mHRJf2J5hpitWDYxsMmacGeuvo1wKU7 +# block: 19927630 From 0e61694b879fb9d6bae46c187a579a0a86f46bf5 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:30:32 -0700 Subject: [PATCH 34/88] update arbitrum manifest --- .../manifests/arbitrum.yaml | 14 +++++++++++--- .../src/handlers/SiloHandler.ts | 19 ++++++++++++++++++- .../src/handlers/legacy/LegacySiloHandler.ts | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml index f62a8bd837..07281e0439 100644 --- a/projects/subgraph-beanstalk/manifests/arbitrum.yaml +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -2,6 +2,11 @@ specVersion: 0.0.9 schema: file: ../schema.graphql dataSources: + ### + # L1 -> L2 MIGRATION + ### + # (TODO) + ### # INITIALIZATION ### @@ -102,7 +107,8 @@ dataSources: handler: handleTotalGerminatingStalkChanged - event: TotalStalkChangedFromGermination(int256,int256) handler: handleTotalStalkChangedFromGermination - # TODO: need replacement for UpdateGaugeSettings, which was deleted in BIP50 + - event: UpdatedOptimalPercentDepositedBdvForToken(indexed address,uint64) + handler: handleUpdatedOptimalPercentDepositedBdvForToken file: ../src/handlers/GaugeHandler.ts ### # FIELD @@ -123,7 +129,6 @@ dataSources: abis: - name: Reseed file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - # TODO: see if this can be removed - name: CurvePrice file: ../../subgraph-core/abis/CurvePrice.json - name: BeanstalkPrice @@ -242,7 +247,10 @@ dataSources: - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: - # TODO: need replacement for Reward, which was deleted in BIP50 + - event: Shipped(indexed uint32,uint256) + handler: handleShipped + - event: Receipt(indexed uint8,uint256,bytes) + handler: handleReceipt - event: WellOracle(indexed uint32,address,int256,bytes) handler: handleWellOracle - event: Soil(indexed uint32,uint256) diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 74eadd8384..75734228d0 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -1,6 +1,6 @@ import { BigInt, log } from "@graphprotocol/graph-ts"; import { addDeposits, removeDeposits, updateDepositInSiloAsset, updateStalkBalances } from "../utils/Silo"; -import { loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; +import { addToSiloWhitelist, loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; import { takeSiloSnapshots } from "../entities/snapshots/Silo"; import { takeWhitelistTokenSettingSnapshots } from "../entities/snapshots/WhitelistTokenSetting"; import { @@ -16,6 +16,7 @@ import { import { unripeChopped } from "../utils/Barn"; import { getProtocolToken, isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; +import { WhitelistToken } from "../../generated/Beanstalk-ABIs/Reseed"; export function handleAddDeposit(event: AddDeposit): void { addDeposits({ @@ -106,6 +107,22 @@ export function handlePlant(event: Plant): void { ); } +export function handleWhitelistToken(event: WhitelistToken): void { + addToSiloWhitelist(event.address, event.params.token); + + let siloSettings = loadWhitelistTokenSetting(event.params.token); + + siloSettings.selector = event.params.selector; + siloSettings.stalkEarnedPerSeason = event.params.stalkEarnedPerSeason; + siloSettings.stalkIssuedPerBdv = event.params.stalkIssuedPerBdv; + siloSettings.gaugePoints = event.params.gaugePoints; + siloSettings.optimalPercentDepositedBdv = event.params.optimalPercentDepositedBdv; + siloSettings.updatedAt = event.block.timestamp; + + takeWhitelistTokenSettingSnapshots(siloSettings, event.block); + siloSettings.save(); +} + export function handleDewhitelistToken(event: DewhitelistToken): void { let silo = loadSilo(event.address); let currentWhitelist = silo.whitelistedTokens; diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index 517d0366ae..f45ac654ed 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -1,4 +1,4 @@ -import { Address, BigInt, Bytes, ethereum, log } from "@graphprotocol/graph-ts"; +import { BigInt, log } from "@graphprotocol/graph-ts"; import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { AddWithdrawal, From d8dabddd2455e395126fa6368c51c63998d8d73a Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:49:32 -0700 Subject: [PATCH 35/88] update stalk decimal constants --- projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts | 1 + projects/subgraph-beanstalk/src/handlers/SiloHandler.ts | 6 +++--- .../src/handlers/legacy/LegacySiloHandler.ts | 2 -- projects/subgraph-beanstalk/src/utils/Season.ts | 5 ++--- projects/subgraph-beanstalk/src/utils/Silo.ts | 5 ++--- projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts | 1 - projects/subgraph-core/constants/RuntimeConstants.ts | 4 ++++ 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index b5981de18a..1bb1799036 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -64,6 +64,7 @@ export function handleUpdateAverageStalkPerBdvPerSeason(event: UpdateAverageStal // GERMINATING STALK // +// TODO: extract legacy logic for the event bug // Tracks germinating balances for individual famers export function handleFarmerGerminatingStalkBalanceChanged(event: FarmerGerminatingStalkBalanceChanged): void { if (event.params.deltaGerminatingStalk == ZERO_BI) { diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 75734228d0..c269a4ee7d 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -14,9 +14,10 @@ import { UpdatedStalkPerBdvPerSeason } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { unripeChopped } from "../utils/Barn"; -import { getProtocolToken, isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; +import { beanDecimals, getProtocolToken, isUnripe, stalkDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; import { WhitelistToken } from "../../generated/Beanstalk-ABIs/Reseed"; +import { BI_10 } from "../../../subgraph-core/utils/Decimals"; export function handleAddDeposit(event: AddDeposit): void { addDeposits({ @@ -84,8 +85,7 @@ export function handlePlant(event: Plant): void { // Actual stalk credit for the farmer will be handled under the StalkBalanceChanged event. let silo = loadSilo(event.address); - // FIXME stalk decimals - let newPlantableStalk = event.params.beans.times(BigInt.fromI32(10000)); + let newPlantableStalk = event.params.beans.times(BI_10.pow(stalkDecimals(v()) - beanDecimals())); // Subtract stalk since it was already added in Reward, and is about to get re-added in StalkBalanceChanged. silo.stalk = silo.stalk.minus(newPlantableStalk); diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index f45ac654ed..09735a7e36 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -112,7 +112,6 @@ export function handleWhitelistToken_v2(event: WhitelistToken_v2): void { let setting = loadWhitelistTokenSetting(event.params.token); setting.selector = event.params.selector; - // FIXME stalk decimals setting.stalkIssuedPerBdv = BigInt.fromString("10000000000"); setting.stalkEarnedPerSeason = event.params.stalk.times(BigInt.fromI32(1000000)); @@ -126,7 +125,6 @@ export function handleWhitelistToken_v3(event: WhitelistToken_v3): void { let setting = loadWhitelistTokenSetting(event.params.token); setting.selector = event.params.selector; - // FIXME stalk decimals setting.stalkIssuedPerBdv = event.params.stalk.times(BigInt.fromI32(1_000_000)); setting.stalkEarnedPerSeason = event.params.stalkEarnedPerSeason; diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index 7daa7aea3c..bf2b36160f 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -12,7 +12,7 @@ import { setBdv, takeWhitelistTokenSettingSnapshots } from "../entities/snapshot import { WhitelistTokenSetting } from "../../generated/schema"; import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { updateUnripeStats } from "./Barn"; -import { getProtocolToken, isUnripe } from "../../../subgraph-core/constants/RuntimeConstants"; +import { beanDecimals, getProtocolToken, isUnripe, stalkDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; import { updateDepositInSiloAsset } from "./Silo"; @@ -67,8 +67,7 @@ export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block export function siloReceipt(amount: BigInt, block: ethereum.Block): void { let silo = loadSilo(v().protocolAddress); - // FIXME stalk decimals - let newPlantableStalk = amount.times(BigInt.fromI32(10000)); // Stalk has 10 decimals + let newPlantableStalk = amount.times(BI_10.pow(stalkDecimals(v()) - beanDecimals())); silo.beanMints = silo.beanMints.plus(amount); silo.stalk = silo.stalk.plus(newPlantableStalk); diff --git a/projects/subgraph-beanstalk/src/utils/Silo.ts b/projects/subgraph-beanstalk/src/utils/Silo.ts index 6f3d83e691..9679ad4da6 100644 --- a/projects/subgraph-beanstalk/src/utils/Silo.ts +++ b/projects/subgraph-beanstalk/src/utils/Silo.ts @@ -5,7 +5,7 @@ import { takeSiloAssetSnapshots } from "../entities/snapshots/SiloAsset"; import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { loadBeanstalk, loadFarmer } from "../entities/Beanstalk"; import { stemFromSeason } from "./legacy/LegacySilo"; -import { isGaugeDeployed } from "../../../subgraph-core/constants/RuntimeConstants"; +import { beanDecimals, isGaugeDeployed } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; class AddRemoveDepositsParams { @@ -112,8 +112,7 @@ export function updateDepositInSiloAsset( let asset = loadSiloAsset(account, token); let tokenSettings = loadWhitelistTokenSetting(token); - // FIXME stalk decimals - let newGrownStalk = deltaBdv.times(tokenSettings.stalkEarnedPerSeason).div(BigInt.fromI32(1000000)); + let newGrownStalk = deltaBdv.times(tokenSettings.stalkEarnedPerSeason).div(BI_10.pow(beanDecimals())); asset.depositedBDV = asset.depositedBDV.plus(deltaBdv); asset.depositedAmount = asset.depositedAmount.plus(deltaAmount); diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts index 1e97e225b7..56ad30dbd1 100644 --- a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts @@ -67,7 +67,6 @@ export function stemFromSeason(season: i32, token: Address): BigInt { // Equivalent to LibLegacyTokenSilo.seasonToStem function seasonToV3Stem(season: i32, stemStartSeason: i32, seedsPerBdv: i32): BigInt { - // FIXME stalk decimals return BigInt.fromI32(season - stemStartSeason).times(BigInt.fromI32(seedsPerBdv).times(BI_10.pow(6))); } diff --git a/projects/subgraph-core/constants/RuntimeConstants.ts b/projects/subgraph-core/constants/RuntimeConstants.ts index 7448369448..b22f9a76ce 100644 --- a/projects/subgraph-core/constants/RuntimeConstants.ts +++ b/projects/subgraph-core/constants/RuntimeConstants.ts @@ -96,3 +96,7 @@ export function stalkDecimals(v: VersionDto): i32 { } throw new Error("Unsupported protocol"); } + +export function beanDecimals(): i32 { + return 6; +} From 6b8f1d27f36cc763c804e868bba51de17a59dee2 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 19:03:03 -0700 Subject: [PATCH 36/88] Update types in tests --- .../src/handlers/SiloHandler.ts | 2 +- .../legacy/LegacyMarketplaceV2Handler.ts | 2 +- .../subgraph-beanstalk/src/utils/Season.ts | 2 +- projects/subgraph-beanstalk/src/utils/Silo.ts | 2 +- .../tests/SeedGauge.test.ts | 11 ++-- .../tests/event-mocking/Marketplace.ts | 42 +++++++-------- .../subgraph-beanstalk/tests/utils/Field.ts | 8 +-- .../tests/utils/Marketplace.ts | 54 +++++++++---------- 8 files changed, 62 insertions(+), 61 deletions(-) diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index c269a4ee7d..c43bc42285 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -85,7 +85,7 @@ export function handlePlant(event: Plant): void { // Actual stalk credit for the farmer will be handled under the StalkBalanceChanged event. let silo = loadSilo(event.address); - let newPlantableStalk = event.params.beans.times(BI_10.pow(stalkDecimals(v()) - beanDecimals())); + let newPlantableStalk = event.params.beans.times(BI_10.pow(stalkDecimals(v()) - beanDecimals())); // Subtract stalk since it was already added in Reward, and is about to get re-added in StalkBalanceChanged. silo.stalk = silo.stalk.minus(newPlantableStalk); diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV2Handler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV2Handler.ts index c57c4c4026..77ad59ae87 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV2Handler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyMarketplaceV2Handler.ts @@ -4,7 +4,7 @@ import { PodOrderCreated as PodOrderCreated_v2, PodOrderFilled as PodOrderFilled_v2, PodListingCancelled as PodListingCancelled_v2 -} from "../../../generated/Beanstalk-ABIs/MarketV2"; +} from "../../../generated/Beanstalk-ABIs/SeedGauge"; import { podListingCancelled, podListingCreated, podListingFilled, podOrderCreated, podOrderFilled } from "../../utils/Marketplace"; // MarketV2 -> Reseed diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index bf2b36160f..b21db3149b 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -67,7 +67,7 @@ export function sunrise(protocol: Address, season: BigInt, block: ethereum.Block export function siloReceipt(amount: BigInt, block: ethereum.Block): void { let silo = loadSilo(v().protocolAddress); - let newPlantableStalk = amount.times(BI_10.pow(stalkDecimals(v()) - beanDecimals())); + let newPlantableStalk = amount.times(BI_10.pow((stalkDecimals(v()) - beanDecimals()))); silo.beanMints = silo.beanMints.plus(amount); silo.stalk = silo.stalk.plus(newPlantableStalk); diff --git a/projects/subgraph-beanstalk/src/utils/Silo.ts b/projects/subgraph-beanstalk/src/utils/Silo.ts index 9679ad4da6..75ac237447 100644 --- a/projects/subgraph-beanstalk/src/utils/Silo.ts +++ b/projects/subgraph-beanstalk/src/utils/Silo.ts @@ -112,7 +112,7 @@ export function updateDepositInSiloAsset( let asset = loadSiloAsset(account, token); let tokenSettings = loadWhitelistTokenSetting(token); - let newGrownStalk = deltaBdv.times(tokenSettings.stalkEarnedPerSeason).div(BI_10.pow(beanDecimals())); + let newGrownStalk = deltaBdv.times(tokenSettings.stalkEarnedPerSeason).div(BI_10.pow(beanDecimals())); asset.depositedBDV = asset.depositedBDV.plus(deltaBdv); asset.depositedAmount = asset.depositedAmount.plus(deltaAmount); diff --git a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts index 3a8711ed8f..a7143e98f7 100644 --- a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts +++ b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts @@ -6,7 +6,6 @@ import { handleGaugePointChange, handleUpdateAverageStalkPerBdvPerSeason, handleFarmerGerminatingStalkBalanceChanged, - handleUpdateGaugeSettings, handleTotalGerminatingStalkChanged, handleTotalStalkChangedFromGermination } from "../src/handlers/GaugeHandler"; @@ -27,8 +26,10 @@ import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { setSeason } from "./utils/Season"; import { dayFromTimestamp } from "../../subgraph-core/utils/Dates"; import { loadSilo } from "../src/entities/Silo"; -import { handleTemperatureChange } from "../src/handlers/FieldHandler"; import { initL1Version } from "./entity-mocking/MockVersion"; +import { handleTemperatureChange_v1 } from "../src/handlers/legacy/LegacyFieldHandler"; +import { handleWhitelistToken_v4 } from "../src/handlers/legacy/LegacySiloHandler"; +import { handleUpdateGaugeSettings } from "../src/handlers/legacy/LegacyGaugeHandler"; const ANVIL_ADDR_1 = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); @@ -48,10 +49,10 @@ describe("Seed Gauge", () => { simpleMockPrice(1, 1); // Temperature inits to 1 - handleTemperatureChange(createTemperatureChangeEvent(BigInt.fromU32(1), BigInt.fromU32(15), 5)); + handleTemperatureChange_v1(createTemperatureChangeEvent(BigInt.fromU32(1), BigInt.fromU32(15), 5)); assert.fieldEquals("Field", BEANSTALK.toHexString(), "temperature", "6"); assert.fieldEquals("FieldHourlySnapshot", BEANSTALK.toHexString() + "-1", "caseId", "15"); - handleTemperatureChange(createTemperatureChangeEvent(BigInt.fromU32(2), BigInt.fromU32(25), 2)); + handleTemperatureChange_v1(createTemperatureChangeEvent(BigInt.fromU32(2), BigInt.fromU32(25), 2)); assert.fieldEquals("Field", BEANSTALK.toHexString(), "temperature", "8"); assert.fieldEquals("FieldHourlySnapshot", BEANSTALK.toHexString() + "-2", "caseId", "25"); }); @@ -176,7 +177,7 @@ describe("Seed Gauge", () => { describe("Owner Configuration", () => { test("event: WhitelistToken", () => { - handleWhitelistToken( + handleWhitelistToken_v4( createWhitelistTokenV4Event( BEAN_ERC20.toHexString(), "0x12345678", diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Marketplace.ts b/projects/subgraph-beanstalk/tests/event-mocking/Marketplace.ts index c9ad6482e4..a5420653ee 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Marketplace.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Marketplace.ts @@ -8,14 +8,14 @@ import { } from "../../generated/Beanstalk-ABIs/PreReplant"; import { PodListingCreated as PodListingCreated_v1_1 } from "../../generated/Beanstalk-ABIs/Replanted"; import { - PodListingCreated, - PodListingFilled, - PodOrderCreated, - PodOrderFilled, - PodOrderCancelled, - PodListingCancelled + PodListingCreated as PodListingCreated_v2, + PodListingFilled as PodListingFilled_v2, + PodOrderCreated as PodOrderCreated_v2, + PodOrderFilled as PodOrderFilled_v2, + PodListingCancelled as PodListingCancelled_v2 } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; +import { PodOrderCancelled } from "../../generated/Beanstalk-ABIs/Reseed"; /** ===== Marketplace V1 Events ===== */ export function createPodListingCreatedEvent( @@ -165,8 +165,8 @@ export function createPodListingCreatedEvent_v2( pricingFunction: Bytes, mode: BigInt, pricingType: BigInt -): PodListingCreated { - let event = changetype(mockBeanstalkEvent()); +): PodListingCreated_v2 { + let event = changetype(mockBeanstalkEvent()); event.parameters = new Array(); let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); @@ -191,7 +191,7 @@ export function createPodListingCreatedEvent_v2( event.parameters.push(param9); event.parameters.push(param10); - return event as PodListingCreated; + return event as PodListingCreated_v2; } export function createPodListingFilledEvent_v2( @@ -201,8 +201,8 @@ export function createPodListingFilledEvent_v2( start: BigInt, amount: BigInt, costInBeans: BigInt -): PodListingFilled { - let event = changetype(mockBeanstalkEvent()); +): PodListingFilled_v2 { + let event = changetype(mockBeanstalkEvent()); event.parameters = new Array(); let param1 = new ethereum.EventParam("from", ethereum.Value.fromAddress(Address.fromString(from))); @@ -219,7 +219,7 @@ export function createPodListingFilledEvent_v2( event.parameters.push(param5); event.parameters.push(param6); - return event as PodListingFilled; + return event as PodListingFilled_v2; } export function createPodOrderCreatedEvent_v2( @@ -231,8 +231,8 @@ export function createPodOrderCreatedEvent_v2( minFillAmount: BigInt, pricingFunction: Bytes, pricingType: BigInt -): PodOrderCreated { - let event = changetype(mockBeanstalkEvent()); +): PodOrderCreated_v2 { + let event = changetype(mockBeanstalkEvent()); event.parameters = new Array(); let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); @@ -253,7 +253,7 @@ export function createPodOrderCreatedEvent_v2( event.parameters.push(param7); event.parameters.push(param8); - return event as PodOrderCreated; + return event as PodOrderCreated_v2; } export function createPodOrderFilledEvent_v2( @@ -264,8 +264,8 @@ export function createPodOrderFilledEvent_v2( start: BigInt, amount: BigInt, costInBeans: BigInt -): PodOrderFilled { - let event = changetype(mockBeanstalkEvent()); +): PodOrderFilled_v2 { + let event = changetype(mockBeanstalkEvent()); event.parameters = new Array(); let param1 = new ethereum.EventParam("from", ethereum.Value.fromAddress(Address.fromString(from))); @@ -284,7 +284,7 @@ export function createPodOrderFilledEvent_v2( event.parameters.push(param6); event.parameters.push(param7); - return event as PodOrderFilled; + return event as PodOrderFilled_v2; } /* Cancellation events */ @@ -301,8 +301,8 @@ export function createPodOrderCancelledEvent(account: string, id: Bytes): PodOrd return event as PodOrderCancelled; } -export function createPodListingCancelledEvent(account: string, index: BigInt): PodListingCancelled { - let event = changetype(mockBeanstalkEvent()); +export function createPodListingCancelledEvent(account: string, index: BigInt): PodListingCancelled_v2 { + let event = changetype(mockBeanstalkEvent()); event.parameters = new Array(); let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); @@ -311,5 +311,5 @@ export function createPodListingCancelledEvent(account: string, index: BigInt): event.parameters.push(param1); event.parameters.push(param2); - return event as PodListingCancelled; + return event as PodListingCancelled_v2; } diff --git a/projects/subgraph-beanstalk/tests/utils/Field.ts b/projects/subgraph-beanstalk/tests/utils/Field.ts index 883722f967..642431aa95 100644 --- a/projects/subgraph-beanstalk/tests/utils/Field.ts +++ b/projects/subgraph-beanstalk/tests/utils/Field.ts @@ -1,24 +1,24 @@ import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { assert, createMockedFunction } from "matchstick-as/assembly/index"; import { createHarvestEvent, createPlotTransferEvent, createSowEvent } from "../event-mocking/Field"; -import { handleHarvest, handlePlotTransfer, handleSow } from "../../src/handlers/FieldHandler"; import { createIncentivizationEvent } from "../event-mocking/Season"; import { handleIncentive } from "../../src/handlers/SeasonHandler"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { handleHarvest_v1, handlePlotTransfer_v1, handleSow_v1 } from "../../src/handlers/legacy/LegacyFieldHandler"; const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); export function sow(account: string, index: BigInt, beans: BigInt, pods: BigInt): void { - handleSow(createSowEvent(account, index, beans, pods)); + handleSow_v1(createSowEvent(account, index, beans, pods)); } export function harvest(account: string, plotIndexex: BigInt[], beans: BigInt): void { - handleHarvest(createHarvestEvent(account, plotIndexex, beans)); + handleHarvest_v1(createHarvestEvent(account, plotIndexex, beans)); } export function transferPlot(from: string, to: string, id: BigInt, amount: BigInt): void { - handlePlotTransfer(createPlotTransferEvent(from, to, id, amount)); + handlePlotTransfer_v1(createPlotTransferEvent(from, to, id, amount)); } export function setHarvestable(harvestableIndex: BigInt): BigInt { diff --git a/projects/subgraph-beanstalk/tests/utils/Marketplace.ts b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts index 9577be5d43..823c2f63b5 100644 --- a/projects/subgraph-beanstalk/tests/utils/Marketplace.ts +++ b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts @@ -14,14 +14,7 @@ import { createPodOrderFilledEvent_v2 } from "../event-mocking/Marketplace"; import { BI_10, ONE_BI, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { - PodListingCreated, - PodListingFilled, - PodOrderCreated, - PodOrderFilled, - PodOrderCancelled, - PodListingCancelled -} from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { PodOrderCancelled } from "../../generated/Beanstalk-ABIs/Reseed"; import { BEANSTALK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { transferPlot } from "./Field"; import { @@ -39,13 +32,20 @@ import { handlePodOrderFilled_v1 } from "../../src/handlers/legacy/LegacyMarketplaceV1Handler"; import { - handlePodListingCancelled, - handlePodListingCreated, - handlePodListingFilled, - handlePodOrderCancelled, - handlePodOrderCreated, - handlePodOrderFilled -} from "../../src/handlers/MarketplaceHandler"; + handlePodListingCancelled_v2, + handlePodListingCreated_v2, + handlePodListingFilled_v2, + handlePodOrderCreated_v2, + handlePodOrderFilled_v2 +} from "../../src/handlers/legacy/LegacyMarketplaceV2Handler"; +import { handlePodOrderCancelled } from "../../src/handlers/MarketplaceHandler"; +import { + PodListingCancelled as PodListingCancelled_v2, + PodListingCreated as PodListingCreated_v2, + PodListingFilled as PodListingFilled_v2, + PodOrderCreated as PodOrderCreated_v2, + PodOrderFilled as PodOrderFilled_v2 +} from "../../generated/Beanstalk-ABIs/SeedGauge"; const pricingFunction = Bytes.fromHexString( "0x0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000c8000000000000000000000000000000000000000000000000000000000000012c000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010101010101010101010101010000" @@ -89,9 +89,9 @@ export function fillListing_v2( listingStart: BigInt, podAmount: BigInt, costInBeans: BigInt -): PodListingFilled { +): PodListingFilled_v2 { const event = createPodListingFilledEvent_v2(from, to, listingIndex, listingStart, podAmount, costInBeans); - handlePodListingFilled(event); + handlePodListingFilled_v2(event); // Perform plot transfer transferPlot(from, to, listingIndex.plus(listingStart), podAmount); @@ -145,9 +145,9 @@ export function fillOrder_v2( start: BigInt, podAmount: BigInt, costInBeans: BigInt -): PodOrderFilled { +): PodOrderFilled_v2 { const event = createPodOrderFilledEvent_v2(from, to, orderId, index, start, podAmount, costInBeans); - handlePodOrderFilled(event); + handlePodOrderFilled_v2(event); // Perform plot transfer transferPlot(from, to, index.plus(start), podAmount); @@ -165,9 +165,9 @@ export function fillOrder_v2( return event; } -export function cancelListing(account: string, listingIndex: BigInt): PodListingCancelled { +export function cancelListing(account: string, listingIndex: BigInt): PodListingCancelled_v2 { const event = createPodListingCancelledEvent(account, listingIndex); - handlePodListingCancelled(event); + handlePodListingCancelled_v2(event); return event; } @@ -209,7 +209,7 @@ function assertListingCreated_v1_1(event: PodListingCreated_v1_1): void { assert.fieldEquals("PodListing", listingID, "mode", event.params.mode.toString()); } -function assertListingCreated_v2(event: PodListingCreated): void { +function assertListingCreated_v2(event: PodListingCreated_v2): void { let listingID = event.params.account.toHexString() + "-" + event.params.index.toString(); assert.fieldEquals("PodListing", listingID, "plot", event.params.index.toString()); assert.fieldEquals("PodListing", listingID, "farmer", event.params.account.toHexString()); @@ -244,7 +244,7 @@ function assertOrderCreated_v1(account: string, event: PodOrderCreated_v1): void assert.fieldEquals("PodOrder", orderID, "pricePerPod", event.params.pricePerPod.toString()); } -function assertOrderCreated_v2(account: string, event: PodOrderCreated): void { +function assertOrderCreated_v2(account: string, event: PodOrderCreated_v2): void { let orderID = event.params.id.toHexString(); assert.fieldEquals("PodOrder", orderID, "historyID", orderID + "-" + event.block.timestamp.toString() + "-" + event.logIndex.toString()); assert.fieldEquals("PodOrder", orderID, "farmer", account); @@ -292,7 +292,7 @@ export function createListing_v2( listedPods: BigInt, start: BigInt, maxHarvestableIndex: BigInt -): PodListingCreated { +): PodListingCreated_v2 { const event = createPodListingCreatedEvent_v2( account, index, @@ -305,7 +305,7 @@ export function createListing_v2( BigInt.fromI32(0), BigInt.fromI32(1) ); - handlePodListingCreated(event); + handlePodListingCreated_v2(event); assertListingCreated_v2(event); return event; } @@ -317,9 +317,9 @@ export function createOrder_v1(account: string, id: Bytes, beans: BigInt, priceP return event; } -export function createOrder_v2(account: string, id: Bytes, beans: BigInt, pricePerPod: BigInt, maxPlaceInLine: BigInt): PodOrderCreated { +export function createOrder_v2(account: string, id: Bytes, beans: BigInt, pricePerPod: BigInt, maxPlaceInLine: BigInt): PodOrderCreated_v2 { const event = createPodOrderCreatedEvent_v2(account, id, beans, pricePerPod, maxPlaceInLine, ONE_BI, pricingFunction, ZERO_BI); - handlePodOrderCreated(event); + handlePodOrderCreated_v2(event); assertOrderCreated_v2(account, event); return event; } From bf99584617bf122cf1efeaed0d45d6ae206a6cde Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 19:10:03 -0700 Subject: [PATCH 37/88] latest events to use reseed abi --- projects/subgraph-beanstalk/src/entities/Fertilizer.ts | 4 ++-- projects/subgraph-beanstalk/src/handlers/BarnHandler.ts | 4 ++-- projects/subgraph-beanstalk/src/handlers/FarmHandler.ts | 2 +- projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts | 1 + projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts | 1 + projects/subgraph-beanstalk/src/handlers/SiloHandler.ts | 2 +- projects/subgraph-beanstalk/src/utils/Barn.ts | 4 ++-- projects/subgraph-beanstalk/src/utils/Season.ts | 4 ++-- projects/subgraph-beanstalk/src/utils/Yield.ts | 4 ++-- 9 files changed, 14 insertions(+), 12 deletions(-) diff --git a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts index 0d01c877c4..06cd4cfdd5 100644 --- a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts +++ b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts @@ -1,7 +1,7 @@ import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { Farmer, Fertilizer, FertilizerBalance, FertilizerToken, FertilizerYield } from "../../generated/schema"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { Reseed } from "../../generated/Beanstalk-ABIs/Reseed"; import { v } from "../utils/constants/Version"; export function loadFertilizer(fertilizerAddress: Address): Fertilizer { @@ -18,7 +18,7 @@ export function loadFertilizer(fertilizerAddress: Address): Fertilizer { export function loadFertilizerToken(fertilizer: Fertilizer, id: BigInt, blockNumber: BigInt): FertilizerToken { let fertilizerToken = FertilizerToken.load(id.toString()); if (fertilizerToken == null) { - const beanstalkContract = SeedGauge.bind(v().protocolAddress); + const beanstalkContract = Reseed.bind(v().protocolAddress); fertilizerToken = new FertilizerToken(id.toString()); fertilizerToken.fertilizer = fertilizer.id; if (blockNumber.gt(BigInt.fromString("15278963"))) { diff --git a/projects/subgraph-beanstalk/src/handlers/BarnHandler.ts b/projects/subgraph-beanstalk/src/handlers/BarnHandler.ts index c8f61efb89..417414cace 100644 --- a/projects/subgraph-beanstalk/src/handlers/BarnHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/BarnHandler.ts @@ -1,5 +1,5 @@ -import { Address, BigInt, log } from "@graphprotocol/graph-ts"; -import { ChangeUnderlying, Chop } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { Address, log } from "@graphprotocol/graph-ts"; +import { ChangeUnderlying, Chop } from "../../generated/Beanstalk-ABIs/Reseed"; import { TransferSingle, TransferBatch } from "../../generated/Beanstalk-ABIs/Fertilizer"; import { loadUnripeToken } from "../entities/Silo"; import { transfer, unripeChopped, updateUnripeStats } from "../utils/Barn"; diff --git a/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts b/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts index 30a8123fdb..307e602ec0 100644 --- a/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts @@ -1,5 +1,5 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; -import { InternalBalanceChanged } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { InternalBalanceChanged } from "../../generated/Beanstalk-ABIs/Reseed"; import { takeSiloAssetSnapshots } from "../entities/snapshots/SiloAsset"; import { loadSiloAsset } from "../entities/Silo"; import { loadFarmer } from "../entities/Beanstalk"; diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index 1bb1799036..14d9607844 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -64,6 +64,7 @@ export function handleUpdateAverageStalkPerBdvPerSeason(event: UpdateAverageStal // GERMINATING STALK // +// TODO: this one must be legacy due to event param names changing anyway // TODO: extract legacy logic for the event bug // Tracks germinating balances for individual famers export function handleFarmerGerminatingStalkBalanceChanged(event: FarmerGerminatingStalkBalanceChanged): void { diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index e5b14e70a2..90234e4b55 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -69,6 +69,7 @@ export function handleIncentive(event: Incentivization): void { season.marketCap = season.price.times(toDecimal(season.beans)); season.incentiveBeans = event.params.beans; + // TODO: need legacy extraction here for providing no field id season.harvestableIndex = beanstalk_contract.harvestableIndex(); season.save(); diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index c43bc42285..62190b3bdf 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -12,7 +12,7 @@ import { RemoveDeposits, StalkBalanceChanged, UpdatedStalkPerBdvPerSeason -} from "../../generated/Beanstalk-ABIs/SeedGauge"; +} from "../../generated/Beanstalk-ABIs/Reseed"; import { unripeChopped } from "../utils/Barn"; import { beanDecimals, getProtocolToken, isUnripe, stalkDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; diff --git a/projects/subgraph-beanstalk/src/utils/Barn.ts b/projects/subgraph-beanstalk/src/utils/Barn.ts index 6502c3daf6..78fd02d650 100644 --- a/projects/subgraph-beanstalk/src/utils/Barn.ts +++ b/projects/subgraph-beanstalk/src/utils/Barn.ts @@ -2,7 +2,7 @@ import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Chop as ChopEntity } from "../../generated/schema"; import { loadFertilizer, loadFertilizerBalance, loadFertilizerToken } from "../entities/Fertilizer"; import { loadFarmer } from "../entities/Beanstalk"; -import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { Reseed } from "../../generated/Beanstalk-ABIs/Reseed"; import { loadUnripeToken, loadWhitelistTokenSetting } from "../entities/Silo"; import { takeUnripeTokenSnapshots } from "../entities/snapshots/UnripeToken"; import { BI_10, toDecimal } from "../../../subgraph-core/utils/Decimals"; @@ -73,7 +73,7 @@ export function unripeChopped(params: ChopParams): void { // Update the status for this unripe token using protocol getters. These values fluctuate without related events. export function updateUnripeStats(unripe: Address, protocol: Address, block: ethereum.Block): void { - const beanstalk_call = SeedGauge.bind(protocol); + const beanstalk_call = Reseed.bind(protocol); let unripeToken = loadUnripeToken(unripe); // Contract values diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index b21db3149b..592a4cda57 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -10,7 +10,7 @@ import { BI_10, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils import { loadField } from "../entities/Field"; import { setBdv, takeWhitelistTokenSettingSnapshots } from "../entities/snapshots/WhitelistTokenSetting"; import { WhitelistTokenSetting } from "../../generated/schema"; -import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { Reseed } from "../../generated/Beanstalk-ABIs/Reseed"; import { updateUnripeStats } from "./Barn"; import { beanDecimals, getProtocolToken, isUnripe, stalkDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; @@ -82,7 +82,7 @@ export function siloReceipt(amount: BigInt, block: ethereum.Block): void { function setTokenBdv(token: Address, protocol: Address, whitelistTokenSetting: WhitelistTokenSetting): void { // Get bdv if the bdv function is available onchain (not available prior to BIP-16) - const beanstalk_call = SeedGauge.bind(protocol); + const beanstalk_call = Reseed.bind(protocol); const bdvResult = beanstalk_call.try_bdv(token, BI_10.pow(whitelistTokenSetting.decimals)); if (bdvResult.reverted) { return; diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index 8e38465f51..f1bfa32439 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -14,7 +14,7 @@ import { calculateAPYPreGauge } from "./legacy/LegacyYield"; import { getGerminatingBdvs } from "../entities/Germinating"; import { getCurrentSeason, getRewardMinted, loadBeanstalk } from "../entities/Beanstalk"; import { loadFertilizer, loadFertilizerYield } from "../entities/Fertilizer"; -import { SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { Reseed } from "../../generated/Beanstalk-ABIs/Reseed"; import { getProtocolFertilizer, minEMASeason, stalkDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; import { toAddress } from "../../../subgraph-core/utils/Bytes"; @@ -426,7 +426,7 @@ function updateFertAPY(protocol: Address, timestamp: BigInt, window: i32): void let siloYield = loadSiloYield(t, window); let fertilizerYield = loadFertilizerYield(t, window); let fertilizer = loadFertilizer(fertAddress); - let contract = SeedGauge.bind(protocol); + let contract = Reseed.bind(protocol); if (t < 6534) { let currentFertHumidity = contract.try_getCurrentHumidity(); fertilizerYield.humidity = BigDecimal.fromString(currentFertHumidity.reverted ? "500" : currentFertHumidity.value.toString()).div( From 2573dbdf1be75b28ef0d788cbc59045e0dd29a6c Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 11 Sep 2024 19:27:16 -0700 Subject: [PATCH 38/88] set manifest abi to reseed --- .../manifests/ethereum.yaml | 43 ++++++++++--------- .../subgraph-beanstalk/manifests/no-apy.yaml | 43 ++++++++++--------- .../src/handlers/SeasonHandler.ts | 2 +- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index bbe456b073..02c2c72668 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -394,7 +394,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 15277986 # Replanted (Silo currently has no support for pre-exploit) mapping: kind: ethereum/events @@ -403,8 +403,8 @@ dataSources: entities: - Silo abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: AddDeposit(indexed address,indexed address,int96,uint256,uint256) handler: handleAddDeposit @@ -530,7 +530,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 19628074 mapping: kind: ethereum/events @@ -539,8 +539,8 @@ dataSources: entities: - SeedGauge abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: @@ -589,7 +589,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 12974075 # Field has all-time support mapping: kind: ethereum/events @@ -598,8 +598,8 @@ dataSources: entities: - Field abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: CurvePrice file: ../../subgraph-core/abis/CurvePrice.json - name: BeanstalkPrice @@ -655,7 +655,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 14148509 # BIP-11 Pod Marketplace mapping: kind: ethereum/events @@ -664,9 +664,10 @@ dataSources: entities: - PodMarketplace abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: + # The address field did get renamed in the reseed but this will still work - event: PodOrderCancelled(indexed address,bytes32) handler: handlePodOrderCancelled file: ../src/handlers/MarketplaceHandler.ts @@ -782,7 +783,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 15277986 mapping: kind: ethereum/events @@ -791,8 +792,8 @@ dataSources: entities: - Chop abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: Chop(indexed address,indexed address,uint256,uint256) handler: handleChop @@ -807,7 +808,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 12974075 mapping: kind: ethereum/events @@ -816,8 +817,8 @@ dataSources: entities: - Season abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: @@ -1010,7 +1011,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 15277986 # Replanted mapping: kind: ethereum/events @@ -1019,8 +1020,8 @@ dataSources: entities: - SiloAsset abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: InternalBalanceChanged(indexed address,indexed address,int256) handler: handleInternalBalanceChanged diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index babc3a25cb..e3e9fc31b1 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -61,7 +61,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 15277986 # Replanted (Silo currently has no support for pre-exploit) mapping: kind: ethereum/events @@ -70,8 +70,8 @@ dataSources: entities: - Silo abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: AddDeposit(indexed address,indexed address,int96,uint256,uint256) handler: handleAddDeposit @@ -197,7 +197,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 19628074 mapping: kind: ethereum/events @@ -206,8 +206,8 @@ dataSources: entities: - SeedGauge abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: @@ -256,7 +256,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 12974075 # Field has all-time support mapping: kind: ethereum/events @@ -265,8 +265,8 @@ dataSources: entities: - Field abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: CurvePrice file: ../../subgraph-core/abis/CurvePrice.json - name: BeanstalkPrice @@ -322,7 +322,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 14148509 # BIP-11 Pod Marketplace mapping: kind: ethereum/events @@ -331,9 +331,10 @@ dataSources: entities: - PodMarketplace abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: + # The address field did get renamed in the reseed but this will still work - event: PodOrderCancelled(indexed address,bytes32) handler: handlePodOrderCancelled file: ../src/handlers/MarketplaceHandler.ts @@ -449,7 +450,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 15277986 mapping: kind: ethereum/events @@ -458,8 +459,8 @@ dataSources: entities: - Chop abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: Chop(indexed address,indexed address,uint256,uint256) handler: handleChop @@ -474,7 +475,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 12974075 mapping: kind: ethereum/events @@ -483,8 +484,8 @@ dataSources: entities: - Season abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: @@ -677,7 +678,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: Reseed startBlock: 15277986 # Replanted mapping: kind: ethereum/events @@ -686,8 +687,8 @@ dataSources: entities: - SiloAsset abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: InternalBalanceChanged(indexed address,indexed address,int256) handler: handleInternalBalanceChanged diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index 90234e4b55..34fbec8466 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -1,5 +1,5 @@ import { BigInt } from "@graphprotocol/graph-ts"; -import { Reward, Soil, WellOracle, Sunrise, Incentivization, SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { Soil, WellOracle, Sunrise, Incentivization, SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { toDecimal, ZERO_BD } from "../../../subgraph-core/utils/Decimals"; import { updateStalkWithCalls } from "../utils/legacy/LegacySilo"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; From 2010d2e84b4f8c153ba7728afcaa5d6eac2ebd6d Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:45:49 -0700 Subject: [PATCH 39/88] move legacy gauge event handlers --- .../manifests/ethereum.yaml | 11 +- .../subgraph-beanstalk/manifests/no-apy.yaml | 11 +- .../src/entities/Germinating.ts | 31 ----- .../src/handlers/GaugeHandler.ts | 76 +++--------- .../src/handlers/legacy/LegacyGaugeHandler.ts | 111 +++++++++++++++++- .../src/utils/legacy/LegacySilo.ts | 37 +++++- .../tests/event-mocking/SeedGauge.ts | 4 +- .../tests/event-mocking/Silo.ts | 10 +- .../tests/event-mocking/Whitelist.ts | 9 +- 9 files changed, 186 insertions(+), 114 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index 02c2c72668..176036a6e5 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -550,14 +550,13 @@ dataSources: handler: handleGaugePointChange - event: UpdateAverageStalkPerBdvPerSeason(uint256) handler: handleUpdateAverageStalkPerBdvPerSeason - - event: FarmerGerminatingStalkBalanceChanged(indexed address,int256,uint8) - handler: handleFarmerGerminatingStalkBalanceChanged - - event: TotalGerminatingBalanceChanged(uint256,indexed address,int256,int256) - handler: handleTotalGerminatingBalanceChanged - event: TotalGerminatingStalkChanged(uint256,int256) handler: handleTotalGerminatingStalkChanged - event: TotalStalkChangedFromGermination(int256,int256) handler: handleTotalStalkChangedFromGermination + # events were bugged and resolved on Reseed, they are handled in legacy: + # FarmerGerminatingStalkBalanceChanged + # TotalGerminatingBalanceChanged file: ../src/handlers/GaugeHandler.ts - kind: ethereum/contract name: LegacySeedGauge-SeedGauge-Reseed @@ -578,6 +577,10 @@ dataSources: - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: + - event: FarmerGerminatingStalkBalanceChanged(indexed address,int256,uint8) + handler: handleFarmerGerminatingStalkBalanceChanged_bugged + - event: TotalGerminatingBalanceChanged(uint256,indexed address,int256,int256) + handler: handleTotalGerminatingBalanceChanged_bugged - event: UpdateGaugeSettings(indexed address,bytes4,bytes4,uint64) handler: handleUpdateGaugeSettings file: ../src/handlers/legacy/LegacyGaugeHandler.ts diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index e3e9fc31b1..cc3ffceb98 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -217,14 +217,13 @@ dataSources: handler: handleGaugePointChange - event: UpdateAverageStalkPerBdvPerSeason(uint256) handler: handleUpdateAverageStalkPerBdvPerSeason - - event: FarmerGerminatingStalkBalanceChanged(indexed address,int256,uint8) - handler: handleFarmerGerminatingStalkBalanceChanged - - event: TotalGerminatingBalanceChanged(uint256,indexed address,int256,int256) - handler: handleTotalGerminatingBalanceChanged - event: TotalGerminatingStalkChanged(uint256,int256) handler: handleTotalGerminatingStalkChanged - event: TotalStalkChangedFromGermination(int256,int256) handler: handleTotalStalkChangedFromGermination + # events were bugged and resolved on Reseed, they are handled in legacy: + # FarmerGerminatingStalkBalanceChanged + # TotalGerminatingBalanceChanged file: ../src/handlers/GaugeHandler.ts - kind: ethereum/contract name: LegacySeedGauge-SeedGauge-Reseed @@ -245,6 +244,10 @@ dataSources: - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: + - event: FarmerGerminatingStalkBalanceChanged(indexed address,int256,uint8) + handler: handleFarmerGerminatingStalkBalanceChanged_bugged + - event: TotalGerminatingBalanceChanged(uint256,indexed address,int256,int256) + handler: handleTotalGerminatingBalanceChanged_bugged - event: UpdateGaugeSettings(indexed address,bytes4,bytes4,uint64) handler: handleUpdateGaugeSettings file: ../src/handlers/legacy/LegacyGaugeHandler.ts diff --git a/projects/subgraph-beanstalk/src/entities/Germinating.ts b/projects/subgraph-beanstalk/src/entities/Germinating.ts index 46b8f62150..faebf889e9 100644 --- a/projects/subgraph-beanstalk/src/entities/Germinating.ts +++ b/projects/subgraph-beanstalk/src/entities/Germinating.ts @@ -42,37 +42,6 @@ export function deleteGerminating(germinating: Germinating): void { store.remove("Germinating", germinating.id); } -// This is the entity that exists to resolve the issue in LibGerminate when deposits from multiple seasons -// complete their germination (the event emission itself has a bug) -export function loadPrevFarmerGerminatingEvent(account: Address): PrevFarmerGerminatingEvent { - let savedEvent = PrevFarmerGerminatingEvent.load(account); - if (savedEvent == null) { - savedEvent = new PrevFarmerGerminatingEvent(account); - savedEvent.eventBlock = ZERO_BI; - savedEvent.logIndex = ZERO_BI; - savedEvent.deltaGerminatingStalk = ZERO_BI; - // No point in saving it - } - return savedEvent as PrevFarmerGerminatingEvent; -} - -export function savePrevFarmerGerminatingEvent(account: Address, event: ethereum.Event, deltaGerminatingStalk: BigInt): void { - const savedEvent = new PrevFarmerGerminatingEvent(account); - savedEvent.eventBlock = event.block.number; - savedEvent.logIndex = event.logIndex; - savedEvent.deltaGerminatingStalk = deltaGerminatingStalk; - savedEvent.save(); -} - -// Returns the stalk offset that should be applied to the encountered FarmerGerminatingStalkBalanceChanged event. -export function getFarmerGerminatingBugOffset(account: Address, event: ethereum.Event): BigInt { - const prevEvent = loadPrevFarmerGerminatingEvent(account); - if (prevEvent.eventBlock == event.block.number && prevEvent.logIndex == event.logIndex.minus(ONE_BI)) { - return prevEvent.deltaGerminatingStalk.neg(); - } - return ZERO_BI; -} - export function germinationSeasonCategory(season: i32): string { return season % 2 == 0 ? "EVEN" : "ODD"; } diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index 14d9607844..2e985db6ef 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -5,17 +5,14 @@ import { FarmerGerminatingStalkBalanceChanged, TotalGerminatingBalanceChanged, TotalGerminatingStalkChanged, - TotalStalkChangedFromGermination, - SeedGauge -} from "../../generated/Beanstalk-ABIs/SeedGauge"; + TotalStalkChangedFromGermination +} from "../../generated/Beanstalk-ABIs/Reseed"; import { deleteGerminating, germinationEnumCategory, germinationSeasonCategory, - getFarmerGerminatingBugOffset, loadGerminating, - loadOrCreateGerminating, - savePrevFarmerGerminatingEvent + loadOrCreateGerminating } from "../entities/Germinating"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { setSiloHourlyCaseId, takeSiloSnapshots } from "../entities/snapshots/Silo"; @@ -64,36 +61,28 @@ export function handleUpdateAverageStalkPerBdvPerSeason(event: UpdateAverageStal // GERMINATING STALK // -// TODO: this one must be legacy due to event param names changing anyway -// TODO: extract legacy logic for the event bug // Tracks germinating balances for individual famers export function handleFarmerGerminatingStalkBalanceChanged(event: FarmerGerminatingStalkBalanceChanged): void { - if (event.params.deltaGerminatingStalk == ZERO_BI) { + if (event.params.delta == ZERO_BI) { return; } const currentSeason = getCurrentSeason(); - if (event.params.deltaGerminatingStalk > ZERO_BI) { + if (event.params.delta > ZERO_BI) { // Germinating stalk is added. It is possible to begin germination in the prior season rather than the // current season when converting. See ConvertFacet._depositTokensForConvert for more information. // If the event's germinationState doesnt match with the current season, use the prior season. const germinatingSeason = - germinationSeasonCategory(currentSeason) === germinationEnumCategory(event.params.germinationState) - ? currentSeason - : currentSeason - 1; + germinationSeasonCategory(currentSeason) === germinationEnumCategory(event.params.germ) ? currentSeason : currentSeason - 1; let farmerGerminating = loadOrCreateGerminating(event.params.account, germinatingSeason, true); - farmerGerminating.stalk = farmerGerminating.stalk.plus(event.params.deltaGerminatingStalk); + farmerGerminating.stalk = farmerGerminating.stalk.plus(event.params.delta); farmerGerminating.save(); } else { - // Adjusts for the event's inherent bug when both even/odd germination complete in the same txn - const bugfixStalkOffset = getFarmerGerminatingBugOffset(event.params.account, event); - const actualDeltaGerminatingStalk = event.params.deltaGerminatingStalk.plus(bugfixStalkOffset); - // Germinating stalk is being removed. It therefore must have created the entity already - let farmerGerminating = loadGerminating(event.params.account, event.params.germinationState); - farmerGerminating.stalk = farmerGerminating.stalk.plus(actualDeltaGerminatingStalk); + let farmerGerminating = loadGerminating(event.params.account, event.params.germ); + farmerGerminating.stalk = farmerGerminating.stalk.plus(event.params.delta); if (farmerGerminating.stalk == ZERO_BI) { deleteGerminating(farmerGerminating); } else { @@ -104,17 +93,14 @@ export function handleFarmerGerminatingStalkBalanceChanged(event: FarmerGerminat // If germination finished, need to subtract stalk from system silo. This stalk was already added // into system stalk upon sunrise for season - 2. let systemSilo = loadSilo(event.address); - systemSilo.stalk = systemSilo.stalk.plus(actualDeltaGerminatingStalk); + systemSilo.stalk = systemSilo.stalk.plus(event.params.delta); takeSiloSnapshots(systemSilo, event.block); systemSilo.save(); } - - // Also for the event bug adjustment - savePrevFarmerGerminatingEvent(event.params.account, event, event.params.deltaGerminatingStalk); } let farmerSilo = loadSilo(event.params.account); - farmerSilo.germinatingStalk = farmerSilo.germinatingStalk.plus(event.params.deltaGerminatingStalk); + farmerSilo.germinatingStalk = farmerSilo.germinatingStalk.plus(event.params.delta); takeSiloSnapshots(farmerSilo, event.block); farmerSilo.save(); } @@ -125,41 +111,15 @@ export function handleTotalGerminatingBalanceChanged(event: TotalGerminatingBala return; } - // SeedGauge: there is a bug where the germinating season number here can be incorrect/incongruent - // with the values set at s.(odd|even)Germinating.deposited[token].bdv. - // Best solution is to use view functions to determine what the correct amount should be for each. - const beanstalk_call = SeedGauge.bind(event.address); - - const evenGerminating = beanstalk_call.getEvenGerminating(event.params.token); - let tokenGerminatingEven = loadOrCreateGerminating(event.params.token, 0, false); - tokenGerminatingEven.tokenAmount = evenGerminating.getValue0(); - tokenGerminatingEven.bdv = evenGerminating.getValue1(); - if (tokenGerminatingEven.tokenAmount == ZERO_BI) { - deleteGerminating(tokenGerminatingEven); + let tokenGerminating = loadOrCreateGerminating(event.params.token, event.params.germinationSeason.toU32(), false); + tokenGerminating.season = event.params.germinationSeason.toU32(); + tokenGerminating.tokenAmount = tokenGerminating.tokenAmount.plus(event.params.deltaAmount); + tokenGerminating.bdv = tokenGerminating.bdv.plus(event.params.deltaBdv); + if (tokenGerminating.tokenAmount == ZERO_BI) { + deleteGerminating(tokenGerminating); } else { - tokenGerminatingEven.save(); + tokenGerminating.save(); } - - const oddGerminating = beanstalk_call.getOddGerminating(event.params.token); - let tokenGerminatingOdd = loadOrCreateGerminating(event.params.token, 1, false); - tokenGerminatingOdd.tokenAmount = oddGerminating.getValue0(); - tokenGerminatingOdd.bdv = oddGerminating.getValue1(); - if (tokenGerminatingOdd.tokenAmount == ZERO_BI) { - deleteGerminating(tokenGerminatingOdd); - } else { - tokenGerminatingOdd.save(); - } - - /** This is the correct implementation, but can't be used due to the bug in contracts described above. **/ - // let tokenGerminating = loadOrCreateGerminating(event.params.token, event.params.germinationSeason.toU32(), false); - // tokenGerminating.season = event.params.germinationSeason.toU32(); - // tokenGerminating.tokenAmount = tokenGerminating.tokenAmount.plus(event.params.deltaAmount); - // tokenGerminating.bdv = tokenGerminating.bdv.plus(event.params.deltaBdv); - // if (tokenGerminating.tokenAmount == ZERO_BI) { - // deleteGerminating(tokenGerminating); - // } else { - // tokenGerminating.save(); - // } } // This occurs at the beanstalk level regardless of whether users mow their own germinating stalk into regular stalk. diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts index fa28f4c207..a91d15af67 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts @@ -1,9 +1,116 @@ import { Bytes4_emptyToNull } from "../../../../subgraph-core/utils/Bytes"; -import { UpdateGaugeSettings } from "../../../generated/Beanstalk-ABIs/SeedGauge"; -import { loadWhitelistTokenSetting } from "../../entities/Silo"; +import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { + FarmerGerminatingStalkBalanceChanged, + SeedGauge, + TotalGerminatingBalanceChanged, + UpdateGaugeSettings +} from "../../../generated/Beanstalk-ABIs/SeedGauge"; +import { getCurrentSeason } from "../../entities/Beanstalk"; +import { + deleteGerminating, + germinationEnumCategory, + germinationSeasonCategory, + loadGerminating, + loadOrCreateGerminating +} from "../../entities/Germinating"; +import { loadSilo, loadWhitelistTokenSetting } from "../../entities/Silo"; +import { takeSiloSnapshots } from "../../entities/snapshots/Silo"; import { takeWhitelistTokenSettingSnapshots } from "../../entities/snapshots/WhitelistTokenSetting"; +import { getFarmerGerminatingBugOffset, savePrevFarmerGerminatingEvent } from "../../utils/legacy/LegacySilo"; import { legacyInitGauge } from "../../utils/legacy/LegacyWhitelist"; +// SeedGauge -> Reseed +// There was a bug in this event which occurred when both even and odd germination complete in +// the same transaction. +export function handleFarmerGerminatingStalkBalanceChanged_bugged(event: FarmerGerminatingStalkBalanceChanged): void { + if (event.params.deltaGerminatingStalk == ZERO_BI) { + return; + } + + const currentSeason = getCurrentSeason(); + let actualDeltaGerminatingStalk = event.params.deltaGerminatingStalk; + + if (event.params.deltaGerminatingStalk > ZERO_BI) { + // Germinating stalk is added. It is possible to begin germination in the prior season rather than the + // current season when converting. See ConvertFacet._depositTokensForConvert for more information. + // If the event's germinationState doesnt match with the current season, use the prior season. + const germinatingSeason = + germinationSeasonCategory(currentSeason) === germinationEnumCategory(event.params.germinationState) + ? currentSeason + : currentSeason - 1; + + let farmerGerminating = loadOrCreateGerminating(event.params.account, germinatingSeason, true); + farmerGerminating.stalk = farmerGerminating.stalk.plus(event.params.deltaGerminatingStalk); + farmerGerminating.save(); + } else { + // Adjusts for the event's inherent bug when both even/odd germination complete in the same txn + const bugfixStalkOffset = getFarmerGerminatingBugOffset(event.params.account, event); + actualDeltaGerminatingStalk = event.params.deltaGerminatingStalk.plus(bugfixStalkOffset); + + // Germinating stalk is being removed. It therefore must have created the entity already + let farmerGerminating = loadGerminating(event.params.account, event.params.germinationState); + farmerGerminating.stalk = farmerGerminating.stalk.plus(actualDeltaGerminatingStalk); + if (farmerGerminating.stalk == ZERO_BI) { + deleteGerminating(farmerGerminating); + } else { + farmerGerminating.save(); + } + + if (currentSeason >= farmerGerminating.season + 2) { + // If germination finished, need to subtract stalk from system silo. This stalk was already added + // into system stalk upon sunrise for season - 2. + let systemSilo = loadSilo(event.address); + systemSilo.stalk = systemSilo.stalk.plus(actualDeltaGerminatingStalk); + takeSiloSnapshots(systemSilo, event.block); + systemSilo.save(); + } + + // Also for the event bug adjustment + savePrevFarmerGerminatingEvent(event.params.account, event, event.params.deltaGerminatingStalk); + } + + let farmerSilo = loadSilo(event.params.account); + farmerSilo.germinatingStalk = farmerSilo.germinatingStalk.plus(actualDeltaGerminatingStalk); + takeSiloSnapshots(farmerSilo, event.block); + farmerSilo.save(); +} + +// SeedGauge -> Reseed +// There was a bug where the germinating season number here can be incorrect/incongruent +// with the values set at s.(odd|even)Germinating.deposited[token].bdv. +// Best solution is to use view functions to determine what the correct amount should be for each. +export function handleTotalGerminatingBalanceChanged_bugged(event: TotalGerminatingBalanceChanged): void { + if (event.params.deltaAmount == ZERO_BI && event.params.deltaBdv == ZERO_BI) { + return; + } + + // SeedGauge: there is a bug where the germinating season number here can be incorrect/incongruent + // with the values set at s.(odd|even)Germinating.deposited[token].bdv. + // Best solution is to use view functions to determine what the correct amount should be for each. + const beanstalk_call = SeedGauge.bind(event.address); + + const evenGerminating = beanstalk_call.getEvenGerminating(event.params.token); + let tokenGerminatingEven = loadOrCreateGerminating(event.params.token, 0, false); + tokenGerminatingEven.tokenAmount = evenGerminating.getValue0(); + tokenGerminatingEven.bdv = evenGerminating.getValue1(); + if (tokenGerminatingEven.tokenAmount == ZERO_BI) { + deleteGerminating(tokenGerminatingEven); + } else { + tokenGerminatingEven.save(); + } + + const oddGerminating = beanstalk_call.getOddGerminating(event.params.token); + let tokenGerminatingOdd = loadOrCreateGerminating(event.params.token, 1, false); + tokenGerminatingOdd.tokenAmount = oddGerminating.getValue0(); + tokenGerminatingOdd.bdv = oddGerminating.getValue1(); + if (tokenGerminatingOdd.tokenAmount == ZERO_BI) { + deleteGerminating(tokenGerminatingOdd); + } else { + tokenGerminatingOdd.save(); + } +} + // SeedGauge -> Reseed export function handleUpdateGaugeSettings(event: UpdateGaugeSettings): void { let siloSettings = loadWhitelistTokenSetting(event.params.token); diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts index 56ad30dbd1..432c6840d2 100644 --- a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts @@ -5,9 +5,10 @@ import { loadBeanstalk } from "../../entities/Beanstalk"; import { updateStalkBalances } from "../Silo"; import { Replanted } from "../../../generated/Beanstalk-ABIs/Replanted"; import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; -import { BI_10 } from "../../../../subgraph-core/utils/Decimals"; +import { BI_10, ONE_BI, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { toAddress } from "../../../../subgraph-core/utils/Bytes"; import { takeSiloSnapshots } from "../../entities/snapshots/Silo"; +import { PrevFarmerGerminatingEvent } from "../../../generated/schema"; export function updateClaimedWithdraw(account: Address, token: Address, withdrawSeason: BigInt, block: ethereum.Block): void { let withdraw = loadSiloWithdraw(account, token, withdrawSeason.toI32()); @@ -83,3 +84,37 @@ function getLegacySeedsPerToken(token: Address): i32 { } return 0; } + +// (legacy bugfix adjustment) +// This is the entity that exists to resolve the issue in LibGerminate when deposits from multiple seasons +// complete their germination (the event emission itself has a bug) +export function loadPrevFarmerGerminatingEvent(account: Address): PrevFarmerGerminatingEvent { + let savedEvent = PrevFarmerGerminatingEvent.load(account); + if (savedEvent == null) { + savedEvent = new PrevFarmerGerminatingEvent(account); + savedEvent.eventBlock = ZERO_BI; + savedEvent.logIndex = ZERO_BI; + savedEvent.deltaGerminatingStalk = ZERO_BI; + // No point in saving it + } + return savedEvent as PrevFarmerGerminatingEvent; +} + +// (legacy bugfix adjustment) +export function savePrevFarmerGerminatingEvent(account: Address, event: ethereum.Event, deltaGerminatingStalk: BigInt): void { + const savedEvent = new PrevFarmerGerminatingEvent(account); + savedEvent.eventBlock = event.block.number; + savedEvent.logIndex = event.logIndex; + savedEvent.deltaGerminatingStalk = deltaGerminatingStalk; + savedEvent.save(); +} + +// (legacy bugfix adjustment) +// Returns the stalk offset that should be applied to the encountered FarmerGerminatingStalkBalanceChanged event. +export function getFarmerGerminatingBugOffset(account: Address, event: ethereum.Event): BigInt { + const prevEvent = loadPrevFarmerGerminatingEvent(account); + if (prevEvent.eventBlock == event.block.number && prevEvent.logIndex == event.logIndex.minus(ONE_BI)) { + return prevEvent.deltaGerminatingStalk.neg(); + } + return ZERO_BI; +} diff --git a/projects/subgraph-beanstalk/tests/event-mocking/SeedGauge.ts b/projects/subgraph-beanstalk/tests/event-mocking/SeedGauge.ts index e9a80ae257..fc469a8299 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/SeedGauge.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/SeedGauge.ts @@ -5,11 +5,11 @@ import { UpdateAverageStalkPerBdvPerSeason, FarmerGerminatingStalkBalanceChanged, TotalGerminatingBalanceChanged, - UpdateGaugeSettings, TotalGerminatingStalkChanged, TotalStalkChangedFromGermination -} from "../../generated/Beanstalk-ABIs/SeedGauge"; +} from "../../generated/Beanstalk-ABIs/Reseed"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; +import { UpdateGaugeSettings } from "../../generated/Beanstalk-ABIs/SeedGauge"; export function createBeanToMaxLpGpPerBdvRatioChangeEvent( season: BigInt, diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Silo.ts b/projects/subgraph-beanstalk/tests/event-mocking/Silo.ts index 25b2a9fa73..2760020030 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Silo.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Silo.ts @@ -8,14 +8,8 @@ import { RemoveWithdrawals } from "../../generated/Beanstalk-ABIs/Replanted"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; -import { - AddDeposit, - RemoveDeposits, - RemoveDeposit, - SeedsBalanceChanged, - StalkBalanceChanged, - Plant -} from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { AddDeposit, RemoveDeposits, RemoveDeposit, StalkBalanceChanged, Plant } from "../../generated/Beanstalk-ABIs/Reseed"; +import { SeedsBalanceChanged } from "../../generated/Beanstalk-ABIs/SeedGauge"; export function createAddDepositV2Event( account: string, token: string, diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Whitelist.ts b/projects/subgraph-beanstalk/tests/event-mocking/Whitelist.ts index dcd20b5f48..696897d30d 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Whitelist.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Whitelist.ts @@ -2,8 +2,9 @@ import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; import { WhitelistToken as WhitelistToken_V2 } from "../../generated/Beanstalk-ABIs/Replanted"; import { WhitelistToken as WhitelistToken_V3 } from "../../generated/Beanstalk-ABIs/SiloV3"; -import { WhitelistToken, DewhitelistToken } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { WhitelistToken as WhitelistToken_V4 } from "../../generated/Beanstalk-ABIs/SeedGauge"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; +import { DewhitelistToken } from "../../generated/Beanstalk-ABIs/Reseed"; export function createWhitelistTokenV2Event(token: string, selector: string, seeds: BigInt, stalk: BigInt): WhitelistToken_V2 { let event = changetype(mockBeanstalkEvent()); @@ -53,8 +54,8 @@ export function createWhitelistTokenV4Event( lwSelector: string, gaugePoints: BigInt, optimalPercentDepositedBdv: BigInt -): WhitelistToken { - let event = changetype(mockBeanstalkEvent()); +): WhitelistToken_V4 { + let event = changetype(mockBeanstalkEvent()); event.parameters = new Array(); let param1 = new ethereum.EventParam("token", ethereum.Value.fromAddress(Address.fromString(token))); @@ -75,7 +76,7 @@ export function createWhitelistTokenV4Event( event.parameters.push(param7); event.parameters.push(param8); - return event as WhitelistToken; + return event as WhitelistToken_V4; } export function createDewhitelistTokenEvent(token: string): DewhitelistToken { From 03db4f26760369f3b384840527fffcbd0c4fdf44 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:07:00 -0700 Subject: [PATCH 40/88] update farm event --- .../manifests/ethereum.yaml | 8 +++--- .../subgraph-beanstalk/manifests/no-apy.yaml | 8 +++--- .../src/handlers/FarmHandler.ts | 25 +++---------------- .../src/handlers/legacy/LegacyFarmHandler.ts | 9 +++++++ projects/subgraph-beanstalk/src/utils/Farm.ts | 20 +++++++++++++++ 5 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 projects/subgraph-beanstalk/src/handlers/legacy/LegacyFarmHandler.ts create mode 100644 projects/subgraph-beanstalk/src/utils/Farm.ts diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index 176036a6e5..371bffe5bf 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -1014,7 +1014,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: Reseed + abi: SeedGauge startBlock: 15277986 # Replanted mapping: kind: ethereum/events @@ -1023,12 +1023,12 @@ dataSources: entities: - SiloAsset abis: - - name: Reseed - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: InternalBalanceChanged(indexed address,indexed address,int256) handler: handleInternalBalanceChanged - file: ../src/handlers/FarmHandler.ts + file: ../src/handlers/legacy/LegacyFarmHandler.ts # features: # - grafting # graft: diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index cc3ffceb98..6ad0b59f8f 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -681,7 +681,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: Reseed + abi: SeedGauge startBlock: 15277986 # Replanted mapping: kind: ethereum/events @@ -690,12 +690,12 @@ dataSources: entities: - SiloAsset abis: - - name: Reseed - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: InternalBalanceChanged(indexed address,indexed address,int256) handler: handleInternalBalanceChanged - file: ../src/handlers/FarmHandler.ts + file: ../src/handlers/legacy/LegacyFarmHandler.ts # features: # - grafting # graft: diff --git a/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts b/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts index 307e602ec0..eda5f5ce8f 100644 --- a/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/FarmHandler.ts @@ -1,27 +1,8 @@ -import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { InternalBalanceChanged } from "../../generated/Beanstalk-ABIs/Reseed"; -import { takeSiloAssetSnapshots } from "../entities/snapshots/SiloAsset"; -import { loadSiloAsset } from "../entities/Silo"; import { loadFarmer } from "../entities/Beanstalk"; +import { updateFarmTotals } from "../utils/Farm"; export function handleInternalBalanceChanged(event: InternalBalanceChanged): void { - loadFarmer(event.params.user); - updateFarmTotals(event.address, event.params.user, event.params.token, event.params.delta, event.block); -} - -function updateFarmTotals( - protocol: Address, - account: Address, - token: Address, - deltaAmount: BigInt, - block: ethereum.Block, - recursive: boolean = true -): void { - if (recursive && account != protocol) { - updateFarmTotals(protocol, protocol, token, deltaAmount, block); - } - let asset = loadSiloAsset(account, token); - asset.farmAmount = asset.farmAmount.plus(deltaAmount); - takeSiloAssetSnapshots(asset, block); - asset.save(); + loadFarmer(event.params.account); + updateFarmTotals(event.address, event.params.account, event.params.token, event.params.delta, event.block); } diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFarmHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFarmHandler.ts new file mode 100644 index 0000000000..09ca79ea3d --- /dev/null +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyFarmHandler.ts @@ -0,0 +1,9 @@ +import { InternalBalanceChanged } from "../../../generated/Beanstalk-ABIs/SeedGauge"; +import { loadFarmer } from "../../entities/Beanstalk"; +import { updateFarmTotals } from "../../utils/Farm"; + +// Replanted -> Reseed +export function handleInternalBalanceChanged(event: InternalBalanceChanged): void { + loadFarmer(event.params.user); + updateFarmTotals(event.address, event.params.user, event.params.token, event.params.delta, event.block); +} diff --git a/projects/subgraph-beanstalk/src/utils/Farm.ts b/projects/subgraph-beanstalk/src/utils/Farm.ts new file mode 100644 index 0000000000..08f4d2cc33 --- /dev/null +++ b/projects/subgraph-beanstalk/src/utils/Farm.ts @@ -0,0 +1,20 @@ +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { loadSiloAsset } from "../entities/Silo"; +import { takeSiloAssetSnapshots } from "../entities/snapshots/SiloAsset"; + +export function updateFarmTotals( + protocol: Address, + account: Address, + token: Address, + deltaAmount: BigInt, + block: ethereum.Block, + recursive: boolean = true +): void { + if (recursive && account != protocol) { + updateFarmTotals(protocol, protocol, token, deltaAmount, block); + } + let asset = loadSiloAsset(account, token); + asset.farmAmount = asset.farmAmount.plus(deltaAmount); + takeSiloAssetSnapshots(asset, block); + asset.save(); +} From 25a55fccf932ee952fab2f1312dd0abc72c4a1be Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:24:05 -0700 Subject: [PATCH 41/88] legacy season --- .../manifests/arbitrum.yaml | 2 - .../subgraph-beanstalk/manifests/no-apy.yaml | 62 +++++++++---------- .../src/handlers/SeasonHandler.ts | 14 ++--- .../src/handlers/SiloHandler.ts | 3 +- .../handlers/legacy/LegacySeasonHandler.ts | 17 +++-- .../src/utils/contracts/Beanstalk.ts | 18 ++++++ 6 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 projects/subgraph-beanstalk/src/utils/contracts/Beanstalk.ts diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml index 07281e0439..e031622839 100644 --- a/projects/subgraph-beanstalk/manifests/arbitrum.yaml +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -129,8 +129,6 @@ dataSources: abis: - name: Reseed file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - - name: CurvePrice - file: ../../subgraph-core/abis/CurvePrice.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index 6ad0b59f8f..73e263cff4 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -255,11 +255,11 @@ dataSources: # FIELD ### - kind: ethereum/contract - name: Field + name: LegacyField-PreReplant-Reseed network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: Reseed + abi: SeedGauge startBlock: 12974075 # Field has all-time support mapping: kind: ethereum/events @@ -268,8 +268,8 @@ dataSources: entities: - Field abis: - - name: Reseed - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - name: CurvePrice file: ../../subgraph-core/abis/CurvePrice.json - name: BeanstalkPrice @@ -489,6 +489,8 @@ dataSources: abis: - name: Reseed file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: SeedGauge # Needed for call to get harvestable index + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: @@ -499,6 +501,26 @@ dataSources: - event: Incentivization(indexed address,uint256) handler: handleIncentive file: ../src/handlers/SeasonHandler.ts + - kind: ethereum/contract + name: Season-SiloV3-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: Reseed + startBlock: 17671557 # SiloV3 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Season + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: Sunrise(indexed uint256) + handler: handleSunrise + file: ../src/handlers/SeasonHandler.ts - kind: ethereum/contract name: LegacySeason-PreReplant-SeedGauge network: mainnet @@ -550,7 +572,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: PreReplant startBlock: 12974075 endBlock: 15277986 # Replanted mapping: @@ -560,12 +582,12 @@ dataSources: entities: - Season abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: PreReplant + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json eventHandlers: - event: Sunrise(indexed uint256) - handler: handleSunrise - file: ../src/handlers/SeasonHandler.ts + handler: handleSunrise_v1 + file: ../src/handlers/legacy/LegacySeasonHandler.ts - kind: ethereum/contract name: LegacySeason-Replanted-SiloV3 network: mainnet @@ -583,32 +605,10 @@ dataSources: abis: - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: Sunrise(indexed uint256) handler: handleReplantSunrise file: ../src/handlers/legacy/LegacySeasonHandler.ts - - kind: ethereum/contract - name: Season-SiloV3- - network: mainnet - source: - address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge - startBlock: 17671557 # SiloV3 - mapping: - kind: ethereum/events - apiVersion: 0.0.6 - language: wasm/assemblyscript - entities: - - Season - abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - eventHandlers: - - event: Sunrise(indexed uint256) - handler: handleSunrise - file: ../src/handlers/SeasonHandler.ts - kind: ethereum/contract name: LegacySeason-PreReplant-Reseed network: mainnet diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index 34fbec8466..ada0e96834 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -1,7 +1,6 @@ import { BigInt } from "@graphprotocol/graph-ts"; -import { Soil, WellOracle, Sunrise, Incentivization, SeedGauge } from "../../generated/Beanstalk-ABIs/SeedGauge"; -import { toDecimal, ZERO_BD } from "../../../subgraph-core/utils/Decimals"; -import { updateStalkWithCalls } from "../utils/legacy/LegacySilo"; +import { Soil, WellOracle, Sunrise, Incentivization } from "../../generated/Beanstalk-ABIs/Reseed"; +import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { loadBeanstalk, loadSeason } from "../entities/Beanstalk"; import { getBeanstalkPrice } from "../utils/contracts/BeanstalkPrice"; import { takeFieldSnapshots } from "../entities/snapshots/Field"; @@ -13,12 +12,9 @@ import { siloReceipt, sunrise } from "../utils/Season"; import { isGaugeDeployed, isReplanted } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; import { Receipt, Shipped } from "../../generated/Beanstalk-ABIs/Reseed"; +import { Beanstalk_harvestableIndex } from "../utils/contracts/Beanstalk"; export function handleSunrise(event: Sunrise): void { - // (Legacy) Update any farmers that had silo transfers from the prior season. - // This is intentionally done before beanstalk.lastSeason gets updated - updateStalkWithCalls(event.address, event.block); - sunrise(event.address, event.params.season, event.block); } @@ -64,13 +60,11 @@ export function handleSoil(event: Soil): void { export function handleIncentive(event: Incentivization): void { // Update market cap for season let beanstalk = loadBeanstalk(); - let beanstalk_contract = SeedGauge.bind(event.address); let season = loadSeason(BigInt.fromI32(beanstalk.lastSeason)); season.marketCap = season.price.times(toDecimal(season.beans)); season.incentiveBeans = event.params.beans; - // TODO: need legacy extraction here for providing no field id - season.harvestableIndex = beanstalk_contract.harvestableIndex(); + season.harvestableIndex = Beanstalk_harvestableIndex(ZERO_BI); season.save(); updateExpiredPlots(season.harvestableIndex, event.block); diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 62190b3bdf..7925590405 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -1,4 +1,3 @@ -import { BigInt, log } from "@graphprotocol/graph-ts"; import { addDeposits, removeDeposits, updateDepositInSiloAsset, updateStalkBalances } from "../utils/Silo"; import { addToSiloWhitelist, loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; import { takeSiloSnapshots } from "../entities/snapshots/Silo"; @@ -85,7 +84,7 @@ export function handlePlant(event: Plant): void { // Actual stalk credit for the farmer will be handled under the StalkBalanceChanged event. let silo = loadSilo(event.address); - let newPlantableStalk = event.params.beans.times(BI_10.pow(stalkDecimals(v()) - beanDecimals())); + let newPlantableStalk = event.params.beans.times(BI_10.pow((stalkDecimals(v()) - beanDecimals()))); // Subtract stalk since it was already added in Reward, and is about to get re-added in StalkBalanceChanged. silo.stalk = silo.stalk.minus(newPlantableStalk); diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts index 871dea8cfa..0355fd094a 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySeasonHandler.ts @@ -1,16 +1,25 @@ -import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; +import { BigDecimal } from "@graphprotocol/graph-ts"; import { REPLANT_SEASON } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal } from "../../../../subgraph-core/utils/Decimals"; -import { SeasonSnapshot, Sunrise } from "../../../generated/Beanstalk-ABIs/PreReplant"; -import { MetapoolOracle } from "../../../generated/Beanstalk-ABIs/Replanted"; +import { SeasonSnapshot, Sunrise as Sunrise_PreReplant } from "../../../generated/Beanstalk-ABIs/PreReplant"; +import { MetapoolOracle, Sunrise as Sunrise_Replanted } from "../../../generated/Beanstalk-ABIs/Replanted"; import { BeanstalkPrice_priceOnly } from "../../utils/contracts/BeanstalkPrice"; import { loadSeason } from "../../entities/Beanstalk"; import { updateStalkWithCalls } from "../../utils/legacy/LegacySilo"; import { siloReceipt, sunrise } from "../../utils/Season"; import { Reward } from "../../../generated/Beanstalk-ABIs/SeedGauge"; +// PreReplant -> Replanted +export function handleSunrise_v1(event: Sunrise_PreReplant): void { + // (Legacy) Update any farmers that had silo transfers from the prior season. + // This is intentionally done before beanstalk.lastSeason gets updated + updateStalkWithCalls(event.address, event.block); + + sunrise(event.address, event.params.season, event.block); +} + // Replanted -> SiloV3 -export function handleReplantSunrise(event: Sunrise): void { +export function handleReplantSunrise(event: Sunrise_Replanted): void { // Update any farmers that had silo transfers from the prior season. // This is intentionally done before beanstalk.lastSeason gets updated updateStalkWithCalls(event.address, event.block); diff --git a/projects/subgraph-beanstalk/src/utils/contracts/Beanstalk.ts b/projects/subgraph-beanstalk/src/utils/contracts/Beanstalk.ts new file mode 100644 index 0000000000..33c5725f22 --- /dev/null +++ b/projects/subgraph-beanstalk/src/utils/contracts/Beanstalk.ts @@ -0,0 +1,18 @@ +import { BigInt } from "@graphprotocol/graph-ts"; +import { BEANSTALK as BEANSTALK_ETH } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { SeedGauge } from "../../../generated/Beanstalk-ABIs/SeedGauge"; +import { v } from "../constants/Version"; +import { BEANSTALK as BEANSTALK_ARB } from "../../../../subgraph-core/constants/raw/BeanstalkArbConstants"; +import { Reseed } from "../../../generated/Beanstalk-ABIs/Reseed"; + +export function Beanstalk_harvestableIndex(fieldId: BigInt): BigInt { + const version = v(); + if (version.chain == "ethereum" && version.protocolAddress == BEANSTALK_ETH) { + let beanstalk_contract = SeedGauge.bind(version.protocolAddress); + return beanstalk_contract.harvestableIndex(); + } else if (version.chain == "arbitrum" && version.protocolAddress == BEANSTALK_ARB) { + let beanstalk_contract = Reseed.bind(version.protocolAddress); + return beanstalk_contract.harvestableIndex(fieldId); + } + throw new Error("Unsupported protocol"); +} From 3b4707e57b2998f4f69628bbb32c9d70e77aa5c1 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:27:30 -0700 Subject: [PATCH 42/88] update type --- projects/subgraph-beanstalk/tests/event-mocking/Season.ts | 2 +- .../subgraph-core/constants/raw/BeanstalkArbConstants.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Season.ts b/projects/subgraph-beanstalk/tests/event-mocking/Season.ts index b04656e82e..e2adc26c12 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Season.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Season.ts @@ -1,5 +1,5 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; -import { Incentivization } from "../../generated/Beanstalk-ABIs/SeedGauge"; +import { Incentivization } from "../../generated/Beanstalk-ABIs/Reseed"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; export function createSunriseEvent(season: BigInt): void {} diff --git a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts new file mode 100644 index 0000000000..1bdde62a72 --- /dev/null +++ b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts @@ -0,0 +1,5 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; + +export const BEANSTALK = Address.fromString("0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70"); + +// export const RESEED_SEASON = BigInt.fromU32(??); From 44bb42a9cee1d96832a504f11dd321f9c2026dab Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:55:30 -0700 Subject: [PATCH 43/88] Add l2 constants --- .../subgraph-beanstalk/manifests/no-apy.yaml | 4 +-- .../src/entities/Fertilizer.ts | 1 + .../constants/raw/BeanstalkArbConstants.ts | 32 ++++++++++++++++++- .../constants/raw/BeanstalkEthConstants.ts | 3 +- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index 73e263cff4..c04e085b82 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -440,8 +440,8 @@ dataSources: abis: - name: Fertilizer file: ../../subgraph-core/abis/Fertilizer.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) handler: handleTransferBatch diff --git a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts index 06cd4cfdd5..29d236f297 100644 --- a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts +++ b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts @@ -21,6 +21,7 @@ export function loadFertilizerToken(fertilizer: Fertilizer, id: BigInt, blockNum const beanstalkContract = Reseed.bind(v().protocolAddress); fertilizerToken = new FertilizerToken(id.toString()); fertilizerToken.fertilizer = fertilizer.id; + // TODO: extract legacy logic if (blockNumber.gt(BigInt.fromString("15278963"))) { fertilizerToken.humidity = BigDecimal.fromString(beanstalkContract.getCurrentHumidity().toString()).div(BigDecimal.fromString("10")); fertilizerToken.season = beanstalkContract.season().toI32(); diff --git a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts index 1bdde62a72..73ccd57948 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts @@ -1,5 +1,35 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; +// Protocol tokens +export const BEAN_ERC20 = Address.fromString("0xBEA0005B8599265D41256905A9B3073D397812E4"); +export const UNRIPE_BEAN = Address.fromString("0x1BEA054dddBca12889e07B3E076f511Bf1d27543"); +export const UNRIPE_LP = Address.fromString("0x1BEA059c3Ea15F6C10be1c53d70C75fD1266D788"); +export const BEAN_WETH = Address.fromString("0xBEA00A3F7aaF99476862533Fe7DcA4b50f6158cB"); +export const BEAN_WSTETH = Address.fromString("0xBEA0093f626Ce32dd6dA19617ba4e7aA0c3228e8"); +export const BEAN_WEETH = Address.fromString("0xBEA00865405A02215B44eaADB853d0d2192Fc29D"); +export const BEAN_WBTC = Address.fromString("0xBEA008aC57c2bEfe82E87d1D8Fb9f4784d0B73cA"); +export const BEAN_USDC = Address.fromString("0xBEA00dAf62D5549D265c5cA6D6BE87eF17881279"); +export const BEAN_USDT = Address.fromString("0xBEA00bE150FEF7560A8ff3C68D07387693Ddfd0b"); + +// External tokens +export const ARB = Address.fromString("0x912CE59144191C1204E64559FE8253a0e49E6548"); +export const WETH = Address.fromString("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"); +export const WSTETH = Address.fromString("0x5979D7b546E38E414F7E9822514be443A4800529"); +export const WEETH = Address.fromString("0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe"); +export const WBTC = Address.fromString("0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f"); +export const USDC = Address.fromString("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"); +export const USDT = Address.fromString("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"); + +// Contracts export const BEANSTALK = Address.fromString("0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70"); +////// TODO: These are subject to change +export const FERTILIZER = Address.fromString("0x2D5E484Dd7D43dFE32BF1Ed9fE6517b64F13Ea51"); +export const BEANSTALK_PRICE = Address.fromString("0xEfE94bE746681ed73DfD15F932f9a8e8ffDdEE56"); +////// +export const AQUIFER = Address.fromString("0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521"); -// export const RESEED_SEASON = BigInt.fromU32(??); +// Milestone +////// TODO: Set this upon deployment +export const RESEED_SEASON = BigInt.fromU32(30000); +export const RESEED_BLOCK = BigInt.fromU32(585858585858); +////// diff --git a/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts index 8ce21ebd52..207c582ecf 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts @@ -19,6 +19,7 @@ export const AQUIFER = Address.fromString("0xBA51AAAA95aeEFc1292515b36D86C51dC78 export const CURVE_PRICE = Address.fromString("0xA57289161FF18D67A68841922264B317170b0b81"); export const BEANSTALK_PRICE_1 = Address.fromString("0xb01CE0008CaD90104651d6A84b6B11e182a9B62A"); export const BEANSTALK_PRICE_2 = Address.fromString("0x4bed6cb142b7d474242d87f4796387deb9e1e1b4"); +export const CALCULATIONS_CURVE = Address.fromString("0x25BF7b72815476Dd515044F9650Bf79bAd0Df655"); // LP Addresses export const BEAN_3CRV_V1 = Address.fromString("0x3a70DfA7d2262988064A2D051dd47521E43c9BdD"); @@ -31,8 +32,6 @@ export const LUSD_3POOL = Address.fromString("0xEd279fDD11cA84bEef15AF5D39BB4d4b export const BEAN_WETH_CP2_WELL = Address.fromString("0xBEA0e11282e2bB5893bEcE110cF199501e872bAd"); export const BEAN_WSTETH_CP2_WELL = Address.fromString("0xBeA0000113B0d182f4064C86B71c315389E4715D"); -export const CALCULATIONS_CURVE = Address.fromString("0x25BF7b72815476Dd515044F9650Bf79bAd0Df655"); - export const REPLANT_SEASON = BigInt.fromU32(6075); // Milestone blocks From ea2a3065031b4a6e1f0dc36f1c1bc9cc288a9822 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:07:11 -0700 Subject: [PATCH 44/88] arbitrum runtime constants --- .../subgraph-core/constants/BeanstalkArb.ts | 86 +++++++++++++++++++ .../constants/RuntimeConstants.ts | 52 ++++++++--- 2 files changed, 125 insertions(+), 13 deletions(-) create mode 100644 projects/subgraph-core/constants/BeanstalkArb.ts diff --git a/projects/subgraph-core/constants/BeanstalkArb.ts b/projects/subgraph-core/constants/BeanstalkArb.ts new file mode 100644 index 0000000000..5252ab7077 --- /dev/null +++ b/projects/subgraph-core/constants/BeanstalkArb.ts @@ -0,0 +1,86 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { + BEAN_ERC20, + UNRIPE_BEAN, + UNRIPE_LP, + FERTILIZER, + BEAN_WETH, + BEAN_WSTETH, + BEANSTALK_PRICE, + RESEED_SEASON +} from "./raw/BeanstalkArbConstants"; + +/// ADDRESSES /// + +export function getProtocolToken(): Address { + return BEAN_ERC20; +} + +export function getProtocolFertilizer(): Address { + return FERTILIZER; +} + +export function getUnripeBeanAddr(): Address { + return UNRIPE_BEAN; +} + +export function getUnripeLpAddr(): Address { + return UNRIPE_LP; +} + +export function isUnripe(token: Address): boolean { + const unripeTokens = [getUnripeBeanAddr(), getUnripeLpAddr()]; + for (let i = 0; i < unripeTokens.length; ++i) { + if (unripeTokens[i] == token) { + return true; + } + } + return false; +} + +export function getTokenDecimals(token: Address): i32 { + if (token == BEAN_ERC20) { + return 6; + } else if (token == UNRIPE_BEAN) { + return 6; + } else if (token == UNRIPE_LP) { + return 6; + } else if (token == BEAN_WETH) { + return 18; + } else if (token == BEAN_WSTETH) { + return 18; + } + // TODO: need to add the rest of token decimals here + throw new Error("Unsupported token"); +} + +/// MILESTONE /// + +export function isReplanted(): boolean { + return true; +} + +export function isGaugeDeployed(): boolean { + return true; +} + +export function getUnripeUnderlying(unripeToken: Address, blockNumber: BigInt): Address { + if (unripeToken == UNRIPE_BEAN) { + return BEAN_ERC20; + } else if (unripeToken == UNRIPE_LP) { + return BEAN_WSTETH; + } + throw new Error("Unsupported unripe token"); +} + +export function getBeanstalkPriceAddress(blockNumber: BigInt): Address { + return BEANSTALK_PRICE; +} + +export function minEMASeason(): i32 { + return RESEED_SEASON.toI32(); +} + +export function stalkDecimals(): i32 { + return 16; +} diff --git a/projects/subgraph-core/constants/RuntimeConstants.ts b/projects/subgraph-core/constants/RuntimeConstants.ts index b22f9a76ce..2371d8cfed 100644 --- a/projects/subgraph-core/constants/RuntimeConstants.ts +++ b/projects/subgraph-core/constants/RuntimeConstants.ts @@ -1,6 +1,8 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; -import { BEANSTALK } from "./raw/BeanstalkEthConstants"; +import * as ConstantsEth from "./raw/BeanstalkEthConstants"; import * as BeanstalkEth from "./BeanstalkEth"; +import * as ConstantsArb from "./raw/BeanstalkArbConstants"; +import * as BeanstalkArb from "./BeanstalkArb"; /// Used to determine the appropriate constants for subgraphs at runtime /// @@ -12,43 +14,55 @@ export class VersionDto { } export function getProtocolToken(v: VersionDto, blockNumber: BigInt): Address { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.getProtocolToken(blockNumber); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.getProtocolToken(); } throw new Error("Unsupported protocol"); } export function getProtocolFertilizer(v: VersionDto): Address | null { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { + return BeanstalkEth.getProtocolFertilizer(); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { return BeanstalkEth.getProtocolFertilizer(); } throw new Error("Unsupported protocol"); } export function getUnripeBeanAddr(v: VersionDto): Address { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.getUnripeBeanAddr(); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.getUnripeBeanAddr(); } throw new Error("Unsupported protocol"); } export function getUnripeLpAddr(v: VersionDto): Address { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.getUnripeLpAddr(); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.getUnripeLpAddr(); } throw new Error("Unsupported protocol"); } export function isUnripe(v: VersionDto, token: Address): boolean { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.isUnripe(token); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.isUnripe(token); } throw new Error("Unsupported protocol"); } export function getTokenDecimals(v: VersionDto, token: Address): i32 { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.getTokenDecimals(token); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.getTokenDecimals(token); } throw new Error("Unsupported protocol"); } @@ -56,43 +70,55 @@ export function getTokenDecimals(v: VersionDto, token: Address): i32 { /// MILESTONE /// export function isReplanted(v: VersionDto, blockNumber: BigInt): boolean { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.isReplanted(blockNumber); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.isReplanted(); } throw new Error("Unsupported protocol"); } export function isGaugeDeployed(v: VersionDto, blockNumber: BigInt): boolean { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.isGaugeDeployed(blockNumber); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.isGaugeDeployed(); } throw new Error("Unsupported protocol"); } export function getUnripeUnderlying(v: VersionDto, unripeToken: Address, blockNumber: BigInt): Address { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.getUnripeUnderlying(unripeToken, blockNumber); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.getUnripeUnderlying(unripeToken, blockNumber); } throw new Error("Unsupported protocol"); } export function getBeanstalkPriceAddress(v: VersionDto, blockNumber: BigInt): Address { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.getBeanstalkPriceAddress(blockNumber); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.getBeanstalkPriceAddress(blockNumber); } throw new Error("Unsupported protocol"); } export function minEMASeason(v: VersionDto): i32 { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.minEMASeason(); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.minEMASeason(); } throw new Error("Unsupported protocol"); } export function stalkDecimals(v: VersionDto): i32 { - if (v.chain == "ethereum" && v.protocolAddress == BEANSTALK) { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.stalkDecimals(); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkArb.stalkDecimals(); } throw new Error("Unsupported protocol"); } From 9a6af5f932df01ad36d7dc314ff6a6ca78e1d251 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:41:09 -0700 Subject: [PATCH 45/88] init arb version --- .../src/utils/constants/Version.ts | 17 +++-- .../src/utils/constants/Version.ts | 17 +++-- .../src/utils/constants/Version.ts | 2 +- .../manifests/ethereum.yaml | 66 +++++++++---------- .../src/utils/constants/Version.ts | 17 +++-- .../subgraph-core/constants/BeanstalkArb.ts | 15 ++++- .../constants/raw/BeanstalkArbConstants.ts | 1 + .../constants/raw/BeanstalkEthConstants.ts | 1 + 8 files changed, 85 insertions(+), 51 deletions(-) diff --git a/projects/subgraph-basin/src/utils/constants/Version.ts b/projects/subgraph-basin/src/utils/constants/Version.ts index 202461cd99..ba751091bb 100644 --- a/projects/subgraph-basin/src/utils/constants/Version.ts +++ b/projects/subgraph-basin/src/utils/constants/Version.ts @@ -1,8 +1,9 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../../generated/schema"; -import { BEANSTALK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { VersionDto } from "../../../../subgraph-core/constants/RuntimeConstants"; import { toAddress } from "../../../../subgraph-core/utils/Bytes"; +import * as BeanstalkEth from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import * as BeanstalkArb from "../../../../subgraph-core/constants/raw/BeanstalkArbConstants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); @@ -14,22 +15,28 @@ export function handleInitVersion(block: ethereum.Block): void { } function subgraphNameForBlockNumber(blockNumber: BigInt): string { - if (blockNumber == BigInt.fromU32(17977922)) { + if (blockNumber == BeanstalkEth.BASIN_BLOCK) { + return "basin"; + } else if (blockNumber == BeanstalkArb.BASIN_BLOCK) { return "basin"; } throw new Error("Unable to initialize subgraph name for this block number"); } function protocolForBlockNumber(blockNumber: BigInt): Address { - if (blockNumber == BigInt.fromU32(12974075)) { - return BEANSTALK; + if (blockNumber == BeanstalkEth.BASIN_BLOCK) { + return BeanstalkEth.BEANSTALK; + } else if (blockNumber == BeanstalkArb.BASIN_BLOCK) { + return BeanstalkArb.BEANSTALK; } throw new Error("Unable to initialize protocol address for this block number"); } function chainForBlockNumber(blockNumber: BigInt): string { - if (blockNumber == BigInt.fromU32(17977922)) { + if (blockNumber == BeanstalkEth.BASIN_BLOCK) { return "ethereum"; + } else if (blockNumber == BeanstalkArb.BASIN_BLOCK) { + return "arbitrum"; } throw new Error("Unable to initialize chain for this block number"); } diff --git a/projects/subgraph-bean/src/utils/constants/Version.ts b/projects/subgraph-bean/src/utils/constants/Version.ts index b563e6af93..12e3507250 100644 --- a/projects/subgraph-bean/src/utils/constants/Version.ts +++ b/projects/subgraph-bean/src/utils/constants/Version.ts @@ -1,8 +1,9 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../../generated/schema"; -import { BEANSTALK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { VersionDto } from "../../../../subgraph-core/constants/RuntimeConstants"; import { toAddress } from "../../../../subgraph-core/utils/Bytes"; +import * as BeanstalkEth from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import * as BeanstalkArb from "../../../../subgraph-core/constants/raw/BeanstalkArbConstants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); @@ -14,22 +15,28 @@ export function handleInitVersion(block: ethereum.Block): void { } function subgraphNameForBlockNumber(blockNumber: BigInt): string { - if (blockNumber == BigInt.fromU32(12974075)) { + if (blockNumber == BeanstalkEth.BEANSTALK_BLOCK) { + return "bean"; + } else if (blockNumber == BeanstalkArb.RESEED_BLOCK) { return "bean"; } throw new Error("Unable to initialize subgraph name for this block number"); } function protocolForBlockNumber(blockNumber: BigInt): Address { - if (blockNumber == BigInt.fromU32(12974075)) { - return BEANSTALK; + if (blockNumber == BeanstalkEth.BEANSTALK_BLOCK) { + return BeanstalkEth.BEANSTALK; + } else if (blockNumber == BeanstalkArb.RESEED_BLOCK) { + return BeanstalkArb.BEANSTALK; } throw new Error("Unable to initialize protocol address for this block number"); } function chainForBlockNumber(blockNumber: BigInt): string { - if (blockNumber == BigInt.fromU32(12974075)) { + if (blockNumber == BeanstalkEth.BEANSTALK_BLOCK) { return "ethereum"; + } else if (blockNumber == BeanstalkArb.RESEED_BLOCK) { + return "arbitrum"; } throw new Error("Unable to initialize chain for this block number"); } diff --git a/projects/subgraph-beanft/src/utils/constants/Version.ts b/projects/subgraph-beanft/src/utils/constants/Version.ts index c41656425c..4fe3aa2c2b 100644 --- a/projects/subgraph-beanft/src/utils/constants/Version.ts +++ b/projects/subgraph-beanft/src/utils/constants/Version.ts @@ -21,7 +21,7 @@ function subgraphNameForBlockNumber(blockNumber: BigInt): string { } function protocolForBlockNumber(blockNumber: BigInt): Address { - if (blockNumber == BigInt.fromU32(12974075)) { + if (blockNumber == BigInt.fromU32(13323594)) { return BEANSTALK; } throw new Error("Unable to initialize protocol address for this block number"); diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index 371bffe5bf..1c8fc2908d 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -588,11 +588,11 @@ dataSources: # FIELD ### - kind: ethereum/contract - name: Field + name: LegacyField-PreReplant-Reseed network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: Reseed + abi: SeedGauge startBlock: 12974075 # Field has all-time support mapping: kind: ethereum/events @@ -601,8 +601,8 @@ dataSources: entities: - Field abis: - - name: Reseed - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - name: CurvePrice file: ../../subgraph-core/abis/CurvePrice.json - name: BeanstalkPrice @@ -773,8 +773,8 @@ dataSources: abis: - name: Fertilizer file: ../../subgraph-core/abis/Fertilizer.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) handler: handleTransferBatch @@ -822,6 +822,8 @@ dataSources: abis: - name: Reseed file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: SeedGauge # Needed for call to get harvestable index + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json eventHandlers: @@ -832,6 +834,26 @@ dataSources: - event: Incentivization(indexed address,uint256) handler: handleIncentive file: ../src/handlers/SeasonHandler.ts + - kind: ethereum/contract + name: Season-SiloV3-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: Reseed + startBlock: 17671557 # SiloV3 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Season + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: Sunrise(indexed uint256) + handler: handleSunrise + file: ../src/handlers/SeasonHandler.ts - kind: ethereum/contract name: LegacySeason-PreReplant-SeedGauge network: mainnet @@ -883,7 +905,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge + abi: PreReplant startBlock: 12974075 endBlock: 15277986 # Replanted mapping: @@ -893,12 +915,12 @@ dataSources: entities: - Season abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: PreReplant + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json eventHandlers: - event: Sunrise(indexed uint256) - handler: handleSunrise - file: ../src/handlers/SeasonHandler.ts + handler: handleSunrise_v1 + file: ../src/handlers/legacy/LegacySeasonHandler.ts - kind: ethereum/contract name: LegacySeason-Replanted-SiloV3 network: mainnet @@ -916,32 +938,10 @@ dataSources: abis: - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: Sunrise(indexed uint256) handler: handleReplantSunrise file: ../src/handlers/legacy/LegacySeasonHandler.ts - - kind: ethereum/contract - name: Season-SiloV3- - network: mainnet - source: - address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: SeedGauge - startBlock: 17671557 # SiloV3 - mapping: - kind: ethereum/events - apiVersion: 0.0.6 - language: wasm/assemblyscript - entities: - - Season - abis: - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - eventHandlers: - - event: Sunrise(indexed uint256) - handler: handleSunrise - file: ../src/handlers/SeasonHandler.ts - kind: ethereum/contract name: LegacySeason-PreReplant-Reseed network: mainnet diff --git a/projects/subgraph-beanstalk/src/utils/constants/Version.ts b/projects/subgraph-beanstalk/src/utils/constants/Version.ts index 48dd38bd52..2bb739d91e 100644 --- a/projects/subgraph-beanstalk/src/utils/constants/Version.ts +++ b/projects/subgraph-beanstalk/src/utils/constants/Version.ts @@ -1,8 +1,9 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Version } from "../../../generated/schema"; -import { BEANSTALK } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { VersionDto } from "../../../../subgraph-core/constants/RuntimeConstants"; import { toAddress } from "../../../../subgraph-core/utils/Bytes"; +import * as BeanstalkEth from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import * as BeanstalkArb from "../../../../subgraph-core/constants/raw/BeanstalkArbConstants"; export function handleInitVersion(block: ethereum.Block): void { const versionEntity = new Version("subgraph"); @@ -14,22 +15,28 @@ export function handleInitVersion(block: ethereum.Block): void { } function subgraphNameForBlockNumber(blockNumber: BigInt): string { - if (blockNumber == BigInt.fromU32(12974075)) { + if (blockNumber == BeanstalkEth.BEANSTALK_BLOCK) { + return "beanstalk"; + } else if (blockNumber == BeanstalkArb.RESEED_BLOCK) { return "beanstalk"; } throw new Error("Unable to initialize subgraph name for this block number"); } function protocolForBlockNumber(blockNumber: BigInt): Address { - if (blockNumber == BigInt.fromU32(12974075)) { - return BEANSTALK; + if (blockNumber == BeanstalkEth.BEANSTALK_BLOCK) { + return BeanstalkEth.BEANSTALK; + } else if (blockNumber == BeanstalkArb.RESEED_BLOCK) { + return BeanstalkArb.BEANSTALK; } throw new Error("Unable to initialize protocol address for this block number"); } function chainForBlockNumber(blockNumber: BigInt): string { - if (blockNumber == BigInt.fromU32(12974075)) { + if (blockNumber == BeanstalkEth.BEANSTALK_BLOCK) { return "ethereum"; + } else if (blockNumber == BeanstalkArb.RESEED_BLOCK) { + return "arbitrum"; } throw new Error("Unable to initialize chain for this block number"); } diff --git a/projects/subgraph-core/constants/BeanstalkArb.ts b/projects/subgraph-core/constants/BeanstalkArb.ts index 5252ab7077..544d2451f6 100644 --- a/projects/subgraph-core/constants/BeanstalkArb.ts +++ b/projects/subgraph-core/constants/BeanstalkArb.ts @@ -7,7 +7,11 @@ import { BEAN_WETH, BEAN_WSTETH, BEANSTALK_PRICE, - RESEED_SEASON + RESEED_SEASON, + BEAN_WEETH, + BEAN_WBTC, + BEAN_USDC, + BEAN_USDT } from "./raw/BeanstalkArbConstants"; /// ADDRESSES /// @@ -49,8 +53,15 @@ export function getTokenDecimals(token: Address): i32 { return 18; } else if (token == BEAN_WSTETH) { return 18; + } else if (token == BEAN_WEETH) { + return 18; + } else if (token == BEAN_WBTC) { + return 18; + } else if (token == BEAN_USDC) { + return 18; + } else if (token == BEAN_USDT) { + return 18; } - // TODO: need to add the rest of token decimals here throw new Error("Unsupported token"); } diff --git a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts index 73ccd57948..8603655da7 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts @@ -32,4 +32,5 @@ export const AQUIFER = Address.fromString("0xBA51AAAa8C2f911AE672e783707Ceb2dA6E ////// TODO: Set this upon deployment export const RESEED_SEASON = BigInt.fromU32(30000); export const RESEED_BLOCK = BigInt.fromU32(585858585858); +export const BASIN_BLOCK = BigInt.fromU32(585858585858); ////// diff --git a/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts index 207c582ecf..45fab40be4 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts @@ -39,6 +39,7 @@ export const BEANSTALK_BLOCK = BigInt.fromU32(12974075); export const EXPLOIT_BLOCK = BigInt.fromU32(14602790); export const NEW_BEAN_TOKEN_BLOCK = BigInt.fromU32(15278082); export const REPLANT_SUNRISE_BLOCK = BigInt.fromU32(15289934); +export const BASIN_BLOCK = BigInt.fromU32(17977922); export const GAUGE_BIP45_BLOCK = BigInt.fromU32(19927634); export const BEAN_WETH_CP2_WELL_BLOCK = BigInt.fromU32(17978134); From 0a343c8bab77ea1bc7ce50f7ca7b62cb4e20f543 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:43:48 -0700 Subject: [PATCH 46/88] set fictitious deployment block --- .../manifests/arbitrum.yaml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml index e031622839..4c48cc2918 100644 --- a/projects/subgraph-beanstalk/manifests/arbitrum.yaml +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -16,8 +16,8 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 1 # TODO: set this to the contract deployment block - endBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 + endBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -41,7 +41,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -80,7 +80,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -119,7 +119,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -150,7 +150,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -183,7 +183,7 @@ dataSources: source: address: "0x2D5E484Dd7D43dFE32BF1Ed9fE6517b64F13Ea51" abi: Fertilizer - startBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -207,7 +207,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -232,7 +232,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -265,7 +265,7 @@ dataSources: source: address: "0xBEA0005B8599265D41256905A9B3073D397812E4" abi: ERC20 - startBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -288,7 +288,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 1 # TODO: set this to the contract deployment block + startBlock: 585858585858 mapping: kind: ethereum/events apiVersion: 0.0.6 From d0efc386982f28c4e57556ce97be1ac1687197dd Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:50:05 -0700 Subject: [PATCH 47/88] fix replant milestone --- projects/subgraph-beanstalk/src/entities/Fertilizer.ts | 4 ++-- projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts | 2 +- projects/subgraph-core/constants/BeanstalkEth.ts | 3 ++- projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts index 29d236f297..238125f6dd 100644 --- a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts +++ b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts @@ -3,6 +3,7 @@ import { Farmer, Fertilizer, FertilizerBalance, FertilizerToken, FertilizerYield import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { Reseed } from "../../generated/Beanstalk-ABIs/Reseed"; import { v } from "../utils/constants/Version"; +import { isReplanted } from "../../../subgraph-core/constants/RuntimeConstants"; export function loadFertilizer(fertilizerAddress: Address): Fertilizer { let fertilizer = Fertilizer.load(fertilizerAddress); @@ -21,8 +22,7 @@ export function loadFertilizerToken(fertilizer: Fertilizer, id: BigInt, blockNum const beanstalkContract = Reseed.bind(v().protocolAddress); fertilizerToken = new FertilizerToken(id.toString()); fertilizerToken.fertilizer = fertilizer.id; - // TODO: extract legacy logic - if (blockNumber.gt(BigInt.fromString("15278963"))) { + if (isReplanted(v(), blockNumber)) { fertilizerToken.humidity = BigDecimal.fromString(beanstalkContract.getCurrentHumidity().toString()).div(BigDecimal.fromString("10")); fertilizerToken.season = beanstalkContract.season().toI32(); fertilizerToken.startBpf = beanstalkContract.beansPerFertilizer(); diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index ada0e96834..8f0cfecc97 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -51,7 +51,7 @@ export function handleSoil(event: Soil): void { takeFieldSnapshots(field, event.block); field.save(); - if (isReplanted(v(), event.params.season)) { + if (isReplanted(v(), event.block.number)) { updateBeanEMA(event.address, event.block.timestamp); } } diff --git a/projects/subgraph-core/constants/BeanstalkEth.ts b/projects/subgraph-core/constants/BeanstalkEth.ts index ebf308e75b..6191498a0e 100644 --- a/projects/subgraph-core/constants/BeanstalkEth.ts +++ b/projects/subgraph-core/constants/BeanstalkEth.ts @@ -16,6 +16,7 @@ import { GAUGE_BIP45_BLOCK, NEW_BEAN_TOKEN_BLOCK, PRICE_2_BLOCK, + REPLANT_BLOCK, REPLANT_SEASON, UNRIPE_BEAN, UNRIPE_LP @@ -81,7 +82,7 @@ export function getTokenDecimals(token: Address): i32 { /// MILESTONE /// export function isReplanted(blockNumber: BigInt): boolean { - return blockNumber >= REPLANT_SEASON; + return blockNumber >= REPLANT_BLOCK; } export function isGaugeDeployed(blockNumber: BigInt): boolean { diff --git a/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts index 45fab40be4..ec68c7b8f3 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts @@ -38,6 +38,7 @@ export const REPLANT_SEASON = BigInt.fromU32(6075); export const BEANSTALK_BLOCK = BigInt.fromU32(12974075); export const EXPLOIT_BLOCK = BigInt.fromU32(14602790); export const NEW_BEAN_TOKEN_BLOCK = BigInt.fromU32(15278082); +export const REPLANT_BLOCK = BigInt.fromU32(15278963); export const REPLANT_SUNRISE_BLOCK = BigInt.fromU32(15289934); export const BASIN_BLOCK = BigInt.fromU32(17977922); export const GAUGE_BIP45_BLOCK = BigInt.fromU32(19927634); From bb26fdb9a4e20acc8d2516d4eaecf45e56142586 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:02:01 -0700 Subject: [PATCH 48/88] basin arbitrum yaml --- .../subgraph-basin/manifests/arbitrum.yaml | 109 ++++++++++++++++++ .../constants/raw/BeanstalkArbConstants.ts | 4 +- 2 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 projects/subgraph-basin/manifests/arbitrum.yaml diff --git a/projects/subgraph-basin/manifests/arbitrum.yaml b/projects/subgraph-basin/manifests/arbitrum.yaml new file mode 100644 index 0000000000..2256f172e6 --- /dev/null +++ b/projects/subgraph-basin/manifests/arbitrum.yaml @@ -0,0 +1,109 @@ +specVersion: 0.0.9 +schema: + file: ../schema.graphql +dataSources: + ### + # INITIALIZATION + ### + - kind: ethereum/contract + name: Version + network: arbitrum-one + source: + address: "0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521" + abi: Aquifer + startBlock: 393939393939 + endBlock: 393939393939 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Version + abis: + - name: Aquifer + file: ../../subgraph-core/abis/Aquifer.json + blockHandlers: + - handler: handleInitVersion + filter: + kind: once + file: ../src/utils/constants/Version.ts + - kind: ethereum/contract + name: Aquifer + network: arbitrum-one + source: + address: "0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521" + abi: Aquifer + startBlock: 393939393939 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Aquifer + abis: + - name: Aquifer + file: ../../subgraph-core/abis/Aquifer.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + eventHandlers: + - event: BoreWell(address,address,address[],(address,bytes),(address,bytes)[],bytes) + handler: handleBoreWell + file: ../src/templates/AquiferHandler.ts + - kind: ethereum/contract + name: Beanstalk + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Beanstalk + startBlock: 393939393939 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Beanstalk + abis: + - name: Beanstalk + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: Sunrise(indexed uint256) + handler: handleSunrise + file: ../src/BeanstalkHandler.ts +templates: + - kind: ethereum/contract + name: Well + network: arbitrum-one + source: + abi: Well + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Well + abis: + - name: Well + file: ../../subgraph-core/abis/Well.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + eventHandlers: + - event: AddLiquidity(uint256[],uint256,address) + handler: handleAddLiquidity + - event: RemoveLiquidity(uint256,uint256[],address) + handler: handleRemoveLiquidity + - event: RemoveLiquidityOneToken(uint256,address,uint256,address) + handler: handleRemoveLiquidityOneToken + - event: Swap(address,address,uint256,uint256,address) + handler: handleSwap + - event: Shift(uint256[],address,uint256,address) + handler: handleShift + - event: Sync(uint256[],uint256,address) + handler: handleSync + file: ../src/WellHandler.ts +# features: +# - grafting +# graft: +# base: QmWHi6hu2wXnyxBHHmQHwCQLoq5KkoTX2qLm8MdyVXTyTu +# block: 20216425 diff --git a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts index 8603655da7..6c9776b287 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts @@ -31,6 +31,6 @@ export const AQUIFER = Address.fromString("0xBA51AAAa8C2f911AE672e783707Ceb2dA6E // Milestone ////// TODO: Set this upon deployment export const RESEED_SEASON = BigInt.fromU32(30000); -export const RESEED_BLOCK = BigInt.fromU32(585858585858); -export const BASIN_BLOCK = BigInt.fromU32(585858585858); +export const RESEED_BLOCK = BigInt.fromU64(585858585858); +export const BASIN_BLOCK = BigInt.fromU64(393939393939); ////// From 01274b3d2987a06ea8b51317849300fb83807164 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:35:15 -0700 Subject: [PATCH 49/88] refactor basin subgraph for arb --- .../subgraph-basin/src/BeanstalkHandler.ts | 5 +-- .../src/utils/BeanstalkPrice.ts | 31 +++++++++++++------ projects/subgraph-basin/src/utils/Token.ts | 31 ++++++------------- projects/subgraph-basin/src/utils/Well.ts | 8 +++-- projects/subgraph-basin/tests/Aquifer.test.ts | 2 ++ .../tests/DepositWithdrawEntity.test.ts | 2 ++ .../subgraph-basin/tests/Exchange.test.ts | 2 ++ .../subgraph-basin/tests/Liquidity.test.ts | 2 ++ .../subgraph-basin/tests/SwapEntity.test.ts | 2 ++ .../tests/entity-mocking/MockVersion.ts | 7 +++++ .../subgraph-basin/tests/helpers/Liquidity.ts | 7 ++++- projects/subgraph-basin/tests/helpers/Swap.ts | 4 ++- .../tests/entity-mocking/MockVersion.ts | 4 +-- .../subgraph-core/constants/BeanstalkArb.ts | 7 ++++- .../subgraph-core/constants/BeanstalkEth.ts | 5 +++ .../constants/RuntimeConstants.ts | 9 ++++++ 16 files changed, 88 insertions(+), 40 deletions(-) create mode 100644 projects/subgraph-basin/tests/entity-mocking/MockVersion.ts diff --git a/projects/subgraph-basin/src/BeanstalkHandler.ts b/projects/subgraph-basin/src/BeanstalkHandler.ts index 7a4bbee916..24522d5734 100644 --- a/projects/subgraph-basin/src/BeanstalkHandler.ts +++ b/projects/subgraph-basin/src/BeanstalkHandler.ts @@ -1,14 +1,15 @@ import { Address } from "@graphprotocol/graph-ts"; -import { AQUIFER } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { Sunrise } from "../generated/Basin-ABIs/Beanstalk"; import { loadOrCreateAquifer } from "./utils/Aquifer"; import { checkForSnapshot } from "./utils/Well"; +import { getAquifer } from "../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./utils/constants/Version"; export function handleSunrise(event: Sunrise): void { // Right now this is a manual list of aquifers that are checked for deployments and wells updated // Keeping this manual is reasonable as each aquifer has to be defined as a datasource in subgraph.yaml - let aquifer = loadOrCreateAquifer(AQUIFER); + let aquifer = loadOrCreateAquifer(getAquifer(v())); for (let i = 0; i < aquifer.wells.length; i++) { checkForSnapshot(Address.fromBytes(aquifer.wells[i]), event.block.timestamp, event.block.number); diff --git a/projects/subgraph-basin/src/utils/BeanstalkPrice.ts b/projects/subgraph-basin/src/utils/BeanstalkPrice.ts index c27b9bcdf4..b4198e9a55 100644 --- a/projects/subgraph-basin/src/utils/BeanstalkPrice.ts +++ b/projects/subgraph-basin/src/utils/BeanstalkPrice.ts @@ -1,17 +1,30 @@ // Unfortunately this file must be copied across the various subgraph projects. This is due to the codegen -import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { BeanstalkPrice } from "../../generated/Basin-ABIs/BeanstalkPrice"; -import { BEANSTALK_PRICE_1, BEANSTALK_PRICE_2, PRICE_2_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { getBeanstalkPriceAddress } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./constants/Version"; +import { toDecimal } from "../../../subgraph-core/utils/Decimals"; +import { CurvePrice } from "../../generated/Basin-ABIs/CurvePrice"; +import { CURVE_PRICE } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; // Gets the BeanstalkPrice contract, bound to the appropriate instance of the contract. -// Note: Will bind to PRICE_1 even if that contract has not been deployed yet -// Thus the caller still needs to check for reverts. export function getBeanstalkPrice(blockNumber: BigInt): BeanstalkPrice { - let contractAddress: Address; - if (blockNumber < PRICE_2_BLOCK) { - contractAddress = BEANSTALK_PRICE_1; + return BeanstalkPrice.bind(getBeanstalkPriceAddress(v(), blockNumber)); +} + +export function getBeanPrice(blockNumber: BigInt): BigDecimal | null { + let beanstalkPrice = getBeanstalkPrice(blockNumber); + let price = beanstalkPrice.try_price(); + if (!price.reverted) { + return toDecimal(price.value.price); } else { - contractAddress = BEANSTALK_PRICE_2; + // Fetch price on Curve + let curvePrice = CurvePrice.bind(CURVE_PRICE); + let curve = curvePrice.try_getCurve(); + + if (curve.reverted) { + return null; + } + return toDecimal(curve.value.price); } - return BeanstalkPrice.bind(contractAddress); } diff --git a/projects/subgraph-basin/src/utils/Token.ts b/projects/subgraph-basin/src/utils/Token.ts index 69ac8b4021..b48b948136 100644 --- a/projects/subgraph-basin/src/utils/Token.ts +++ b/projects/subgraph-basin/src/utils/Token.ts @@ -1,10 +1,10 @@ import { Address, BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; import { ERC20 } from "../../generated/Basin-ABIs/ERC20"; import { Token } from "../../generated/schema"; -import { CurvePrice } from "../../generated/Basin-ABIs/CurvePrice"; -import { BEAN_ERC20, CURVE_PRICE } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; -import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { getBeanstalkPrice } from "./BeanstalkPrice"; +import { BI_MAX, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { getBeanPrice } from "./BeanstalkPrice"; +import { getProtocolToken } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./constants/Version"; export function loadOrCreateToken(tokenAddress: Address): Token { let token = Token.load(tokenAddress); @@ -45,7 +45,7 @@ export function loadToken(tokenAddress: Address): Token { } export function getBeanPriceUDSC(): BigDecimal { - let token = loadToken(BEAN_ERC20); + let token = loadToken(getProtocolToken(v(), BI_MAX)); return token.lastPriceUSD; } @@ -56,23 +56,12 @@ export function getTokenDecimals(tokenAddress: Address): i32 { export function updateTokenUSD(tokenAddress: Address, blockNumber: BigInt, beanPrice: BigDecimal = ZERO_BD): void { let token = loadToken(tokenAddress); - if (tokenAddress == BEAN_ERC20) { - // Attempt to use Beanstalk price contract first - - let beanstalkPrice = getBeanstalkPrice(blockNumber); - let price = beanstalkPrice.try_price(); - if (!price.reverted) { - token.lastPriceUSD = toDecimal(price.value.price); - } else { - // Fetch price on Curve - let curvePrice = CurvePrice.bind(CURVE_PRICE); - let curve = curvePrice.try_getCurve(); - - if (curve.reverted) { - return; - } - token.lastPriceUSD = toDecimal(curve.value.price); + if (tokenAddress == getProtocolToken(v(), BI_MAX)) { + const beanPrice = getBeanPrice(blockNumber); + if (beanPrice === null) { + return; } + token.lastPriceUSD = beanPrice; } else { token.lastPriceUSD = beanPrice.times(getBeanPriceUDSC()); } diff --git a/projects/subgraph-basin/src/utils/Well.ts b/projects/subgraph-basin/src/utils/Well.ts index 1ee559b690..bf4e00bef4 100644 --- a/projects/subgraph-basin/src/utils/Well.ts +++ b/projects/subgraph-basin/src/utils/Well.ts @@ -2,7 +2,6 @@ import { Address, BigDecimal, BigInt, Bytes, log } from "@graphprotocol/graph-ts import { BoreWellWellFunctionStruct } from "../../generated/Basin-ABIs/Aquifer"; import { Well, WellDailySnapshot, WellFunction, WellHourlySnapshot } from "../../generated/schema"; import { ERC20 } from "../../generated/Basin-ABIs/ERC20"; -import { BEAN_ERC20 } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates"; import { deltaBigDecimalArray, @@ -15,6 +14,8 @@ import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { getTokenDecimals, loadToken, updateTokenUSD } from "./Token"; +import { getProtocolToken } from "../../../subgraph-core/constants/RuntimeConstants"; +import { v } from "./constants/Version"; export function createWell(wellAddress: Address, implementation: Address, inputTokens: Address[]): Well { let well = Well.load(wellAddress); @@ -135,8 +136,9 @@ export function updateWellTokenUSDPrices(wellAddress: Address, blockNumber: BigI let well = loadWell(wellAddress); // Update the BEAN price first as it is the reference for other USD calculations - updateTokenUSD(BEAN_ERC20, blockNumber, BigDecimal.fromString("1")); - let beanIndex = well.tokens.indexOf(BEAN_ERC20); + const beanToken = getProtocolToken(v(), blockNumber); + updateTokenUSD(beanToken, blockNumber, BigDecimal.fromString("1")); + let beanIndex = well.tokens.indexOf(beanToken); // Curretly only supporting USD values for Wells with BEAN as a token. if (beanIndex == -1) { return; diff --git a/projects/subgraph-basin/tests/Aquifer.test.ts b/projects/subgraph-basin/tests/Aquifer.test.ts index db7e0a8d3e..d79ee0b040 100644 --- a/projects/subgraph-basin/tests/Aquifer.test.ts +++ b/projects/subgraph-basin/tests/Aquifer.test.ts @@ -2,9 +2,11 @@ import { afterEach, assert, beforeEach, clearStore, describe, test } from "match import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { boreDefaultWell } from "./helpers/Aquifer"; import { AQUIFER, PUMP, WELL } from "./helpers/Constants"; +import { initL1Version } from "./entity-mocking/MockVersion"; describe("Aquifer Well Deployment", () => { beforeEach(() => { + initL1Version(); boreDefaultWell(); }); diff --git a/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts b/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts index 967048b847..e3a3baa447 100644 --- a/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts +++ b/projects/subgraph-basin/tests/DepositWithdrawEntity.test.ts @@ -16,9 +16,11 @@ import { boreDefaultWell } from "./helpers/Aquifer"; import { mockAddLiquidity, mockRemoveLiquidity, mockRemoveLiquidityOneBean, loadWithdraw, mockSync } from "./helpers/Liquidity"; import { loadDeposit } from "./helpers/Liquidity"; import { BigInt } from "@graphprotocol/graph-ts"; +import { initL1Version } from "./entity-mocking/MockVersion"; describe("Deposit/Withdraw Entities", () => { beforeEach(() => { + initL1Version(); boreDefaultWell(); }); diff --git a/projects/subgraph-basin/tests/Exchange.test.ts b/projects/subgraph-basin/tests/Exchange.test.ts index 8a628b5cc7..b328c30715 100644 --- a/projects/subgraph-basin/tests/Exchange.test.ts +++ b/projects/subgraph-basin/tests/Exchange.test.ts @@ -18,9 +18,11 @@ import { mockAddLiquidity } from "./helpers/Liquidity"; import { dayFromTimestamp, hourFromTimestamp } from "../../subgraph-core/utils/Dates"; import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { BEAN_ERC20 } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { initL1Version } from "./entity-mocking/MockVersion"; describe("Well Entity: Exchange Tests", () => { beforeEach(() => { + initL1Version(); boreDefaultWell(); }); diff --git a/projects/subgraph-basin/tests/Liquidity.test.ts b/projects/subgraph-basin/tests/Liquidity.test.ts index 9462bf7d7f..3e0a894cf4 100644 --- a/projects/subgraph-basin/tests/Liquidity.test.ts +++ b/projects/subgraph-basin/tests/Liquidity.test.ts @@ -23,6 +23,7 @@ import { BigDecimal_max, BigDecimal_min } from "../../subgraph-core/utils/ArrayM import { calcLiquidityVolume } from "../src/utils/VolumeCP"; import { loadToken } from "../src/utils/Token"; import { BEAN_ERC20, WETH } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { initL1Version } from "./entity-mocking/MockVersion"; const BI_2 = BigInt.fromU32(2); const BI_3 = BigInt.fromU32(3); @@ -46,6 +47,7 @@ function assignUSD(tokenAmounts: BigInt[]): BigDecimal[] { describe("Well Entity: Liquidity Event Tests", () => { beforeEach(() => { + initL1Version(); boreDefaultWell(); }); diff --git a/projects/subgraph-basin/tests/SwapEntity.test.ts b/projects/subgraph-basin/tests/SwapEntity.test.ts index 152f47f69e..519d2a9676 100644 --- a/projects/subgraph-basin/tests/SwapEntity.test.ts +++ b/projects/subgraph-basin/tests/SwapEntity.test.ts @@ -6,9 +6,11 @@ import { mockShift, mockSwap } from "./helpers/Swap"; import { mockAddLiquidity } from "./helpers/Liquidity"; import { BigInt } from "@graphprotocol/graph-ts"; import { BI_10 } from "../../subgraph-core/utils/Decimals"; +import { initL1Version } from "./entity-mocking/MockVersion"; describe("Swap Entity", () => { beforeEach(() => { + initL1Version(); boreDefaultWell(); }); diff --git a/projects/subgraph-basin/tests/entity-mocking/MockVersion.ts b/projects/subgraph-basin/tests/entity-mocking/MockVersion.ts new file mode 100644 index 0000000000..6d185774fb --- /dev/null +++ b/projects/subgraph-basin/tests/entity-mocking/MockVersion.ts @@ -0,0 +1,7 @@ +import { BASIN_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { mockBlock } from "../../../subgraph-core/tests/event-mocking/Block"; +import { handleInitVersion } from "../../src/utils/constants/Version"; + +export function initL1Version(): void { + handleInitVersion(mockBlock(BASIN_BLOCK)); +} diff --git a/projects/subgraph-basin/tests/helpers/Liquidity.ts b/projects/subgraph-basin/tests/helpers/Liquidity.ts index 6b2ad41c3f..e0399b97f2 100644 --- a/projects/subgraph-basin/tests/helpers/Liquidity.ts +++ b/projects/subgraph-basin/tests/helpers/Liquidity.ts @@ -1,6 +1,6 @@ import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; import { Deposit, Withdraw } from "../../generated/schema"; -import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { BASIN_BLOCK, BEAN_ERC20, WETH } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { handleAddLiquidity, handleRemoveLiquidity, handleRemoveLiquidityOneToken, handleSync } from "../../src/WellHandler"; import { BEAN_SWAP_AMOUNT, SWAP_ACCOUNT, WELL, WELL_LP_AMOUNT, WETH_SWAP_AMOUNT } from "./Constants"; import { createContractCallMocks } from "./Functions"; @@ -13,6 +13,7 @@ export function mockAddLiquidity( ): string { createContractCallMocks(beanPriceMultiple); let newEvent = createAddLiquidityEvent(WELL, SWAP_ACCOUNT, WELL_LP_AMOUNT, tokenAmounts); + newEvent.block.number = BASIN_BLOCK; handleAddLiquidity(newEvent); return newEvent.transaction.hash.toHexString() + "-" + newEvent.logIndex.toString(); } @@ -20,6 +21,7 @@ export function mockAddLiquidity( export function mockRemoveLiquidity(tokenAmounts: BigInt[] = [BEAN_SWAP_AMOUNT, WETH_SWAP_AMOUNT]): string { createContractCallMocks(); let newEvent = createRemoveLiquidityEvent(WELL, SWAP_ACCOUNT, WELL_LP_AMOUNT, tokenAmounts); + newEvent.block.number = BASIN_BLOCK; handleRemoveLiquidity(newEvent); return newEvent.transaction.hash.toHexString() + "-" + newEvent.logIndex.toString(); } @@ -27,6 +29,7 @@ export function mockRemoveLiquidity(tokenAmounts: BigInt[] = [BEAN_SWAP_AMOUNT, export function mockRemoveLiquidityOneBean(): string { createContractCallMocks(); let newEvent = createRemoveLiquidityOneTokenEvent(WELL, SWAP_ACCOUNT, WELL_LP_AMOUNT, BEAN_ERC20, BEAN_SWAP_AMOUNT); + newEvent.block.number = BASIN_BLOCK; handleRemoveLiquidityOneToken(newEvent); return newEvent.transaction.hash.toHexString() + "-" + newEvent.logIndex.toString(); } @@ -34,6 +37,7 @@ export function mockRemoveLiquidityOneBean(): string { export function mockRemoveLiquidityOneWeth(beanPriceMultiple: BigDecimal = ONE_BD): string { createContractCallMocks(beanPriceMultiple); let newEvent = createRemoveLiquidityOneTokenEvent(WELL, SWAP_ACCOUNT, WELL_LP_AMOUNT, WETH, WETH_SWAP_AMOUNT); + newEvent.block.number = BASIN_BLOCK; handleRemoveLiquidityOneToken(newEvent); return newEvent.transaction.hash.toHexString() + "-" + newEvent.logIndex.toString(); } @@ -41,6 +45,7 @@ export function mockRemoveLiquidityOneWeth(beanPriceMultiple: BigDecimal = ONE_B export function mockSync(newReserves: BigInt[], lpAmountOut: BigInt, beanPriceMultiple: BigDecimal = ONE_BD): string { createContractCallMocks(beanPriceMultiple); let newSyncEvent = createSyncEvent(WELL, SWAP_ACCOUNT, newReserves, lpAmountOut); + newSyncEvent.block.number = BASIN_BLOCK; handleSync(newSyncEvent); return newSyncEvent.transaction.hash.toHexString() + "-" + newSyncEvent.logIndex.toString(); } diff --git a/projects/subgraph-basin/tests/helpers/Swap.ts b/projects/subgraph-basin/tests/helpers/Swap.ts index 401e8a983c..89d0cd5701 100644 --- a/projects/subgraph-basin/tests/helpers/Swap.ts +++ b/projects/subgraph-basin/tests/helpers/Swap.ts @@ -1,5 +1,5 @@ import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; -import { BEAN_ERC20, WETH } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { BASIN_BLOCK, BEAN_ERC20, WETH } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { handleShift, handleSwap } from "../../src/WellHandler"; import { BEAN_SWAP_AMOUNT, SWAP_ACCOUNT, WELL, WETH_SWAP_AMOUNT } from "./Constants"; import { createContractCallMocks } from "./Functions"; @@ -9,6 +9,7 @@ import { ONE_BD } from "../../../subgraph-core/utils/Decimals"; export function mockSwap(beanPriceMultiple: BigDecimal = ONE_BD): string { createContractCallMocks(beanPriceMultiple); let newSwapEvent = createSwapEvent(WELL, SWAP_ACCOUNT, BEAN_ERC20, WETH, BEAN_SWAP_AMOUNT, WETH_SWAP_AMOUNT); + newSwapEvent.block.number = BASIN_BLOCK; handleSwap(newSwapEvent); return newSwapEvent.transaction.hash.toHexString() + "-" + newSwapEvent.logIndex.toString(); } @@ -16,6 +17,7 @@ export function mockSwap(beanPriceMultiple: BigDecimal = ONE_BD): string { export function mockShift(newReserves: BigInt[], toToken: Address, amountOut: BigInt, beanPriceMultiple: BigDecimal = ONE_BD): string { createContractCallMocks(beanPriceMultiple); let newShiftEvent = createShiftEvent(WELL, SWAP_ACCOUNT, newReserves, toToken, amountOut); + newShiftEvent.block.number = BASIN_BLOCK; handleShift(newShiftEvent); return newShiftEvent.transaction.hash.toHexString() + "-" + newShiftEvent.logIndex.toString(); } diff --git a/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts b/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts index bfc1a8a7dc..b1fa5aa34f 100644 --- a/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts +++ b/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts @@ -1,7 +1,7 @@ -import { BigInt } from "@graphprotocol/graph-ts"; import { handleInitVersion } from "../../src/utils/constants/Version"; import { mockBlock } from "../../../subgraph-core/tests/event-mocking/Block"; +import { BEANSTALK_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; export function initL1Version(): void { - handleInitVersion(mockBlock(BigInt.fromU32(12974075))); + handleInitVersion(mockBlock(BEANSTALK_BLOCK)); } diff --git a/projects/subgraph-core/constants/BeanstalkArb.ts b/projects/subgraph-core/constants/BeanstalkArb.ts index 544d2451f6..b00f3a2b03 100644 --- a/projects/subgraph-core/constants/BeanstalkArb.ts +++ b/projects/subgraph-core/constants/BeanstalkArb.ts @@ -11,7 +11,8 @@ import { BEAN_WEETH, BEAN_WBTC, BEAN_USDC, - BEAN_USDT + BEAN_USDT, + AQUIFER } from "./raw/BeanstalkArbConstants"; /// ADDRESSES /// @@ -24,6 +25,10 @@ export function getProtocolFertilizer(): Address { return FERTILIZER; } +export function getAquifer(): Address { + return AQUIFER; +} + export function getUnripeBeanAddr(): Address { return UNRIPE_BEAN; } diff --git a/projects/subgraph-core/constants/BeanstalkEth.ts b/projects/subgraph-core/constants/BeanstalkEth.ts index 6191498a0e..25890e548b 100644 --- a/projects/subgraph-core/constants/BeanstalkEth.ts +++ b/projects/subgraph-core/constants/BeanstalkEth.ts @@ -1,5 +1,6 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { + AQUIFER, BEAN_3CRV, BEAN_3CRV_V1, BEAN_ERC20, @@ -36,6 +37,10 @@ export function getProtocolFertilizer(): Address { return FERTILIZER; } +export function getAquifer(): Address { + return AQUIFER; +} + export function getUnripeBeanAddr(): Address { return UNRIPE_BEAN; } diff --git a/projects/subgraph-core/constants/RuntimeConstants.ts b/projects/subgraph-core/constants/RuntimeConstants.ts index 2371d8cfed..e642cabd31 100644 --- a/projects/subgraph-core/constants/RuntimeConstants.ts +++ b/projects/subgraph-core/constants/RuntimeConstants.ts @@ -31,6 +31,15 @@ export function getProtocolFertilizer(v: VersionDto): Address | null { throw new Error("Unsupported protocol"); } +export function getAquifer(v: VersionDto): Address { + if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { + return BeanstalkEth.getAquifer(); + } else if (v.chain == "arbitrum" && v.protocolAddress == ConstantsArb.BEANSTALK) { + return BeanstalkEth.getAquifer(); + } + throw new Error("Unsupported protocol"); +} + export function getUnripeBeanAddr(v: VersionDto): Address { if (v.chain == "ethereum" && v.protocolAddress == ConstantsEth.BEANSTALK) { return BeanstalkEth.getUnripeBeanAddr(); From 09e678b7a8399c41671f8895aa3b04e6d92599ea Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:26:09 -0700 Subject: [PATCH 50/88] refactor bean subgraph event abis --- .../manifests/codegen-abis.yaml | 4 +- .../subgraph-basin/manifests/ethereum.yaml | 2 +- .../subgraph-bean/manifests/arbitrum.yaml | 178 ++++++++++++++++++ .../subgraph-bean/manifests/codegen-abis.yaml | 2 + .../subgraph-bean/manifests/ethereum.yaml | 10 +- .../src/handlers/BeanstalkHandler.ts | 7 +- .../handlers/legacy/LegacyBeanstalkHandler.ts | 12 +- .../subgraph-bean/src/utils/LockedBeans.ts | 10 +- .../src/utils/price/TwaOracle.ts | 2 +- .../tests/event-mocking/Beanstalk.ts | 4 +- projects/subgraph-bean/tests/l2sr.test.ts | 2 +- .../manifests/arbitrum.yaml | 22 +-- 12 files changed, 220 insertions(+), 35 deletions(-) create mode 100644 projects/subgraph-bean/manifests/arbitrum.yaml diff --git a/projects/subgraph-basin/manifests/codegen-abis.yaml b/projects/subgraph-basin/manifests/codegen-abis.yaml index 2c066381aa..2ba9d2e239 100644 --- a/projects/subgraph-basin/manifests/codegen-abis.yaml +++ b/projects/subgraph-basin/manifests/codegen-abis.yaml @@ -26,7 +26,7 @@ dataSources: - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - name: Beanstalk - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: Well file: ../../subgraph-core/abis/Well.json - name: CurvePrice @@ -57,4 +57,4 @@ templates: - handler: handleInitVersion filter: kind: once - file: ../src/utils/Init.ts + file: ../src/utils/constants/Version.ts diff --git a/projects/subgraph-basin/manifests/ethereum.yaml b/projects/subgraph-basin/manifests/ethereum.yaml index 26dc082a30..5ace1135a6 100644 --- a/projects/subgraph-basin/manifests/ethereum.yaml +++ b/projects/subgraph-basin/manifests/ethereum.yaml @@ -64,7 +64,7 @@ dataSources: - Beanstalk abis: - name: Beanstalk - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: Sunrise(indexed uint256) handler: handleSunrise diff --git a/projects/subgraph-bean/manifests/arbitrum.yaml b/projects/subgraph-bean/manifests/arbitrum.yaml new file mode 100644 index 0000000000..d67cf9dca5 --- /dev/null +++ b/projects/subgraph-bean/manifests/arbitrum.yaml @@ -0,0 +1,178 @@ +specVersion: 0.0.9 +schema: + file: ../schema.graphql +dataSources: + ### + # INITIALIZATION + ### + - kind: ethereum/contract + name: Version + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 585858585858 # Reseed + endBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Version + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + blockHandlers: + - handler: handleInitVersion + filter: + kind: once + file: ../src/utils/constants/Version.ts + ### + # BEAN TOKEN + ### + - kind: ethereum/contract + name: BeanToken + network: arbitrum-one + source: + address: "0xBEA0005B8599265D41256905A9B3073D397812E4" + abi: ERC20 + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Bean + abis: + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: Transfer(indexed address,indexed address,uint256) + handler: handleTransfer + file: ../src/handlers/BeanHandler.ts + ### + # BEANSTALK PROTOCOL + ### + - kind: ethereum/contract + name: Beanstalk + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Bean + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + eventHandlers: + - event: DewhitelistToken(indexed address) + handler: handleDewhitelistToken + - event: Chop(indexed address,indexed address,uint256,uint256) + handler: handleChop + - event: Convert(indexed address,address,address,uint256,uint256) + handler: handleConvert + - event: Sunrise(indexed uint256) + handler: handleSunrise + - event: Shipped(indexed uint32,uint256) + handler: handleShipped + file: ../src/handlers/BeanstalkHandler.ts + - kind: ethereum/contract + name: WellTWAP + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Bean + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + - name: Well + file: ../../subgraph-core/abis/Well.json + eventHandlers: + - event: WellOracle(indexed uint32,address,int256,bytes) + handler: handleWellOracle + file: ../src/handlers/BeanstalkHandler.ts + ### + # POOLS + ### + - kind: ethereum/contract + name: BeanWETHCP2w-V2 + network: arbitrum-one + source: + address: "0xBEA0e11282e2bB5893bEcE110cF199501e872bAd" + abi: Well + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Pool + abis: + - name: Well + file: ../../subgraph-core/abis/Well.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: AddLiquidity(uint256[],uint256,address) + handler: handleAddLiquidity + - event: RemoveLiquidity(uint256,uint256[],address) + handler: handleRemoveLiquidity + - event: RemoveLiquidityOneToken(uint256,address,uint256,address) + handler: handleRemoveLiquidityOneToken + - event: Swap(address,address,uint256,uint256,address) + handler: handleSwap + - event: Shift(uint256[],address,uint256,address) + handler: handleShift + - event: Sync(uint256[],uint256,address) + handler: handleSync + file: ../src/handlers/BeanWellHandler.ts + #TODO: other pools go here + ### + # PEG CROSS CHECK PER BLOCK + ### + - kind: ethereum/contract + name: CrossCheck + network: arbitrum-one + source: + address: "0xEfE94bE746681ed73DfD15F932f9a8e8ffDdEE56" + abi: BeanstalkPrice + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - BeanCross + abis: + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + blockHandlers: + - handler: handleBlock + file: ../src/handlers/CrossHandler.ts +# features: +# - grafting +# graft: +# base: QmYnY2GzZbwTqot3H4jAV83mPbGTnBavdbB8bVXYxJzLUd +# block: 20291520 diff --git a/projects/subgraph-bean/manifests/codegen-abis.yaml b/projects/subgraph-bean/manifests/codegen-abis.yaml index e08b49436e..ba69070834 100644 --- a/projects/subgraph-bean/manifests/codegen-abis.yaml +++ b/projects/subgraph-bean/manifests/codegen-abis.yaml @@ -37,6 +37,8 @@ dataSources: file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP37.json - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json - name: CurvePrice diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index c02ee3a8d8..3e2330c5ce 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -110,8 +110,6 @@ dataSources: eventHandlers: - event: DewhitelistToken(indexed address) handler: handleDewhitelistToken - - event: Reward(indexed uint32,uint256,uint256,uint256) - handler: handleRewardMint - event: Chop(indexed address,indexed address,uint256,uint256) handler: handleChop - event: Convert(indexed address,address,address,uint256,uint256) @@ -153,7 +151,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: PreReplant + abi: Replanted startBlock: 15277986 # Replanted mapping: kind: ethereum/events @@ -162,8 +160,8 @@ dataSources: entities: - Bean abis: - - name: PreReplant - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json + - name: Replanted + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json - name: CurvePrice @@ -177,6 +175,8 @@ dataSources: eventHandlers: - event: Sunrise(indexed uint256) handler: handleSunrise_v2 + - event: Reward(indexed uint32,uint256,uint256,uint256) + handler: handleRewardMint file: ../src/handlers/legacy/LegacyBeanstalkHandler.ts - kind: ethereum/contract name: LegacyCurveTWAP diff --git a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts index db56181cc0..5c891447b1 100644 --- a/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/BeanstalkHandler.ts @@ -1,8 +1,6 @@ -import { BigInt } from "@graphprotocol/graph-ts"; import { updateBeanSupplyPegPercent, updateBeanTwa } from "../utils/Bean"; -import { Chop, Convert, DewhitelistToken, Reward, Sunrise } from "../../generated/Bean-ABIs/Replanted"; +import { Chop, Convert, DewhitelistToken, Shipped, Sunrise, WellOracle } from "../../generated/Bean-ABIs/Reseed"; import { loadBean } from "../entities/Bean"; -import { WellOracle } from "../../generated/Bean-ABIs/BasinBip"; import { setRawWellReserves, setTwaLast } from "../utils/price/TwaOracle"; import { decodeCumulativeWellReserves, setWellTwa } from "../utils/price/WellPrice"; import { updateSeason } from "../utils/legacy/Beanstalk"; @@ -61,7 +59,8 @@ export function handleConvert(event: Convert): void { } } -export function handleRewardMint(event: Reward): void { +// Overall reward mint +export function handleShipped(event: Shipped): void { let beanToken = getProtocolToken(v(), event.block.number); updateBeanSupplyPegPercent(beanToken, event.block.number); } diff --git a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts index a71265c5f4..bcd4a08e53 100644 --- a/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts +++ b/projects/subgraph-bean/src/handlers/legacy/LegacyBeanstalkHandler.ts @@ -2,11 +2,10 @@ import { toAddress } from "../../../../subgraph-core/utils/Bytes"; import { BEAN_3CRV, BEAN_WETH_V1, CURVE_PRICE } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { toDecimal, ZERO_BD, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { CurvePrice } from "../../../generated/Bean-ABIs/CurvePrice"; -import { Sunrise } from "../../../generated/Bean-ABIs/PreReplant"; -import { MetapoolOracle } from "../../../generated/Bean-ABIs/Replanted"; +import { MetapoolOracle, Reward, Sunrise } from "../../../generated/Bean-ABIs/Replanted"; import { loadBean } from "../../entities/Bean"; import { loadOrCreatePool } from "../../entities/Pool"; -import { updateBeanTwa, updateBeanValues } from "../../utils/Bean"; +import { updateBeanSupplyPegPercent, updateBeanTwa, updateBeanValues } from "../../utils/Bean"; import { checkBeanCross, updatePoolPricesOnCross } from "../../utils/Cross"; import { updateSeason } from "../../utils/legacy/Beanstalk"; import { updatePoolPrice, updatePoolValues } from "../../utils/Pool"; @@ -52,6 +51,7 @@ export function handleSunrise_v1(event: Sunrise): void { updateBeanTwa(event.block); } +// Replanted -> Reseed export function handleSunrise_v2(event: Sunrise): void { updateSeason(event.params.season.toI32(), event.block); @@ -87,6 +87,12 @@ export function handleSunrise_v2(event: Sunrise): void { } } +// Replanted -> Reseed +export function handleRewardMint(event: Reward): void { + let beanToken = getProtocolToken(v(), event.block.number); + updateBeanSupplyPegPercent(beanToken, event.block.number); +} + // POST REPLANT TWA DELTAB // export function handleMetapoolOracle(event: MetapoolOracle): void { diff --git a/projects/subgraph-bean/src/utils/LockedBeans.ts b/projects/subgraph-bean/src/utils/LockedBeans.ts index a11b32842d..c7a0920831 100644 --- a/projects/subgraph-bean/src/utils/LockedBeans.ts +++ b/projects/subgraph-bean/src/utils/LockedBeans.ts @@ -1,5 +1,5 @@ import { BigDecimal, BigInt, Address, log } from "@graphprotocol/graph-ts"; -import { SeedGauge } from "../../generated/Bean-ABIs/SeedGauge"; +import { Reseed } from "../../generated/Bean-ABIs/Reseed"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { ERC20 } from "../../generated/Bean-ABIs/ERC20"; import { loadOrCreateTwaOracle } from "../entities/TwaOracle"; @@ -28,15 +28,15 @@ export function calcLockedBeans(blockNumber: BigInt): BigInt { ? twaOracle.cumulativeWellReservesPrevTime : twaOracle.cumulativeWellReservesTime; - let beanstalkBIP45 = SeedGauge.bind(protocol); - let lockedBeans = beanstalkBIP45.try_getLockedBeansFromTwaReserves(twaReserves, twaTime); + let beanstalk = Reseed.bind(protocol); + let lockedBeans = beanstalk.try_getLockedBeansFromTwaReserves(twaReserves, twaTime); if (!lockedBeans.reverted) { return lockedBeans.value; } } // Pre-gauge there was no lockedBeans contract function, instead we recreate the same calculation. - let beanstalk = SeedGauge.bind(protocol); + let beanstalk = Reseed.bind(protocol); const recapPercentResult = beanstalk.try_getRecapPaidPercent(); if (recapPercentResult.reverted) { // This function was made available later in the Replant process, for a few hundred blocks it is unavailable @@ -56,7 +56,7 @@ export function calcLockedBeans(blockNumber: BigInt): BigInt { } export function LibLockedUnderlying_getLockedUnderlying(protocol: Address, unripeToken: Address, recapPercentPaid: BigDecimal): BigInt { - const balanceOfUnderlying = SeedGauge.bind(protocol).getTotalUnderlying(unripeToken); + const balanceOfUnderlying = Reseed.bind(protocol).getTotalUnderlying(unripeToken); const percentLocked = LibLockedUnderlying_getPercentLockedUnderlying(unripeToken, recapPercentPaid); return BigInt.fromString(new BigDecimal(balanceOfUnderlying).times(percentLocked).truncate(0).toString()); } diff --git a/projects/subgraph-bean/src/utils/price/TwaOracle.ts b/projects/subgraph-bean/src/utils/price/TwaOracle.ts index 66c2cd2711..01617b8804 100644 --- a/projects/subgraph-bean/src/utils/price/TwaOracle.ts +++ b/projects/subgraph-bean/src/utils/price/TwaOracle.ts @@ -5,7 +5,7 @@ import { WETH_USDC_PAIR } from "../../../../subgraph-core/constants/raw/Beanstal import { curveCumulativePrices } from "./CurvePrice"; import { TWAType } from "./Types"; import { wellCumulativePrices, wellTwaReserves } from "./WellPrice"; -import { WellOracle } from "../../../generated/Bean-ABIs/BasinBip"; +import { WellOracle } from "../../../generated/Bean-ABIs/Reseed"; import { loadOrCreateTwaOracle } from "../../entities/TwaOracle"; export function manualTwa(poolAddress: Address, newReserves: BigInt[], timestamp: BigInt): void { diff --git a/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts b/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts index dba01552dc..61db336116 100644 --- a/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts +++ b/projects/subgraph-bean/tests/event-mocking/Beanstalk.ts @@ -1,7 +1,7 @@ import { BigInt, ethereum, Address, Bytes } from "@graphprotocol/graph-ts"; -import { WellOracle } from "../../generated/Bean-ABIs/BasinBip"; +import { WellOracle, Convert, DewhitelistToken } from "../../generated/Bean-ABIs/Reseed"; import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; -import { Convert, DewhitelistToken, MetapoolOracle } from "../../generated/Bean-ABIs/Replanted"; +import { MetapoolOracle } from "../../generated/Bean-ABIs/Replanted"; export function createMetapoolOracleEvent( season: BigInt, diff --git a/projects/subgraph-bean/tests/l2sr.test.ts b/projects/subgraph-bean/tests/l2sr.test.ts index ef678f29c0..827f172203 100644 --- a/projects/subgraph-bean/tests/l2sr.test.ts +++ b/projects/subgraph-bean/tests/l2sr.test.ts @@ -18,7 +18,7 @@ import { mockSeedGaugeLockedBeansReverts } from "./call-mocking/Beanstalk"; import { mockBeanstalkEvent } from "../../subgraph-core/tests/event-mocking/Util"; -import { Chop, Convert } from "../generated/Bean-ABIs/Replanted"; +import { Chop } from "../generated/Bean-ABIs/Reseed"; import { calcLockedBeans, LibLockedUnderlying_getPercentLockedUnderlying } from "../src/utils/LockedBeans"; import { mockERC20TokenSupply } from "../../subgraph-core/tests/event-mocking/Tokens"; import { TwaOracle } from "../generated/schema"; diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml index 4c48cc2918..af608d335c 100644 --- a/projects/subgraph-beanstalk/manifests/arbitrum.yaml +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -16,8 +16,8 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 585858585858 - endBlock: 585858585858 + startBlock: 585858585858 # Reseed + endBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -41,7 +41,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 585858585858 + startBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -80,7 +80,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 585858585858 + startBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -119,7 +119,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 585858585858 + startBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -150,7 +150,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 585858585858 + startBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -183,7 +183,7 @@ dataSources: source: address: "0x2D5E484Dd7D43dFE32BF1Ed9fE6517b64F13Ea51" abi: Fertilizer - startBlock: 585858585858 + startBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -207,7 +207,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 585858585858 + startBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -232,7 +232,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 585858585858 + startBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -265,7 +265,7 @@ dataSources: source: address: "0xBEA0005B8599265D41256905A9B3073D397812E4" abi: ERC20 - startBlock: 585858585858 + startBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -288,7 +288,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Reseed - startBlock: 585858585858 + startBlock: 585858585858 # Reseed mapping: kind: ethereum/events apiVersion: 0.0.6 From fde954e66d034df5072be394c34b8d76e9be3f9d Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:35:19 -0700 Subject: [PATCH 51/88] configure new pools --- .../subgraph-bean/manifests/arbitrum.yaml | 185 +++++++++++++++++- .../src/utils/constants/PooledTokens.ts | 108 +++++++--- 2 files changed, 258 insertions(+), 35 deletions(-) diff --git a/projects/subgraph-bean/manifests/arbitrum.yaml b/projects/subgraph-bean/manifests/arbitrum.yaml index d67cf9dca5..c39ca2e125 100644 --- a/projects/subgraph-bean/manifests/arbitrum.yaml +++ b/projects/subgraph-bean/manifests/arbitrum.yaml @@ -113,10 +113,190 @@ dataSources: # POOLS ### - kind: ethereum/contract - name: BeanWETHCP2w-V2 + name: BeanWETH network: arbitrum-one source: - address: "0xBEA0e11282e2bB5893bEcE110cF199501e872bAd" + address: "0xBEA00A3F7aaF99476862533Fe7DcA4b50f6158cB" + abi: Well + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Pool + abis: + - name: Well + file: ../../subgraph-core/abis/Well.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: AddLiquidity(uint256[],uint256,address) + handler: handleAddLiquidity + - event: RemoveLiquidity(uint256,uint256[],address) + handler: handleRemoveLiquidity + - event: RemoveLiquidityOneToken(uint256,address,uint256,address) + handler: handleRemoveLiquidityOneToken + - event: Swap(address,address,uint256,uint256,address) + handler: handleSwap + - event: Shift(uint256[],address,uint256,address) + handler: handleShift + - event: Sync(uint256[],uint256,address) + handler: handleSync + file: ../src/handlers/BeanWellHandler.ts + - kind: ethereum/contract + name: BeanwstETH + network: arbitrum-one + source: + address: "0xBEA0093f626Ce32dd6dA19617ba4e7aA0c3228e8" + abi: Well + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Pool + abis: + - name: Well + file: ../../subgraph-core/abis/Well.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: AddLiquidity(uint256[],uint256,address) + handler: handleAddLiquidity + - event: RemoveLiquidity(uint256,uint256[],address) + handler: handleRemoveLiquidity + - event: RemoveLiquidityOneToken(uint256,address,uint256,address) + handler: handleRemoveLiquidityOneToken + - event: Swap(address,address,uint256,uint256,address) + handler: handleSwap + - event: Shift(uint256[],address,uint256,address) + handler: handleShift + - event: Sync(uint256[],uint256,address) + handler: handleSync + file: ../src/handlers/BeanWellHandler.ts + - kind: ethereum/contract + name: BeanweETH + network: arbitrum-one + source: + address: "0xBEA00865405A02215B44eaADB853d0d2192Fc29D" + abi: Well + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Pool + abis: + - name: Well + file: ../../subgraph-core/abis/Well.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: AddLiquidity(uint256[],uint256,address) + handler: handleAddLiquidity + - event: RemoveLiquidity(uint256,uint256[],address) + handler: handleRemoveLiquidity + - event: RemoveLiquidityOneToken(uint256,address,uint256,address) + handler: handleRemoveLiquidityOneToken + - event: Swap(address,address,uint256,uint256,address) + handler: handleSwap + - event: Shift(uint256[],address,uint256,address) + handler: handleShift + - event: Sync(uint256[],uint256,address) + handler: handleSync + file: ../src/handlers/BeanWellHandler.ts + - kind: ethereum/contract + name: BeanWBTC + network: arbitrum-one + source: + address: "0xBEA008aC57c2bEfe82E87d1D8Fb9f4784d0B73cA" + abi: Well + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Pool + abis: + - name: Well + file: ../../subgraph-core/abis/Well.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: AddLiquidity(uint256[],uint256,address) + handler: handleAddLiquidity + - event: RemoveLiquidity(uint256,uint256[],address) + handler: handleRemoveLiquidity + - event: RemoveLiquidityOneToken(uint256,address,uint256,address) + handler: handleRemoveLiquidityOneToken + - event: Swap(address,address,uint256,uint256,address) + handler: handleSwap + - event: Shift(uint256[],address,uint256,address) + handler: handleShift + - event: Sync(uint256[],uint256,address) + handler: handleSync + file: ../src/handlers/BeanWellHandler.ts + - kind: ethereum/contract + name: BeanUSDC + network: arbitrum-one + source: + address: "0xBEA00dAf62D5549D265c5cA6D6BE87eF17881279" + abi: Well + startBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Pool + abis: + - name: Well + file: ../../subgraph-core/abis/Well.json + - name: BeanstalkPrice + file: ../../subgraph-core/abis/BeanstalkPrice.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: AddLiquidity(uint256[],uint256,address) + handler: handleAddLiquidity + - event: RemoveLiquidity(uint256,uint256[],address) + handler: handleRemoveLiquidity + - event: RemoveLiquidityOneToken(uint256,address,uint256,address) + handler: handleRemoveLiquidityOneToken + - event: Swap(address,address,uint256,uint256,address) + handler: handleSwap + - event: Shift(uint256[],address,uint256,address) + handler: handleShift + - event: Sync(uint256[],uint256,address) + handler: handleSync + file: ../src/handlers/BeanWellHandler.ts + - kind: ethereum/contract + name: BeanUSDT + network: arbitrum-one + source: + address: "0xBEA00bE150FEF7560A8ff3C68D07387693Ddfd0b" abi: Well startBlock: 585858585858 # Reseed mapping: @@ -148,7 +328,6 @@ dataSources: - event: Sync(uint256[],uint256,address) handler: handleSync file: ../src/handlers/BeanWellHandler.ts - #TODO: other pools go here ### # PEG CROSS CHECK PER BLOCK ### diff --git a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts index 24aad21212..88ad1ad786 100644 --- a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts +++ b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts @@ -1,18 +1,6 @@ import { BigInt, Address, log } from "@graphprotocol/graph-ts"; -import { - BEAN_ERC20, - BEAN_ERC20_V1, - WETH, - CRV3_TOKEN, - LUSD, - BEAN_WETH_V1, - BEAN_3CRV_V1, - BEAN_LUSD_V1, - BEAN_3CRV, - BEAN_WETH_CP2_WELL, - BEAN_WSTETH_CP2_WELL, - WSTETH -} from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import * as BeanstalkEth from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import * as BeanstalkArb from "../../../../subgraph-core/constants/raw/BeanstalkArbConstants"; // Use this mapping to determine which tokens are in each pool. Pools may each follow a distinct interface, // so a view function shouldn't be used, and a new subgraph build is already required to track a newly whitelisted asset. @@ -41,29 +29,55 @@ class PoolTokens { } // WHITELIST: Add new pools here const poolTokens: PoolTokens[] = [ + // ethereum { - pool: BEAN_WETH_V1, - tokens: [BEAN_ERC20_V1, WETH] + pool: BeanstalkEth.BEAN_WETH_V1, + tokens: [BeanstalkEth.BEAN_ERC20_V1, BeanstalkEth.WETH] }, { - pool: BEAN_3CRV_V1, - tokens: [BEAN_ERC20_V1, CRV3_TOKEN] + pool: BeanstalkEth.BEAN_3CRV_V1, + tokens: [BeanstalkEth.BEAN_ERC20_V1, BeanstalkEth.CRV3_TOKEN] }, { - pool: BEAN_LUSD_V1, - tokens: [BEAN_ERC20_V1, LUSD] + pool: BeanstalkEth.BEAN_LUSD_V1, + tokens: [BeanstalkEth.BEAN_ERC20_V1, BeanstalkEth.LUSD] }, { - pool: BEAN_3CRV, - tokens: [BEAN_ERC20, CRV3_TOKEN] + pool: BeanstalkEth.BEAN_3CRV, + tokens: [BeanstalkEth.BEAN_ERC20, BeanstalkEth.CRV3_TOKEN] }, { - pool: BEAN_WETH_CP2_WELL, - tokens: [BEAN_ERC20, WETH] + pool: BeanstalkEth.BEAN_WETH_CP2_WELL, + tokens: [BeanstalkEth.BEAN_ERC20, BeanstalkEth.WETH] }, { - pool: BEAN_WSTETH_CP2_WELL, - tokens: [BEAN_ERC20, WSTETH] + pool: BeanstalkEth.BEAN_WSTETH_CP2_WELL, + tokens: [BeanstalkEth.BEAN_ERC20, BeanstalkEth.WSTETH] + }, + // arbitrum + { + pool: BeanstalkArb.BEAN_WETH, + tokens: [BeanstalkArb.BEAN_ERC20, BeanstalkArb.WETH] + }, + { + pool: BeanstalkArb.BEAN_WSTETH, + tokens: [BeanstalkArb.BEAN_ERC20, BeanstalkArb.WSTETH] + }, + { + pool: BeanstalkArb.BEAN_WEETH, + tokens: [BeanstalkArb.BEAN_ERC20, BeanstalkArb.WEETH] + }, + { + pool: BeanstalkArb.BEAN_WBTC, + tokens: [BeanstalkArb.BEAN_ERC20, BeanstalkArb.WBTC] + }, + { + pool: BeanstalkArb.BEAN_USDC, + tokens: [BeanstalkArb.BEAN_ERC20, BeanstalkArb.USDC] + }, + { + pool: BeanstalkArb.BEAN_USDT, + tokens: [BeanstalkArb.BEAN_ERC20, BeanstalkArb.USDT] } ]; @@ -79,28 +93,58 @@ class TokenInfo { // WHITELIST: Add new tokens here const tokens: Token[] = [ + // ethereum { - address: BEAN_ERC20_V1, + address: BeanstalkEth.BEAN_ERC20_V1, info: { name: "BEAN", decimals: BigInt.fromU32(6) } }, { - address: BEAN_ERC20, + address: BeanstalkEth.BEAN_ERC20, info: { name: "BEAN", decimals: BigInt.fromU32(6) } }, { - address: WETH, + address: BeanstalkEth.WETH, info: { name: "WETH", decimals: BigInt.fromU32(18) } }, { - address: CRV3_TOKEN, + address: BeanstalkEth.CRV3_TOKEN, info: { name: "3CRV", decimals: BigInt.fromU32(18) } }, { - address: LUSD, + address: BeanstalkEth.LUSD, info: { name: "LUSD", decimals: BigInt.fromU32(18) } }, { - address: WSTETH, + address: BeanstalkEth.WSTETH, info: { name: "wstETH", decimals: BigInt.fromU32(18) } + }, + // arbitrum + { + address: BeanstalkArb.BEAN_ERC20, + info: { name: "BEAN", decimals: BigInt.fromU32(6) } + }, + { + address: BeanstalkArb.WETH, + info: { name: "WETH", decimals: BigInt.fromU32(18) } + }, + { + address: BeanstalkArb.WSTETH, + info: { name: "wstETH", decimals: BigInt.fromU32(18) } + }, + { + address: BeanstalkArb.WEETH, + info: { name: "weETH", decimals: BigInt.fromU32(18) } + }, + { + address: BeanstalkArb.WBTC, + info: { name: "WBTC", decimals: BigInt.fromU32(18) } + }, + { + address: BeanstalkArb.USDC, + info: { name: "USDC", decimals: BigInt.fromU32(6) } + }, + { + address: BeanstalkArb.USDT, + info: { name: "USDT", decimals: BigInt.fromU32(6) } } ]; From a0d978858c065d63cf0ff8f8bbd65f1eef075749 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:44:28 -0700 Subject: [PATCH 52/88] clean up manifests --- .../subgraph-bean/manifests/codegen-abis.yaml | 4 -- .../subgraph-bean/manifests/ethereum.yaml | 44 ++++++------------- 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/projects/subgraph-bean/manifests/codegen-abis.yaml b/projects/subgraph-bean/manifests/codegen-abis.yaml index ba69070834..7105b7c2dc 100644 --- a/projects/subgraph-bean/manifests/codegen-abis.yaml +++ b/projects/subgraph-bean/manifests/codegen-abis.yaml @@ -33,10 +33,6 @@ dataSources: file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: BasinBip - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP37.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - name: Reseed file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: BeanstalkPrice diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 3e2330c5ce..9cd4454f1d 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -66,8 +66,8 @@ dataSources: abis: - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: Transfer(indexed address,indexed address,uint256) handler: handleTransfer @@ -89,12 +89,8 @@ dataSources: entities: - Bean abis: - - name: Replanted - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - - name: PreReplant - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json - name: CurvePrice @@ -206,7 +202,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: BasinBip + abi: Reseed startBlock: 15277988 mapping: kind: ethereum/events @@ -215,8 +211,8 @@ dataSources: entities: - Bean abis: - - name: BasinBip - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP37.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: Well file: ../../subgraph-core/abis/Well.json eventHandlers: @@ -276,10 +272,6 @@ dataSources: file: ../../subgraph-core/abis/CurvePrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Replanted - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: TokenExchange(indexed address,int128,uint256,int128,uint256) handler: handleTokenExchange @@ -317,10 +309,6 @@ dataSources: file: ../../subgraph-core/abis/CurvePrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Replanted - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - event: TokenExchange(indexed address,int128,uint256,int128,uint256) handler: handleTokenExchange @@ -357,10 +345,8 @@ dataSources: file: ../../subgraph-core/abis/CurvePrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Replanted - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: TokenExchange(indexed address,int128,uint256,int128,uint256) handler: handleTokenExchange @@ -395,10 +381,8 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Replanted - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: AddLiquidity(uint256[],uint256,address) handler: handleAddLiquidity @@ -433,10 +417,8 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - - name: Replanted - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: AddLiquidity(uint256[],uint256,address) handler: handleAddLiquidity From beea273c55575e085cf83c07e366eadd5c18c7e5 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:14:13 -0700 Subject: [PATCH 53/88] fix comparisons --- projects/subgraph-bean/manifests/ethereum.yaml | 4 +--- projects/subgraph-bean/src/utils/Bean.ts | 4 ++-- projects/subgraph-bean/src/utils/legacy/Curve.ts | 2 +- projects/subgraph-beanstalk/manifests/ethereum.yaml | 2 ++ projects/subgraph-beanstalk/manifests/no-apy.yaml | 2 ++ 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 9cd4454f1d..92b7b1652d 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -80,7 +80,7 @@ dataSources: network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" - abi: Replanted + abi: Reseed startBlock: 12974075 mapping: kind: ethereum/events @@ -239,8 +239,6 @@ dataSources: abis: - name: UniswapV2Pair file: ../../subgraph-core/abis/UniswapV2Pair.json - - name: SeedGauge - file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json eventHandlers: diff --git a/projects/subgraph-bean/src/utils/Bean.ts b/projects/subgraph-bean/src/utils/Bean.ts index f4c9ddce6a..96ea2bd50c 100644 --- a/projects/subgraph-bean/src/utils/Bean.ts +++ b/projects/subgraph-bean/src/utils/Bean.ts @@ -103,7 +103,7 @@ export function calcLiquidityWeightedBeanPrice(token: Address): BigDecimal { } export function updateBeanSupplyPegPercent(beanToken: Address, blockNumber: BigInt): void { - if (beanToken === BEAN_ERC20_V1) { + if (beanToken == BEAN_ERC20_V1) { updateBeanSupplyPegPercent_v1(beanToken, blockNumber); return; } @@ -142,7 +142,7 @@ export function updateBeanAfterPoolSwap( univ2_externalUpdatePoolPrice(BEAN_WETH_V1, block); beanPrice = calcLiquidityWeightedBeanPrice(beanAddr); } else { - if (priceContractResult === null) { + if (priceContractResult == null) { priceContractResult = BeanstalkPrice_try_price(block.number); } if (!priceContractResult.reverted) { diff --git a/projects/subgraph-bean/src/utils/legacy/Curve.ts b/projects/subgraph-bean/src/utils/legacy/Curve.ts index 405e0ffdde..a43241f05e 100644 --- a/projects/subgraph-bean/src/utils/legacy/Curve.ts +++ b/projects/subgraph-bean/src/utils/legacy/Curve.ts @@ -21,7 +21,7 @@ export function calcPostSwapValues(poolAddress: Address, block: ethereum.Block): let newPoolPrice = ZERO_BD; let reserveBalances: BigInt[] = []; let deltaLiquidityUSD = ZERO_BD; - if (poolAddress === BEAN_3CRV_V1) { + if (poolAddress == BEAN_3CRV_V1) { let pool = loadOrCreatePool(poolAddress, block.number); let priceAndLp = curvePriceAndLp(poolAddress); diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index 1c8fc2908d..c37118fe67 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -938,6 +938,8 @@ dataSources: abis: - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: Sunrise(indexed uint256) handler: handleReplantSunrise diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index c04e085b82..2e3901703d 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -605,6 +605,8 @@ dataSources: abis: - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json eventHandlers: - event: Sunrise(indexed uint256) handler: handleReplantSunrise From 63dada49038a54ab58cd96dab76f2d16a06f1acf Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:34:13 -0700 Subject: [PATCH 54/88] add calculations curve abi --- projects/subgraph-bean/manifests/ethereum.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 92b7b1652d..02ad92da82 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -268,6 +268,8 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json - name: CurvePrice file: ../../subgraph-core/abis/CurvePrice.json + - name: CalculationsCurve + file: ../../subgraph-core/abis/CalculationsCurve.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json eventHandlers: @@ -305,6 +307,8 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json - name: CurvePrice file: ../../subgraph-core/abis/CurvePrice.json + - name: CalculationsCurve + file: ../../subgraph-core/abis/CalculationsCurve.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json eventHandlers: @@ -341,6 +345,8 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json - name: CurvePrice file: ../../subgraph-core/abis/CurvePrice.json + - name: CalculationsCurve + file: ../../subgraph-core/abis/CalculationsCurve.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json - name: Reseed From 77395323e1e433ee92d20e0b101f95497721df68 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:14:10 -0700 Subject: [PATCH 55/88] fix variable shadowing --- .../subgraph-bean/manifests/ethereum.yaml | 4 +- .../subgraph-bean/src/utils/legacy/Curve.ts | 2 +- .../src/entities/Fertilizer.ts | 1 + .../abis/Beanstalk/Beanstalk-BIP50.json | 432 +++++++++++------- 4 files changed, 275 insertions(+), 164 deletions(-) diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 02ad92da82..353792dfb9 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -482,5 +482,5 @@ dataSources: # features: # - grafting # graft: -# base: QmYnY2GzZbwTqot3H4jAV83mPbGTnBavdbB8bVXYxJzLUd -# block: 20291520 +# base: QmXeppf8ju3vxmLRimVqhQvQEo3LvXSB9zJa2cSahuL8A2 +# block: 13954070 diff --git a/projects/subgraph-bean/src/utils/legacy/Curve.ts b/projects/subgraph-bean/src/utils/legacy/Curve.ts index a43241f05e..582a5bcfe6 100644 --- a/projects/subgraph-bean/src/utils/legacy/Curve.ts +++ b/projects/subgraph-bean/src/utils/legacy/Curve.ts @@ -25,7 +25,7 @@ export function calcPostSwapValues(poolAddress: Address, block: ethereum.Block): let pool = loadOrCreatePool(poolAddress, block.number); let priceAndLp = curvePriceAndLp(poolAddress); - let newPoolPrice = priceAndLp[0]; + newPoolPrice = priceAndLp[0]; let lpValue = priceAndLp[1]; let beanContract = ERC20.bind(BEAN_ERC20_V1); diff --git a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts index 238125f6dd..0c76a8c45c 100644 --- a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts +++ b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts @@ -23,6 +23,7 @@ export function loadFertilizerToken(fertilizer: Fertilizer, id: BigInt, blockNum fertilizerToken = new FertilizerToken(id.toString()); fertilizerToken.fertilizer = fertilizer.id; if (isReplanted(v(), blockNumber)) { + // TODO: fix this for migrated fert. Need carry-over for all FertilizerToken. fertilizerToken.humidity = BigDecimal.fromString(beanstalkContract.getCurrentHumidity().toString()).div(BigDecimal.fromString("10")); fertilizerToken.season = beanstalkContract.season().toI32(); fertilizerToken.startBpf = beanstalkContract.beansPerFertilizer(); diff --git a/projects/subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json b/projects/subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json index f38c9fb054..94601f8701 100644 --- a/projects/subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json +++ b/projects/subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json @@ -10927,167 +10927,6 @@ "stateMutability": "payable", "type": "function" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "reciever", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "enum LibTransfer.To", - "name": "toMode", - "type": "uint8" - } - ], - "name": "L1BeansMigrated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "reciever", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "depositIds", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "bdvs", - "type": "uint256[]" - } - ], - "name": "L1DepositsMigrated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "reciever", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "fertIds", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "uint128[]", - "name": "amounts", - "type": "uint128[]" - }, - { - "indexed": false, - "internalType": "uint128", - "name": "lastBpf", - "type": "uint128" - } - ], - "name": "L1FertilizerMigrated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "reciever", - "type": "address" - }, - { - "indexed": false, - "internalType": "address[]", - "name": "tokens", - "type": "address[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "name": "L1InternalBalancesMigrated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "reciever", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "index", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "pods", - "type": "uint256[]" - } - ], - "name": "L1PlotsMigrated", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -11486,5 +11325,276 @@ ], "stateMutability": "pure", "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int96", + "name": "stem", + "type": "int96" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bdv", + "type": "uint256" + } + ], + "name": "AddMigratedDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "fid", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "lastBpf", + "type": "uint128" + } + ], + "name": "FertilizerMigrated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "delta", + "type": "int256" + } + ], + "name": "InternalBalanceMigrated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stalk", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "roots", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bdv", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int96", + "name": "lastStem", + "type": "int96" + } + ], + "name": "MigratedAccountStatus", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "plotIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "pods", + "type": "uint256" + } + ], + "name": "MigratedPlot", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "lister", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "start", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "podAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "maxHarvestableIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "enum LibTransfer.To", + "name": "mode", + "type": "uint8" + } + ], + "name": "MigratedPodListing", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "orderer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "beanAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fieldId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint24", + "name": "pricePerPod", + "type": "uint24" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "maxPlaceInLine", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minFillAmount", + "type": "uint256" + } + ], + "name": "MigratedPodOrder", + "type": "event" } ] From 4fb87365a0cea6b9b56df3bc0f3f3992e9c9129d Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:30:51 -0700 Subject: [PATCH 56/88] migration event handlers --- .../subgraph-bean/manifests/ethereum.yaml | 4 + .../cache-builder/beanstalk3.js | 6 + .../cache-builder/results/B3Migration_arb.ts | 6 +- projects/subgraph-beanstalk/schema.graphql | 10 +- .../src/entities/Beanstalk.ts | 8 +- .../subgraph-beanstalk/src/entities/Field.ts | 1 + .../src/entities/snapshots/Field.ts | 10 ++ .../src/handlers/SeasonHandler.ts | 10 +- .../legacy/ArbitrumMigrationHandler.ts | 115 +++++++++++++ .../subgraph-beanstalk/src/utils/Field.ts | 25 +-- .../src/utils/b3-migration/Init.ts | 11 +- .../tests/Migration.test.ts | 153 ++++++++++++------ .../tests/event-mocking/Migration.ts | 132 +++++++++++++++ 13 files changed, 409 insertions(+), 82 deletions(-) create mode 100644 projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts create mode 100644 projects/subgraph-beanstalk/tests/event-mocking/Migration.ts diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 353792dfb9..5d66811711 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -272,6 +272,8 @@ dataSources: file: ../../subgraph-core/abis/CalculationsCurve.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json + - name: UniswapV2Pair + file: ../../subgraph-core/abis/UniswapV2Pair.json eventHandlers: - event: TokenExchange(indexed address,int128,uint256,int128,uint256) handler: handleTokenExchange @@ -311,6 +313,8 @@ dataSources: file: ../../subgraph-core/abis/CalculationsCurve.json - name: ERC20 file: ../../subgraph-core/abis/ERC20.json + - name: UniswapV2Pair + file: ../../subgraph-core/abis/UniswapV2Pair.json eventHandlers: - event: TokenExchange(indexed address,int128,uint256,int128,uint256) handler: handleTokenExchange diff --git a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js index 892eba7ce7..77f143297c 100644 --- a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js +++ b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js @@ -21,6 +21,8 @@ const tokenMap = { numberOfSows sownBeans harvestedPods + podIndex + harvestableIndex } podMarketplace(id: "0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5") { filledListedPods @@ -53,6 +55,8 @@ const tokenMap = { numberOfSows: i32; sownBeans: BigInt; harvestedPods: BigInt; + podIndex: BigInt; + harvestableIndex: BigInt; } class PodMarketplaceInitialValues { @@ -80,6 +84,8 @@ const tokenMap = { numberOfSows: ${l1Values.field.numberOfSows}, sownBeans: BigInt.fromString('${l1Values.field.sownBeans}'), harvestedPods: BigInt.fromString('${l1Values.field.harvestedPods}') + podIndex: BigInt.fromString('${l1Values.field.podIndex}'), + harvestableIndex: BigInt.fromString('${l1Values.field.harvestableIndex}'), }; export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { diff --git a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts index 7475e2ba67..897f9fa563 100644 --- a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts +++ b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts @@ -7,6 +7,8 @@ class FieldInitialValues { numberOfSows: i32; sownBeans: BigInt; harvestedPods: BigInt; + podIndex: BigInt; + harvestableIndex: BigInt; } class PodMarketplaceInitialValues { @@ -33,7 +35,9 @@ export const FIELD_INITIAL_VALUES: FieldInitialValues = { numberOfSowers: 0, numberOfSows: 19172, sownBeans: BigInt.fromString("33592460721984"), - harvestedPods: BigInt.fromString("61126608133951") + harvestedPods: BigInt.fromString("61126608133951"), + podIndex: BigInt.fromString("980532024384892"), + harvestableIndex: BigInt.fromString("61128909242563") }; export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { diff --git a/projects/subgraph-beanstalk/schema.graphql b/projects/subgraph-beanstalk/schema.graphql index 5dceba48fa..9283439101 100644 --- a/projects/subgraph-beanstalk/schema.graphql +++ b/projects/subgraph-beanstalk/schema.graphql @@ -79,8 +79,6 @@ type Season @entity { rewardBeans: BigInt! "Amount of Beans paid to sunrise caller" incentiveBeans: BigInt! - "New harvestable index for the season" - harvestableIndex: BigInt! } type Silo @entity { @@ -481,6 +479,8 @@ type Field @entity { soil: BigInt! "Current pod index" podIndex: BigInt! + "Current harvestable index" + harvestableIndex: BigInt! "Current pod rate: Total unharvestable pods / bean supply" podRate: BigDecimal! "Season when the previous hourly snapshot was taken/updated" @@ -522,6 +522,8 @@ type FieldHourlySnapshot @entity { issuedSoil: BigInt! "Point in time pod index" podIndex: BigInt! + "Point in time harvestable index" + harvestableIndex: BigInt! "Point in time pod rate: Total unharvestable pods / bean supply" podRate: BigDecimal! @@ -536,6 +538,7 @@ type FieldHourlySnapshot @entity { deltaSoil: BigInt! deltaIssuedSoil: BigInt! deltaPodIndex: BigInt! + deltaHarvestableIndex: BigInt! deltaPodRate: BigDecimal! "Timestamp of initial snapshot creation" @@ -583,6 +586,8 @@ type FieldDailySnapshot @entity { issuedSoil: BigInt! "Point in time pod index" podIndex: BigInt! + "Point in time harvestable index" + harvestableIndex: BigInt! "Point in time pod rate: Total unharvestable pods / bean supply" podRate: BigDecimal! @@ -597,6 +602,7 @@ type FieldDailySnapshot @entity { deltaSoil: BigInt! deltaIssuedSoil: BigInt! deltaPodIndex: BigInt! + deltaHarvestableIndex: BigInt! deltaPodRate: BigDecimal! "Timestamp of initial snapshot creation" diff --git a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts index 53dfeb9188..5b8f86baf6 100644 --- a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts +++ b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts @@ -5,6 +5,7 @@ import { Season } from "../../generated/schema"; import { BI_MAX, ONE_BI, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { getProtocolFertilizer, getProtocolToken } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; +import { loadField } from "./Field"; export function loadBeanstalk(): Beanstalk { let beanstalk = Beanstalk.load("beanstalk"); @@ -45,12 +46,10 @@ export function loadSeason(id: BigInt): Season { season.deltaBeans = ZERO_BI; season.rewardBeans = ZERO_BI; season.incentiveBeans = ZERO_BI; - season.harvestableIndex = ZERO_BI; season.save(); if (id > ZERO_BI) { let lastSeason = loadSeason(id.minus(ONE_BI)); season.beans = lastSeason.beans; - season.harvestableIndex = lastSeason.harvestableIndex; season.save(); } @@ -76,7 +75,6 @@ export function getRewardMinted(season: i32): BigInt { } export function getHarvestableIndex(): BigInt { - let bs = loadBeanstalk(); - let season = loadSeason(BigInt.fromI32(bs.lastSeason)); - return season.harvestableIndex; + let field = loadField(v().protocolAddress); + return field.harvestableIndex; } diff --git a/projects/subgraph-beanstalk/src/entities/Field.ts b/projects/subgraph-beanstalk/src/entities/Field.ts index 4ffd0c6182..a18e3465fb 100644 --- a/projects/subgraph-beanstalk/src/entities/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/Field.ts @@ -24,6 +24,7 @@ export function loadField(account: Address): Field { field.harvestedPods = ZERO_BI; field.soil = ZERO_BI; field.podIndex = ZERO_BI; + field.harvestableIndex = ZERO_BI; field.podRate = ZERO_BD; field.save(); } diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts index 7c00352d4d..adb87a181a 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Field.ts @@ -38,6 +38,7 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { hourly.soil = field.soil; // issuedSoil set below, on initial snapshot hourly.podIndex = field.podIndex; + hourly.harvestableIndex = field.harvestableIndex; hourly.podRate = field.podRate; // Set deltas @@ -53,6 +54,7 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { hourly.deltaSoil = hourly.soil.minus(baseHourly.soil); // deltaIssuedSoil set below, on initial snapshot hourly.deltaPodIndex = hourly.podIndex.minus(baseHourly.podIndex); + hourly.deltaHarvestableIndex = hourly.harvestableIndex.minus(baseHourly.harvestableIndex); hourly.deltaPodRate = hourly.podRate.minus(baseHourly.podRate); if (hourly.id == baseHourly.id) { @@ -67,6 +69,7 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { hourly.deltaHarvestedPods = hourly.deltaHarvestedPods.plus(baseHourly.deltaHarvestedPods); hourly.deltaSoil = hourly.deltaSoil.plus(baseHourly.deltaSoil); hourly.deltaPodIndex = hourly.deltaPodIndex.plus(baseHourly.deltaPodIndex); + hourly.deltaHarvestableIndex = hourly.deltaHarvestableIndex.plus(baseHourly.deltaHarvestableIndex); hourly.deltaPodRate = hourly.deltaPodRate.plus(baseHourly.deltaPodRate); // Carry over unset values that would otherwise get erased hourly.issuedSoil = baseHourly.issuedSoil; @@ -93,6 +96,7 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { hourly.deltaHarvestedPods = hourly.harvestedPods; hourly.deltaSoil = hourly.soil; hourly.deltaPodIndex = hourly.podIndex; + hourly.deltaHarvestableIndex = hourly.harvestableIndex; hourly.deltaPodRate = hourly.podRate; // Sets initial creation values @@ -121,6 +125,7 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { daily.soil = field.soil; // issuedSoil set below, on initial snapshot daily.podIndex = field.podIndex; + daily.harvestableIndex = field.harvestableIndex; daily.podRate = field.podRate; if (baseDaily !== null) { daily.deltaTemperature = daily.temperature - baseDaily.temperature; @@ -134,6 +139,7 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { daily.deltaSoil = daily.soil.minus(baseDaily.soil); // deltaIssuedSoil set below, on initial snapshot daily.deltaPodIndex = daily.podIndex.minus(baseDaily.podIndex); + daily.deltaHarvestableIndex = daily.harvestableIndex.minus(baseDaily.harvestableIndex); daily.deltaPodRate = daily.podRate.minus(baseDaily.podRate); if (daily.id == baseDaily.id) { @@ -148,6 +154,7 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { daily.deltaHarvestedPods = daily.deltaHarvestedPods.plus(baseDaily.deltaHarvestedPods); daily.deltaSoil = daily.deltaSoil.plus(baseDaily.deltaSoil); daily.deltaPodIndex = daily.deltaPodIndex.plus(baseDaily.deltaPodIndex); + daily.deltaHarvestableIndex = daily.deltaHarvestableIndex.plus(baseDaily.deltaHarvestableIndex); daily.deltaPodRate = daily.deltaPodRate.plus(baseDaily.deltaPodRate); // Carry over existing values daily.issuedSoil = baseDaily.issuedSoil; @@ -168,6 +175,7 @@ export function takeFieldSnapshots(field: Field, block: ethereum.Block): void { daily.deltaHarvestedPods = daily.harvestedPods; daily.deltaSoil = daily.soil; daily.deltaPodIndex = daily.podIndex; + daily.deltaHarvestableIndex = daily.harvestableIndex; daily.deltaPodRate = daily.podRate; // Sets issued soil here since this is the initial creation @@ -198,6 +206,7 @@ export function clearFieldDeltas(field: Field, block: ethereum.Block): void { hourly.deltaHarvestedPods = ZERO_BI; hourly.deltaSoil = ZERO_BI; hourly.deltaPodIndex = ZERO_BI; + hourly.deltaHarvestableIndex = ZERO_BI; hourly.deltaPodRate = ZERO_BD; hourly.deltaIssuedSoil = ZERO_BI; hourly.save(); @@ -213,6 +222,7 @@ export function clearFieldDeltas(field: Field, block: ethereum.Block): void { daily.deltaHarvestedPods = ZERO_BI; daily.deltaSoil = ZERO_BI; daily.deltaPodIndex = ZERO_BI; + daily.deltaHarvestableIndex = ZERO_BI; daily.deltaPodRate = ZERO_BD; daily.deltaIssuedSoil = ZERO_BI; daily.save(); diff --git a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts index 8f0cfecc97..4f788928cd 100644 --- a/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SeasonHandler.ts @@ -64,9 +64,13 @@ export function handleIncentive(event: Incentivization): void { season.marketCap = season.price.times(toDecimal(season.beans)); season.incentiveBeans = event.params.beans; - season.harvestableIndex = Beanstalk_harvestableIndex(ZERO_BI); season.save(); - updateExpiredPlots(season.harvestableIndex, event.block); - updateHarvestablePlots(event.address, season.harvestableIndex, event.block); + let field = loadField(v().protocolAddress); + field.harvestableIndex = Beanstalk_harvestableIndex(ZERO_BI); + takeFieldSnapshots(field, event.block); + field.save(); + + updateExpiredPlots(field.harvestableIndex, event.block); + updateHarvestablePlots(event.address, field.harvestableIndex, event.block); } diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts new file mode 100644 index 0000000000..427ef6219d --- /dev/null +++ b/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts @@ -0,0 +1,115 @@ +import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; +import { + AddMigratedDeposit, + InternalBalanceMigrated, + MigratedPlot, + MigratedPodListing, + MigratedPodOrder +} from "../../../generated/Beanstalk-ABIs/Reseed"; +import { getHarvestableIndex, loadFarmer } from "../../entities/Beanstalk"; +import { loadField, loadPlot } from "../../entities/Field"; +import { clearFieldDeltas, takeFieldSnapshots } from "../../entities/snapshots/Field"; +import { updateFarmTotals } from "../../utils/Farm"; +import { podListingCreated, podOrderCreated } from "../../utils/Marketplace"; +import { addDeposits } from "../../utils/Silo"; + +export function handleAddMigratedDeposit(event: AddMigratedDeposit): void { + addDeposits({ + event, + account: event.params.account, + token: event.params.token, + seasons: null, + stems: [event.params.stem], + amounts: [event.params.amount], + bdvs: [event.params.bdv], + depositVersion: "stem" + }); +} + +export function handleMigratedPlot(event: MigratedPlot): void { + // The migration logic conflicts with some cumulative values already set in utils/b3-migration/Init. + // Therefore the basic "sow" method is unsuitable for this purpose + + const harvestableIndex = getHarvestableIndex(); + const plotStart = event.params.plotIndex; + const plotEnd = event.params.plotIndex.plus(event.params.pods); + let harvestablePods = ZERO_BI; + let unharvestablePods = event.params.pods; + if (plotStart < harvestableIndex && plotEnd > harvestableIndex) { + // Partially harvestable + harvestablePods = harvestableIndex.minus(plotStart); + unharvestablePods = event.params.pods.minus(harvestablePods); + } else if (plotEnd <= harvestableIndex) { + // Fully harvestable + harvestablePods = event.params.pods; + unharvestablePods = ZERO_BI; + } + + let field = loadField(event.address); + field.unharvestablePods = field.unharvestablePods.plus(unharvestablePods); + field.harvestablePods = field.harvestablePods.plus(harvestablePods); + takeFieldSnapshots(field, event.block); + field.save(); + clearFieldDeltas(field, event.block); + + let accountField = loadField(event.params.account); + accountField.unharvestablePods = accountField.unharvestablePods.plus(unharvestablePods); + accountField.harvestablePods = accountField.harvestablePods.plus(harvestablePods); + takeFieldSnapshots(accountField, event.block); + accountField.save(); + clearFieldDeltas(accountField, event.block); + + loadFarmer(event.params.account); + let plot = loadPlot(event.address, event.params.plotIndex); + + plot.farmer = event.params.account; + plot.source = "Reseed Migrated"; + plot.sourceHash = event.transaction.hash; + plot.season = 0; + plot.creationHash = event.transaction.hash; + plot.createdAt = event.block.timestamp; + plot.updatedAt = event.block.timestamp; + plot.updatedAtBlock = event.block.number; + plot.pods = event.params.pods; + plot.beansPerPod = ZERO_BI; + plot.save(); +} + +export function handleMigratedPodListing(event: MigratedPodListing): void { + podListingCreated({ + event: event, + account: event.params.lister, + index: event.params.index, + start: event.params.start, + amount: event.params.podAmount, + pricePerPod: event.params.pricePerPod, + maxHarvestableIndex: event.params.maxHarvestableIndex, + mode: event.params.mode, + minFillAmount: event.params.minFillAmount, + pricingFunction: null, + pricingType: 0 + }); +} + +export function handleMigratedPodOrder(event: MigratedPodOrder): void { + podOrderCreated({ + event: event, + account: event.params.orderer, + id: event.params.id, + beanAmount: event.params.beanAmount, + pricePerPod: event.params.pricePerPod, + maxPlaceInLine: event.params.maxPlaceInLine, + minFillAmount: event.params.minFillAmount, + pricingFunction: null, + pricingType: 0 + }); +} + +export function handleInternalBalanceMigrated(event: InternalBalanceMigrated): void { + loadFarmer(event.params.account); + updateFarmTotals(event.address, event.params.account, event.params.token, event.params.delta, event.block); +} + +// Not currently necessary to handle the below. They are appropriately accounted for by the other events +// MigratedAccountStatus - AddMigratedDeposit +// FertilizerMigrated - TransferSingle events on fertilizer mints diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index 9acdd572c5..589927dafd 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -43,18 +43,12 @@ class TemperatureChangedParams { export function sow(params: SowParams): void { const protocol = params.event.address; let sownBeans = params.beans; - // Update Farmer Totals updateFieldTotals(protocol, params.account, ZERO_BI, sownBeans, params.pods, ZERO_BI, ZERO_BI, ZERO_BI, params.event.block); let field = loadField(protocol); loadFarmer(params.account); let plot = loadPlot(protocol, params.index); - let newIndexes = field.plotIndexes; - newIndexes.push(plot.index); - field.plotIndexes = newIndexes; - field.save(); - plot.farmer = params.account; plot.source = "SOW"; plot.sourceHash = params.event.transaction.hash; @@ -73,7 +67,6 @@ export function sow(params: SowParams): void { export function harvest(params: HarvestParams): void { const protocol = params.event.address; let beanstalk = loadBeanstalk(); - let season = loadSeason(BigInt.fromI32(beanstalk.lastSeason)); let remainingIndex = ZERO_BI; for (let i = 0; i < params.plots.length; i++) { @@ -82,7 +75,7 @@ export function harvest(params: HarvestParams): void { expirePodListingIfExists(toAddress(plot.farmer), plot.index, params.event.block); - let harvestablePods = season.harvestableIndex.minus(plot.index); + let harvestablePods = getHarvestableIndex().minus(plot.index); if (harvestablePods >= plot.pods) { // Plot fully harvests @@ -217,7 +210,6 @@ export function plotTransfer(params: PlotTransferParams): void { // Start value of zero let remainderIndex = sourceIndex.plus(params.amount); let remainderPlot = loadPlot(protocol, remainderIndex); - sortedPlots.push(remainderIndex); const isMarket = sourcePlot.source == "MARKET" && sourcePlot.sourceHash == params.event.transaction.hash; if (!isMarket) { @@ -251,7 +243,6 @@ export function plotTransfer(params: PlotTransferParams): void { // We are only needing to split this plot once to send // Non-zero start value. Sending to end of plot let toPlot = loadPlot(protocol, params.index); - sortedPlots.push(params.index); sourcePlot.updatedAt = params.event.block.timestamp; sourcePlot.updatedAtBlock = params.event.block.number; @@ -281,9 +272,6 @@ export function plotTransfer(params: PlotTransferParams): void { let toPlot = loadPlot(protocol, params.index); let remainderPlot = loadPlot(protocol, remainderIndex); - sortedPlots.push(params.index); - sortedPlots.push(remainderIndex); - sourcePlot.updatedAt = params.event.block.timestamp; sourcePlot.updatedAtBlock = params.event.block.number; sourcePlot.pods = params.index.minus(sourcePlot.index); @@ -321,9 +309,6 @@ export function plotTransfer(params: PlotTransferParams): void { remainderPlot.beansPerPod = sourcePlot.beansPerPod; remainderPlot.save(); } - sortedPlots.sort(); - field.plotIndexes = sortedPlots; - field.save(); // Update any harvestable pod amounts // No need to shift beanstalk field, only the farmer fields. @@ -386,18 +371,20 @@ export function updateFieldTotals( let field = loadField(account); field.season = getCurrentSeason(); - field.soil = field.soil.plus(soil).minus(sownBeans); field.sownBeans = field.sownBeans.plus(sownBeans); field.unharvestablePods = field.unharvestablePods.plus(sownPods).minus(harvestablePods).plus(transferredPods); field.harvestablePods = field.harvestablePods.plus(harvestablePods); field.harvestedPods = field.harvestedPods.plus(harvestedPods); - field.podIndex = field.podIndex.plus(sownPods); + if (account == protocol) { + field.soil = field.soil.plus(soil).minus(sownBeans); + field.podIndex = field.podIndex.plus(sownPods); + } takeFieldSnapshots(field, block); field.save(); // Set extra info on the hourly snapshot - if (field.soil == ZERO_BI) { + if (account == protocol && field.soil == ZERO_BI) { setHourlySoilSoldOut(block.number, field); } } diff --git a/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts index b21c5aee22..8431feec7c 100644 --- a/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts +++ b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts @@ -10,19 +10,20 @@ import { import { clearFieldDeltas, takeFieldSnapshots } from "../../entities/snapshots/Field"; import { loadPodMarketplace } from "../../entities/PodMarketplace"; import { clearMarketDeltas, takeMarketSnapshots } from "../../entities/snapshots/Marketplace"; -import { loadSilo, loadSiloAsset, loadUnripeToken, loadWhitelistTokenSetting } from "../../entities/Silo"; -import { getUnripeBeanAddr, getUnripeLpAddr, isUnripe } from "../../../../subgraph-core/constants/RuntimeConstants"; +import { loadSilo, loadUnripeToken } from "../../entities/Silo"; +import { getUnripeBeanAddr, getUnripeLpAddr } from "../../../../subgraph-core/constants/RuntimeConstants"; import { clearUnripeTokenDeltas, takeUnripeTokenSnapshots } from "../../entities/snapshots/UnripeToken"; import { loadBeanstalk } from "../../entities/Beanstalk"; import { clearSiloDeltas } from "../../entities/snapshots/Silo"; -import { clearSiloAssetDeltas } from "../../entities/snapshots/SiloAsset"; -import { clearWhitelistTokenSettingDeltas } from "../../entities/snapshots/WhitelistTokenSetting"; -import { toAddress } from "../../../../subgraph-core/utils/Bytes"; export function init(block: ethereum.Block): void { let beanstalk = loadBeanstalk(); beanstalk.lastSeason = SEASON_INITIAL; beanstalk.save(); + let field = loadField(v().protocolAddress); + field.podIndex = FIELD_INITIAL_VALUES.podIndex; + field.harvestableIndex = FIELD_INITIAL_VALUES.harvestableIndex; + field.save(); } // Carries over cumulative data from L1 -> L2 subgraph. See cache-builder/beanstalk3.js for the input source. diff --git a/projects/subgraph-beanstalk/tests/Migration.test.ts b/projects/subgraph-beanstalk/tests/Migration.test.ts index 1618db3b8a..24aacb064f 100644 --- a/projects/subgraph-beanstalk/tests/Migration.test.ts +++ b/projects/subgraph-beanstalk/tests/Migration.test.ts @@ -2,13 +2,23 @@ import { clearStore, beforeEach, afterEach, describe, test, assert } from "match import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { initL1Version } from "./entity-mocking/MockVersion"; import { init, preUnpause } from "../src/utils/b3-migration/Init"; -import { BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { AQUIFER, BEAN_ERC20, BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { FIELD_INITIAL_VALUES, POD_MARKETPLACE_INITIAL_VALUES, SEASON_INITIAL, UNRIPE_TOKENS_INITIAL_VALUES } from "../cache-builder/results/B3Migration_arb"; +import { + handleInternalBalanceMigrated, + handleMigratedPodListing, + handleMigratedPodOrder +} from "../src/handlers/legacy/ArbitrumMigrationHandler"; +import { createInternalBalanceMigratedEvent, createMigratedPodListingEvent, createMigratedPodOrderEvent } from "./event-mocking/Migration"; +import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; +import { BigInt, Bytes } from "@graphprotocol/graph-ts"; + +const account = AQUIFER; describe("Beanstalk 3 Migration", () => { beforeEach(() => { @@ -22,54 +32,103 @@ describe("Beanstalk 3 Migration", () => { clearStore(); }); - test("Field entity initialization", () => { - assert.fieldEquals("Field", BEANSTALK.toHexString(), "numberOfSowers", FIELD_INITIAL_VALUES.numberOfSowers.toString()); - assert.fieldEquals("Field", BEANSTALK.toHexString(), "sownBeans", FIELD_INITIAL_VALUES.sownBeans.toString()); - assert.fieldEquals( - "FieldHourlySnapshot", - BEANSTALK.toHexString() + "-" + SEASON_INITIAL.toString(), - "sownBeans", - FIELD_INITIAL_VALUES.sownBeans.toString() - ); - assert.fieldEquals("FieldHourlySnapshot", BEANSTALK.toHexString() + "-" + SEASON_INITIAL.toString(), "deltaSownBeans", "0"); - }); + describe("Initial entity data carry-over", () => { + test("Field entity initialization", () => { + assert.fieldEquals("Field", BEANSTALK.toHexString(), "numberOfSowers", FIELD_INITIAL_VALUES.numberOfSowers.toString()); + assert.fieldEquals("Field", BEANSTALK.toHexString(), "sownBeans", FIELD_INITIAL_VALUES.sownBeans.toString()); + assert.fieldEquals( + "FieldHourlySnapshot", + BEANSTALK.toHexString() + "-" + SEASON_INITIAL.toString(), + "sownBeans", + FIELD_INITIAL_VALUES.sownBeans.toString() + ); + assert.fieldEquals("FieldHourlySnapshot", BEANSTALK.toHexString() + "-" + SEASON_INITIAL.toString(), "deltaSownBeans", "0"); + }); - test("PodMarketplace entity initialization", () => { - assert.fieldEquals("PodMarketplace", "0", "filledListedPods", POD_MARKETPLACE_INITIAL_VALUES.filledListedPods.toString()); - assert.fieldEquals("PodMarketplace", "0", "beanVolume", POD_MARKETPLACE_INITIAL_VALUES.beanVolume.toString()); - assert.fieldEquals( - "PodMarketplaceHourlySnapshot", - "0-" + SEASON_INITIAL.toString(), - "beanVolume", - POD_MARKETPLACE_INITIAL_VALUES.beanVolume.toString() - ); - assert.fieldEquals("PodMarketplaceHourlySnapshot", "0-" + SEASON_INITIAL.toString(), "deltaBeanVolume", "0"); + test("PodMarketplace entity initialization", () => { + assert.fieldEquals("PodMarketplace", "0", "filledListedPods", POD_MARKETPLACE_INITIAL_VALUES.filledListedPods.toString()); + assert.fieldEquals("PodMarketplace", "0", "beanVolume", POD_MARKETPLACE_INITIAL_VALUES.beanVolume.toString()); + assert.fieldEquals( + "PodMarketplaceHourlySnapshot", + "0-" + SEASON_INITIAL.toString(), + "beanVolume", + POD_MARKETPLACE_INITIAL_VALUES.beanVolume.toString() + ); + assert.fieldEquals("PodMarketplaceHourlySnapshot", "0-" + SEASON_INITIAL.toString(), "deltaBeanVolume", "0"); + }); + + test("UnripeTokens entity initialization", () => { + assert.fieldEquals( + "UnripeToken", + UNRIPE_BEAN.toHexString(), + "totalChoppedAmount", + UNRIPE_TOKENS_INITIAL_VALUES[0].totalChoppedAmount.toString() + ); + assert.fieldEquals( + "UnripeToken", + UNRIPE_LP.toHexString(), + "totalChoppedBdvReceived", + UNRIPE_TOKENS_INITIAL_VALUES[1].totalChoppedBdvReceived.toString() + ); + assert.fieldEquals( + "UnripeTokenHourlySnapshot", + UNRIPE_BEAN.toHexString() + "-" + SEASON_INITIAL.toString(), + "totalChoppedBdvReceived", + UNRIPE_TOKENS_INITIAL_VALUES[0].totalChoppedBdvReceived.toString() + ); + assert.fieldEquals( + "UnripeTokenHourlySnapshot", + UNRIPE_BEAN.toHexString() + "-" + SEASON_INITIAL.toString(), + "deltaTotalChoppedBdvReceived", + "0" + ); + }); }); - test("UnripeTokens entity initialization", () => { - assert.fieldEquals( - "UnripeToken", - UNRIPE_BEAN.toHexString(), - "totalChoppedAmount", - UNRIPE_TOKENS_INITIAL_VALUES[0].totalChoppedAmount.toString() - ); - assert.fieldEquals( - "UnripeToken", - UNRIPE_LP.toHexString(), - "totalChoppedBdvReceived", - UNRIPE_TOKENS_INITIAL_VALUES[1].totalChoppedBdvReceived.toString() - ); - assert.fieldEquals( - "UnripeTokenHourlySnapshot", - UNRIPE_BEAN.toHexString() + "-" + SEASON_INITIAL.toString(), - "totalChoppedBdvReceived", - UNRIPE_TOKENS_INITIAL_VALUES[0].totalChoppedBdvReceived.toString() - ); - assert.fieldEquals( - "UnripeTokenHourlySnapshot", - UNRIPE_BEAN.toHexString() + "-" + SEASON_INITIAL.toString(), - "deltaTotalChoppedBdvReceived", - "0" - ); + describe("Asset Migration Events", () => { + test("AddMigratedDeposit", () => {}); + test("MigratedPlot", () => {}); + test("MigratedPodListing", () => { + const index = BigInt.fromU32(500).times(BI_10.pow(6)); + const amount = BigInt.fromU32(1500).times(BI_10.pow(6)); + handleMigratedPodListing( + createMigratedPodListingEvent( + account, + ZERO_BI, + index, + ZERO_BI, + amount, + BigInt.fromU32(50000), // 0.05 + BigInt.fromU32(7500).times(BI_10.pow(6)), + ONE_BI, + 0 + ) + ); + assert.fieldEquals("PodListing", account.toHexString() + "-" + index.toString(), "amount", amount.toString()); + }); + test("MigratedPodOrder", () => { + const orderId = Bytes.fromHexString("0xabcd"); + const beanAmount = BigInt.fromU32(500).times(BI_10.pow(6)); + handleMigratedPodOrder( + createMigratedPodOrderEvent( + account, + orderId, + beanAmount, + ZERO_BI, + BigInt.fromU32(50000), // 0.05 + BigInt.fromU32(7500).times(BI_10.pow(6)), + ONE_BI + ) + ); + assert.fieldEquals("PodOrder", orderId.toString(), "beanAmount", beanAmount.toString()); + }); + test("InternalBalanceMigrated", () => { + const beanAmount = BigInt.fromU32(2500).times(BI_10.pow(6)); + handleInternalBalanceMigrated(createInternalBalanceMigratedEvent(account, BEAN_ERC20, beanAmount)); + assert.fieldEquals("SiloAsset", account.toHexString() + "-" + BEAN_ERC20.toHexString(), "farmAmount", beanAmount.toString()); + }); + }); + test("Fertilizer Minted on L2", () => { + assert.assertTrue(false); }); }); diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Migration.ts b/projects/subgraph-beanstalk/tests/event-mocking/Migration.ts new file mode 100644 index 0000000000..30ce67ca89 --- /dev/null +++ b/projects/subgraph-beanstalk/tests/event-mocking/Migration.ts @@ -0,0 +1,132 @@ +import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; +import { + AddMigratedDeposit, + InternalBalanceMigrated, + MigratedPlot, + MigratedPodListing, + MigratedPodOrder +} from "../../generated/Beanstalk-ABIs/Reseed"; +import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; + +export function createAddMigratedDepositEvent( + account: Address, + token: Address, + stem: BigInt, + amount: BigInt, + bdv: BigInt +): AddMigratedDeposit { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(account)); + let param2 = new ethereum.EventParam("token", ethereum.Value.fromAddress(token)); + let param3 = new ethereum.EventParam("stem", ethereum.Value.fromUnsignedBigInt(stem)); + let param4 = new ethereum.EventParam("amount", ethereum.Value.fromUnsignedBigInt(amount)); + let param5 = new ethereum.EventParam("bdv", ethereum.Value.fromUnsignedBigInt(bdv)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + + return event as AddMigratedDeposit; +} + +export function createMigratedPlotEvent(account: Address, plotIndex: BigInt, pods: BigInt): MigratedPlot { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(account)); + let param2 = new ethereum.EventParam("plotIndex", ethereum.Value.fromUnsignedBigInt(plotIndex)); + let param3 = new ethereum.EventParam("pods", ethereum.Value.fromUnsignedBigInt(pods)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + + return event as MigratedPlot; +} + +export function createMigratedPodListingEvent( + lister: Address, + fieldId: BigInt, + index: BigInt, + start: BigInt, + podAmount: BigInt, + pricePerPod: BigInt, + maxHarvestableIndex: BigInt, + minFillAmount: BigInt, + mode: i32 +): MigratedPodListing { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("lister", ethereum.Value.fromAddress(lister)); + let param2 = new ethereum.EventParam("fieldId", ethereum.Value.fromUnsignedBigInt(fieldId)); + let param3 = new ethereum.EventParam("index", ethereum.Value.fromUnsignedBigInt(index)); + let param4 = new ethereum.EventParam("start", ethereum.Value.fromUnsignedBigInt(start)); + let param5 = new ethereum.EventParam("podAmount", ethereum.Value.fromUnsignedBigInt(podAmount)); + let param6 = new ethereum.EventParam("pricePerPod", ethereum.Value.fromUnsignedBigInt(pricePerPod)); + let param7 = new ethereum.EventParam("maxHarvestableIndex", ethereum.Value.fromUnsignedBigInt(maxHarvestableIndex)); + let param8 = new ethereum.EventParam("minFillAmount", ethereum.Value.fromUnsignedBigInt(minFillAmount)); + let param9 = new ethereum.EventParam("mode", ethereum.Value.fromI32(mode)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + event.parameters.push(param6); + event.parameters.push(param7); + event.parameters.push(param8); + event.parameters.push(param9); + + return event as MigratedPodListing; +} + +export function createMigratedPodOrderEvent( + orderer: Address, + id: Bytes, + beanAmount: BigInt, + fieldId: BigInt, + pricePerPod: BigInt, + maxPlaceInLine: BigInt, + minFillAmount: BigInt +): MigratedPodOrder { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("orderer", ethereum.Value.fromAddress(orderer)); + let param2 = new ethereum.EventParam("id", ethereum.Value.fromBytes(id)); + let param3 = new ethereum.EventParam("beanAmount", ethereum.Value.fromUnsignedBigInt(beanAmount)); + let param4 = new ethereum.EventParam("fieldId", ethereum.Value.fromUnsignedBigInt(fieldId)); + let param5 = new ethereum.EventParam("pricePerPod", ethereum.Value.fromUnsignedBigInt(pricePerPod)); + let param6 = new ethereum.EventParam("maxPlaceInLine", ethereum.Value.fromUnsignedBigInt(maxPlaceInLine)); + let param7 = new ethereum.EventParam("minFillAmount", ethereum.Value.fromUnsignedBigInt(minFillAmount)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + event.parameters.push(param6); + event.parameters.push(param7); + + return event as MigratedPodOrder; +} + +export function createInternalBalanceMigratedEvent(account: Address, token: Address, delta: BigInt): InternalBalanceMigrated { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(account)); + let param2 = new ethereum.EventParam("token", ethereum.Value.fromAddress(token)); + let param3 = new ethereum.EventParam("delta", ethereum.Value.fromUnsignedBigInt(delta)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + + return event as InternalBalanceMigrated; +} From 773c351a7597eaa21e1b7761700f43a3c2a251a7 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:10:07 -0700 Subject: [PATCH 57/88] fix plot index issue --- projects/subgraph-beanstalk/src/entities/Field.ts | 4 ---- .../src/handlers/legacy/ArbitrumMigrationHandler.ts | 11 ++++++++--- projects/subgraph-beanstalk/src/utils/Field.ts | 13 +++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/projects/subgraph-beanstalk/src/entities/Field.ts b/projects/subgraph-beanstalk/src/entities/Field.ts index a18e3465fb..0c45066b1a 100644 --- a/projects/subgraph-beanstalk/src/entities/Field.ts +++ b/projects/subgraph-beanstalk/src/entities/Field.ts @@ -51,10 +51,6 @@ export function loadPlot(diamondAddress: Address, index: BigInt): Plot { plot.harvestedPods = ZERO_BI; plot.fullyHarvested = false; plot.save(); - - let field = loadField(diamondAddress); - field.plotIndexes.push(plot.index); - field.save(); } return plot; } diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts index 427ef6219d..fd57939b2e 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts @@ -48,6 +48,14 @@ export function handleMigratedPlot(event: MigratedPlot): void { let field = loadField(event.address); field.unharvestablePods = field.unharvestablePods.plus(unharvestablePods); field.harvestablePods = field.harvestablePods.plus(harvestablePods); + + loadFarmer(event.params.account); + let plot = loadPlot(event.address, event.params.plotIndex); + + let newIndexes = field.plotIndexes; + newIndexes.push(plot.index); + field.plotIndexes = newIndexes; + takeFieldSnapshots(field, event.block); field.save(); clearFieldDeltas(field, event.block); @@ -59,9 +67,6 @@ export function handleMigratedPlot(event: MigratedPlot): void { accountField.save(); clearFieldDeltas(accountField, event.block); - loadFarmer(event.params.account); - let plot = loadPlot(event.address, event.params.plotIndex); - plot.farmer = event.params.account; plot.source = "Reseed Migrated"; plot.sourceHash = event.transaction.hash; diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index 589927dafd..58c2d9b865 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -49,6 +49,11 @@ export function sow(params: SowParams): void { loadFarmer(params.account); let plot = loadPlot(protocol, params.index); + let newIndexes = field.plotIndexes; + newIndexes.push(plot.index); + field.plotIndexes = newIndexes; + field.save(); + plot.farmer = params.account; plot.source = "SOW"; plot.sourceHash = params.event.transaction.hash; @@ -210,6 +215,7 @@ export function plotTransfer(params: PlotTransferParams): void { // Start value of zero let remainderIndex = sourceIndex.plus(params.amount); let remainderPlot = loadPlot(protocol, remainderIndex); + sortedPlots.push(remainderIndex); const isMarket = sourcePlot.source == "MARKET" && sourcePlot.sourceHash == params.event.transaction.hash; if (!isMarket) { @@ -243,6 +249,7 @@ export function plotTransfer(params: PlotTransferParams): void { // We are only needing to split this plot once to send // Non-zero start value. Sending to end of plot let toPlot = loadPlot(protocol, params.index); + sortedPlots.push(params.index); sourcePlot.updatedAt = params.event.block.timestamp; sourcePlot.updatedAtBlock = params.event.block.number; @@ -272,6 +279,9 @@ export function plotTransfer(params: PlotTransferParams): void { let toPlot = loadPlot(protocol, params.index); let remainderPlot = loadPlot(protocol, remainderIndex); + sortedPlots.push(params.index); + sortedPlots.push(remainderIndex); + sourcePlot.updatedAt = params.event.block.timestamp; sourcePlot.updatedAtBlock = params.event.block.number; sourcePlot.pods = params.index.minus(sourcePlot.index); @@ -309,6 +319,9 @@ export function plotTransfer(params: PlotTransferParams): void { remainderPlot.beansPerPod = sourcePlot.beansPerPod; remainderPlot.save(); } + sortedPlots.sort(); + field.plotIndexes = sortedPlots; + field.save(); // Update any harvestable pod amounts // No need to shift beanstalk field, only the farmer fields. From a7208b7a1110863a5775dc9a48f00aaceac470f5 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Sat, 14 Sep 2024 10:26:07 -0700 Subject: [PATCH 58/88] add abi --- projects/subgraph-bean/manifests/ethereum.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 5d66811711..d063338c14 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -138,6 +138,8 @@ dataSources: file: ../../subgraph-core/abis/Bean3CRV.json - name: CalculationsCurve file: ../../subgraph-core/abis/CalculationsCurve.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json eventHandlers: - event: Sunrise(indexed uint256) handler: handleSunrise_v1 From bfee5e00186d4adb9702888a91fe059292c3a834 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Sun, 15 Sep 2024 15:15:52 -0700 Subject: [PATCH 59/88] use correct handler name --- projects/subgraph-beanstalk/manifests/ethereum.yaml | 2 +- projects/subgraph-beanstalk/manifests/no-apy.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index c37118fe67..8e84247594 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -516,7 +516,7 @@ dataSources: - event: SeedsBalanceChanged(indexed address,int256) handler: handleSeedsBalanceChanged - event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64) - handler: handleWhitelistToken + handler: handleWhitelistToken_v4 - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) handler: handleRemoveWithdrawal - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index 2e3901703d..5d18ccf389 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -183,7 +183,7 @@ dataSources: - event: SeedsBalanceChanged(indexed address,int256) handler: handleSeedsBalanceChanged - event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64) - handler: handleWhitelistToken + handler: handleWhitelistToken_v4 - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) handler: handleRemoveWithdrawal - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) From 8249090d080e747034d1ef19605c4af8c3d0285c Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Sun, 15 Sep 2024 15:26:03 -0700 Subject: [PATCH 60/88] update endBlock for pre exploit --- projects/subgraph-bean/manifests/ethereum.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index d063338c14..d266b1013b 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -118,7 +118,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: PreReplant startBlock: 12974075 - endBlock: 14602789 # Exploit + endBlock: 14602789 # Exploit -1 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -231,7 +231,7 @@ dataSources: address: "0x87898263B6C5BABe34b4ec53F22d98430b91e371" abi: UniswapV2Pair startBlock: 12974077 - endBlock: 14602790 + endBlock: 14602789 # Exploit -1 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -256,7 +256,7 @@ dataSources: address: "0x3a70DfA7d2262988064A2D051dd47521E43c9BdD" abi: Bean3CRV startBlock: 13954026 - endBlock: 14602790 + endBlock: 14602789 # Exploit -1 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -297,7 +297,7 @@ dataSources: address: "0xD652c40fBb3f06d6B58Cb9aa9CFF063eE63d465D" abi: Bean3CRV startBlock: 14450075 - endBlock: 14602790 + endBlock: 14602789 # Exploit -1 mapping: kind: ethereum/events apiVersion: 0.0.7 From 3c9859ed244ca78a5b077978ec56a1975d5155e3 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:45:01 -0700 Subject: [PATCH 61/88] update manifest --- projects/subgraph-bean/manifests/ethereum.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index d266b1013b..54308075b5 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -160,6 +160,8 @@ dataSources: abis: - name: Replanted file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json - name: BeanstalkPrice file: ../../subgraph-core/abis/BeanstalkPrice.json - name: CurvePrice From 99736a72756d8992c4cf8b0effb0c531da2d07be Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:46:32 -0700 Subject: [PATCH 62/88] migration tests --- .../src/utils/constants/PooledTokens.ts | 2 +- .../tests/Migration.test.ts | 70 ++++++++++++++++--- .../tests/entity-mocking/MockVersion.ts | 5 ++ .../tests/event-mocking/Barn.ts | 22 ++++++ 4 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 projects/subgraph-beanstalk/tests/event-mocking/Barn.ts diff --git a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts index 88ad1ad786..e022db38ce 100644 --- a/projects/subgraph-bean/src/utils/constants/PooledTokens.ts +++ b/projects/subgraph-bean/src/utils/constants/PooledTokens.ts @@ -137,7 +137,7 @@ const tokens: Token[] = [ }, { address: BeanstalkArb.WBTC, - info: { name: "WBTC", decimals: BigInt.fromU32(18) } + info: { name: "WBTC", decimals: BigInt.fromU32(8) } }, { address: BeanstalkArb.USDC, diff --git a/projects/subgraph-beanstalk/tests/Migration.test.ts b/projects/subgraph-beanstalk/tests/Migration.test.ts index 24aacb064f..8e2b7b2f8f 100644 --- a/projects/subgraph-beanstalk/tests/Migration.test.ts +++ b/projects/subgraph-beanstalk/tests/Migration.test.ts @@ -1,8 +1,15 @@ import { clearStore, beforeEach, afterEach, describe, test, assert } from "matchstick-as/assembly/index"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; -import { initL1Version } from "./entity-mocking/MockVersion"; +import { initL2Version } from "./entity-mocking/MockVersion"; import { init, preUnpause } from "../src/utils/b3-migration/Init"; -import { AQUIFER, BEAN_ERC20, BEANSTALK, UNRIPE_BEAN, UNRIPE_LP } from "../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { + AQUIFER, + BEAN_ERC20, + BEANSTALK, + FERTILIZER, + UNRIPE_BEAN, + UNRIPE_LP +} from "../../subgraph-core/constants/raw/BeanstalkArbConstants"; import { FIELD_INITIAL_VALUES, POD_MARKETPLACE_INITIAL_VALUES, @@ -10,21 +17,30 @@ import { UNRIPE_TOKENS_INITIAL_VALUES } from "../cache-builder/results/B3Migration_arb"; import { + handleAddMigratedDeposit, handleInternalBalanceMigrated, + handleMigratedPlot, handleMigratedPodListing, handleMigratedPodOrder } from "../src/handlers/legacy/ArbitrumMigrationHandler"; -import { createInternalBalanceMigratedEvent, createMigratedPodListingEvent, createMigratedPodOrderEvent } from "./event-mocking/Migration"; +import { + createAddMigratedDepositEvent, + createInternalBalanceMigratedEvent, + createMigratedPlotEvent, + createMigratedPodListingEvent, + createMigratedPodOrderEvent +} from "./event-mocking/Migration"; import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { BigInt, Bytes } from "@graphprotocol/graph-ts"; +import { handleTransferSingle } from "../src/handlers/BarnHandler"; +import { createTransferSingleEvent } from "./event-mocking/Barn"; +import { ADDRESS_ZERO } from "../../subgraph-core/utils/Bytes"; const account = AQUIFER; describe("Beanstalk 3 Migration", () => { beforeEach(() => { - // NOTE: it may be more appropriate to init l2 version, but this shouldnt affect the tests - // (aside from having to use L1 addresses in this test) - initL1Version(); + initL2Version(); init(mockBlock()); preUnpause(mockBlock()); }); @@ -86,8 +102,24 @@ describe("Beanstalk 3 Migration", () => { }); describe("Asset Migration Events", () => { - test("AddMigratedDeposit", () => {}); - test("MigratedPlot", () => {}); + test("AddMigratedDeposit", () => { + const stem = BigInt.fromU32(2500); + const amount = BigInt.fromU32(500).times(BI_10.pow(6)); + handleAddMigratedDeposit(createAddMigratedDepositEvent(account, BEAN_ERC20, stem, amount, amount)); + assert.fieldEquals( + "SiloDeposit", + account.toHexString() + "-" + BEAN_ERC20.toHexString() + "-stem-" + stem.toString(), + "stemV31", + stem.toString() + ); + }); + test("MigratedPlot", () => { + const index = BigInt.fromU32(250000000).times(BI_10.pow(6)); + const amount = BigInt.fromU32(1500).times(BI_10.pow(6)); + handleMigratedPlot(createMigratedPlotEvent(account, index, amount)); + assert.fieldEquals("Plot", index.toString(), "source", "Reseed Migrated"); + assert.fieldEquals("Field", account.toHexString(), "unharvestablePods", amount.toString()); + }); test("MigratedPodListing", () => { const index = BigInt.fromU32(500).times(BI_10.pow(6)); const amount = BigInt.fromU32(1500).times(BI_10.pow(6)); @@ -128,7 +160,25 @@ describe("Beanstalk 3 Migration", () => { assert.fieldEquals("SiloAsset", account.toHexString() + "-" + BEAN_ERC20.toHexString(), "farmAmount", beanAmount.toString()); }); }); - test("Fertilizer Minted on L2", () => { - assert.assertTrue(false); + test("Barn - Fertilizer Minted during Reseed (no contract view functions available)", () => { + const fertId = BigInt.fromU32(6000000); + const amount = BigInt.fromU32(1500); + handleTransferSingle(createTransferSingleEvent(account, ADDRESS_ZERO, account, fertId, amount)); + assert.fieldEquals("Fertilizer", FERTILIZER.toHexString(), "supply", amount.toString()); + assert.fieldEquals("FertilizerToken", fertId.toString(), "supply", amount.toString()); + assert.fieldEquals("FertilizerToken", fertId.toString(), "humidity", "500"); + assert.fieldEquals("FertilizerToken", fertId.toString(), "season", "6074"); + assert.fieldEquals("FertilizerToken", fertId.toString(), "startBpf", "0"); + assert.fieldEquals("FertilizerBalance", fertId.toString() + "-" + account.toHexString(), "amount", amount.toString()); + + const fertId2 = BigInt.fromU32(2373025); + const amount2 = BigInt.fromU32(700); + handleTransferSingle(createTransferSingleEvent(account, ADDRESS_ZERO, account, fertId2, amount2)); + assert.fieldEquals("Fertilizer", FERTILIZER.toHexString(), "supply", amount.plus(amount2).toString()); + assert.fieldEquals("FertilizerToken", fertId2.toString(), "supply", amount2.toString()); + assert.fieldEquals("FertilizerToken", fertId2.toString(), "humidity", "124"); + assert.fieldEquals("FertilizerToken", fertId2.toString(), "season", "6326"); + assert.fieldEquals("FertilizerToken", fertId2.toString(), "startBpf", "133025"); + assert.fieldEquals("FertilizerBalance", fertId2.toString() + "-" + account.toHexString(), "amount", amount2.toString()); }); }); diff --git a/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts b/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts index b1fa5aa34f..b527349d41 100644 --- a/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts +++ b/projects/subgraph-beanstalk/tests/entity-mocking/MockVersion.ts @@ -1,7 +1,12 @@ import { handleInitVersion } from "../../src/utils/constants/Version"; import { mockBlock } from "../../../subgraph-core/tests/event-mocking/Block"; import { BEANSTALK_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkEthConstants"; +import { RESEED_BLOCK } from "../../../subgraph-core/constants/raw/BeanstalkArbConstants"; export function initL1Version(): void { handleInitVersion(mockBlock(BEANSTALK_BLOCK)); } + +export function initL2Version(): void { + handleInitVersion(mockBlock(RESEED_BLOCK)); +} diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Barn.ts b/projects/subgraph-beanstalk/tests/event-mocking/Barn.ts new file mode 100644 index 0000000000..1347998c47 --- /dev/null +++ b/projects/subgraph-beanstalk/tests/event-mocking/Barn.ts @@ -0,0 +1,22 @@ +import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; +import { TransferSingle } from "../../generated/Beanstalk-ABIs/Fertilizer"; +import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; + +export function createTransferSingleEvent(operator: Address, from: Address, to: Address, id: BigInt, value: BigInt): TransferSingle { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)); + let param2 = new ethereum.EventParam("from", ethereum.Value.fromAddress(from)); + let param3 = new ethereum.EventParam("to", ethereum.Value.fromAddress(to)); + let param4 = new ethereum.EventParam("id", ethereum.Value.fromUnsignedBigInt(id)); + let param5 = new ethereum.EventParam("value", ethereum.Value.fromUnsignedBigInt(value)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + + return event as TransferSingle; +} From 8e2855aacb2d154cc5fdad73b6abb55b6663b685 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:51:27 -0700 Subject: [PATCH 63/88] fix market tests --- projects/subgraph-beanstalk/tests/Migration.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/subgraph-beanstalk/tests/Migration.test.ts b/projects/subgraph-beanstalk/tests/Migration.test.ts index 8e2b7b2f8f..a2a174fc3c 100644 --- a/projects/subgraph-beanstalk/tests/Migration.test.ts +++ b/projects/subgraph-beanstalk/tests/Migration.test.ts @@ -123,6 +123,7 @@ describe("Beanstalk 3 Migration", () => { test("MigratedPodListing", () => { const index = BigInt.fromU32(500).times(BI_10.pow(6)); const amount = BigInt.fromU32(1500).times(BI_10.pow(6)); + handleMigratedPlot(createMigratedPlotEvent(account, index, amount)); handleMigratedPodListing( createMigratedPodListingEvent( account, @@ -152,7 +153,7 @@ describe("Beanstalk 3 Migration", () => { ONE_BI ) ); - assert.fieldEquals("PodOrder", orderId.toString(), "beanAmount", beanAmount.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmount", beanAmount.toString()); }); test("InternalBalanceMigrated", () => { const beanAmount = BigInt.fromU32(2500).times(BI_10.pow(6)); From b79550913eac535b03da4d2751ec9f5e9e82ec37 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:25:59 -0700 Subject: [PATCH 64/88] refactor isgauge check on whitelisted tokens --- projects/subgraph-beanstalk/schema.graphql | 20 ++++++++----------- .../subgraph-beanstalk/src/entities/Silo.ts | 1 + .../snapshots/WhitelistTokenSetting.ts | 12 +++++++---- .../src/handlers/legacy/LegacyGaugeHandler.ts | 5 ++--- .../src/handlers/legacy/LegacySiloHandler.ts | 5 ++--- .../subgraph-beanstalk/src/utils/Yield.ts | 2 +- .../tests/SeedGauge.test.ts | 13 +++++------- .../subgraph-beanstalk/tests/Yield.test.ts | 3 +-- projects/subgraph-core/utils/Bytes.ts | 5 ++--- 9 files changed, 30 insertions(+), 36 deletions(-) diff --git a/projects/subgraph-beanstalk/schema.graphql b/projects/subgraph-beanstalk/schema.graphql index 9283439101..3bd0103ab8 100644 --- a/projects/subgraph-beanstalk/schema.graphql +++ b/projects/subgraph-beanstalk/schema.graphql @@ -336,16 +336,14 @@ type WhitelistTokenSetting @entity { id: Bytes! "Encoded BDV selector" selector: Bytes! - "[Seed Gauge] Encoded Gauge Point selector" - gpSelector: Bytes - "[Seed Gauge] Encoded Liquidity Weight selector" - lwSelector: Bytes "Represents how much Stalk one BDV of the underlying deposited token grows each season." stalkEarnedPerSeason: BigInt! "The stalk per BDV that the silo grants in exchange for depositing this token." stalkIssuedPerBdv: BigInt! "The last season in which the stalkEarnedPerSeason for this token was updated." milestoneSeason: Int! + "Whether the seed gauge is enabled on this whitelisted token" + isGaugeEnabled: Boolean! "[Seed Gauge] Current Gauge Points" gaugePoints: BigInt "[Seed Gauge] The current optimal targeted distribution of BDV for this whitelisted asset" @@ -375,16 +373,14 @@ type WhitelistTokenHourlySnapshot @entity { token: WhitelistTokenSetting! "Encoded BDV selector" selector: Bytes! - "[Seed Gauge] Encoded Gauge Point selector" - gpSelector: Bytes - "[Seed Gauge] Encoded Liquidity Weight selector" - lwSelector: Bytes "Represents how much Stalk one BDV of the underlying deposited token grows each season." stalkEarnedPerSeason: BigInt! "The stalk per BDV that the silo grants in exchange for depositing this token." stalkIssuedPerBdv: BigInt! "The last season in which the stalkEarnedPerSeason for this token was updated." milestoneSeason: Int! + "Whether the seed gauge is enabled on this whitelisted token" + isGaugeEnabled: Boolean! "[Seed Gauge] Current Gauge Points" gaugePoints: BigInt "[Seed Gauge] The current optimal targeted distribution of BDV for this whitelisted asset" @@ -393,6 +389,7 @@ type WhitelistTokenHourlySnapshot @entity { deltaStalkEarnedPerSeason: BigInt! deltaStalkIssuedPerBdv: BigInt! deltaMilestoneSeason: Int! + deltaIsGaugeEnabled: Boolean! deltaGaugePoints: BigInt deltaOptimalPercentDepositedBdv: BigInt @@ -416,16 +413,14 @@ type WhitelistTokenDailySnapshot @entity { token: WhitelistTokenSetting! "Encoded BDV selector" selector: Bytes! - "[Seed Gauge] Encoded Gauge Point selector" - gpSelector: Bytes - "[Seed Gauge] Encoded Liquidity Weight selector" - lwSelector: Bytes "Represents how much Stalk one BDV of the underlying deposited token grows each season." stalkEarnedPerSeason: BigInt! "The stalk per BDV that the silo grants in exchange for depositing this token." stalkIssuedPerBdv: BigInt! "The last season in which the stalkEarnedPerSeason for this token was updated." milestoneSeason: Int! + "Whether the seed gauge is enabled on this whitelisted token" + isGaugeEnabled: Boolean! "[Seed Gauge] Current Gauge Points" gaugePoints: BigInt "[Seed Gauge] The current optimal targeted distribution of BDV for this whitelisted asset" @@ -434,6 +429,7 @@ type WhitelistTokenDailySnapshot @entity { deltaStalkEarnedPerSeason: BigInt! deltaStalkIssuedPerBdv: BigInt! deltaMilestoneSeason: Int! + deltaIsGaugeEnabled: Boolean! deltaGaugePoints: BigInt deltaOptimalPercentDepositedBdv: BigInt diff --git a/projects/subgraph-beanstalk/src/entities/Silo.ts b/projects/subgraph-beanstalk/src/entities/Silo.ts index 6c8ba4908a..c9cc2fa821 100644 --- a/projects/subgraph-beanstalk/src/entities/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/Silo.ts @@ -77,6 +77,7 @@ export function loadWhitelistTokenSetting(token: Address): WhitelistTokenSetting setting.stalkEarnedPerSeason = ZERO_BI; setting.stalkIssuedPerBdv = ZERO_BI; setting.milestoneSeason = 0; + setting.isGaugeEnabled = false; setting.decimals = getTokenDecimals(v(), token); setting.updatedAt = ZERO_BI; initLegacyUnripe(setting); diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts b/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts index 4bf7d329f6..5eb0ef6d49 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/WhitelistTokenSetting.ts @@ -32,11 +32,10 @@ export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: Whitel hourly.season = currentSeason; hourly.token = whitelistTokenSetting.id; hourly.selector = whitelistTokenSetting.selector; - hourly.gpSelector = whitelistTokenSetting.gpSelector; - hourly.lwSelector = whitelistTokenSetting.lwSelector; hourly.stalkEarnedPerSeason = whitelistTokenSetting.stalkEarnedPerSeason; hourly.stalkIssuedPerBdv = whitelistTokenSetting.stalkIssuedPerBdv; hourly.milestoneSeason = whitelistTokenSetting.milestoneSeason; + hourly.isGaugeEnabled = whitelistTokenSetting.isGaugeEnabled; hourly.gaugePoints = whitelistTokenSetting.gaugePoints; hourly.optimalPercentDepositedBdv = whitelistTokenSetting.optimalPercentDepositedBdv; @@ -45,6 +44,7 @@ export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: Whitel hourly.deltaStalkEarnedPerSeason = hourly.stalkEarnedPerSeason.minus(baseHourly.stalkEarnedPerSeason); hourly.deltaStalkIssuedPerBdv = hourly.stalkIssuedPerBdv.minus(baseHourly.stalkIssuedPerBdv); hourly.deltaMilestoneSeason = hourly.milestoneSeason - baseHourly.milestoneSeason; + hourly.deltaIsGaugeEnabled = hourly.isGaugeEnabled != baseHourly.isGaugeEnabled; if (hourly.gaugePoints !== null) { if (baseHourly.gaugePoints !== null) { hourly.deltaGaugePoints = hourly.gaugePoints!.minus(baseHourly.gaugePoints!); @@ -65,6 +65,7 @@ export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: Whitel hourly.deltaStalkEarnedPerSeason = hourly.deltaStalkEarnedPerSeason.plus(baseHourly.deltaStalkEarnedPerSeason); hourly.deltaStalkIssuedPerBdv = hourly.deltaStalkIssuedPerBdv.plus(baseHourly.deltaStalkIssuedPerBdv); hourly.deltaMilestoneSeason = hourly.deltaMilestoneSeason + baseHourly.deltaMilestoneSeason; + hourly.deltaIsGaugeEnabled = hourly.deltaIsGaugeEnabled != baseHourly.deltaIsGaugeEnabled; if (hourly.deltaGaugePoints !== null && baseHourly.deltaGaugePoints !== null) { hourly.deltaGaugePoints = hourly.deltaGaugePoints!.plus(baseHourly.deltaGaugePoints!); } @@ -76,6 +77,7 @@ export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: Whitel hourly.deltaStalkEarnedPerSeason = hourly.stalkEarnedPerSeason; hourly.deltaStalkIssuedPerBdv = hourly.stalkIssuedPerBdv; hourly.deltaMilestoneSeason = hourly.milestoneSeason; + hourly.deltaIsGaugeEnabled = hourly.isGaugeEnabled; hourly.deltaGaugePoints = hourly.gaugePoints; hourly.deltaOptimalPercentDepositedBdv = hourly.optimalPercentDepositedBdv; } @@ -89,17 +91,17 @@ export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: Whitel daily.season = currentSeason; daily.token = whitelistTokenSetting.id; daily.selector = whitelistTokenSetting.selector; - daily.gpSelector = whitelistTokenSetting.gpSelector; - daily.lwSelector = whitelistTokenSetting.lwSelector; daily.stalkEarnedPerSeason = whitelistTokenSetting.stalkEarnedPerSeason; daily.stalkIssuedPerBdv = whitelistTokenSetting.stalkIssuedPerBdv; daily.milestoneSeason = whitelistTokenSetting.milestoneSeason; + daily.isGaugeEnabled = whitelistTokenSetting.isGaugeEnabled; daily.gaugePoints = whitelistTokenSetting.gaugePoints; daily.optimalPercentDepositedBdv = whitelistTokenSetting.optimalPercentDepositedBdv; if (baseDaily !== null) { daily.deltaStalkEarnedPerSeason = daily.stalkEarnedPerSeason.minus(baseDaily.stalkEarnedPerSeason); daily.deltaStalkIssuedPerBdv = daily.stalkIssuedPerBdv.minus(baseDaily.stalkIssuedPerBdv); daily.deltaMilestoneSeason = daily.milestoneSeason - baseDaily.milestoneSeason; + daily.deltaIsGaugeEnabled = daily.isGaugeEnabled != baseDaily.isGaugeEnabled; if (daily.gaugePoints !== null) { if (baseDaily.gaugePoints !== null) { daily.deltaGaugePoints = daily.gaugePoints!.minus(baseDaily.gaugePoints!); @@ -120,6 +122,7 @@ export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: Whitel daily.deltaStalkEarnedPerSeason = daily.deltaStalkEarnedPerSeason.plus(baseDaily.deltaStalkEarnedPerSeason); daily.deltaStalkIssuedPerBdv = daily.deltaStalkIssuedPerBdv.plus(baseDaily.deltaStalkIssuedPerBdv); daily.deltaMilestoneSeason = daily.deltaMilestoneSeason + baseDaily.deltaMilestoneSeason; + daily.deltaIsGaugeEnabled = daily.deltaIsGaugeEnabled != baseDaily.deltaIsGaugeEnabled; if (daily.deltaGaugePoints !== null && baseDaily.deltaGaugePoints !== null) { daily.deltaGaugePoints = daily.deltaGaugePoints!.plus(baseDaily.deltaGaugePoints!); } @@ -131,6 +134,7 @@ export function takeWhitelistTokenSettingSnapshots(whitelistTokenSetting: Whitel daily.deltaStalkEarnedPerSeason = daily.stalkEarnedPerSeason; daily.deltaStalkIssuedPerBdv = daily.stalkIssuedPerBdv; daily.deltaMilestoneSeason = daily.milestoneSeason; + daily.deltaIsGaugeEnabled = daily.isGaugeEnabled; daily.deltaGaugePoints = daily.gaugePoints; daily.deltaOptimalPercentDepositedBdv = daily.optimalPercentDepositedBdv; } diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts index a91d15af67..ddfd08a397 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacyGaugeHandler.ts @@ -1,4 +1,4 @@ -import { Bytes4_emptyToNull } from "../../../../subgraph-core/utils/Bytes"; +import { Bytes4_emptySelector } from "../../../../subgraph-core/utils/Bytes"; import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { FarmerGerminatingStalkBalanceChanged, @@ -114,8 +114,7 @@ export function handleTotalGerminatingBalanceChanged_bugged(event: TotalGerminat // SeedGauge -> Reseed export function handleUpdateGaugeSettings(event: UpdateGaugeSettings): void { let siloSettings = loadWhitelistTokenSetting(event.params.token); - siloSettings.gpSelector = Bytes4_emptyToNull(event.params.gpSelector); - siloSettings.lwSelector = Bytes4_emptyToNull(event.params.lwSelector); + siloSettings.isGaugeEnabled = !Bytes4_emptySelector(event.params.gpSelector); siloSettings.optimalPercentDepositedBdv = event.params.optimalPercentDepositedBdv; siloSettings.updatedAt = event.block.timestamp; diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index 09735a7e36..7c8c70b2cb 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -16,7 +16,7 @@ import { takeWhitelistTokenSettingSnapshots } from "../../entities/snapshots/Whi import { WhitelistToken as WhitelistToken_v3 } from "../../../generated/Beanstalk-ABIs/SiloV3"; import { RemoveWithdrawal, RemoveWithdrawals, SeedsBalanceChanged, WhitelistToken } from "../../../generated/Beanstalk-ABIs/SeedGauge"; import { updateClaimedWithdraw, updateSeedsBalances } from "../../utils/legacy/LegacySilo"; -import { Bytes4_emptyToNull } from "../../../../subgraph-core/utils/Bytes"; +import { Bytes4_emptySelector } from "../../../../subgraph-core/utils/Bytes"; // Note: No silo v1 (pre-replant) handlers have been developed. @@ -142,8 +142,7 @@ export function handleWhitelistToken_v4(event: WhitelistToken): void { siloSettings.stalkEarnedPerSeason = event.params.stalkEarnedPerSeason; siloSettings.stalkIssuedPerBdv = event.params.stalkIssuedPerBdv; siloSettings.gaugePoints = event.params.gaugePoints; - siloSettings.gpSelector = Bytes4_emptyToNull(event.params.gpSelector); - siloSettings.lwSelector = Bytes4_emptyToNull(event.params.lwSelector); + siloSettings.isGaugeEnabled = !Bytes4_emptySelector(event.params.gpSelector); siloSettings.optimalPercentDepositedBdv = event.params.optimalPercentDepositedBdv; siloSettings.updatedAt = event.block.timestamp; diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index f1bfa32439..3216808165 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -105,7 +105,7 @@ export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i3 let tokenSetting = loadWhitelistTokenSetting(token); whitelistSettings.push(tokenSetting); - if (tokenSetting.gpSelector !== null) { + if (tokenSetting.isGaugeEnabled) { gaugeSettings.push(tokenSetting); isGaugeLive = true; } else { diff --git a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts index a7143e98f7..4cd6e0f43f 100644 --- a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts +++ b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts @@ -192,8 +192,7 @@ describe("Seed Gauge", () => { assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "selector", "0x12345678"); assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "stalkEarnedPerSeason", BigInt.fromU64(35000000000).toString()); assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "stalkIssuedPerBdv", BigInt.fromU64(10000000000).toString()); - assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "gpSelector", "0xabcdabcd"); - assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "lwSelector", "null"); + assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "isGaugeEnabled", "true"); assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "gaugePoints", BigInt.fromU32(12345).toString()); assert.fieldEquals( "WhitelistTokenSetting", @@ -207,8 +206,7 @@ describe("Seed Gauge", () => { handleUpdateGaugeSettings( createUpdateGaugeSettingsEvent(BEAN_ERC20.toHexString(), "0x12341234", "0xabcabcde", BigInt.fromU32(66).times(ratioDecimals)) ); - assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "gpSelector", "0x12341234"); - assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "lwSelector", "0xabcabcde"); + assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "isGaugeEnabled", "true"); assert.fieldEquals( "WhitelistTokenSetting", BEAN_ERC20.toHexString(), @@ -220,8 +218,7 @@ describe("Seed Gauge", () => { handleUpdateGaugeSettings( createUpdateGaugeSettingsEvent(BEAN_ERC20.toHexString(), "0x00000000", "0x00000000", BigInt.fromU32(66).times(ratioDecimals)) ); - assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "gpSelector", "null"); - assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "lwSelector", "null"); + assert.fieldEquals("WhitelistTokenSetting", BEAN_ERC20.toHexString(), "isGaugeEnabled", "false"); }); test("WhitelistToken Snapshots Get Created", () => { @@ -239,8 +236,8 @@ describe("Seed Gauge", () => { event.block = mockBlock(BigInt.fromU32(19628585), timestamp); handleUpdateGaugeSettings(event); - assert.fieldEquals("WhitelistTokenHourlySnapshot", BEAN_ERC20.toHexString() + "-1", "gpSelector", "0x12341234"); - assert.fieldEquals("WhitelistTokenDailySnapshot", BEAN_ERC20.toHexString() + "-" + day.toString(), "gpSelector", "0x12341234"); + assert.fieldEquals("WhitelistTokenHourlySnapshot", BEAN_ERC20.toHexString() + "-1", "isGaugeEnabled", "true"); + assert.fieldEquals("WhitelistTokenDailySnapshot", BEAN_ERC20.toHexString() + "-" + day.toString(), "isGaugeEnabled", "true"); }); }); }); diff --git a/projects/subgraph-beanstalk/tests/Yield.test.ts b/projects/subgraph-beanstalk/tests/Yield.test.ts index f953917e81..cc4b0dc7d0 100644 --- a/projects/subgraph-beanstalk/tests/Yield.test.ts +++ b/projects/subgraph-beanstalk/tests/Yield.test.ts @@ -165,8 +165,7 @@ describe("APY Calculations", () => { let beanEthWhitelistSettings = loadWhitelistTokenSetting(BEAN_WETH_CP2_WELL); beanEthWhitelistSettings.gaugePoints = BigInt.fromString("100000000000000000000"); - beanEthWhitelistSettings.gpSelector = Bytes.fromHexString("0x12345678"); - beanEthWhitelistSettings.lwSelector = Bytes.fromHexString("0x12345678"); + beanEthWhitelistSettings.isGaugeEnabled = true; beanEthWhitelistSettings.optimalPercentDepositedBdv = BigInt.fromString("100000000"); beanEthWhitelistSettings.save(); diff --git a/projects/subgraph-core/utils/Bytes.ts b/projects/subgraph-core/utils/Bytes.ts index 1657a5d94d..dbf6d463f5 100644 --- a/projects/subgraph-core/utils/Bytes.ts +++ b/projects/subgraph-core/utils/Bytes.ts @@ -2,9 +2,8 @@ import { BigInt, Bytes, Address } from "@graphprotocol/graph-ts"; export const ADDRESS_ZERO = Address.fromString("0x0000000000000000000000000000000000000000"); -// If all zeros are provided, convert into a null. Otherwise return the provided value -export function Bytes4_emptyToNull(b: Bytes): Bytes | null { - return b == Bytes.fromHexString("0x00000000") ? null : b; +export function Bytes4_emptySelector(b: Bytes): boolean { + return b == Bytes.fromHexString("0x00000000"); } // For using the graph's Bytes in big endian format From c58ea1c688458252869552f8b04616d9c6d30e09 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:47:10 -0700 Subject: [PATCH 65/88] handleUpdateWhitelistStatus --- projects/subgraph-beanstalk/manifests/arbitrum.yaml | 2 ++ projects/subgraph-beanstalk/src/entities/Silo.ts | 2 -- .../subgraph-beanstalk/src/handlers/SiloHandler.ts | 10 +++++++++- .../src/handlers/legacy/LegacySiloHandler.ts | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml index af608d335c..8e77f89772 100644 --- a/projects/subgraph-beanstalk/manifests/arbitrum.yaml +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -66,6 +66,8 @@ dataSources: handler: handlePlant - event: WhitelistToken(indexed address,bytes4,uint32,uint256,uint128,uint64) handler: handleWhitelistToken + - event: UpdateWhitelistStatus(address,uint256,bool,bool,bool,bool) + handler: handleUpdateWhitelistStatus - event: DewhitelistToken(indexed address) handler: handleDewhitelistToken - event: UpdatedStalkPerBdvPerSeason(indexed address,uint32,uint32) diff --git a/projects/subgraph-beanstalk/src/entities/Silo.ts b/projects/subgraph-beanstalk/src/entities/Silo.ts index c9cc2fa821..4d64d0b459 100644 --- a/projects/subgraph-beanstalk/src/entities/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/Silo.ts @@ -12,7 +12,6 @@ import { import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { getTokenDecimals, getUnripeUnderlying } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; -import { initLegacyUnripe } from "../utils/legacy/LegacyWhitelist"; /* ===== Base Silo Entities ===== */ @@ -80,7 +79,6 @@ export function loadWhitelistTokenSetting(token: Address): WhitelistTokenSetting setting.isGaugeEnabled = false; setting.decimals = getTokenDecimals(v(), token); setting.updatedAt = ZERO_BI; - initLegacyUnripe(setting); setting.save(); } return setting as WhitelistTokenSetting; diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 7925590405..6df1f8681f 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -10,7 +10,8 @@ import { RemoveDeposit, RemoveDeposits, StalkBalanceChanged, - UpdatedStalkPerBdvPerSeason + UpdatedStalkPerBdvPerSeason, + UpdateWhitelistStatus } from "../../generated/Beanstalk-ABIs/Reseed"; import { unripeChopped } from "../utils/Barn"; import { beanDecimals, getProtocolToken, isUnripe, stalkDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; @@ -122,6 +123,13 @@ export function handleWhitelistToken(event: WhitelistToken): void { siloSettings.save(); } +export function handleUpdateWhitelistStatus(event: UpdateWhitelistStatus): void { + let siloSettings = loadWhitelistTokenSetting(event.params.token); + siloSettings.isGaugeEnabled = event.params.isWhitelistedWell; + takeWhitelistTokenSettingSnapshots(siloSettings, event.block); + siloSettings.save(); +} + export function handleDewhitelistToken(event: DewhitelistToken): void { let silo = loadSilo(event.address); let currentWhitelist = silo.whitelistedTokens; diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index 7c8c70b2cb..22c86b5622 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -17,6 +17,7 @@ import { WhitelistToken as WhitelistToken_v3 } from "../../../generated/Beanstal import { RemoveWithdrawal, RemoveWithdrawals, SeedsBalanceChanged, WhitelistToken } from "../../../generated/Beanstalk-ABIs/SeedGauge"; import { updateClaimedWithdraw, updateSeedsBalances } from "../../utils/legacy/LegacySilo"; import { Bytes4_emptySelector } from "../../../../subgraph-core/utils/Bytes"; +import { initLegacyUnripe } from "../../utils/legacy/LegacyWhitelist"; // Note: No silo v1 (pre-replant) handlers have been developed. @@ -114,6 +115,7 @@ export function handleWhitelistToken_v2(event: WhitelistToken_v2): void { setting.selector = event.params.selector; setting.stalkIssuedPerBdv = BigInt.fromString("10000000000"); setting.stalkEarnedPerSeason = event.params.stalk.times(BigInt.fromI32(1000000)); + initLegacyUnripe(setting); takeWhitelistTokenSettingSnapshots(setting, event.block); setting.save(); From 80b8c2fc5475539d4269348126cc8ffeec722b26 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:54:30 -0700 Subject: [PATCH 66/88] manifest for arb migration --- .../manifests/arbitrum.yaml | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml index 8e77f89772..b067e7f96f 100644 --- a/projects/subgraph-beanstalk/manifests/arbitrum.yaml +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -5,8 +5,35 @@ dataSources: ### # L1 -> L2 MIGRATION ### - # (TODO) - + - kind: ethereum/contract + name: ReseedMigration + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 585858585858 # Reseed + endBlock: 575757575757 # Reseed Completion + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Plot + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + eventHandlers: + - event: AddMigratedDeposit(indexed address,indexed address,int96,uint256,uint256) + handler: handleAddMigratedDeposit + - event: MigratedPlot(indexed address,indexed uint256,uint256) + handler: handleMigratedPlot + - event: MigratedPodListing(indexed address,uint256,uint256,uint256,uint256,uint24,uint256,uint256,uint8) + handler: handleMigratedPodListing + - event: MigratedPodOrder(indexed address,bytes32,uint256,uint256,uint24,uint256,uint256) + handler: handleMigratedPodOrder + - event: InternalBalanceMigrated(indexed address,indexed address,int256) + handler: handleInternalBalanceMigrated + file: ../src/handlers/legacy/ArbitrumMigrationHandler.ts ### # INITIALIZATION ### From f4faf0f84913d17636cd3096aeb7af6a1b45fe40 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:30:36 -0700 Subject: [PATCH 67/88] fert token info cached --- .../cache-builder/beanstalk3.js | 36 +- .../cache-builder/results/B3Migration_arb.ts | 660 +++++++++++++++++- .../src/entities/Fertilizer.ts | 27 +- .../src/handlers/BarnHandler.ts | 4 +- projects/subgraph-beanstalk/src/utils/Barn.ts | 23 +- .../tests/Migration.test.ts | 4 +- .../tests/event-mocking/Barn.ts | 13 +- 7 files changed, 721 insertions(+), 46 deletions(-) diff --git a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js index 77f143297c..6366fee2fa 100644 --- a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js +++ b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js @@ -1,7 +1,7 @@ const { GraphQLClient, gql } = require("graphql-request"); const fs = require("fs"); -const url = "https://graph.bean.money/beanstalk_eth"; +const url = "https://graph.bean.money/beanstalk-testing_eth"; const subgraph = new GraphQLClient(url); const tokenMap = { @@ -13,7 +13,7 @@ const tokenMap = { (async () => { const l1Values = await subgraph.request(gql` { - beanstalk(id: "0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5") { + beanstalk(id: "beanstalk") { lastSeason } field(id: "0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5") { @@ -24,7 +24,7 @@ const tokenMap = { podIndex harvestableIndex } - podMarketplace(id: "0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5") { + podMarketplace(id: "0") { filledListedPods expiredListedPods cancelledListedPods @@ -34,6 +34,12 @@ const tokenMap = { podVolume beanVolume } + fertilizerTokens(first: 1000) { + id + humidity + season + startBpf + } unripeTokens { id totalChoppedAmount @@ -43,12 +49,21 @@ const tokenMap = { } `); + const fertTokenInfo = l1Values.fertilizerTokens.map((fertToken) => { + return `{ + id: BigInt.fromString('${fertToken.id}'), + humidity: BigDecimal.fromString('${fertToken.humidity}'), + season: ${fertToken.season}, + startBpf: BigInt.fromString('${fertToken.startBpf}') + }`; + }); + const outFile = `${__dirname}/results/B3Migration_arb.ts`; await fs.promises.writeFile( outFile, `/* This is a generated file */ - import { BigInt } from "@graphprotocol/graph-ts"; + import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; class FieldInitialValues { numberOfSowers: i32; @@ -70,6 +85,13 @@ const tokenMap = { beanVolume: BigInt; } + export class FertilizerTokenInfo { + id: BigInt; + humidity: BigDecimal; + season: i32; + startBpf: BigInt; + } + class UnripeTokenInitialValues { tokenType: string; totalChoppedAmount: BigInt; @@ -83,9 +105,9 @@ const tokenMap = { numberOfSowers: ${l1Values.field.numberOfSowers}, numberOfSows: ${l1Values.field.numberOfSows}, sownBeans: BigInt.fromString('${l1Values.field.sownBeans}'), - harvestedPods: BigInt.fromString('${l1Values.field.harvestedPods}') + harvestedPods: BigInt.fromString('${l1Values.field.harvestedPods}'), podIndex: BigInt.fromString('${l1Values.field.podIndex}'), - harvestableIndex: BigInt.fromString('${l1Values.field.harvestableIndex}'), + harvestableIndex: BigInt.fromString('${l1Values.field.harvestableIndex}') }; export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { @@ -99,6 +121,8 @@ const tokenMap = { beanVolume: BigInt.fromString('${l1Values.podMarketplace.beanVolume}') }; + export const FERT_TOKEN_INFO_CACHED: FertilizerTokenInfo[] = [${fertTokenInfo.join(",")}]; + export const UNRIPE_TOKENS_INITIAL_VALUES: UnripeTokenInitialValues[] = [ { tokenType: '${tokenMap[l1Values.unripeTokens[0].id]}', diff --git a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts index 897f9fa563..a209b5a34e 100644 --- a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts +++ b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts @@ -1,6 +1,6 @@ /* This is a generated file */ -import { BigInt } from "@graphprotocol/graph-ts"; +import { BigInt, BigDecimal } from "@graphprotocol/graph-ts"; class FieldInitialValues { numberOfSowers: i32; @@ -22,6 +22,13 @@ class PodMarketplaceInitialValues { beanVolume: BigInt; } +export class FertilizerTokenInfo { + id: BigInt; + humidity: BigDecimal; + season: i32; + startBpf: BigInt; +} + class UnripeTokenInitialValues { tokenType: string; totalChoppedAmount: BigInt; @@ -29,34 +36,661 @@ class UnripeTokenInitialValues { totalChoppedBdvReceived: BigInt; } -export const SEASON_INITIAL = 24484; +export const SEASON_INITIAL = 24607; export const FIELD_INITIAL_VALUES: FieldInitialValues = { numberOfSowers: 0, - numberOfSows: 19172, - sownBeans: BigInt.fromString("33592460721984"), + numberOfSows: 19295, + sownBeans: BigInt.fromString("33592460890398"), harvestedPods: BigInt.fromString("61126608133951"), - podIndex: BigInt.fromString("980532024384892"), + podIndex: BigInt.fromString("980532032792248"), harvestableIndex: BigInt.fromString("61128909242563") }; export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { filledListedPods: BigInt.fromString("49222911145993"), expiredListedPods: BigInt.fromString("7065428228776"), - cancelledListedPods: BigInt.fromString("60134193309316"), - filledOrderBeans: BigInt.fromString("762556935865"), - filledOrderedPods: BigInt.fromString("14851692494599"), + cancelledListedPods: BigInt.fromString("60153188425068"), + filledOrderBeans: BigInt.fromString("763175980418"), + filledOrderedPods: BigInt.fromString("14858570767416"), cancelledOrderBeans: BigInt.fromString("1308742101463"), - podVolume: BigInt.fromString("64074603640592"), - beanVolume: BigInt.fromString("6508703985303") + podVolume: BigInt.fromString("64081481913409"), + beanVolume: BigInt.fromString("6509323029856") }; +export const FERT_TOKEN_INFO_CACHED: FertilizerTokenInfo[] = [ + { + id: BigInt.fromString("1334303"), + humidity: BigDecimal.fromString("20"), + season: 6624, + startBpf: BigInt.fromString("134303") + }, + { + id: BigInt.fromString("1334880"), + humidity: BigDecimal.fromString("20"), + season: 6997, + startBpf: BigInt.fromString("134880") + }, + { + id: BigInt.fromString("1334901"), + humidity: BigDecimal.fromString("20"), + season: 7041, + startBpf: BigInt.fromString("134901") + }, + { + id: BigInt.fromString("1334925"), + humidity: BigDecimal.fromString("20"), + season: 7151, + startBpf: BigInt.fromString("134925") + }, + { + id: BigInt.fromString("1335008"), + humidity: BigDecimal.fromString("20"), + season: 7733, + startBpf: BigInt.fromString("135008") + }, + { + id: BigInt.fromString("1335068"), + humidity: BigDecimal.fromString("20"), + season: 7824, + startBpf: BigInt.fromString("135068") + }, + { + id: BigInt.fromString("1335304"), + humidity: BigDecimal.fromString("20"), + season: 7886, + startBpf: BigInt.fromString("135304") + }, + { + id: BigInt.fromString("1336323"), + humidity: BigDecimal.fromString("20"), + season: 8017, + startBpf: BigInt.fromString("136323") + }, + { + id: BigInt.fromString("1337953"), + humidity: BigDecimal.fromString("20"), + season: 8110, + startBpf: BigInt.fromString("137953") + }, + { + id: BigInt.fromString("1338731"), + humidity: BigDecimal.fromString("20"), + season: 8153, + startBpf: BigInt.fromString("138731") + }, + { + id: BigInt.fromString("1348369"), + humidity: BigDecimal.fromString("20"), + season: 8741, + startBpf: BigInt.fromString("148369") + }, + { + id: BigInt.fromString("1363069"), + humidity: BigDecimal.fromString("20"), + season: 15928, + startBpf: BigInt.fromString("163069") + }, + { + id: BigInt.fromString("1363641"), + humidity: BigDecimal.fromString("20"), + season: 15973, + startBpf: BigInt.fromString("163641") + }, + { + id: BigInt.fromString("1418854"), + humidity: BigDecimal.fromString("28.5"), + season: 6517, + startBpf: BigInt.fromString("133854") + }, + { + id: BigInt.fromString("1553682"), + humidity: BigDecimal.fromString("42"), + season: 6490, + startBpf: BigInt.fromString("133682") + }, + { + id: BigInt.fromString("1593637"), + humidity: BigDecimal.fromString("46"), + season: 6482, + startBpf: BigInt.fromString("133637") + }, + { + id: BigInt.fromString("2078193"), + humidity: BigDecimal.fromString("94.5"), + season: 6385, + startBpf: BigInt.fromString("133193") + }, + { + id: BigInt.fromString("2313052"), + humidity: BigDecimal.fromString("118"), + season: 6338, + startBpf: BigInt.fromString("133052") + }, + { + id: BigInt.fromString("2373025"), + humidity: BigDecimal.fromString("124"), + season: 6326, + startBpf: BigInt.fromString("133025") + }, + { + id: BigInt.fromString("2382999"), + humidity: BigDecimal.fromString("125"), + season: 6324, + startBpf: BigInt.fromString("132999") + }, + { + id: BigInt.fromString("2412881"), + humidity: BigDecimal.fromString("128"), + season: 6318, + startBpf: BigInt.fromString("132881") + }, + { + id: BigInt.fromString("2452755"), + humidity: BigDecimal.fromString("132"), + season: 6310, + startBpf: BigInt.fromString("132755") + }, + { + id: BigInt.fromString("2482696"), + humidity: BigDecimal.fromString("135"), + season: 6304, + startBpf: BigInt.fromString("132696") + }, + { + id: BigInt.fromString("2492679"), + humidity: BigDecimal.fromString("136"), + season: 6302, + startBpf: BigInt.fromString("132679") + }, + { + id: BigInt.fromString("2502666"), + humidity: BigDecimal.fromString("137"), + season: 6300, + startBpf: BigInt.fromString("132666") + }, + { + id: BigInt.fromString("2687438"), + humidity: BigDecimal.fromString("155.5"), + season: 6263, + startBpf: BigInt.fromString("132438") + }, + { + id: BigInt.fromString("2702430"), + humidity: BigDecimal.fromString("157"), + season: 6260, + startBpf: BigInt.fromString("132430") + }, + { + id: BigInt.fromString("2767422"), + humidity: BigDecimal.fromString("163.5"), + season: 6247, + startBpf: BigInt.fromString("132422") + }, + { + id: BigInt.fromString("2811995"), + humidity: BigDecimal.fromString("168"), + season: 6238, + startBpf: BigInt.fromString("131995") + }, + { + id: BigInt.fromString("2871153"), + humidity: BigDecimal.fromString("174"), + season: 6226, + startBpf: BigInt.fromString("131153") + }, + { + id: BigInt.fromString("2886153"), + humidity: BigDecimal.fromString("175.5"), + season: 6223, + startBpf: BigInt.fromString("131153") + }, + { + id: BigInt.fromString("2891153"), + humidity: BigDecimal.fromString("176"), + season: 6222, + startBpf: BigInt.fromString("131153") + }, + { + id: BigInt.fromString("2901153"), + humidity: BigDecimal.fromString("177"), + season: 6220, + startBpf: BigInt.fromString("131153") + }, + { + id: BigInt.fromString("2921113"), + humidity: BigDecimal.fromString("179"), + season: 6216, + startBpf: BigInt.fromString("131113") + }, + { + id: BigInt.fromString("2945769"), + humidity: BigDecimal.fromString("181.5"), + season: 6211, + startBpf: BigInt.fromString("130769") + }, + { + id: BigInt.fromString("2955590"), + humidity: BigDecimal.fromString("182.5"), + season: 6209, + startBpf: BigInt.fromString("130590") + }, + { + id: BigInt.fromString("2975557"), + humidity: BigDecimal.fromString("184.5"), + season: 6205, + startBpf: BigInt.fromString("130557") + }, + { + id: BigInt.fromString("3005557"), + humidity: BigDecimal.fromString("187.5"), + season: 6199, + startBpf: BigInt.fromString("130557") + }, + { + id: BigInt.fromString("3015555"), + humidity: BigDecimal.fromString("188.5"), + season: 6197, + startBpf: BigInt.fromString("130555") + }, + { + id: BigInt.fromString("3045431"), + humidity: BigDecimal.fromString("191.5"), + season: 6191, + startBpf: BigInt.fromString("130431") + }, + { + id: BigInt.fromString("3060408"), + humidity: BigDecimal.fromString("193"), + season: 6188, + startBpf: BigInt.fromString("130408") + }, + { + id: BigInt.fromString("3095329"), + humidity: BigDecimal.fromString("196.5"), + season: 6181, + startBpf: BigInt.fromString("130329") + }, + { + id: BigInt.fromString("3125329"), + humidity: BigDecimal.fromString("199.5"), + season: 6175, + startBpf: BigInt.fromString("130329") + }, + { + id: BigInt.fromString("3130329"), + humidity: BigDecimal.fromString("200"), + season: 6174, + startBpf: BigInt.fromString("130329") + }, + { + id: BigInt.fromString("3164439"), + humidity: BigDecimal.fromString("203.5"), + season: 6167, + startBpf: BigInt.fromString("129439") + }, + { + id: BigInt.fromString("3223426"), + humidity: BigDecimal.fromString("209.5"), + season: 6155, + startBpf: BigInt.fromString("128426") + }, + { + id: BigInt.fromString("3268426"), + humidity: BigDecimal.fromString("214"), + season: 6146, + startBpf: BigInt.fromString("128426") + }, + { + id: BigInt.fromString("3278426"), + humidity: BigDecimal.fromString("215"), + season: 6144, + startBpf: BigInt.fromString("128426") + }, + { + id: BigInt.fromString("3293426"), + humidity: BigDecimal.fromString("216.5"), + season: 6141, + startBpf: BigInt.fromString("128426") + }, + { + id: BigInt.fromString("3303426"), + humidity: BigDecimal.fromString("217.5"), + season: 6139, + startBpf: BigInt.fromString("128426") + }, + { + id: BigInt.fromString("3308426"), + humidity: BigDecimal.fromString("218"), + season: 6138, + startBpf: BigInt.fromString("128426") + }, + { + id: BigInt.fromString("3313426"), + humidity: BigDecimal.fromString("218.5"), + season: 6137, + startBpf: BigInt.fromString("128426") + }, + { + id: BigInt.fromString("3328426"), + humidity: BigDecimal.fromString("220"), + season: 6134, + startBpf: BigInt.fromString("128426") + }, + { + id: BigInt.fromString("3338293"), + humidity: BigDecimal.fromString("221"), + season: 6132, + startBpf: BigInt.fromString("128293") + }, + { + id: BigInt.fromString("3343293"), + humidity: BigDecimal.fromString("221.5"), + season: 6131, + startBpf: BigInt.fromString("128293") + }, + { + id: BigInt.fromString("3363293"), + humidity: BigDecimal.fromString("223.5"), + season: 6127, + startBpf: BigInt.fromString("128293") + }, + { + id: BigInt.fromString("3383071"), + humidity: BigDecimal.fromString("225.5"), + season: 6123, + startBpf: BigInt.fromString("128071") + }, + { + id: BigInt.fromString("3393052"), + humidity: BigDecimal.fromString("226.5"), + season: 6121, + startBpf: BigInt.fromString("128052") + }, + { + id: BigInt.fromString("3398029"), + humidity: BigDecimal.fromString("227"), + season: 6120, + startBpf: BigInt.fromString("128029") + }, + { + id: BigInt.fromString("3413005"), + humidity: BigDecimal.fromString("228.5"), + season: 6117, + startBpf: BigInt.fromString("128005") + }, + { + id: BigInt.fromString("3418005"), + humidity: BigDecimal.fromString("229"), + season: 6116, + startBpf: BigInt.fromString("128005") + }, + { + id: BigInt.fromString("3423005"), + humidity: BigDecimal.fromString("229.5"), + season: 6115, + startBpf: BigInt.fromString("128005") + }, + { + id: BigInt.fromString("3428005"), + humidity: BigDecimal.fromString("230"), + season: 6114, + startBpf: BigInt.fromString("128005") + }, + { + id: BigInt.fromString("3433005"), + humidity: BigDecimal.fromString("230.5"), + season: 6113, + startBpf: BigInt.fromString("128005") + }, + { + id: BigInt.fromString("3438005"), + humidity: BigDecimal.fromString("231"), + season: 6112, + startBpf: BigInt.fromString("128005") + }, + { + id: BigInt.fromString("3439448"), + humidity: BigDecimal.fromString("241"), + season: 6092, + startBpf: BigInt.fromString("29448") + }, + { + id: BigInt.fromString("3441470"), + humidity: BigDecimal.fromString("241.5"), + season: 6091, + startBpf: BigInt.fromString("26470") + }, + { + id: BigInt.fromString("3441822"), + humidity: BigDecimal.fromString("240.5"), + season: 6093, + startBpf: BigInt.fromString("36822") + }, + { + id: BigInt.fromString("3443005"), + humidity: BigDecimal.fromString("231.5"), + season: 6111, + startBpf: BigInt.fromString("128005") + }, + { + id: BigInt.fromString("3443526"), + humidity: BigDecimal.fromString("242"), + season: 6090, + startBpf: BigInt.fromString("23526") + }, + { + id: BigInt.fromString("3445713"), + humidity: BigDecimal.fromString("242.5"), + season: 6089, + startBpf: BigInt.fromString("20713") + }, + { + id: BigInt.fromString("3446568"), + humidity: BigDecimal.fromString("240"), + season: 6094, + startBpf: BigInt.fromString("46568") + }, + { + id: BigInt.fromString("3447839"), + humidity: BigDecimal.fromString("243"), + season: 6088, + startBpf: BigInt.fromString("17839") + }, + { + id: BigInt.fromString("3447990"), + humidity: BigDecimal.fromString("232"), + season: 6110, + startBpf: BigInt.fromString("127990") + }, + { + id: BigInt.fromString("3450159"), + humidity: BigDecimal.fromString("243.5"), + season: 6087, + startBpf: BigInt.fromString("15159") + }, + { + id: BigInt.fromString("3452316"), + humidity: BigDecimal.fromString("239.5"), + season: 6095, + startBpf: BigInt.fromString("57316") + }, + { + id: BigInt.fromString("3452735"), + humidity: BigDecimal.fromString("244"), + season: 6086, + startBpf: BigInt.fromString("12735") + }, + { + id: BigInt.fromString("3452989"), + humidity: BigDecimal.fromString("232.5"), + season: 6109, + startBpf: BigInt.fromString("127989") + }, + { + id: BigInt.fromString("3455539"), + humidity: BigDecimal.fromString("244.5"), + season: 6085, + startBpf: BigInt.fromString("10539") + }, + { + id: BigInt.fromString("3457989"), + humidity: BigDecimal.fromString("233"), + season: 6108, + startBpf: BigInt.fromString("127989") + }, + { + id: BigInt.fromString("3458512"), + humidity: BigDecimal.fromString("239"), + season: 6096, + startBpf: BigInt.fromString("68512") + }, + { + id: BigInt.fromString("3458531"), + humidity: BigDecimal.fromString("245"), + season: 6084, + startBpf: BigInt.fromString("8531") + }, + { + id: BigInt.fromString("3461694"), + humidity: BigDecimal.fromString("245.5"), + season: 6083, + startBpf: BigInt.fromString("6694") + }, + { + id: BigInt.fromString("3462428"), + humidity: BigDecimal.fromString("233.5"), + season: 6107, + startBpf: BigInt.fromString("127428") + }, + { + id: BigInt.fromString("3463060"), + humidity: BigDecimal.fromString("238.5"), + season: 6097, + startBpf: BigInt.fromString("78060") + }, + { + id: BigInt.fromString("3465087"), + humidity: BigDecimal.fromString("246"), + season: 6082, + startBpf: BigInt.fromString("5087") + }, + { + id: BigInt.fromString("3465205"), + humidity: BigDecimal.fromString("238"), + season: 6098, + startBpf: BigInt.fromString("85205") + }, + { + id: BigInt.fromString("3466192"), + humidity: BigDecimal.fromString("234"), + season: 6106, + startBpf: BigInt.fromString("126192") + }, + { + id: BigInt.fromString("3467650"), + humidity: BigDecimal.fromString("237.5"), + season: 6099, + startBpf: BigInt.fromString("92650") + }, + { + id: BigInt.fromString("3468402"), + humidity: BigDecimal.fromString("234.5"), + season: 6105, + startBpf: BigInt.fromString("123402") + }, + { + id: BigInt.fromString("3468691"), + humidity: BigDecimal.fromString("246.5"), + season: 6081, + startBpf: BigInt.fromString("3691") + }, + { + id: BigInt.fromString("3470075"), + humidity: BigDecimal.fromString("235"), + season: 6104, + startBpf: BigInt.fromString("120075") + }, + { + id: BigInt.fromString("3470220"), + humidity: BigDecimal.fromString("237"), + season: 6100, + startBpf: BigInt.fromString("100220") + }, + { + id: BigInt.fromString("3471339"), + humidity: BigDecimal.fromString("235.5"), + season: 6103, + startBpf: BigInt.fromString("116339") + }, + { + id: BigInt.fromString("3471974"), + humidity: BigDecimal.fromString("236.5"), + season: 6101, + startBpf: BigInt.fromString("106974") + }, + { + id: BigInt.fromString("3472026"), + humidity: BigDecimal.fromString("236"), + season: 6102, + startBpf: BigInt.fromString("112026") + }, + { + id: BigInt.fromString("3472520"), + humidity: BigDecimal.fromString("247"), + season: 6080, + startBpf: BigInt.fromString("2520") + }, + { + id: BigInt.fromString("3476597"), + humidity: BigDecimal.fromString("247.5"), + season: 6079, + startBpf: BigInt.fromString("1597") + }, + { + id: BigInt.fromString("3480951"), + humidity: BigDecimal.fromString("248"), + season: 6078, + startBpf: BigInt.fromString("951") + }, + { + id: BigInt.fromString("3485472"), + humidity: BigDecimal.fromString("248.5"), + season: 6077, + startBpf: BigInt.fromString("472") + }, + { + id: BigInt.fromString("3490157"), + humidity: BigDecimal.fromString("249"), + season: 6076, + startBpf: BigInt.fromString("157") + }, + { + id: BigInt.fromString("3495000"), + humidity: BigDecimal.fromString("249.5"), + season: 6075, + startBpf: BigInt.fromString("0") + }, + { + id: BigInt.fromString("3500000"), + humidity: BigDecimal.fromString("250"), + season: 6074, + startBpf: BigInt.fromString("0") + }, + { + id: BigInt.fromString("6000000"), + humidity: BigDecimal.fromString("500"), + season: 6074, + startBpf: BigInt.fromString("0") + } +]; + export const UNRIPE_TOKENS_INITIAL_VALUES: UnripeTokenInitialValues[] = [ { tokenType: "urbean", - totalChoppedAmount: BigInt.fromString("24665725897573"), - totalChoppedBdv: BigInt.fromString("5882168812974"), - totalChoppedBdvReceived: BigInt.fromString("1334001323440") + totalChoppedAmount: BigInt.fromString("25248630479617"), + totalChoppedBdv: BigInt.fromString("6035933361833"), + totalChoppedBdvReceived: BigInt.fromString("1370603113776") }, { tokenType: "urlp", diff --git a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts index 0c76a8c45c..a4297f4eef 100644 --- a/projects/subgraph-beanstalk/src/entities/Fertilizer.ts +++ b/projects/subgraph-beanstalk/src/entities/Fertilizer.ts @@ -1,9 +1,7 @@ -import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; +import { Address, BigInt } from "@graphprotocol/graph-ts"; import { Farmer, Fertilizer, FertilizerBalance, FertilizerToken, FertilizerYield } from "../../generated/schema"; import { ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { Reseed } from "../../generated/Beanstalk-ABIs/Reseed"; -import { v } from "../utils/constants/Version"; -import { isReplanted } from "../../../subgraph-core/constants/RuntimeConstants"; +import { getFertilizerInfo } from "../utils/Barn"; export function loadFertilizer(fertilizerAddress: Address): Fertilizer { let fertilizer = Fertilizer.load(fertilizerAddress); @@ -16,22 +14,17 @@ export function loadFertilizer(fertilizerAddress: Address): Fertilizer { return fertilizer; } -export function loadFertilizerToken(fertilizer: Fertilizer, id: BigInt, blockNumber: BigInt): FertilizerToken { +export function loadFertilizerToken(fertilizer: Fertilizer, id: BigInt): FertilizerToken { let fertilizerToken = FertilizerToken.load(id.toString()); if (fertilizerToken == null) { - const beanstalkContract = Reseed.bind(v().protocolAddress); fertilizerToken = new FertilizerToken(id.toString()); fertilizerToken.fertilizer = fertilizer.id; - if (isReplanted(v(), blockNumber)) { - // TODO: fix this for migrated fert. Need carry-over for all FertilizerToken. - fertilizerToken.humidity = BigDecimal.fromString(beanstalkContract.getCurrentHumidity().toString()).div(BigDecimal.fromString("10")); - fertilizerToken.season = beanstalkContract.season().toI32(); - fertilizerToken.startBpf = beanstalkContract.beansPerFertilizer(); - } else { - fertilizerToken.humidity = BigDecimal.fromString("500"); - fertilizerToken.season = 6074; - fertilizerToken.startBpf = ZERO_BI; - } + + const fertInfo = getFertilizerInfo(id); + fertilizerToken.humidity = fertInfo.humidity; + fertilizerToken.season = fertInfo.season; + fertilizerToken.startBpf = fertInfo.startBpf; + fertilizerToken.endBpf = id; fertilizerToken.supply = ZERO_BI; fertilizerToken.save(); @@ -40,7 +33,7 @@ export function loadFertilizerToken(fertilizer: Fertilizer, id: BigInt, blockNum } export function loadFertilizerBalance(fertilizerToken: FertilizerToken, farmer: Farmer): FertilizerBalance { - const id = `${fertilizerToken.id}-${farmer.id}`; + const id = `${fertilizerToken.id}-${farmer.id.toHexString()}`; let fertilizerBalance = FertilizerBalance.load(id); if (fertilizerBalance == null) { fertilizerBalance = new FertilizerBalance(id); diff --git a/projects/subgraph-beanstalk/src/handlers/BarnHandler.ts b/projects/subgraph-beanstalk/src/handlers/BarnHandler.ts index 417414cace..2a2edc7fe9 100644 --- a/projects/subgraph-beanstalk/src/handlers/BarnHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/BarnHandler.ts @@ -5,14 +5,14 @@ import { loadUnripeToken } from "../entities/Silo"; import { transfer, unripeChopped, updateUnripeStats } from "../utils/Barn"; export function handleTransferSingle(event: TransferSingle): void { - transfer(event.address, event.params.from, event.params.to, event.params.id, event.params.value, event.block.number); + transfer(event.address, event.params.from, event.params.to, event.params.id, event.params.value); } export function handleTransferBatch(event: TransferBatch): void { for (let i = 0; i < event.params.ids.length; i++) { let id = event.params.ids[i]; let amount = event.params.values[i]; - transfer(event.address, event.params.from, event.params.to, id, amount, event.block.number); + transfer(event.address, event.params.from, event.params.to, id, amount); } } diff --git a/projects/subgraph-beanstalk/src/utils/Barn.ts b/projects/subgraph-beanstalk/src/utils/Barn.ts index 78fd02d650..35fbda009b 100644 --- a/projects/subgraph-beanstalk/src/utils/Barn.ts +++ b/projects/subgraph-beanstalk/src/utils/Barn.ts @@ -1,4 +1,4 @@ -import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; +import { Address, BigInt, BigDecimal, ethereum, log } from "@graphprotocol/graph-ts"; import { Chop as ChopEntity } from "../../generated/schema"; import { loadFertilizer, loadFertilizerBalance, loadFertilizerToken } from "../entities/Fertilizer"; import { loadFarmer } from "../entities/Beanstalk"; @@ -10,6 +10,7 @@ import { getLatestBdv } from "../entities/snapshots/WhitelistTokenSetting"; import { ADDRESS_ZERO } from "../../../subgraph-core/utils/Bytes"; import { getUnripeUnderlying } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "./constants/Version"; +import { FERT_TOKEN_INFO_CACHED, FertilizerTokenInfo } from "../../cache-builder/results/B3Migration_arb"; class ChopParams { event: ethereum.Event; @@ -20,9 +21,25 @@ class ChopParams { underlyingAmount: BigInt; } -export function transfer(fertilizer1155: Address, from: Address, to: Address, id: BigInt, amount: BigInt, blockNumber: BigInt): void { +export function getFertilizerInfo(fertId: BigInt): FertilizerTokenInfo { + for (let i = 0; i < FERT_TOKEN_INFO_CACHED.length; ++i) { + if (FERT_TOKEN_INFO_CACHED[i].id == fertId) { + return FERT_TOKEN_INFO_CACHED[i]; + } + } + // If not cached, get on chain + const beanstalkContract = Reseed.bind(v().protocolAddress); + return { + id: fertId, + humidity: BigDecimal.fromString(beanstalkContract.getCurrentHumidity().toString()).div(BigDecimal.fromString("10")), + season: beanstalkContract.season().toI32(), + startBpf: beanstalkContract.beansPerFertilizer() + }; +} + +export function transfer(fertilizer1155: Address, from: Address, to: Address, id: BigInt, amount: BigInt): void { let fertilizer = loadFertilizer(fertilizer1155); - let fertilizerToken = loadFertilizerToken(fertilizer, id, blockNumber); + let fertilizerToken = loadFertilizerToken(fertilizer, id); if (from != ADDRESS_ZERO) { let fromFarmer = loadFarmer(from); let fromFertilizerBalance = loadFertilizerBalance(fertilizerToken, fromFarmer); diff --git a/projects/subgraph-beanstalk/tests/Migration.test.ts b/projects/subgraph-beanstalk/tests/Migration.test.ts index a2a174fc3c..7aa1a9124d 100644 --- a/projects/subgraph-beanstalk/tests/Migration.test.ts +++ b/projects/subgraph-beanstalk/tests/Migration.test.ts @@ -164,7 +164,7 @@ describe("Beanstalk 3 Migration", () => { test("Barn - Fertilizer Minted during Reseed (no contract view functions available)", () => { const fertId = BigInt.fromU32(6000000); const amount = BigInt.fromU32(1500); - handleTransferSingle(createTransferSingleEvent(account, ADDRESS_ZERO, account, fertId, amount)); + handleTransferSingle(createTransferSingleEvent(FERTILIZER, account, ADDRESS_ZERO, account, fertId, amount)); assert.fieldEquals("Fertilizer", FERTILIZER.toHexString(), "supply", amount.toString()); assert.fieldEquals("FertilizerToken", fertId.toString(), "supply", amount.toString()); assert.fieldEquals("FertilizerToken", fertId.toString(), "humidity", "500"); @@ -174,7 +174,7 @@ describe("Beanstalk 3 Migration", () => { const fertId2 = BigInt.fromU32(2373025); const amount2 = BigInt.fromU32(700); - handleTransferSingle(createTransferSingleEvent(account, ADDRESS_ZERO, account, fertId2, amount2)); + handleTransferSingle(createTransferSingleEvent(FERTILIZER, account, ADDRESS_ZERO, account, fertId2, amount2)); assert.fieldEquals("Fertilizer", FERTILIZER.toHexString(), "supply", amount.plus(amount2).toString()); assert.fieldEquals("FertilizerToken", fertId2.toString(), "supply", amount2.toString()); assert.fieldEquals("FertilizerToken", fertId2.toString(), "humidity", "124"); diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Barn.ts b/projects/subgraph-beanstalk/tests/event-mocking/Barn.ts index 1347998c47..55e0fba1e3 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Barn.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Barn.ts @@ -1,9 +1,16 @@ import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; import { TransferSingle } from "../../generated/Beanstalk-ABIs/Fertilizer"; -import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; +import { mockContractEvent } from "../../../subgraph-core/tests/event-mocking/Util"; -export function createTransferSingleEvent(operator: Address, from: Address, to: Address, id: BigInt, value: BigInt): TransferSingle { - let event = changetype(mockBeanstalkEvent()); +export function createTransferSingleEvent( + fertContract: Address, + operator: Address, + from: Address, + to: Address, + id: BigInt, + value: BigInt +): TransferSingle { + let event = changetype(mockContractEvent(fertContract)); event.parameters = new Array(); let param1 = new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)); From d33a6e3134dee5c2bbf95bbb03007b19337582bd Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:39:48 -0700 Subject: [PATCH 68/88] fix bean manifest --- projects/subgraph-bean/manifests/ethereum.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 54308075b5..d6abbeed46 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -168,6 +168,8 @@ dataSources: file: ../../subgraph-core/abis/CurvePrice.json - name: UniswapV2Pair file: ../../subgraph-core/abis/UniswapV2Pair.json + - name: ERC20 + file: ../../subgraph-core/abis/ERC20.json - name: Bean3CRV file: ../../subgraph-core/abis/Bean3CRV.json - name: CalculationsCurve From fbb86a7645a3f2cac6123a040e5da6e7dadbf57c Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:43:38 -0700 Subject: [PATCH 69/88] Set basin deployment block --- projects/subgraph-basin/manifests/arbitrum.yaml | 8 ++++---- .../subgraph-core/constants/raw/BeanstalkArbConstants.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/projects/subgraph-basin/manifests/arbitrum.yaml b/projects/subgraph-basin/manifests/arbitrum.yaml index 2256f172e6..e26cb20d3a 100644 --- a/projects/subgraph-basin/manifests/arbitrum.yaml +++ b/projects/subgraph-basin/manifests/arbitrum.yaml @@ -11,8 +11,8 @@ dataSources: source: address: "0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521" abi: Aquifer - startBlock: 393939393939 - endBlock: 393939393939 + startBlock: 235608025 + endBlock: 235608025 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -33,7 +33,7 @@ dataSources: source: address: "0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521" abi: Aquifer - startBlock: 393939393939 + startBlock: 235608025 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -55,7 +55,7 @@ dataSources: source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" abi: Beanstalk - startBlock: 393939393939 + startBlock: 235608025 mapping: kind: ethereum/events apiVersion: 0.0.7 diff --git a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts index 6c9776b287..0026cd50f6 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts @@ -32,5 +32,5 @@ export const AQUIFER = Address.fromString("0xBA51AAAa8C2f911AE672e783707Ceb2dA6E ////// TODO: Set this upon deployment export const RESEED_SEASON = BigInt.fromU32(30000); export const RESEED_BLOCK = BigInt.fromU64(585858585858); -export const BASIN_BLOCK = BigInt.fromU64(393939393939); ////// +export const BASIN_BLOCK = BigInt.fromU64(235608025); From 0e2cd73670173e15562387a195b53f5321ea017a Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:59:49 -0700 Subject: [PATCH 70/88] add init datasource to manifests --- .../subgraph-basin/manifests/arbitrum.yaml | 2 +- .../subgraph-basin/manifests/ethereum.yaml | 2 +- .../subgraph-bean/manifests/arbitrum.yaml | 24 +++++++++- .../subgraph-bean/manifests/ethereum.yaml | 2 +- .../subgraph-beanft/manifests/ethereum.yaml | 2 +- .../manifests/arbitrum.yaml | 47 ++++++++++++++++++- .../manifests/ethereum.yaml | 2 +- .../subgraph-beanstalk/manifests/no-apy.yaml | 2 +- 8 files changed, 75 insertions(+), 8 deletions(-) diff --git a/projects/subgraph-basin/manifests/arbitrum.yaml b/projects/subgraph-basin/manifests/arbitrum.yaml index e26cb20d3a..d3a85aef98 100644 --- a/projects/subgraph-basin/manifests/arbitrum.yaml +++ b/projects/subgraph-basin/manifests/arbitrum.yaml @@ -6,7 +6,7 @@ dataSources: # INITIALIZATION ### - kind: ethereum/contract - name: Version + name: InitVersion network: arbitrum-one source: address: "0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521" diff --git a/projects/subgraph-basin/manifests/ethereum.yaml b/projects/subgraph-basin/manifests/ethereum.yaml index 5ace1135a6..de516ee1d6 100644 --- a/projects/subgraph-basin/manifests/ethereum.yaml +++ b/projects/subgraph-basin/manifests/ethereum.yaml @@ -6,7 +6,7 @@ dataSources: # INITIALIZATION ### - kind: ethereum/contract - name: Version + name: InitVersion network: mainnet source: address: "0xBA51AAAA95aeEFc1292515b36D86C51dC7877773" diff --git a/projects/subgraph-bean/manifests/arbitrum.yaml b/projects/subgraph-bean/manifests/arbitrum.yaml index c39ca2e125..15b894b39f 100644 --- a/projects/subgraph-bean/manifests/arbitrum.yaml +++ b/projects/subgraph-bean/manifests/arbitrum.yaml @@ -6,7 +6,7 @@ dataSources: # INITIALIZATION ### - kind: ethereum/contract - name: Version + name: InitVersion network: arbitrum-one source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" @@ -27,6 +27,28 @@ dataSources: filter: kind: once file: ../src/utils/constants/Version.ts + - kind: ethereum/contract + name: InitInit + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 585858585858 # Reseed + endBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Version + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + blockHandlers: + - handler: init + filter: + kind: once + file: ../src/utils/b3-migration/Init.ts ### # BEAN TOKEN ### diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index d6abbeed46..848ed43a6d 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -6,7 +6,7 @@ dataSources: # INITIALIZATION ### - kind: ethereum/contract - name: Version + name: InitVersion network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" diff --git a/projects/subgraph-beanft/manifests/ethereum.yaml b/projects/subgraph-beanft/manifests/ethereum.yaml index 7ad32490e5..09ed536f95 100644 --- a/projects/subgraph-beanft/manifests/ethereum.yaml +++ b/projects/subgraph-beanft/manifests/ethereum.yaml @@ -6,7 +6,7 @@ dataSources: # INITIALIZATION ### - kind: ethereum/contract - name: Version + name: InitVersion network: mainnet source: address: "0xa755A670Aaf1FeCeF2bea56115E65e03F7722A79" diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml index b067e7f96f..7e6716417a 100644 --- a/projects/subgraph-beanstalk/manifests/arbitrum.yaml +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -38,7 +38,7 @@ dataSources: # INITIALIZATION ### - kind: ethereum/contract - name: Version + name: InitVersion network: arbitrum-one source: address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" @@ -59,6 +59,51 @@ dataSources: filter: kind: once file: ../src/utils/constants/Version.ts + - kind: ethereum/contract + name: InitInit + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 585858585858 # Reseed + endBlock: 585858585858 # Reseed + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Beanstalk + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + blockHandlers: + - handler: init + filter: + kind: once + file: ../src/utils/b3-migration/Init.ts + - kind: ethereum/contract + name: InitPreUnpause + network: arbitrum-one + source: + address: "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70" + abi: Reseed + startBlock: 575757575757 # Reseed Completion + endBlock: 575757575757 # Reseed Completion + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Beanstalk + abis: + - name: Reseed + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP50.json + blockHandlers: + - handler: preUnpause + filter: + kind: once + file: ../src/utils/b3-migration/Init.ts + ### # SILO ### diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index 8e84247594..2277206446 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -340,7 +340,7 @@ dataSources: # INITIALIZATION ### - kind: ethereum/contract - name: Version + name: InitVersion network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index 5d18ccf389..f37044ff3f 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -7,7 +7,7 @@ dataSources: # INITIALIZATION ### - kind: ethereum/contract - name: Version + name: InitVersion network: mainnet source: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" From dced90efb9554af4eeff7c71e4fa1eebb4c545da Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:08:54 -0700 Subject: [PATCH 71/88] fix season beans init --- projects/subgraph-beanstalk/src/entities/Beanstalk.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts index 5b8f86baf6..20233be974 100644 --- a/projects/subgraph-beanstalk/src/entities/Beanstalk.ts +++ b/projects/subgraph-beanstalk/src/entities/Beanstalk.ts @@ -46,12 +46,12 @@ export function loadSeason(id: BigInt): Season { season.deltaBeans = ZERO_BI; season.rewardBeans = ZERO_BI; season.incentiveBeans = ZERO_BI; - season.save(); - if (id > ZERO_BI) { - let lastSeason = loadSeason(id.minus(ONE_BI)); + + let lastSeason = Season.load(id.minus(ONE_BI).toString()); + if (lastSeason != null) { season.beans = lastSeason.beans; - season.save(); } + season.save(); // Update beanstalk season let beanstalk = loadBeanstalk(); From 0e3115d134dfff21c6d639d8ba1799ceb9b3c14b Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:00:12 -0700 Subject: [PATCH 72/88] add RESEED_MIGRATED to plot source enum --- projects/subgraph-beanstalk/schema.graphql | 1 + .../src/handlers/legacy/ArbitrumMigrationHandler.ts | 2 +- projects/subgraph-beanstalk/tests/Migration.test.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/projects/subgraph-beanstalk/schema.graphql b/projects/subgraph-beanstalk/schema.graphql index 3bd0103ab8..77f6dd777f 100644 --- a/projects/subgraph-beanstalk/schema.graphql +++ b/projects/subgraph-beanstalk/schema.graphql @@ -25,6 +25,7 @@ enum PlotSource { SOW TRANSFER MARKET + RESEED_MIGRATED } enum EmaWindow { diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts index fd57939b2e..7bd6c0bea3 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts @@ -68,7 +68,7 @@ export function handleMigratedPlot(event: MigratedPlot): void { clearFieldDeltas(accountField, event.block); plot.farmer = event.params.account; - plot.source = "Reseed Migrated"; + plot.source = "RESEED_MIGRATED"; plot.sourceHash = event.transaction.hash; plot.season = 0; plot.creationHash = event.transaction.hash; diff --git a/projects/subgraph-beanstalk/tests/Migration.test.ts b/projects/subgraph-beanstalk/tests/Migration.test.ts index 7aa1a9124d..063a26d3b2 100644 --- a/projects/subgraph-beanstalk/tests/Migration.test.ts +++ b/projects/subgraph-beanstalk/tests/Migration.test.ts @@ -117,7 +117,7 @@ describe("Beanstalk 3 Migration", () => { const index = BigInt.fromU32(250000000).times(BI_10.pow(6)); const amount = BigInt.fromU32(1500).times(BI_10.pow(6)); handleMigratedPlot(createMigratedPlotEvent(account, index, amount)); - assert.fieldEquals("Plot", index.toString(), "source", "Reseed Migrated"); + assert.fieldEquals("Plot", index.toString(), "source", "RESEED_MIGRATED"); assert.fieldEquals("Field", account.toHexString(), "unharvestablePods", amount.toString()); }); test("MigratedPodListing", () => { From fe1b794d4b599965e80925c2fecca2c22a040966 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:09:50 -0700 Subject: [PATCH 73/88] volatile price peg check every 10 seconds --- projects/subgraph-bean/manifests/arbitrum.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/subgraph-bean/manifests/arbitrum.yaml b/projects/subgraph-bean/manifests/arbitrum.yaml index 15b894b39f..b930f8afb4 100644 --- a/projects/subgraph-bean/manifests/arbitrum.yaml +++ b/projects/subgraph-bean/manifests/arbitrum.yaml @@ -371,6 +371,9 @@ dataSources: file: ../../subgraph-core/abis/BeanstalkPrice.json blockHandlers: - handler: handleBlock + filter: + kind: polling + every: 40 # 10 seconds on arbitrum file: ../src/handlers/CrossHandler.ts # features: # - grafting From a3fc8a13da6a1528127d7a83d2cef29229deb504 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:16:40 -0700 Subject: [PATCH 74/88] fix number of sows --- .../cache-builder/beanstalk3.js | 12 ++++++---- .../cache-builder/results/B3Migration_arb.ts | 24 +++++++++---------- .../subgraph-beanstalk/src/utils/Field.ts | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js index 6366fee2fa..80a097596d 100644 --- a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js +++ b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js @@ -11,12 +11,14 @@ const tokenMap = { // NOTE: once latest subgraph is deployed, will need to update beanstalk/marketplace ids in this query. (async () => { + // for testing purposes. set to empty string to ignore + const block = "block: { number: 20736200 }"; const l1Values = await subgraph.request(gql` { - beanstalk(id: "beanstalk") { + beanstalk(id: "beanstalk" ${block}) { lastSeason } - field(id: "0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5") { + field(id: "0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5" ${block}) { numberOfSowers numberOfSows sownBeans @@ -24,7 +26,7 @@ const tokenMap = { podIndex harvestableIndex } - podMarketplace(id: "0") { + podMarketplace(id: "0" ${block}) { filledListedPods expiredListedPods cancelledListedPods @@ -34,13 +36,13 @@ const tokenMap = { podVolume beanVolume } - fertilizerTokens(first: 1000) { + fertilizerTokens(first: 1000 ${block}) { id humidity season startBpf } - unripeTokens { + unripeTokens${block ? `(${block})` : ""} { id totalChoppedAmount totalChoppedBdv diff --git a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts index a209b5a34e..21a20446ca 100644 --- a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts +++ b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts @@ -36,26 +36,26 @@ class UnripeTokenInitialValues { totalChoppedBdvReceived: BigInt; } -export const SEASON_INITIAL = 24607; +export const SEASON_INITIAL = 24508; export const FIELD_INITIAL_VALUES: FieldInitialValues = { numberOfSowers: 0, - numberOfSows: 19295, - sownBeans: BigInt.fromString("33592460890398"), + numberOfSows: 19196, + sownBeans: BigInt.fromString("33592460856188"), harvestedPods: BigInt.fromString("61126608133951"), - podIndex: BigInt.fromString("980532032792248"), + podIndex: BigInt.fromString("980532024233292"), harvestableIndex: BigInt.fromString("61128909242563") }; export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { filledListedPods: BigInt.fromString("49222911145993"), expiredListedPods: BigInt.fromString("7065428228776"), - cancelledListedPods: BigInt.fromString("60153188425068"), - filledOrderBeans: BigInt.fromString("763175980418"), - filledOrderedPods: BigInt.fromString("14858570767416"), + cancelledListedPods: BigInt.fromString("60134193309316"), + filledOrderBeans: BigInt.fromString("762556935865"), + filledOrderedPods: BigInt.fromString("14851692494599"), cancelledOrderBeans: BigInt.fromString("1308742101463"), - podVolume: BigInt.fromString("64081481913409"), - beanVolume: BigInt.fromString("6509323029856") + podVolume: BigInt.fromString("64074603640592"), + beanVolume: BigInt.fromString("6508703985303") }; export const FERT_TOKEN_INFO_CACHED: FertilizerTokenInfo[] = [ @@ -688,9 +688,9 @@ export const FERT_TOKEN_INFO_CACHED: FertilizerTokenInfo[] = [ export const UNRIPE_TOKENS_INITIAL_VALUES: UnripeTokenInitialValues[] = [ { tokenType: "urbean", - totalChoppedAmount: BigInt.fromString("25248630479617"), - totalChoppedBdv: BigInt.fromString("6035933361833"), - totalChoppedBdvReceived: BigInt.fromString("1370603113776") + totalChoppedAmount: BigInt.fromString("24665725897573"), + totalChoppedBdv: BigInt.fromString("5882168812974"), + totalChoppedBdvReceived: BigInt.fromString("1334001323440") }, { tokenType: "urlp", diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index 58c2d9b865..ff156314dc 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -448,7 +448,7 @@ function incrementSows(protocol: Address, account: Address, block: ethereum.Bloc field.save(); // Add to protocol numberOfSowers if this is the first time this account has sown - if (account != protocol && field.numberOfSows == 0) { + if (account != protocol && field.numberOfSows == 1) { incrementSowers(protocol, block); } } From 4b3033611b47695102f62bc7bdcbc6995a13a65a Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:32:16 -0700 Subject: [PATCH 75/88] fix harvestable pods count --- .../subgraph-beanstalk/src/utils/Field.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/projects/subgraph-beanstalk/src/utils/Field.ts b/projects/subgraph-beanstalk/src/utils/Field.ts index ff156314dc..7a76edce18 100644 --- a/projects/subgraph-beanstalk/src/utils/Field.ts +++ b/projects/subgraph-beanstalk/src/utils/Field.ts @@ -84,14 +84,34 @@ export function harvest(params: HarvestParams): void { if (harvestablePods >= plot.pods) { // Plot fully harvests - updateFieldTotals(protocol, params.account, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, plot.pods, params.event.block); + updateFieldTotals( + protocol, + params.account, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI.minus(plot.pods), + plot.pods, + params.event.block + ); plot.harvestedPods = plot.pods; plot.fullyHarvested = true; plot.save(); } else { // Plot partially harvests - updateFieldTotals(protocol, params.account, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, ZERO_BI, harvestablePods, params.event.block); + updateFieldTotals( + protocol, + params.account, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI.minus(harvestablePods), + harvestablePods, + params.event.block + ); remainingIndex = plot.index.plus(harvestablePods); let remainingPods = plot.pods.minus(harvestablePods); From 5a870e772b37054b7c43e53e741e442a19bd04d1 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:53:53 -0700 Subject: [PATCH 76/88] Update arb fert address --- projects/subgraph-beanstalk/manifests/arbitrum.yaml | 2 +- projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml index 7e6716417a..8d7afda424 100644 --- a/projects/subgraph-beanstalk/manifests/arbitrum.yaml +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -255,7 +255,7 @@ dataSources: name: Fertilizer-1155 network: arbitrum-one source: - address: "0x2D5E484Dd7D43dFE32BF1Ed9fE6517b64F13Ea51" + address: "0x82a17bdeC3368f549A7BfE6734D6E2Aba82be455" abi: Fertilizer startBlock: 585858585858 # Reseed mapping: diff --git a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts index 0026cd50f6..12e658e9c7 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts @@ -22,8 +22,8 @@ export const USDT = Address.fromString("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCb // Contracts export const BEANSTALK = Address.fromString("0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70"); -////// TODO: These are subject to change -export const FERTILIZER = Address.fromString("0x2D5E484Dd7D43dFE32BF1Ed9fE6517b64F13Ea51"); +////// TODO: These are subject to change. Fertilizer is "Proxy" +export const FERTILIZER = Address.fromString("0x82a17bdeC3368f549A7BfE6734D6E2Aba82be455"); export const BEANSTALK_PRICE = Address.fromString("0xEfE94bE746681ed73DfD15F932f9a8e8ffDdEE56"); ////// export const AQUIFER = Address.fromString("0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521"); From 8c3e498a820d0883712e26b065f19c536246433d Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:35:42 -0700 Subject: [PATCH 77/88] set initial temperature --- projects/subgraph-beanstalk/cache-builder/beanstalk3.js | 6 ++++-- .../cache-builder/results/B3Migration_arb.ts | 4 +++- projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js index 80a097596d..fd9bf80156 100644 --- a/projects/subgraph-beanstalk/cache-builder/beanstalk3.js +++ b/projects/subgraph-beanstalk/cache-builder/beanstalk3.js @@ -9,7 +9,6 @@ const tokenMap = { "0x1bea3ccd22f4ebd3d37d731ba31eeca95713716d": "urlp" }; -// NOTE: once latest subgraph is deployed, will need to update beanstalk/marketplace ids in this query. (async () => { // for testing purposes. set to empty string to ignore const block = "block: { number: 20736200 }"; @@ -25,6 +24,7 @@ const tokenMap = { harvestedPods podIndex harvestableIndex + temperature } podMarketplace(id: "0" ${block}) { filledListedPods @@ -74,6 +74,7 @@ const tokenMap = { harvestedPods: BigInt; podIndex: BigInt; harvestableIndex: BigInt; + temperature: i32; } class PodMarketplaceInitialValues { @@ -109,7 +110,8 @@ const tokenMap = { sownBeans: BigInt.fromString('${l1Values.field.sownBeans}'), harvestedPods: BigInt.fromString('${l1Values.field.harvestedPods}'), podIndex: BigInt.fromString('${l1Values.field.podIndex}'), - harvestableIndex: BigInt.fromString('${l1Values.field.harvestableIndex}') + harvestableIndex: BigInt.fromString('${l1Values.field.harvestableIndex}'), + temperature: ${l1Values.field.temperature} }; export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { diff --git a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts index 21a20446ca..f812c12701 100644 --- a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts +++ b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts @@ -9,6 +9,7 @@ class FieldInitialValues { harvestedPods: BigInt; podIndex: BigInt; harvestableIndex: BigInt; + temperature: i32; } class PodMarketplaceInitialValues { @@ -44,7 +45,8 @@ export const FIELD_INITIAL_VALUES: FieldInitialValues = { sownBeans: BigInt.fromString("33592460856188"), harvestedPods: BigInt.fromString("61126608133951"), podIndex: BigInt.fromString("980532024233292"), - harvestableIndex: BigInt.fromString("61128909242563") + harvestableIndex: BigInt.fromString("61128909242563"), + temperature: 24919 }; export const POD_MARKETPLACE_INITIAL_VALUES: PodMarketplaceInitialValues = { diff --git a/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts index 8431feec7c..6801f98505 100644 --- a/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts +++ b/projects/subgraph-beanstalk/src/utils/b3-migration/Init.ts @@ -23,6 +23,7 @@ export function init(block: ethereum.Block): void { let field = loadField(v().protocolAddress); field.podIndex = FIELD_INITIAL_VALUES.podIndex; field.harvestableIndex = FIELD_INITIAL_VALUES.harvestableIndex; + field.temperature = FIELD_INITIAL_VALUES.temperature; field.save(); } From 10f590f7ae3b2b3072e69c5783fa75ad86f9897f Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:03:23 -0700 Subject: [PATCH 78/88] MigratedAccountStatus --- .../legacy/ArbitrumMigrationHandler.ts | 8 +++- .../tests/Migration.test.ts | 19 +++++++++ .../tests/event-mocking/Migration.ts | 42 ++++++++++++++++--- 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts index 7bd6c0bea3..7a6e70cfd2 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/ArbitrumMigrationHandler.ts @@ -2,6 +2,7 @@ import { ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { AddMigratedDeposit, InternalBalanceMigrated, + MigratedAccountStatus, MigratedPlot, MigratedPodListing, MigratedPodOrder @@ -11,7 +12,7 @@ import { loadField, loadPlot } from "../../entities/Field"; import { clearFieldDeltas, takeFieldSnapshots } from "../../entities/snapshots/Field"; import { updateFarmTotals } from "../../utils/Farm"; import { podListingCreated, podOrderCreated } from "../../utils/Marketplace"; -import { addDeposits } from "../../utils/Silo"; +import { addDeposits, updateStalkBalances } from "../../utils/Silo"; export function handleAddMigratedDeposit(event: AddMigratedDeposit): void { addDeposits({ @@ -26,6 +27,10 @@ export function handleAddMigratedDeposit(event: AddMigratedDeposit): void { }); } +export function handleMigratedAccountStatus(event: MigratedAccountStatus): void { + updateStalkBalances(event.address, event.params.account, event.params.stalk, event.params.roots, event.block); +} + export function handleMigratedPlot(event: MigratedPlot): void { // The migration logic conflicts with some cumulative values already set in utils/b3-migration/Init. // Therefore the basic "sow" method is unsuitable for this purpose @@ -116,5 +121,4 @@ export function handleInternalBalanceMigrated(event: InternalBalanceMigrated): v } // Not currently necessary to handle the below. They are appropriately accounted for by the other events -// MigratedAccountStatus - AddMigratedDeposit // FertilizerMigrated - TransferSingle events on fertilizer mints diff --git a/projects/subgraph-beanstalk/tests/Migration.test.ts b/projects/subgraph-beanstalk/tests/Migration.test.ts index 063a26d3b2..48e30309a7 100644 --- a/projects/subgraph-beanstalk/tests/Migration.test.ts +++ b/projects/subgraph-beanstalk/tests/Migration.test.ts @@ -19,6 +19,7 @@ import { import { handleAddMigratedDeposit, handleInternalBalanceMigrated, + handleMigratedAccountStatus, handleMigratedPlot, handleMigratedPodListing, handleMigratedPodOrder @@ -26,6 +27,7 @@ import { import { createAddMigratedDepositEvent, createInternalBalanceMigratedEvent, + createMigratedAccountStatus, createMigratedPlotEvent, createMigratedPodListingEvent, createMigratedPodOrderEvent @@ -113,6 +115,23 @@ describe("Beanstalk 3 Migration", () => { stem.toString() ); }); + test("MigratedAccountStatus", () => { + const stalk1 = BigInt.fromU32(100).times(BI_10.pow(16)); + const roots1 = BigInt.fromU32(100).times(BI_10.pow(22)); + const bdv1 = BigInt.fromU32(30).times(BI_10.pow(6)); + const stem1 = BigInt.fromU32(248672); + handleMigratedAccountStatus(createMigratedAccountStatus(account, BEAN_ERC20, stalk1, roots1, bdv1, stem1)); + assert.fieldEquals("Silo", account.toHexString(), "stalk", stalk1.toString()); + assert.fieldEquals("Silo", BEANSTALK.toHexString(), "stalk", stalk1.toString()); + + const stalk2 = BigInt.fromU32(700).times(BI_10.pow(16)); + const roots2 = BigInt.fromU32(700).times(BI_10.pow(22)); + const bdv2 = BigInt.fromU32(130).times(BI_10.pow(6)); + const stem2 = BigInt.fromU32(2458672); + handleMigratedAccountStatus(createMigratedAccountStatus(account, UNRIPE_BEAN, stalk2, roots2, bdv2, stem2)); + assert.fieldEquals("Silo", account.toHexString(), "stalk", stalk1.plus(stalk2).toString()); + assert.fieldEquals("Silo", BEANSTALK.toHexString(), "stalk", stalk1.plus(stalk2).toString()); + }); test("MigratedPlot", () => { const index = BigInt.fromU32(250000000).times(BI_10.pow(6)); const amount = BigInt.fromU32(1500).times(BI_10.pow(6)); diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Migration.ts b/projects/subgraph-beanstalk/tests/event-mocking/Migration.ts index 30ce67ca89..dd521eb4c1 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Migration.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Migration.ts @@ -2,11 +2,13 @@ import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; import { AddMigratedDeposit, InternalBalanceMigrated, + MigratedAccountStatus, MigratedPlot, MigratedPodListing, MigratedPodOrder } from "../../generated/Beanstalk-ABIs/Reseed"; -import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; +import { mockContractEvent } from "../../../subgraph-core/tests/event-mocking/Util"; +import { BEANSTALK as BEANSTALK_ARB } from "../../../subgraph-core/constants/raw/BeanstalkArbConstants"; export function createAddMigratedDepositEvent( account: Address, @@ -15,7 +17,7 @@ export function createAddMigratedDepositEvent( amount: BigInt, bdv: BigInt ): AddMigratedDeposit { - let event = changetype(mockBeanstalkEvent()); + let event = changetype(mockContractEvent(BEANSTALK_ARB)); event.parameters = new Array(); let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(account)); @@ -33,8 +35,36 @@ export function createAddMigratedDepositEvent( return event as AddMigratedDeposit; } +export function createMigratedAccountStatus( + account: Address, + token: Address, + stalk: BigInt, + roots: BigInt, + bdv: BigInt, + lastStem: BigInt +): MigratedAccountStatus { + let event = changetype(mockContractEvent(BEANSTALK_ARB)); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(account)); + let param2 = new ethereum.EventParam("token", ethereum.Value.fromAddress(token)); + let param3 = new ethereum.EventParam("stalk", ethereum.Value.fromUnsignedBigInt(stalk)); + let param4 = new ethereum.EventParam("roots", ethereum.Value.fromUnsignedBigInt(roots)); + let param5 = new ethereum.EventParam("bdv", ethereum.Value.fromUnsignedBigInt(bdv)); + let param6 = new ethereum.EventParam("lastStem", ethereum.Value.fromUnsignedBigInt(lastStem)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + event.parameters.push(param6); + + return event as MigratedAccountStatus; +} + export function createMigratedPlotEvent(account: Address, plotIndex: BigInt, pods: BigInt): MigratedPlot { - let event = changetype(mockBeanstalkEvent()); + let event = changetype(mockContractEvent(BEANSTALK_ARB)); event.parameters = new Array(); let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(account)); @@ -59,7 +89,7 @@ export function createMigratedPodListingEvent( minFillAmount: BigInt, mode: i32 ): MigratedPodListing { - let event = changetype(mockBeanstalkEvent()); + let event = changetype(mockContractEvent(BEANSTALK_ARB)); event.parameters = new Array(); let param1 = new ethereum.EventParam("lister", ethereum.Value.fromAddress(lister)); @@ -94,7 +124,7 @@ export function createMigratedPodOrderEvent( maxPlaceInLine: BigInt, minFillAmount: BigInt ): MigratedPodOrder { - let event = changetype(mockBeanstalkEvent()); + let event = changetype(mockContractEvent(BEANSTALK_ARB)); event.parameters = new Array(); let param1 = new ethereum.EventParam("orderer", ethereum.Value.fromAddress(orderer)); @@ -117,7 +147,7 @@ export function createMigratedPodOrderEvent( } export function createInternalBalanceMigratedEvent(account: Address, token: Address, delta: BigInt): InternalBalanceMigrated { - let event = changetype(mockBeanstalkEvent()); + let event = changetype(mockContractEvent(BEANSTALK_ARB)); event.parameters = new Array(); let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(account)); From 66ec3aed91b5cf66c0bc152b288036e0141f6497 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:13:43 -0700 Subject: [PATCH 79/88] fix ethereum manifest for silo --- .../manifests/ethereum.yaml | 31 +++++++++++++++---- .../src/handlers/GaugeHandler.ts | 6 ++-- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index 2277206446..d7bc40c1c0 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -423,6 +423,31 @@ dataSources: - event: UpdatedStalkPerBdvPerSeason(indexed address,uint32,uint32) handler: handleUpdatedStalkPerBdvPerSeason file: ../src/handlers/SiloHandler.ts + - kind: ethereum/contract + name: LegacySilo-Replanted-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 15277986 # Replanted + # TODO: add reseed paused placeholders here and elsewhere + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Silo + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + eventHandlers: + - event: SeedsBalanceChanged(indexed address,int256) + handler: handleSeedsBalanceChanged + - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) + handler: handleRemoveWithdrawal + - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) + handler: handleRemoveWithdrawals + file: ../src/handlers/legacy/LegacySiloHandler.ts - kind: ethereum/contract name: LegacySilo-Replanted-SeedGauge network: mainnet @@ -513,14 +538,8 @@ dataSources: - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - - event: SeedsBalanceChanged(indexed address,int256) - handler: handleSeedsBalanceChanged - event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64) handler: handleWhitelistToken_v4 - - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) - handler: handleRemoveWithdrawal - - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) - handler: handleRemoveWithdrawals file: ../src/handlers/legacy/LegacySiloHandler.ts ### # SEED GAUGE diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index 2e985db6ef..78c1ab6ce9 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -14,7 +14,7 @@ import { loadGerminating, loadOrCreateGerminating } from "../entities/Germinating"; -import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { setSiloHourlyCaseId, takeSiloSnapshots } from "../entities/snapshots/Silo"; import { loadSilo, loadWhitelistTokenSetting } from "../entities/Silo"; import { takeWhitelistTokenSettingSnapshots } from "../entities/snapshots/WhitelistTokenSetting"; @@ -52,7 +52,9 @@ export function handleUpdateAverageStalkPerBdvPerSeason(event: UpdateAverageStal // This is not exactly accurate, the value in this event is pertaining to gauge only and does not include unripe. // In practice, seed values for non-gauge assets are negligible. // The correct approach is iterating whitelisted assets each season, multipying bdv and seeds - silo.grownStalkPerSeason = silo.depositedBDV.times(event.params.newStalkPerBdvPerSeason); + + // Divide by 1e6. newStalkPerBdvPerSeason is per unit of bdv, not per micro bdv. + silo.grownStalkPerSeason = silo.depositedBDV.times(event.params.newStalkPerBdvPerSeason).div(BI_10.pow(6)); takeSiloSnapshots(silo, event.block); silo.save(); From a95aa2c7692b64aa89da1fcb66cc8c5c2c7cc7cb Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:38:37 -0700 Subject: [PATCH 80/88] fix overcounting deposited beans --- projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts | 5 +++-- projects/subgraph-beanstalk/src/handlers/SiloHandler.ts | 8 ++++---- projects/subgraph-beanstalk/src/utils/Season.ts | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts index 78c1ab6ce9..d345db3eb7 100644 --- a/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/GaugeHandler.ts @@ -21,6 +21,7 @@ import { takeWhitelistTokenSettingSnapshots } from "../entities/snapshots/Whitel import { getCurrentSeason } from "../entities/Beanstalk"; import { updateStalkBalances } from "../utils/Silo"; import { UpdatedOptimalPercentDepositedBdvForToken } from "../../generated/Beanstalk-ABIs/Reseed"; +import { beanDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; // SEED GAUGE SEASONAL ADJUSTMENTS // @@ -53,8 +54,8 @@ export function handleUpdateAverageStalkPerBdvPerSeason(event: UpdateAverageStal // In practice, seed values for non-gauge assets are negligible. // The correct approach is iterating whitelisted assets each season, multipying bdv and seeds - // Divide by 1e6. newStalkPerBdvPerSeason is per unit of bdv, not per micro bdv. - silo.grownStalkPerSeason = silo.depositedBDV.times(event.params.newStalkPerBdvPerSeason).div(BI_10.pow(6)); + // Divide by bdv decimals. newStalkPerBdvPerSeason is per unit of bdv, not per micro bdv. + silo.grownStalkPerSeason = silo.depositedBDV.times(event.params.newStalkPerBdvPerSeason).div(BI_10.pow(beanDecimals())); takeSiloSnapshots(silo, event.block); silo.save(); diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 6df1f8681f..7b355b7bc2 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -17,7 +17,7 @@ import { unripeChopped } from "../utils/Barn"; import { beanDecimals, getProtocolToken, isUnripe, stalkDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; import { WhitelistToken } from "../../generated/Beanstalk-ABIs/Reseed"; -import { BI_10 } from "../../../subgraph-core/utils/Decimals"; +import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; export function handleAddDeposit(event: AddDeposit): void { addDeposits({ @@ -95,14 +95,14 @@ export function handlePlant(event: Plant): void { takeSiloSnapshots(silo, event.block); silo.save(); - // Remove the asset-only amount that got added in Reward event handler. + // Remove the protocol asset amount that got added in Reward event handler. // Will be immediately re-credited to the user/system in AddDeposit updateDepositInSiloAsset( event.address, event.address, getProtocolToken(v(), event.block.number), - event.params.beans, - event.params.beans, + ZERO_BI.minus(event.params.beans), + ZERO_BI.minus(event.params.beans), event.block ); } diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index 592a4cda57..cca41eac50 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -77,6 +77,7 @@ export function siloReceipt(amount: BigInt, block: ethereum.Block): void { takeSiloSnapshots(silo, block); silo.save(); + // Add SiloAsset deposit immediately at the protocol level. Will be removed upon plant updateDepositInSiloAsset(v().protocolAddress, v().protocolAddress, getProtocolToken(v(), block.number), amount, amount, block); } From 834bfedd3ff8f3a6b1223f4b8ad81ab2c9242511 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:40:20 -0700 Subject: [PATCH 81/88] Update test --- projects/subgraph-beanstalk/tests/SeedGauge.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts index 4cd6e0f43f..da4bb09485 100644 --- a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts +++ b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts @@ -30,6 +30,7 @@ import { initL1Version } from "./entity-mocking/MockVersion"; import { handleTemperatureChange_v1 } from "../src/handlers/legacy/LegacyFieldHandler"; import { handleWhitelistToken_v4 } from "../src/handlers/legacy/LegacySiloHandler"; import { handleUpdateGaugeSettings } from "../src/handlers/legacy/LegacyGaugeHandler"; +import { BI_10 } from "../../subgraph-core/utils/Decimals"; const ANVIL_ADDR_1 = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); @@ -99,7 +100,7 @@ describe("Seed Gauge", () => { test("event: UpdateAverageStalkPerBdvPerSeason", () => { const initialSilo = loadSilo(BEANSTALK); - initialSilo.depositedBDV = BigInt.fromU32(1000); + initialSilo.depositedBDV = BigInt.fromU32(1000).times(BI_10.pow(6)); initialSilo.save(); handleUpdateAverageStalkPerBdvPerSeason(createUpdateAverageStalkPerBdvPerSeasonEvent(BigInt.fromU32(3456))); From dfa4ecd44bad3a7221d9b3c3594353e1508771f7 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:03:50 -0700 Subject: [PATCH 82/88] set reseed pause block constants --- projects/subgraph-bean/manifests/ethereum.yaml | 7 +++++++ .../subgraph-beanstalk/manifests/ethereum.yaml | 14 +++++++++++++- .../constants/raw/BeanstalkEthConstants.ts | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/projects/subgraph-bean/manifests/ethereum.yaml b/projects/subgraph-bean/manifests/ethereum.yaml index 848ed43a6d..a462f003ed 100644 --- a/projects/subgraph-bean/manifests/ethereum.yaml +++ b/projects/subgraph-bean/manifests/ethereum.yaml @@ -82,6 +82,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 12974075 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -151,6 +152,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Replanted startBlock: 15277986 # Replanted + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -210,6 +212,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 15277988 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -342,6 +345,7 @@ dataSources: address: "0xc9C32cd16Bf7eFB85Ff14e0c8603cc90F6F2eE49" abi: Bean3CRV startBlock: 15278082 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -382,6 +386,7 @@ dataSources: address: "0xBEA0e11282e2bB5893bEcE110cF199501e872bAd" abi: Well startBlock: 17978134 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -418,6 +423,7 @@ dataSources: address: "0xBeA0000113B0d182f4064C86B71c315389E4715D" abi: Well startBlock: 20264128 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -477,6 +483,7 @@ dataSources: address: "0xb01CE0008CaD90104651d6A84b6B11e182a9B62A" abi: BeanstalkPrice startBlock: 15277986 # Replanted + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.7 diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index d7bc40c1c0..e5fb9a5d5f 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -396,6 +396,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 15277986 # Replanted (Silo currently has no support for pre-exploit) + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -430,7 +431,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 15277986 # Replanted - # TODO: add reseed paused placeholders here and elsewhere + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -528,6 +529,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 19927634 # SeedGauge + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -551,6 +553,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 19628074 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -584,6 +587,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 19628074 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -613,6 +617,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 12974075 # Field has all-time support + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -679,6 +684,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 14148509 # BIP-11 Pod Marketplace + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -700,6 +706,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 14148509 # BIP-11 Pod Marketplace + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -783,6 +790,7 @@ dataSources: address: "0x402c84De2Ce49aF88f5e2eF3710ff89bFED36cB6" abi: Fertilizer startBlock: 14910573 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -807,6 +815,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 15277986 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -832,6 +841,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 12974075 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -860,6 +870,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 17671557 # SiloV3 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -970,6 +981,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 12974075 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 diff --git a/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts index ec68c7b8f3..40eae82f84 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkEthConstants.ts @@ -42,6 +42,8 @@ export const REPLANT_BLOCK = BigInt.fromU32(15278963); export const REPLANT_SUNRISE_BLOCK = BigInt.fromU32(15289934); export const BASIN_BLOCK = BigInt.fromU32(17977922); export const GAUGE_BIP45_BLOCK = BigInt.fromU32(19927634); +// End of Beanstalk on L1, except for farm balances. (TODO: update after reseed pause) +export const RESEED_PAUSE_BLOCK = BigInt.fromU32(191919191); export const BEAN_WETH_CP2_WELL_BLOCK = BigInt.fromU32(17978134); export const BEAN_WSTETH_CP2_WELL_BLOCK = BigInt.fromU32(20264128); From 664d054d70aaf1ec91bccf6257b592250a31b2d8 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:12:45 -0700 Subject: [PATCH 83/88] update b3 cached values --- .../subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts index f812c12701..0182135198 100644 --- a/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts +++ b/projects/subgraph-beanstalk/cache-builder/results/B3Migration_arb.ts @@ -40,7 +40,7 @@ class UnripeTokenInitialValues { export const SEASON_INITIAL = 24508; export const FIELD_INITIAL_VALUES: FieldInitialValues = { - numberOfSowers: 0, + numberOfSowers: 1640, numberOfSows: 19196, sownBeans: BigInt.fromString("33592460856188"), harvestedPods: BigInt.fromString("61126608133951"), From 29a3d57afc27a5e66601d8958896c5af91887c6f Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 23 Sep 2024 15:30:50 -0700 Subject: [PATCH 84/88] update fert/bp address --- projects/subgraph-bean/manifests/arbitrum.yaml | 2 +- projects/subgraph-beanstalk/manifests/arbitrum.yaml | 2 +- projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/subgraph-bean/manifests/arbitrum.yaml b/projects/subgraph-bean/manifests/arbitrum.yaml index b930f8afb4..af796c8a5b 100644 --- a/projects/subgraph-bean/manifests/arbitrum.yaml +++ b/projects/subgraph-bean/manifests/arbitrum.yaml @@ -357,7 +357,7 @@ dataSources: name: CrossCheck network: arbitrum-one source: - address: "0xEfE94bE746681ed73DfD15F932f9a8e8ffDdEE56" + address: "0xC218F5a782b0913931DCF502FA2aA959b36Ac9E7" abi: BeanstalkPrice startBlock: 585858585858 # Reseed mapping: diff --git a/projects/subgraph-beanstalk/manifests/arbitrum.yaml b/projects/subgraph-beanstalk/manifests/arbitrum.yaml index 8d7afda424..6e579bd565 100644 --- a/projects/subgraph-beanstalk/manifests/arbitrum.yaml +++ b/projects/subgraph-beanstalk/manifests/arbitrum.yaml @@ -255,7 +255,7 @@ dataSources: name: Fertilizer-1155 network: arbitrum-one source: - address: "0x82a17bdeC3368f549A7BfE6734D6E2Aba82be455" + address: "0xFEFEFECA5375630d6950F40e564A27f6074845B5" abi: Fertilizer startBlock: 585858585858 # Reseed mapping: diff --git a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts index 12e658e9c7..c00f031e61 100644 --- a/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts +++ b/projects/subgraph-core/constants/raw/BeanstalkArbConstants.ts @@ -23,8 +23,8 @@ export const USDT = Address.fromString("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCb // Contracts export const BEANSTALK = Address.fromString("0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70"); ////// TODO: These are subject to change. Fertilizer is "Proxy" -export const FERTILIZER = Address.fromString("0x82a17bdeC3368f549A7BfE6734D6E2Aba82be455"); -export const BEANSTALK_PRICE = Address.fromString("0xEfE94bE746681ed73DfD15F932f9a8e8ffDdEE56"); +export const FERTILIZER = Address.fromString("0xFEFEFECA5375630d6950F40e564A27f6074845B5"); +export const BEANSTALK_PRICE = Address.fromString("0xC218F5a782b0913931DCF502FA2aA959b36Ac9E7"); ////// export const AQUIFER = Address.fromString("0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521"); From ed093f7fe070c91ae4026e892b2dbc5b24252299 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:48:05 -0700 Subject: [PATCH 85/88] remove silo seeds --- .../subgraph-beanstalk/manifests/ethereum.yaml | 2 -- .../subgraph-beanstalk/manifests/no-apy.yaml | 2 -- projects/subgraph-beanstalk/schema.graphql | 18 ++++++++---------- .../subgraph-beanstalk/src/entities/Silo.ts | 1 - .../src/entities/snapshots/Silo.ts | 18 ++++++++---------- .../src/handlers/legacy/LegacySiloHandler.ts | 13 +------------ projects/subgraph-beanstalk/src/utils/Yield.ts | 4 ++-- .../src/utils/legacy/LegacySilo.ts | 17 ----------------- 8 files changed, 19 insertions(+), 56 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index e5fb9a5d5f..78ea4f233b 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -442,8 +442,6 @@ dataSources: - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - - event: SeedsBalanceChanged(indexed address,int256) - handler: handleSeedsBalanceChanged - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) handler: handleRemoveWithdrawal - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index f37044ff3f..1856526dc6 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -180,8 +180,6 @@ dataSources: - name: SeedGauge file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json eventHandlers: - - event: SeedsBalanceChanged(indexed address,int256) - handler: handleSeedsBalanceChanged - event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64) handler: handleWhitelistToken_v4 - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) diff --git a/projects/subgraph-beanstalk/schema.graphql b/projects/subgraph-beanstalk/schema.graphql index 77f6dd777f..f9b763c027 100644 --- a/projects/subgraph-beanstalk/schema.graphql +++ b/projects/subgraph-beanstalk/schema.graphql @@ -51,7 +51,7 @@ type Beanstalk @entity { lastSeason: Int! "Array of the addresses for all active farmers in the silo" activeFarmers: [Bytes!]! - "Array of the addresses for all farmers that had silo transfers and need stalk/seeds/roots updated" + "Array of the addresses for all farmers that had silo transfers and need stalk/roots updated" farmersToUpdate: [Bytes!]! } @@ -101,9 +101,11 @@ type Silo @entity { stalk: BigInt! "Current plantable stalk for bean seigniorage not yet claimed" plantableStalk: BigInt! - "Current seeds balance" - seeds: BigInt! - "Current grown stalk per season" + """ + Current grown stalk per season. + NOTE: This value is currently not accurate for pre-gauge queries (BIP-45). + A correct implementation would recalculate this value when a whitelisted token's seed amount is changed. + """ grownStalkPerSeason: BigInt! "Current roots balance" roots: BigInt! @@ -138,8 +140,6 @@ type SiloHourlySnapshot @entity { stalk: BigInt! "Point in time current plantable stalk for bean seigniorage not yet claimed" plantableStalk: BigInt! - "Point in time current seeds balance" - seeds: BigInt! "Point in time grown stalk per season" grownStalkPerSeason: BigInt! "Point in time current roots balance" @@ -156,7 +156,7 @@ type SiloHourlySnapshot @entity { deltaDepositedBDV: BigInt! deltaStalk: BigInt! deltaPlantableStalk: BigInt! - deltaSeeds: BigInt! + deltaGrownStalkPerSeason: BigInt! deltaRoots: BigInt! deltaGerminatingStalk: BigInt! deltaBeanMints: BigInt! @@ -185,8 +185,6 @@ type SiloDailySnapshot @entity { stalk: BigInt! "Point in time current plantable stalk for bean seigniorage not yet claimed" plantableStalk: BigInt! - "Point in time current seeds balance" - seeds: BigInt! "Point in time grown stalk per season" grownStalkPerSeason: BigInt! "Point in time current roots balance" @@ -203,7 +201,7 @@ type SiloDailySnapshot @entity { deltaDepositedBDV: BigInt! deltaStalk: BigInt! deltaPlantableStalk: BigInt! - deltaSeeds: BigInt! + deltaGrownStalkPerSeason: BigInt! deltaRoots: BigInt! deltaGerminatingStalk: BigInt! deltaBeanMints: BigInt! diff --git a/projects/subgraph-beanstalk/src/entities/Silo.ts b/projects/subgraph-beanstalk/src/entities/Silo.ts index 4d64d0b459..af06a21940 100644 --- a/projects/subgraph-beanstalk/src/entities/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/Silo.ts @@ -28,7 +28,6 @@ export function loadSilo(account: Address): Silo { silo.depositedBDV = ZERO_BI; silo.stalk = ZERO_BI; silo.plantableStalk = ZERO_BI; - silo.seeds = ZERO_BI; silo.grownStalkPerSeason = ZERO_BI; silo.roots = ZERO_BI; silo.germinatingStalk = ZERO_BI; diff --git a/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts b/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts index 5aa4f306cd..42a38cc5d2 100644 --- a/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts +++ b/projects/subgraph-beanstalk/src/entities/snapshots/Silo.ts @@ -30,7 +30,6 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { hourly.depositedBDV = silo.depositedBDV; hourly.stalk = silo.stalk; hourly.plantableStalk = silo.plantableStalk; - hourly.seeds = silo.seeds; hourly.grownStalkPerSeason = silo.grownStalkPerSeason; hourly.roots = silo.roots; hourly.germinatingStalk = silo.germinatingStalk; @@ -43,7 +42,7 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { hourly.deltaDepositedBDV = hourly.depositedBDV.minus(baseHourly.depositedBDV); hourly.deltaStalk = hourly.stalk.minus(baseHourly.stalk); hourly.deltaPlantableStalk = hourly.plantableStalk.minus(baseHourly.plantableStalk); - hourly.deltaSeeds = hourly.seeds.minus(baseHourly.seeds); + hourly.deltaGrownStalkPerSeason = hourly.grownStalkPerSeason.minus(baseHourly.grownStalkPerSeason); hourly.deltaRoots = hourly.roots.minus(baseHourly.roots); hourly.deltaGerminatingStalk = hourly.germinatingStalk.minus(baseHourly.germinatingStalk); // NOTE: missing beanToMaxLpGpPerBdvRatio @@ -54,7 +53,7 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { hourly.deltaDepositedBDV = hourly.deltaDepositedBDV.plus(baseHourly.deltaDepositedBDV); hourly.deltaStalk = hourly.deltaStalk.plus(baseHourly.deltaStalk); hourly.deltaPlantableStalk = hourly.deltaPlantableStalk.plus(baseHourly.deltaPlantableStalk); - hourly.deltaSeeds = hourly.deltaSeeds.plus(baseHourly.deltaSeeds); + hourly.deltaGrownStalkPerSeason = hourly.deltaGrownStalkPerSeason.plus(baseHourly.deltaGrownStalkPerSeason); hourly.deltaRoots = hourly.deltaRoots.plus(baseHourly.deltaRoots); hourly.deltaGerminatingStalk = hourly.deltaGerminatingStalk.plus(baseHourly.deltaGerminatingStalk); // NOTE: missing beanToMaxLpGpPerBdvRatio @@ -67,7 +66,7 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { hourly.deltaDepositedBDV = hourly.depositedBDV; hourly.deltaStalk = hourly.stalk; hourly.deltaPlantableStalk = hourly.plantableStalk; - hourly.deltaSeeds = hourly.seeds; + hourly.deltaGrownStalkPerSeason = hourly.grownStalkPerSeason; hourly.deltaRoots = hourly.roots; hourly.deltaGerminatingStalk = hourly.germinatingStalk; // NOTE: missing beanToMaxLpGpPerBdvRatio @@ -86,7 +85,6 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { daily.depositedBDV = silo.depositedBDV; daily.stalk = silo.stalk; daily.plantableStalk = silo.plantableStalk; - daily.seeds = silo.seeds; daily.grownStalkPerSeason = silo.grownStalkPerSeason; daily.roots = silo.roots; daily.germinatingStalk = silo.germinatingStalk; @@ -97,7 +95,7 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { daily.deltaDepositedBDV = daily.depositedBDV.minus(baseDaily.depositedBDV); daily.deltaStalk = daily.stalk.minus(baseDaily.stalk); daily.deltaPlantableStalk = daily.plantableStalk.minus(baseDaily.plantableStalk); - daily.deltaSeeds = daily.seeds.minus(baseDaily.seeds); + daily.deltaGrownStalkPerSeason = daily.grownStalkPerSeason.minus(baseDaily.grownStalkPerSeason); daily.deltaRoots = daily.roots.minus(baseDaily.roots); daily.deltaGerminatingStalk = daily.germinatingStalk.minus(baseDaily.germinatingStalk); // NOTE: missing beanToMaxLpGpPerBdvRatio @@ -108,7 +106,7 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { daily.deltaDepositedBDV = daily.deltaDepositedBDV.plus(baseDaily.deltaDepositedBDV); daily.deltaStalk = daily.deltaStalk.plus(baseDaily.deltaStalk); daily.deltaPlantableStalk = daily.deltaPlantableStalk.plus(baseDaily.deltaPlantableStalk); - daily.deltaSeeds = daily.deltaSeeds.plus(baseDaily.deltaSeeds); + daily.deltaGrownStalkPerSeason = daily.deltaGrownStalkPerSeason.plus(baseDaily.deltaGrownStalkPerSeason); daily.deltaRoots = daily.deltaRoots.plus(baseDaily.deltaRoots); daily.deltaGerminatingStalk = daily.deltaGerminatingStalk.plus(baseDaily.deltaGerminatingStalk); // NOTE: missing beanToMaxLpGpPerBdvRatio @@ -119,7 +117,7 @@ export function takeSiloSnapshots(silo: Silo, block: ethereum.Block): void { daily.deltaDepositedBDV = daily.depositedBDV; daily.deltaStalk = daily.stalk; daily.deltaPlantableStalk = daily.plantableStalk; - daily.deltaSeeds = daily.seeds; + daily.deltaGrownStalkPerSeason = daily.grownStalkPerSeason; daily.deltaRoots = daily.roots; daily.deltaGerminatingStalk = daily.germinatingStalk; // NOTE: missing beanToMaxLpGpPerBdvRatio @@ -143,7 +141,7 @@ export function clearSiloDeltas(silo: Silo, block: ethereum.Block): void { hourly.deltaDepositedBDV = ZERO_BI; hourly.deltaStalk = ZERO_BI; hourly.deltaPlantableStalk = ZERO_BI; - hourly.deltaSeeds = ZERO_BI; + hourly.deltaGrownStalkPerSeason = ZERO_BI; hourly.deltaRoots = ZERO_BI; hourly.deltaGerminatingStalk = ZERO_BI; hourly.deltaBeanMints = ZERO_BI; @@ -154,7 +152,7 @@ export function clearSiloDeltas(silo: Silo, block: ethereum.Block): void { daily.deltaDepositedBDV = ZERO_BI; daily.deltaStalk = ZERO_BI; daily.deltaPlantableStalk = ZERO_BI; - daily.deltaSeeds = ZERO_BI; + daily.deltaGrownStalkPerSeason = ZERO_BI; daily.deltaRoots = ZERO_BI; daily.deltaGerminatingStalk = ZERO_BI; daily.deltaBeanMints = ZERO_BI; diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index 22c86b5622..fb865165ea 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -15,7 +15,7 @@ import { addDeposits, addWithdrawToSiloAsset, removeDeposits } from "../../utils import { takeWhitelistTokenSettingSnapshots } from "../../entities/snapshots/WhitelistTokenSetting"; import { WhitelistToken as WhitelistToken_v3 } from "../../../generated/Beanstalk-ABIs/SiloV3"; import { RemoveWithdrawal, RemoveWithdrawals, SeedsBalanceChanged, WhitelistToken } from "../../../generated/Beanstalk-ABIs/SeedGauge"; -import { updateClaimedWithdraw, updateSeedsBalances } from "../../utils/legacy/LegacySilo"; +import { updateClaimedWithdraw } from "../../utils/legacy/LegacySilo"; import { Bytes4_emptySelector } from "../../../../subgraph-core/utils/Bytes"; import { initLegacyUnripe } from "../../utils/legacy/LegacyWhitelist"; @@ -152,17 +152,6 @@ export function handleWhitelistToken_v4(event: WhitelistToken): void { siloSettings.save(); } -// Replanted -> Reseed -// Legacy feature since silo v3, but the event was still present until the reseed // -export function handleSeedsBalanceChanged(event: SeedsBalanceChanged): void { - // Exclude BIP-24 emission of missed past events - if (event.transaction.hash.toHexString() == "0xa89638aeb0d6c4afb4f367ea7a806a4c8b3b2a6eeac773e8cc4eda10bfa804fc") { - return; - } - - updateSeedsBalances(event.address, event.params.account, event.params.delta, event.block); -} - /// Withdrawal is a legacy feature from replant, but these events were still present until the reseed /// // Replanted -> Reseed export function handleRemoveWithdrawal(event: RemoveWithdrawal): void { diff --git a/projects/subgraph-beanstalk/src/utils/Yield.ts b/projects/subgraph-beanstalk/src/utils/Yield.ts index 3216808165..a8b8fd6729 100644 --- a/projects/subgraph-beanstalk/src/utils/Yield.ts +++ b/projects/subgraph-beanstalk/src/utils/Yield.ts @@ -1,5 +1,5 @@ import { Address, BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; -import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { BI_10, toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { loadSilo, loadSiloAsset, @@ -124,7 +124,7 @@ export function updateSiloVAPYs(protocol: Address, timestamp: BigInt, window: i3 toDecimal(whitelistSettings[i].stalkEarnedPerSeason), toDecimal(beanGrownStalk), silo.stalk, - silo.seeds + silo.grownStalkPerSeason ); apys.push(tokenAPY); } diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts index 432c6840d2..5f560b8dcc 100644 --- a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts @@ -38,28 +38,11 @@ export function updateStalkWithCalls(protocol: Address, block: ethereum.Block): block, false ); - updateSeedsBalances(protocol, account, beanstalk_call.balanceOfSeeds(account).minus(silo.seeds), block, false); } beanstalk.farmersToUpdate = []; beanstalk.save(); } -export function updateSeedsBalances( - protocol: Address, - account: Address, - seeds: BigInt, - block: ethereum.Block, - recurs: boolean = true -): void { - if (recurs && account != protocol) { - updateSeedsBalances(protocol, protocol, seeds, block); - } - let silo = loadSilo(account); - silo.seeds = silo.seeds.plus(seeds); - takeSiloSnapshots(silo, block); - silo.save(); -} - const STEM_START_SEASON = 14210; export function stemFromSeason(season: i32, token: Address): BigInt { From fd03aa67c37b8110745f4537694c4a6f133fd835 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:11:37 -0700 Subject: [PATCH 86/88] fix overall silo withdraw --- .../src/handlers/legacy/LegacySiloHandler.ts | 4 ++-- .../src/utils/legacy/LegacySilo.ts | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts index fb865165ea..30c19bf490 100644 --- a/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/legacy/LegacySiloHandler.ts @@ -155,12 +155,12 @@ export function handleWhitelistToken_v4(event: WhitelistToken): void { /// Withdrawal is a legacy feature from replant, but these events were still present until the reseed /// // Replanted -> Reseed export function handleRemoveWithdrawal(event: RemoveWithdrawal): void { - updateClaimedWithdraw(event.params.account, event.params.token, event.params.season, event.block); + updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.season, event.block); } // Replanted -> Reseed export function handleRemoveWithdrawals(event: RemoveWithdrawals): void { for (let i = 0; i < event.params.seasons.length; i++) { - updateClaimedWithdraw(event.params.account, event.params.token, event.params.seasons[i], event.block); + updateClaimedWithdraw(event.address, event.params.account, event.params.token, event.params.seasons[i], event.block); } } diff --git a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts index 5f560b8dcc..f386dd14fd 100644 --- a/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts +++ b/projects/subgraph-beanstalk/src/utils/legacy/LegacySilo.ts @@ -1,24 +1,25 @@ import { Address, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; -import { loadSilo, loadSiloAsset, loadSiloWithdraw } from "../../entities/Silo"; -import { takeSiloAssetSnapshots } from "../../entities/snapshots/SiloAsset"; +import { loadSilo, loadSiloWithdraw } from "../../entities/Silo"; import { loadBeanstalk } from "../../entities/Beanstalk"; -import { updateStalkBalances } from "../Silo"; +import { addWithdrawToSiloAsset, updateStalkBalances } from "../Silo"; import { Replanted } from "../../../generated/Beanstalk-ABIs/Replanted"; import { BEAN_3CRV, BEAN_ERC20, UNRIPE_BEAN, UNRIPE_LP } from "../../../../subgraph-core/constants/raw/BeanstalkEthConstants"; import { BI_10, ONE_BI, ZERO_BI } from "../../../../subgraph-core/utils/Decimals"; import { toAddress } from "../../../../subgraph-core/utils/Bytes"; -import { takeSiloSnapshots } from "../../entities/snapshots/Silo"; import { PrevFarmerGerminatingEvent } from "../../../generated/schema"; -export function updateClaimedWithdraw(account: Address, token: Address, withdrawSeason: BigInt, block: ethereum.Block): void { +export function updateClaimedWithdraw( + protocol: Address, + account: Address, + token: Address, + withdrawSeason: BigInt, + block: ethereum.Block +): void { let withdraw = loadSiloWithdraw(account, token, withdrawSeason.toI32()); withdraw.claimed = true; withdraw.save(); - let asset = loadSiloAsset(account, token); - asset.withdrawnAmount = asset.withdrawnAmount.minus(withdraw.amount); - takeSiloAssetSnapshots(asset, block); - asset.save(); + addWithdrawToSiloAsset(protocol, account, token, withdraw.amount.neg(), block); } // Replanted -> SiloV3 From c023cb04849a8d096067288b66c034fb2d5e7282 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:02:58 -0700 Subject: [PATCH 87/88] Fix deposited amount mismatch --- .../manifests/ethereum.yaml | 5 ++- .../subgraph-beanstalk/manifests/no-apy.yaml | 44 ++++++++++++++++--- .../src/handlers/SiloHandler.ts | 6 +-- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index 78ea4f233b..55e145e1e6 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -446,6 +446,9 @@ dataSources: handler: handleRemoveWithdrawal - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) handler: handleRemoveWithdrawals + # This can continue to occur during v2-v3 migration. + - event: RemoveDeposit(indexed address,indexed address,uint32,uint256) + handler: handleRemoveDeposit_v2 file: ../src/handlers/legacy/LegacySiloHandler.ts - kind: ethereum/contract name: LegacySilo-Replanted-SeedGauge @@ -467,8 +470,6 @@ dataSources: eventHandlers: - event: AddDeposit(indexed address,indexed address,uint32,uint256,uint256) handler: handleAddDeposit_v2 - - event: RemoveDeposit(indexed address,indexed address,uint32,uint256) - handler: handleRemoveDeposit_v2 - event: RemoveDeposits(indexed address,indexed address,uint32[],uint256[],uint256) handler: handleRemoveDeposits_v2 - event: AddWithdrawal(indexed address,indexed address,uint32,uint256) diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index 1856526dc6..647a6e14de 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -63,6 +63,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 15277986 # Replanted (Silo currently has no support for pre-exploit) + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -90,6 +91,32 @@ dataSources: - event: UpdatedStalkPerBdvPerSeason(indexed address,uint32,uint32) handler: handleUpdatedStalkPerBdvPerSeason file: ../src/handlers/SiloHandler.ts + - kind: ethereum/contract + name: LegacySilo-Replanted-Reseed + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: SeedGauge + startBlock: 15277986 # Replanted + endBlock: 191919191 # Reseed Pause on L1 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Silo + abis: + - name: SeedGauge + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json + eventHandlers: + - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) + handler: handleRemoveWithdrawal + - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) + handler: handleRemoveWithdrawals + # This can continue to occur during v2-v3 migration. + - event: RemoveDeposit(indexed address,indexed address,uint32,uint256) + handler: handleRemoveDeposit_v2 + file: ../src/handlers/legacy/LegacySiloHandler.ts - kind: ethereum/contract name: LegacySilo-Replanted-SeedGauge network: mainnet @@ -110,8 +137,6 @@ dataSources: eventHandlers: - event: AddDeposit(indexed address,indexed address,uint32,uint256,uint256) handler: handleAddDeposit_v2 - - event: RemoveDeposit(indexed address,indexed address,uint32,uint256) - handler: handleRemoveDeposit_v2 - event: RemoveDeposits(indexed address,indexed address,uint32[],uint256[],uint256) handler: handleRemoveDeposits_v2 - event: AddWithdrawal(indexed address,indexed address,uint32,uint256) @@ -170,6 +195,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 19927634 # SeedGauge + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -182,10 +208,6 @@ dataSources: eventHandlers: - event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64) handler: handleWhitelistToken_v4 - - event: RemoveWithdrawal(indexed address,indexed address,uint32,uint256) - handler: handleRemoveWithdrawal - - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) - handler: handleRemoveWithdrawals file: ../src/handlers/legacy/LegacySiloHandler.ts ### # SEED GAUGE @@ -197,6 +219,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 19628074 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -230,6 +253,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 19628074 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -259,6 +283,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 12974075 # Field has all-time support + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -325,6 +350,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 14148509 # BIP-11 Pod Marketplace + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -346,6 +372,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 14148509 # BIP-11 Pod Marketplace + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -429,6 +456,7 @@ dataSources: address: "0x402c84De2Ce49aF88f5e2eF3710ff89bFED36cB6" abi: Fertilizer startBlock: 14910573 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -453,6 +481,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 15277986 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -478,6 +507,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 12974075 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -506,6 +536,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: Reseed startBlock: 17671557 # SiloV3 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -616,6 +647,7 @@ dataSources: address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" abi: SeedGauge startBlock: 12974075 + endBlock: 191919191 # Reseed Pause on L1 mapping: kind: ethereum/events apiVersion: 0.0.6 diff --git a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts index 7b355b7bc2..d43398b24e 100644 --- a/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts +++ b/projects/subgraph-beanstalk/src/handlers/SiloHandler.ts @@ -17,7 +17,7 @@ import { unripeChopped } from "../utils/Barn"; import { beanDecimals, getProtocolToken, isUnripe, stalkDecimals } from "../../../subgraph-core/constants/RuntimeConstants"; import { v } from "../utils/constants/Version"; import { WhitelistToken } from "../../generated/Beanstalk-ABIs/Reseed"; -import { BI_10, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { BI_10 } from "../../../subgraph-core/utils/Decimals"; export function handleAddDeposit(event: AddDeposit): void { addDeposits({ @@ -101,8 +101,8 @@ export function handlePlant(event: Plant): void { event.address, event.address, getProtocolToken(v(), event.block.number), - ZERO_BI.minus(event.params.beans), - ZERO_BI.minus(event.params.beans), + event.params.beans.neg(), + event.params.beans.neg(), event.block ); } From 04772380024bbe18c23bfe3a96d924bba81a670e Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:11:08 -0700 Subject: [PATCH 88/88] separate datasource --- .../manifests/ethereum.yaml | 22 ++++++++++++++++++- .../subgraph-beanstalk/manifests/no-apy.yaml | 22 ++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/projects/subgraph-beanstalk/manifests/ethereum.yaml b/projects/subgraph-beanstalk/manifests/ethereum.yaml index 55e145e1e6..3796e0bde8 100644 --- a/projects/subgraph-beanstalk/manifests/ethereum.yaml +++ b/projects/subgraph-beanstalk/manifests/ethereum.yaml @@ -446,7 +446,27 @@ dataSources: handler: handleRemoveWithdrawal - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) handler: handleRemoveWithdrawals - # This can continue to occur during v2-v3 migration. + file: ../src/handlers/legacy/LegacySiloHandler.ts + - kind: ethereum/contract + name: LegacySiloV3MigrationEvents + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: Replanted + startBlock: 15277986 # Replanted + endBlock: 191919191 # Reseed Pause on L1 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Silo + abis: + - name: Replanted + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + eventHandlers: + # The event with this signature is no longer present in SeedGauge ABI because the parameter types changed. + # This event is still emitted during v2-v3 migration even after Gauge deployment. - event: RemoveDeposit(indexed address,indexed address,uint32,uint256) handler: handleRemoveDeposit_v2 file: ../src/handlers/legacy/LegacySiloHandler.ts diff --git a/projects/subgraph-beanstalk/manifests/no-apy.yaml b/projects/subgraph-beanstalk/manifests/no-apy.yaml index 647a6e14de..280166b8e9 100644 --- a/projects/subgraph-beanstalk/manifests/no-apy.yaml +++ b/projects/subgraph-beanstalk/manifests/no-apy.yaml @@ -113,7 +113,27 @@ dataSources: handler: handleRemoveWithdrawal - event: RemoveWithdrawals(indexed address,indexed address,uint32[],uint256) handler: handleRemoveWithdrawals - # This can continue to occur during v2-v3 migration. + file: ../src/handlers/legacy/LegacySiloHandler.ts + - kind: ethereum/contract + name: LegacySiloV3MigrationEvents + network: mainnet + source: + address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5" + abi: Replanted + startBlock: 15277986 # Replanted + endBlock: 191919191 # Reseed Pause on L1 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Silo + abis: + - name: Replanted + file: ../../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json + eventHandlers: + # The event with this signature is no longer present in SeedGauge ABI because the parameter types changed. + # This event is still emitted during v2-v3 migration even after Gauge deployment. - event: RemoveDeposit(indexed address,indexed address,uint32,uint256) handler: handleRemoveDeposit_v2 file: ../src/handlers/legacy/LegacySiloHandler.ts