diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 62909df..19ed5c2 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -24,14 +24,3 @@ Please provide instructions so we can test. Please also list any relevant detail - [ ] I have performed a self-review of my own code - [ ] I have requested at least 1 review (If the PR is significant enough, use best judgement here) - [ ] I have commented my code where relevant, particularly in hard-to-understand areas - -### `dev` -> `master` - -- [ ] I have [checked](https://balancer.github.io/balancer-subgraph-v2/status.html) that all beta deployments have synced -- [ ] I have [checked](https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-prune-v2-beta/graphql?query=%0A%7B%0A++balancers%28block%3A%7Bnumber%3A1%7D%29%7B%0A++++id%0A++%7D%0A%7D) that the earliest block in the polygon pruned deployment is [block, date/time](https://polygonscan.com/block/block) - - [ ] The earliest block is more than 24 hours old -- [ ] I have checked that core metrics are the same in the beta and production deployments - -### Merges to `dev` - -- [ ] I have checked that the graft base is not a pruned deployment diff --git a/.github/workflows/graph-studio.yml b/.github/workflows/graph-studio.yml deleted file mode 100644 index fac6c38..0000000 --- a/.github/workflows/graph-studio.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Deploy Graph Studio Prod - -on: - push: - branches: main - -jobs: - deploy-studio-sepolia: - runs-on: ubuntu-latest - environment: graph - steps: - - uses: actions/checkout@v3 - - name: Install node - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install - run: yarn install - - name: Codegen - run: yarn codegen - - name: Build - run: yarn build - - uses: balancer-labs/graph-deploy@v0.0.1 - with: - graph_deploy_key: ${{secrets.GRAPH_DEPLOY_KEY}} - graph_version_label: ${GITHUB_SHA::8} - graph_subgraph_name: "balancer-sepolia-v3" - graph_account: "balancer-labs" - graph_config_file: "subgraph.yaml" - graph_deploy_studio: true diff --git a/.github/workflows/graph.yml b/.github/workflows/graph.yml new file mode 100644 index 0000000..d05b09f --- /dev/null +++ b/.github/workflows/graph.yml @@ -0,0 +1,71 @@ +name: Deploy Graph Studio Prod +on: + push: + branches: main + +jobs: + deploy-pools-sepolia: + runs-on: ubuntu-latest + environment: graph + defaults: + run: + working-directory: subgraphs/pools + steps: + - uses: actions/checkout@v3 + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 7 + - name: Install dependencies + run: pnpm install + - name: Generate manifests + run: pnpm generate-manifests + - name: Graph Codegen + run: pnpm codegen + - name: Graph Build + run: pnpm build + - uses: balancer-labs/graph-deploy@v0.0.1 + with: + graph_deploy_key: ${{secrets.GRAPH_DEPLOY_KEY}} + graph_version_label: ${GITHUB_SHA::8} + graph_subgraph_name: "balancer-pools-v3-sepolia-7th" + graph_account: "mendesfabio" + graph_config_file: "subgraph.sepolia.yaml" + graph_deploy_studio: true + + deploy-vault-sepolia: + runs-on: ubuntu-latest + environment: graph + defaults: + run: + working-directory: subgraphs/vault + steps: + - uses: actions/checkout@v3 + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 7 + - name: Install dependencies + run: pnpm install + - name: Generate manifests + run: pnpm generate-manifests + - name: Graph Codegen + run: pnpm codegen + - name: Graph Build + run: pnpm build + - uses: balancer-labs/graph-deploy@v0.0.1 + with: + graph_deploy_key: ${{secrets.GRAPH_DEPLOY_KEY}} + graph_version_label: ${GITHUB_SHA::8} + graph_subgraph_name: "balancer-v3-sepolia-7th" + graph_account: "mendesfabio" + graph_config_file: "subgraph.sepolia.yaml" + graph_deploy_studio: true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 348bd63..c165d66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,15 @@ -build/ -node_modules/ -src/types/ +generated +build +dist +node_modules +package-lock.json +pnpm-lock.yaml +subgraph*.yaml +subgraphs/**/src/types +subgraphs/*/node_modules +subgraph.yaml .DS_STORE -.idea +.pnp.* +**/tests/.*/ .vscode -data/ipfs -data/postgres -*.js +.env diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0b68ebf --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 The Graph + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index e6291e2..4229187 100644 --- a/README.md +++ b/README.md @@ -1 +1,85 @@ -# Balancer V3 Subgraphs +# Balancer v3 Subgraphs + +This repository contains the subgraph implementations for Balancer v3, including pools and vault subgraphs. It's structured as a monorepo using pnpm workspaces. + +## Preliminary Deployments + +| Subgraph | Version | Endpoint | +| -------- | ------- | ---------------------------------------------------------------------------------------- | +| Vault | 6th | https://api.studio.thegraph.com/query/31386/balancer-v3-sepolia-6th/version/latest | +| Pools | 6th | https://api.studio.thegraph.com/query/31386/balancer-pools-v3-sepolia-6th/version/latest | +| Vault | 7th | https://api.studio.thegraph.com/query/31386/balancer-v3-sepolia-7th/version/latest | +| Pools | 7th | https://api.studio.thegraph.com/query/31386/balancer-pools-v3-sepolia-7th/version/latest | + +## Prerequisites + +- Node.js (v18 or later) +- pnpm (v7 or later) + +## Setup + +1. Install dependencies: + + ``` + pnpm install + ``` + +2. Generate manifests: + + ``` + pnpm generate-manifests + ``` + + Note: Subgraph manifests (subgraph.yaml) define the smart contracts to index and how to map event data to entities. + +3. Generate types for all subgraphs: + + ``` + pnpm codegen + ``` + + Note: Codegen creates AssemblyScript classes for each smart contract ABI in subgraph.yaml. + +## Development + +### Working on a Specific Subgraph + +To run commands for a specific subgraph: + +``` +pnpm pools # For pools subgraph +pnpm vault # For vault subgraph +``` + +For example, to build the pools subgraph: + +``` +pnpm pools build +``` + +### Extending the Subgraphs + +As Balancer expands to new networks or introduces new pool types, you may need to extend the subgraphs. We've provided detailed documentation to guide you through these processes: + +- [Adding Support for New Pool Types](docs/new-pool-types.md) + If you're building your own pools on Balancer and want to integrate them with the subgraph, this provides a step-by-step guide on how to extend the subgraph to support your new pool type. This ensures that your pool is integrated with Balancer's infraestructure. +- [Adding Support for New Networks](docs/support-new-networks.md) + This guide walks you through the process of adding a new network to the subgraph. It covers updating the `networks.json` file, modifying the GitHub Actions workflow, and generating the necessary manifests. + +## Deployment + +Deployment is handled automatically by GitHub Actions when pushing to the `main` branch. The workflow will: + +1. Generate manifests for all subgraphs +2. Generate code for all subgraphs +3. Build and deploy each subgraph to The Graph's hosted service + +To deploy manually, ensure you have the necessary credentials and run: + +``` +pnpm pools build +pnpm pools deploy + +pnpm vault build +pnpm vault deploy +``` diff --git a/docs/.gitkeep b/docs/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/add-new-networks.md b/docs/add-new-networks.md new file mode 100644 index 0000000..f2bccc3 --- /dev/null +++ b/docs/add-new-networks.md @@ -0,0 +1,84 @@ +# Adding Support for New Networks + +To add support for a new network in the Balancer v3 subgraphs, follow these steps: + +## 1. Update networks.json + +Add the new network configuration to the `networks.json` file in the root of the repository. + +Example: + +```json +{ + "network-name": { + "Vault": { + "address": "0x...", + "startBlock": 0 + }, + "WeightedPoolFactory": { + "address": "0x...", + "startBlock": 0 + }, + "StablePoolFactory": { + "address": "0x...", + "startBlock": 0 + } + } +} +``` + +Replace `"network-name"` with the CLI name found in TheGraph docs, and fill in the correct contract addresses and starting block numbers for the new network. + +For more information on supported networks and their naming conventions, refer to [The Graph's documentation](https://thegraph.com/docs/en/developing/supported-networks/). + +## 2. Update GitHub Actions Workflow + +Duplicate the existing deployment jobs in the `.github/workflows/graph.yml` file for the new network. Here's an example of how to add deployment jobs for a new network: + +```yaml +deploy-pools-network-name: + needs: generate-configs + runs-on: ubuntu-latest + environment: graph + defaults: + run: + working-directory: subgraphs/pools + steps: + # ... (copy steps from existing deploy-pools-sepolia job) + - uses: balancer-labs/graph-deploy@v0.0.1 + with: + graph_deploy_key: ${{secrets.GRAPH_DEPLOY_KEY}} + graph_version_label: ${GITHUB_SHA::8} + graph_subgraph_name: "balancer-v3-network-name" # Update the Subgraph name + graph_account: "balancer-labs" + graph_config_file: "subgraph.network-name.yaml" # Make sure this matches the manifest file name + graph_deploy_studio: true + +deploy-vault-network-name: + needs: generate-configs + runs-on: ubuntu-latest + environment: graph + defaults: + run: + working-directory: subgraphs/vault + steps: + # ... (copy steps from existing deploy-vault-sepolia job) + - uses: balancer-labs/graph-deploy@v0.0.1 + with: + graph_deploy_key: ${{secrets.GRAPH_DEPLOY_KEY}} + graph_version_label: ${GITHUB_SHA::8} + graph_subgraph_name: "balancer-pools-v3-network-name" # Update the Subgraph name + graph_account: "balancer-labs" + graph_config_file: "subgraph.network-name.yaml" # Make sure this matches the manifest file name + graph_deploy_studio: true +``` + +Make sure to replace `network-name` with your actual network name and update the `graph_subgraph_name` and `graph_config_file` for the new network. + +## 3. Generate Configs and Deploy + +After updating `networks.json` and the GitHub Actions files: + +1. Run `pnpm generate-manifests` to create the new manifests. +2. Commit and push the changes to trigger the Actions workflow. +3. The new subgraphs will be built and deployed automatically. diff --git a/docs/new-pool-types.md b/docs/new-pool-types.md new file mode 100644 index 0000000..76d0a9a --- /dev/null +++ b/docs/new-pool-types.md @@ -0,0 +1,84 @@ +# Integrating New Pool Types + +To integrate new pool types into the Balancer subgraph, follow these steps below. We kindly ask developers to start building on Sepolia and add support for pools there before moving to production networks. + +## Setup + +Navigate to the `subgraphs/pools` directory before starting the integration process. + +## Adding the Factory + +Run the following command to add your pool factory: + +``` +pnpm add-factory [factory-address] [network] +``` + +This command fetch the factory ABI, retrieves the deployment block, and adds it to the subgraph manifest. + +## Adding a Pool Instance + +Execute this command to fetch the pool ABI: + +``` +pnpm add-pool [pool-address] [network] +``` + +Ensure you have a pool deployed from your factory before running this command. + +## Generating Types + +Run the codegen command to ensure that types from your ABIs are generated: + +``` +pnpm codegen +``` + +## Updating the GraphQL Schema + +Edit the `schema.graphql` file to add any specific parameters based on your pool type to the `Pool` entity. + +```graphql +type Pool @entity { + # ... Existing fields + + " Your custom parameter " + customParam: BigInt +} +``` + +Add your custom fields to this schema as needed for your specific pool type. + +## Modifying the Pool Creation Handler + +Navigate to `src/mappings/factories.ts` and update the handler function for the new pool type: + + +```typescript +import { YourPool } from "../types/YourPoolFactory/YourPool"; + +export function handleYourPoolCreated(event: PoolCreated): void { + let poolAddress = event.params.pool; + let pool = new Pool(poolAddress); + pool.address = poolAddress; + + let factory = getFactory(event.address, PoolType.YourPoolType, 1); + pool.factory = factory.id; + + + // First, bind the pool address to its contract + let yourPool = YourPool.bind(poolAddress); + + // Then fetch the pool-specific parameters + let customParamResult = yourPool.try_getCustomParameter(); + if (!customParamResult.reverted) { + pool.customParam = customParamResult.value; + } + + // Add more parameter fetching logic as needed + + pool.save(); +} +``` + +In this function, replace the example parameter fetching logic with calls to your pool's specific methods to retrieve and store the relevant parameters. diff --git a/docs/preliminary-deployments.md b/docs/preliminary-deployments.md new file mode 100644 index 0000000..cc89e65 --- /dev/null +++ b/docs/preliminary-deployments.md @@ -0,0 +1,18 @@ +# Preliminary Deployments + +## Deployment Steps + +1. Create both pools and vault subgraphs in TheGraph Studio. + +2. Edit `networks.yaml` file with: + - Vault address + - StablePoolFactory address + - WeightedPoolFactory address + - Deployment blocks for each + +3. Generate manifests: + ``` + pnpm generate-manifests + ``` + +4. Update GitHub Actions diff --git a/networks.json b/networks.json index 9f4fe7c..3c056df 100644 --- a/networks.json +++ b/networks.json @@ -1,8 +1,16 @@ { "sepolia": { "Vault": { - "address": "0xDaa273AeEc06e9CCb7428a77E2abb1E4659B16D2", - "startBlock": 5135341 + "address": "0x7966FE92C59295EcE7FB5D9EfDB271967BFe2fbA", + "startBlock": 6450339 + }, + "WeightedPoolFactory": { + "address": "0x765ce16dbb3D7e89a9beBc834C5D6894e7fAA93c", + "startBlock": 6454545 + }, + "StablePoolFactory": { + "address": "0x4b4b45Edf6Ca26ae894377Cf4FeD1FA9F82D85C6", + "startBlock": 6454538 } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index dfc98f4..edc5f33 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { - "name": "balancer-subgraph-v3", + "name": "balancer-v3-subgraphs", + "private": true, "scripts": { - "codegen": "graph codegen --output-dir src/types/", - "build": "graph build", - "test": "graph test" + "generate-manifests": "node scripts/generate-manifests.js", + "pools": "pnpm --filter @subgraphs/pools", + "vault": "pnpm --filter @subgraphs/vault", + "codegen": "pnpm -r codegen" }, - "dependencies": { - "@graphprotocol/graph-cli": "0.66.0", - "@graphprotocol/graph-ts": "0.32.0" - }, - "devDependencies": { "matchstick-as": "0.5.0" } + "devDependencies": { + "js-yaml": "^4.1.0" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 23087ae..b9aa327 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,41 +4,63 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -dependencies: - '@graphprotocol/graph-cli': - specifier: 0.66.0 - version: 0.66.0(@types/node@20.11.5)(node-fetch@3.3.2)(typescript@5.3.3) - '@graphprotocol/graph-ts': - specifier: 0.32.0 - version: 0.32.0 - -devDependencies: - matchstick-as: - specifier: 0.5.0 - version: 0.5.0 +importers: + + .: + devDependencies: + js-yaml: + specifier: ^4.1.0 + version: 4.1.0 + + subgraphs/pools: + dependencies: + '@graphprotocol/graph-cli': + specifier: 0.66.0 + version: 0.66.0(@types/node@22.5.0)(node-fetch@3.3.2)(typescript@5.5.4) + '@graphprotocol/graph-ts': + specifier: 0.32.0 + version: 0.32.0 + devDependencies: + matchstick-as: + specifier: 0.5.0 + version: 0.5.0 + + subgraphs/vault: + dependencies: + '@graphprotocol/graph-cli': + specifier: 0.66.0 + version: 0.66.0(@types/node@22.5.0)(node-fetch@3.3.2)(typescript@5.5.4) + '@graphprotocol/graph-ts': + specifier: 0.32.0 + version: 0.32.0 + devDependencies: + matchstick-as: + specifier: 0.5.0 + version: 0.5.0 packages: - /@babel/code-frame@7.23.5: - resolution: {integrity: sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==} + /@babel/code-frame@7.24.7: + resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/highlight': 7.23.4 - chalk: 2.4.2 + '@babel/highlight': 7.24.7 + picocolors: 1.0.1 dev: false - /@babel/helper-validator-identifier@7.22.20: - resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} + /@babel/helper-validator-identifier@7.24.7: + resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==} engines: {node: '>=6.9.0'} dev: false - /@babel/highlight@7.23.4: - resolution: {integrity: sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==} + /@babel/highlight@7.24.7: + resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-validator-identifier': 7.22.20 + '@babel/helper-validator-identifier': 7.24.7 chalk: 2.4.2 js-tokens: 4.0.0 + picocolors: 1.0.1 dev: false /@cspotcode/source-map-support@0.8.1: @@ -212,20 +234,20 @@ packages: hasBin: true dependencies: '@rescript/std': 9.0.0 - graphql: 16.8.1 - graphql-import-node: 0.0.5(graphql@16.8.1) + graphql: 16.9.0 + graphql-import-node: 0.0.5(graphql@16.9.0) js-yaml: 4.1.0 dev: false - /@graphprotocol/graph-cli@0.66.0(@types/node@20.11.5)(node-fetch@3.3.2)(typescript@5.3.3): + /@graphprotocol/graph-cli@0.66.0(@types/node@22.5.0)(node-fetch@3.3.2)(typescript@5.5.4): resolution: {integrity: sha512-OiIENdclh/Cy84tOUDIdRmsBg2Dc7xuZ63EdqKcx/GAV96+aWp9XjOWWPsZbE67opfz/DVD/8s6iBBCDohl9Ow==} engines: {node: '>=18'} hasBin: true dependencies: '@float-capital/float-subgraph-uncrashable': 0.0.0-internal-testing.5 - '@oclif/core': 2.8.6(@types/node@20.11.5)(typescript@5.3.3) - '@oclif/plugin-autocomplete': 2.3.10(@types/node@20.11.5)(typescript@5.3.3) - '@oclif/plugin-not-found': 2.4.3(@types/node@20.11.5)(typescript@5.3.3) + '@oclif/core': 2.8.6(@types/node@22.5.0)(typescript@5.5.4) + '@oclif/plugin-autocomplete': 2.3.10(@types/node@22.5.0)(typescript@5.5.4) + '@oclif/plugin-not-found': 2.4.3(@types/node@22.5.0)(typescript@5.5.4) '@whatwg-node/fetch': 0.8.8 assemblyscript: 0.19.23 binary-install-raw: 0.0.13(debug@4.3.4) @@ -294,20 +316,25 @@ packages: multiformats: 9.9.0 dev: false - /@jridgewell/resolve-uri@3.1.1: - resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==} + /@jridgewell/resolve-uri@3.1.2: + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} dev: false - /@jridgewell/sourcemap-codec@1.4.15: - resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + /@jridgewell/sourcemap-codec@1.5.0: + resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} dev: false /@jridgewell/trace-mapping@0.3.9: resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} dependencies: - '@jridgewell/resolve-uri': 3.1.1 - '@jridgewell/sourcemap-codec': 1.4.15 + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.0 + dev: false + + /@noble/hashes@1.4.0: + resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==} + engines: {node: '>= 16'} dev: false /@nodelib/fs.scandir@2.1.5: @@ -328,14 +355,14 @@ packages: engines: {node: '>= 8'} dependencies: '@nodelib/fs.scandir': 2.1.5 - fastq: 1.16.0 + fastq: 1.17.1 dev: false - /@oclif/core@2.15.0(@types/node@20.11.5)(typescript@5.3.3): - resolution: {integrity: sha512-fNEMG5DzJHhYmI3MgpByTvltBOMyFcnRIUMxbiz2ai8rhaYgaTHMG3Q38HcosfIvtw9nCjxpcQtC8MN8QtVCcA==} + /@oclif/core@2.16.0(@types/node@22.5.0)(typescript@5.5.4): + resolution: {integrity: sha512-dL6atBH0zCZl1A1IXCKJgLPrM/wR7K+Wi401E/IvqsK8m2iCHW+0TEOGrans/cuN3oTW+uxIyJFHJ8Im0k4qBw==} engines: {node: '>=14.0.0'} dependencies: - '@types/cli-progress': 3.11.5 + '@types/cli-progress': 3.11.6 ansi-escapes: 4.3.2 ansi-styles: 4.3.0 cardinal: 2.1.1 @@ -343,7 +370,7 @@ packages: clean-stack: 3.0.1 cli-progress: 3.12.0 debug: 4.3.4(supports-color@8.1.1) - ejs: 3.1.9 + ejs: 3.1.10 get-package-type: 0.1.0 globby: 11.1.0 hyperlinker: 1.0.0 @@ -358,8 +385,8 @@ packages: strip-ansi: 6.0.1 supports-color: 8.1.1 supports-hyperlinks: 2.3.0 - ts-node: 10.9.2(@types/node@20.11.5)(typescript@5.3.3) - tslib: 2.6.2 + ts-node: 10.9.2(@types/node@22.5.0)(typescript@5.5.4) + tslib: 2.7.0 widest-line: 3.1.0 wordwrap: 1.0.0 wrap-ansi: 7.0.0 @@ -370,11 +397,11 @@ packages: - typescript dev: false - /@oclif/core@2.8.6(@types/node@20.11.5)(typescript@5.3.3): + /@oclif/core@2.8.6(@types/node@22.5.0)(typescript@5.5.4): resolution: {integrity: sha512-1QlPaHMhOORySCXkQyzjsIsy2GYTilOw3LkjeHkCgsPJQjAT4IclVytJusWktPbYNys9O+O4V23J44yomQvnBQ==} engines: {node: '>=14.0.0'} dependencies: - '@types/cli-progress': 3.11.5 + '@types/cli-progress': 3.11.6 ansi-escapes: 4.3.2 ansi-styles: 4.3.0 cardinal: 2.1.1 @@ -382,7 +409,7 @@ packages: clean-stack: 3.0.1 cli-progress: 3.12.0 debug: 4.3.4(supports-color@8.1.1) - ejs: 3.1.9 + ejs: 3.1.10 fs-extra: 9.1.0 get-package-type: 0.1.0 globby: 11.1.0 @@ -398,8 +425,8 @@ packages: strip-ansi: 6.0.1 supports-color: 8.1.1 supports-hyperlinks: 2.3.0 - ts-node: 10.9.2(@types/node@20.11.5)(typescript@5.3.3) - tslib: 2.6.2 + ts-node: 10.9.2(@types/node@22.5.0)(typescript@5.5.4) + tslib: 2.7.0 widest-line: 3.1.0 wordwrap: 1.0.0 wrap-ansi: 7.0.0 @@ -410,11 +437,11 @@ packages: - typescript dev: false - /@oclif/plugin-autocomplete@2.3.10(@types/node@20.11.5)(typescript@5.3.3): + /@oclif/plugin-autocomplete@2.3.10(@types/node@22.5.0)(typescript@5.5.4): resolution: {integrity: sha512-Ow1AR8WtjzlyCtiWWPgzMyT8SbcDJFr47009riLioHa+MHX2BCDtVn2DVnN/E6b9JlPV5ptQpjefoRSNWBesmg==} engines: {node: '>=12.0.0'} dependencies: - '@oclif/core': 2.15.0(@types/node@20.11.5)(typescript@5.3.3) + '@oclif/core': 2.16.0(@types/node@22.5.0)(typescript@5.5.4) chalk: 4.1.2 debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: @@ -425,11 +452,11 @@ packages: - typescript dev: false - /@oclif/plugin-not-found@2.4.3(@types/node@20.11.5)(typescript@5.3.3): + /@oclif/plugin-not-found@2.4.3(@types/node@22.5.0)(typescript@5.5.4): resolution: {integrity: sha512-nIyaR4y692frwh7wIHZ3fb+2L6XEecQwRDIb4zbEam0TvaVmBQWZoColQyWA84ljFBPZ8XWiQyTz+ixSwdRkqg==} engines: {node: '>=12.0.0'} dependencies: - '@oclif/core': 2.15.0(@types/node@20.11.5)(typescript@5.3.3) + '@oclif/core': 2.16.0(@types/node@22.5.0)(typescript@5.5.4) chalk: 4.1.2 fast-levenshtein: 3.0.0 transitivePeerDependencies: @@ -439,30 +466,30 @@ packages: - typescript dev: false - /@peculiar/asn1-schema@2.3.8: - resolution: {integrity: sha512-ULB1XqHKx1WBU/tTFIA+uARuRoBVZ4pNdOA878RDrRbBfBGcSzi5HBkdScC6ZbHn8z7L8gmKCgPC1LHRrP46tA==} + /@peculiar/asn1-schema@2.3.13: + resolution: {integrity: sha512-3Xq3a01WkHRZL8X04Zsfg//mGaA21xlL4tlVn4v2xGT0JStiztATRkMwa5b+f/HXmY2smsiLXYK46Gwgzvfg3g==} dependencies: asn1js: 3.0.5 pvtsutils: 1.3.5 - tslib: 2.6.2 + tslib: 2.7.0 dev: false /@peculiar/json-schema@1.1.12: resolution: {integrity: sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==} engines: {node: '>=8.0.0'} dependencies: - tslib: 2.6.2 + tslib: 2.7.0 dev: false - /@peculiar/webcrypto@1.4.4: - resolution: {integrity: sha512-VETlZgJqOP3OLRC7AcEYfb6/u05evqsW0Vgs9DyCBATp3FSx7D30Z8ALuDJHsmXCsMblfyTwvB9PLR6IfdlRhg==} + /@peculiar/webcrypto@1.5.0: + resolution: {integrity: sha512-BRs5XUAwiyCDQMsVA9IDvDa7UBR9gAvPHgugOeGng3YN6vJ9JYonyDc0lNczErgtCWtucjR5N7VtaonboD/ezg==} engines: {node: '>=10.12.0'} dependencies: - '@peculiar/asn1-schema': 2.3.8 + '@peculiar/asn1-schema': 2.3.13 '@peculiar/json-schema': 1.1.12 pvtsutils: 1.3.5 - tslib: 2.6.2 - webcrypto-core: 1.7.7 + tslib: 2.7.0 + webcrypto-core: 1.8.0 dev: false /@protobufjs/aspromise@1.1.2: @@ -512,8 +539,8 @@ packages: resolution: {integrity: sha512-zGzFsgtZ44mgL4Xef2gOy1hrRVdrs9mcxCOOKZrIPsmbZW14yTkaF591GXxpQvjXiHtgZ/iA9qLyWH6oSReIxQ==} dev: false - /@tsconfig/node10@1.0.9: - resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==} + /@tsconfig/node10@1.0.11: + resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} dev: false /@tsconfig/node12@1.0.11: @@ -531,13 +558,13 @@ packages: /@types/bn.js@5.1.5: resolution: {integrity: sha512-V46N0zwKRF5Q00AZ6hWtN0T8gGmDUaUzLWQvHFo5yThtVwK/VCenFY3wXVbOvNfajEpsTfQM4IN9k/d6gUVX3A==} dependencies: - '@types/node': 20.11.5 + '@types/node': 22.5.0 dev: false - /@types/cli-progress@3.11.5: - resolution: {integrity: sha512-D4PbNRbviKyppS5ivBGyFO29POlySLmA2HyUFE4p5QGazAMM3CwkKWcvTl8gvElSuxRh6FPKL8XmidX873ou4g==} + /@types/cli-progress@3.11.6: + resolution: {integrity: sha512-cE3+jb9WRlu+uOSAugewNpITJDt1VF8dHOopPO4IABFc3SXYL5WE/+PTz/FCdZRRfIujiWW3n3aMbv1eIGVRWA==} dependencies: - '@types/node': 20.11.5 + '@types/node': 22.5.0 dev: false /@types/concat-stream@1.6.1: @@ -574,10 +601,10 @@ packages: resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} dev: false - /@types/node@20.11.5: - resolution: {integrity: sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w==} + /@types/node@22.5.0: + resolution: {integrity: sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==} dependencies: - undici-types: 5.26.5 + undici-types: 6.19.8 dev: false /@types/node@8.10.66: @@ -591,17 +618,17 @@ packages: /@types/pbkdf2@3.1.2: resolution: {integrity: sha512-uRwJqmiXmh9++aSu1VNEn3iIxWOhd8AHXNSdlaLfdAAdSTY9jYVeGWnzejM3dvrkbqE3/hyQkQQ29IFATEGlew==} dependencies: - '@types/node': 20.11.5 + '@types/node': 22.5.0 dev: false - /@types/qs@6.9.11: - resolution: {integrity: sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ==} + /@types/qs@6.9.15: + resolution: {integrity: sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==} dev: false /@types/secp256k1@4.0.6: resolution: {integrity: sha512-hHxJU6PAEUn0TP4S/ZOzuTUvJWuZ6eIKeNKb5RBpODvSl6hp1Wrw4s7ATY50rklRCScUDpHzVA/DQdSjJ3UoYQ==} dependencies: - '@types/node': 20.11.5 + '@types/node': 22.5.0 dev: false /@types/ws@7.4.7: @@ -617,11 +644,11 @@ packages: /@whatwg-node/fetch@0.8.8: resolution: {integrity: sha512-CdcjGC2vdKhc13KKxgsc6/616BQ7ooDIgPeTuAiE8qfCnS0mGzcfCOoZXypQSz73nxI+GWc7ZReIAVhxoE1KCg==} dependencies: - '@peculiar/webcrypto': 1.4.4 + '@peculiar/webcrypto': 1.5.0 '@whatwg-node/node-fetch': 0.3.6 busboy: 1.6.0 urlpattern-polyfill: 8.0.2 - web-streams-polyfill: 3.3.2 + web-streams-polyfill: 3.3.3 dev: false /@whatwg-node/node-fetch@0.3.6: @@ -631,7 +658,7 @@ packages: busboy: 1.6.0 fast-querystring: 1.1.2 fast-url-parser: 1.1.3 - tslib: 2.6.2 + tslib: 2.7.0 dev: false /JSONStream@1.3.2: @@ -657,13 +684,15 @@ packages: event-target-shim: 5.0.1 dev: false - /acorn-walk@8.3.2: - resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} + /acorn-walk@8.3.3: + resolution: {integrity: sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==} engines: {node: '>=0.4.0'} + dependencies: + acorn: 8.12.1 dev: false - /acorn@8.11.3: - resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} + /acorn@8.12.1: + resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==} engines: {node: '>=0.4.0'} hasBin: true dev: false @@ -760,7 +789,6 @@ packages: /argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - dev: false /array-union@2.1.0: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} @@ -783,7 +811,7 @@ packages: dependencies: pvtsutils: 1.3.5 pvutils: 1.1.3 - tslib: 2.6.2 + tslib: 2.7.0 dev: false /assemblyscript@0.19.10: @@ -811,8 +839,8 @@ packages: engines: {node: '>=8'} dev: false - /async@3.2.5: - resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} + /async@3.2.6: + resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==} dev: false /asynckit@0.4.0: @@ -828,14 +856,14 @@ packages: resolution: {integrity: sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==} dev: false - /aws4@1.12.0: - resolution: {integrity: sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==} + /aws4@1.13.1: + resolution: {integrity: sha512-u5w79Rd7SU4JaIlA/zFqG+gOiuq25q5VLyZ8E+ijJeILuTxVzZgp2CaGw/UTw6pXYN9XMO9yiqj/nEHmhTG5CA==} dev: false /axios@0.21.4(debug@4.3.4): resolution: {integrity: sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==} dependencies: - follow-redirects: 1.15.5(debug@4.3.4) + follow-redirects: 1.15.6(debug@4.3.4) transitivePeerDependencies: - debug dev: false @@ -844,8 +872,8 @@ packages: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: false - /base-x@3.0.9: - resolution: {integrity: sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==} + /base-x@3.0.10: + resolution: {integrity: sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ==} dependencies: safe-buffer: 5.2.1 dev: false @@ -860,8 +888,8 @@ packages: tweetnacl: 0.14.5 dev: false - /binary-extensions@2.2.0: - resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} + /binary-extensions@2.3.0: + resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} dev: false @@ -871,7 +899,7 @@ packages: dependencies: axios: 0.21.4(debug@4.3.4) rimraf: 3.0.2 - tar: 6.2.0 + tar: 6.2.1 transitivePeerDependencies: - debug dev: false @@ -926,11 +954,11 @@ packages: balanced-match: 1.0.2 dev: false - /braces@3.0.2: - resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} + /braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} dependencies: - fill-range: 7.0.1 + fill-range: 7.1.1 dev: false /brorand@1.1.0: @@ -955,7 +983,7 @@ packages: /bs58@4.0.1: resolution: {integrity: sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==} dependencies: - base-x: 3.0.9 + base-x: 3.0.10 dev: false /bs58check@2.1.2: @@ -1002,12 +1030,15 @@ packages: streamsearch: 1.1.0 dev: false - /call-bind@1.0.5: - resolution: {integrity: sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==} + /call-bind@1.0.7: + resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==} + engines: {node: '>= 0.4'} dependencies: + es-define-property: 1.0.0 + es-errors: 1.3.0 function-bind: 1.1.2 - get-intrinsic: 1.2.2 - set-function-length: 1.2.0 + get-intrinsic: 1.2.4 + set-function-length: 1.2.2 dev: false /callsites@3.1.0: @@ -1062,7 +1093,7 @@ packages: engines: {node: '>= 8.10.0'} dependencies: anymatch: 3.1.3 - braces: 3.0.2 + braces: 3.0.3 glob-parent: 5.1.2 is-binary-path: 2.1.0 is-glob: 4.0.3 @@ -1275,13 +1306,13 @@ packages: clone: 1.0.4 dev: false - /define-data-property@1.1.1: - resolution: {integrity: sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==} + /define-data-property@1.1.4: + resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} engines: {node: '>= 0.4'} dependencies: - get-intrinsic: 1.2.2 + es-define-property: 1.0.0 + es-errors: 1.3.0 gopd: 1.0.1 - has-property-descriptors: 1.0.1 dev: false /delay@5.0.0: @@ -1354,20 +1385,20 @@ packages: safer-buffer: 2.1.2 dev: false - /ejs@3.1.6: - resolution: {integrity: sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw==} + /ejs@3.1.10: + resolution: {integrity: sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==} engines: {node: '>=0.10.0'} hasBin: true dependencies: - jake: 10.8.7 + jake: 10.9.2 dev: false - /ejs@3.1.9: - resolution: {integrity: sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==} + /ejs@3.1.6: + resolution: {integrity: sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw==} engines: {node: '>=0.10.0'} hasBin: true dependencies: - jake: 10.8.7 + jake: 10.9.2 dev: false /electron-fetch@1.9.1: @@ -1389,6 +1420,18 @@ packages: minimalistic-crypto-utils: 1.0.1 dev: false + /elliptic@6.5.7: + resolution: {integrity: sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==} + dependencies: + bn.js: 4.12.0 + brorand: 1.1.0 + hash.js: 1.1.7 + hmac-drbg: 1.0.1 + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + minimalistic-crypto-utils: 1.0.1 + dev: false + /emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: false @@ -1422,6 +1465,18 @@ packages: is-arrayish: 0.2.1 dev: false + /es-define-property@1.0.0: + resolution: {integrity: sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==} + engines: {node: '>= 0.4'} + dependencies: + get-intrinsic: 1.2.4 + dev: false + + /es-errors@1.3.0: + resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} + engines: {node: '>= 0.4'} + dev: false + /es6-promise@4.2.8: resolution: {integrity: sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==} dev: false @@ -1448,10 +1503,10 @@ packages: hasBin: true dev: false - /ethereum-bloom-filters@1.0.10: - resolution: {integrity: sha512-rxJ5OFN3RwjQxDcFP2Z5+Q9ho4eIdEmSc2ht0fCu8Se9nbXjZ7/031uXoUYJ87KHCOdVeiUuwSnoS7hmYAGVHA==} + /ethereum-bloom-filters@1.2.0: + resolution: {integrity: sha512-28hyiE7HVsWubqhpVLVmZXFd4ITeHi+BUu05o9isf0GUpMtzBUi+8/gFrGaGYzvGAJQmJ3JKj77Mk9G98T84rA==} dependencies: - js-sha3: 0.8.0 + '@noble/hashes': 1.4.0 dev: false /ethereum-cryptography@0.1.3: @@ -1554,7 +1609,7 @@ packages: '@nodelib/fs.walk': 1.2.8 glob-parent: 5.1.2 merge2: 1.4.1 - micromatch: 4.0.5 + micromatch: 4.0.8 dev: false /fast-json-stable-stringify@2.1.0: @@ -1584,8 +1639,8 @@ packages: engines: {node: '>= 4.9.1'} dev: false - /fastq@1.16.0: - resolution: {integrity: sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==} + /fastq@1.17.1: + resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} dependencies: reusify: 1.0.4 dev: false @@ -1595,7 +1650,7 @@ packages: engines: {node: ^12.20 || >= 14.13} dependencies: node-domexception: 1.0.0 - web-streams-polyfill: 3.3.2 + web-streams-polyfill: 3.3.3 dev: false /filelist@1.0.4: @@ -1604,15 +1659,15 @@ packages: minimatch: 5.1.6 dev: false - /fill-range@7.0.1: - resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} + /fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} dependencies: to-regex-range: 5.0.1 dev: false - /follow-redirects@1.15.5(debug@4.3.4): - resolution: {integrity: sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==} + /follow-redirects@1.15.6(debug@4.3.4): + resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} engines: {node: '>=4.0'} peerDependencies: debug: '*' @@ -1696,13 +1751,15 @@ packages: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} dev: false - /get-intrinsic@1.2.2: - resolution: {integrity: sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==} + /get-intrinsic@1.2.4: + resolution: {integrity: sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==} + engines: {node: '>= 0.4'} dependencies: + es-errors: 1.3.0 function-bind: 1.1.2 - has-proto: 1.0.1 + has-proto: 1.0.3 has-symbols: 1.0.3 - hasown: 2.0.0 + hasown: 2.0.2 dev: false /get-iterator@1.0.2: @@ -1739,6 +1796,7 @@ packages: /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + deprecated: Glob versions prior to v9 are no longer supported dependencies: fs.realpath: 1.0.0 inflight: 1.0.6 @@ -1755,7 +1813,7 @@ packages: fs.realpath: 1.0.0 minimatch: 8.0.4 minipass: 4.2.8 - path-scurry: 1.10.1 + path-scurry: 1.11.1 dev: false /globby@11.1.0: @@ -1765,7 +1823,7 @@ packages: array-union: 2.1.0 dir-glob: 3.0.1 fast-glob: 3.3.2 - ignore: 5.3.0 + ignore: 5.3.2 merge2: 1.4.1 slash: 3.0.0 dev: false @@ -1811,19 +1869,19 @@ packages: /gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} dependencies: - get-intrinsic: 1.2.2 + get-intrinsic: 1.2.4 dev: false /graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} dev: false - /graphql-import-node@0.0.5(graphql@16.8.1): + /graphql-import-node@0.0.5(graphql@16.9.0): resolution: {integrity: sha512-OXbou9fqh9/Lm7vwXT0XoRN9J5+WCYKnbiTalgFDvkQERITRmcfncZs6aVABedd5B85yQU5EULS4a5pnbpuI0Q==} peerDependencies: graphql: '*' dependencies: - graphql: 16.8.1 + graphql: 16.9.0 dev: false /graphql@15.5.0: @@ -1831,8 +1889,8 @@ packages: engines: {node: '>= 10.x'} dev: false - /graphql@16.8.1: - resolution: {integrity: sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==} + /graphql@16.9.0: + resolution: {integrity: sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==} engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} dev: false @@ -1860,14 +1918,14 @@ packages: engines: {node: '>=8'} dev: false - /has-property-descriptors@1.0.1: - resolution: {integrity: sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==} + /has-property-descriptors@1.0.2: + resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==} dependencies: - get-intrinsic: 1.2.2 + es-define-property: 1.0.0 dev: false - /has-proto@1.0.1: - resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==} + /has-proto@1.0.3: + resolution: {integrity: sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==} engines: {node: '>= 0.4'} dev: false @@ -1892,8 +1950,8 @@ packages: minimalistic-assert: 1.0.1 dev: false - /hasown@2.0.0: - resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==} + /hasown@2.0.2: + resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} dependencies: function-bind: 1.1.2 @@ -1953,8 +2011,8 @@ packages: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} dev: false - /ignore@5.3.0: - resolution: {integrity: sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==} + /ignore@5.3.2: + resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} dev: false @@ -1977,6 +2035,7 @@ packages: /inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. dependencies: once: 1.4.0 wrappy: 1.0.2 @@ -2115,7 +2174,7 @@ packages: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} dependencies: - binary-extensions: 2.2.0 + binary-extensions: 2.3.0 dev: false /is-docker@2.2.1: @@ -2205,12 +2264,12 @@ packages: engines: {node: '>=12'} dev: false - /isomorphic-ws@4.0.1(ws@7.5.9): + /isomorphic-ws@4.0.1(ws@7.5.10): resolution: {integrity: sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==} peerDependencies: ws: '*' dependencies: - ws: 7.5.9 + ws: 7.5.10 dev: false /isstream@0.1.2: @@ -2255,12 +2314,12 @@ packages: readable-stream: 3.6.2 dev: false - /jake@10.8.7: - resolution: {integrity: sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==} + /jake@10.9.2: + resolution: {integrity: sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==} engines: {node: '>=10'} hasBin: true dependencies: - async: 3.2.5 + async: 3.2.6 chalk: 4.1.2 filelist: 1.0.4 minimatch: 3.1.2 @@ -2279,10 +2338,10 @@ packages: delay: 5.0.0 es6-promisify: 5.0.0 eyes: 0.1.8 - isomorphic-ws: 4.0.1(ws@7.5.9) + isomorphic-ws: 4.0.1(ws@7.5.10) json-stringify-safe: 5.0.1 uuid: 8.3.2 - ws: 7.5.9 + ws: 7.5.10 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -2309,7 +2368,6 @@ packages: hasBin: true dependencies: argparse: 2.0.1 - dev: false /jsbn@0.1.1: resolution: {integrity: sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==} @@ -2360,7 +2418,7 @@ packages: requiresBuild: true dependencies: node-addon-api: 2.0.2 - node-gyp-build: 4.8.0 + node-gyp-build: 4.8.1 readable-stream: 3.6.2 dev: false @@ -2441,9 +2499,8 @@ packages: /long@5.2.3: resolution: {integrity: sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==} - /lru-cache@10.1.0: - resolution: {integrity: sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==} - engines: {node: 14 || >=16.14} + /lru-cache@10.4.3: + resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} dev: false /lru-cache@6.0.0: @@ -2489,11 +2546,11 @@ packages: engines: {node: '>= 8'} dev: false - /micromatch@4.0.5: - resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} + /micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} dependencies: - braces: 3.0.2 + braces: 3.0.3 picomatch: 2.3.1 dev: false @@ -2563,8 +2620,8 @@ packages: engines: {node: '>=8'} dev: false - /minipass@7.0.4: - resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==} + /minipass@7.1.2: + resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} engines: {node: '>=16 || 14 >=14.17'} dev: false @@ -2690,8 +2747,8 @@ packages: formdata-polyfill: 4.0.10 dev: false - /node-gyp-build@4.8.0: - resolution: {integrity: sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==} + /node-gyp-build@4.8.1: + resolution: {integrity: sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==} hasBin: true dev: false @@ -2724,8 +2781,9 @@ packages: engines: {node: '>=0.10.0'} dev: false - /object-inspect@1.13.1: - resolution: {integrity: sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==} + /object-inspect@1.13.2: + resolution: {integrity: sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==} + engines: {node: '>= 0.4'} dev: false /object-treeify@1.1.33: @@ -2790,7 +2848,7 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} dependencies: - '@babel/code-frame': 7.23.5 + '@babel/code-frame': 7.24.7 error-ex: 1.3.2 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 @@ -2813,12 +2871,12 @@ packages: engines: {node: '>=8'} dev: false - /path-scurry@1.10.1: - resolution: {integrity: sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==} - engines: {node: '>=16 || 14 >=14.17'} + /path-scurry@1.11.1: + resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} + engines: {node: '>=16 || 14 >=14.18'} dependencies: - lru-cache: 10.1.0 - minipass: 7.0.4 + lru-cache: 10.4.3 + minipass: 7.1.2 dev: false /path-type@4.0.0: @@ -2841,6 +2899,10 @@ packages: resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==} dev: false + /picocolors@1.0.1: + resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==} + dev: false + /picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -2883,7 +2945,7 @@ packages: '@protobufjs/pool': 1.1.0 '@protobufjs/utf8': 1.1.0 '@types/long': 4.0.2 - '@types/node': 20.11.5 + '@types/node': 22.5.0 long: 4.0.0 dev: false @@ -2910,7 +2972,7 @@ packages: /pvtsutils@1.3.5: resolution: {integrity: sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA==} dependencies: - tslib: 2.6.2 + tslib: 2.7.0 dev: false /pvutils@1.1.3: @@ -2918,11 +2980,11 @@ packages: engines: {node: '>=6.0.0'} dev: false - /qs@6.11.2: - resolution: {integrity: sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==} + /qs@6.13.0: + resolution: {integrity: sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==} engines: {node: '>=0.6'} dependencies: - side-channel: 1.0.4 + side-channel: 1.0.6 dev: false /qs@6.5.3: @@ -3001,7 +3063,7 @@ packages: deprecated: request has been deprecated, see https://github.com/request/request/issues/3142 dependencies: aws-sign2: 0.7.0 - aws4: 1.12.0 + aws4: 1.13.1 caseless: 0.12.0 combined-stream: 1.0.8 extend: 3.0.2 @@ -3046,6 +3108,7 @@ packages: /rimraf@2.7.1: resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true dependencies: glob: 7.2.3 @@ -3053,6 +3116,7 @@ packages: /rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true dependencies: glob: 7.2.3 @@ -3099,9 +3163,9 @@ packages: engines: {node: '>=10.0.0'} requiresBuild: true dependencies: - elliptic: 6.5.4 + elliptic: 6.5.7 node-addon-api: 2.0.2 - node-gyp-build: 4.8.0 + node-gyp-build: 4.8.1 dev: false /semver@7.3.5: @@ -3120,15 +3184,16 @@ packages: lru-cache: 6.0.0 dev: false - /set-function-length@1.2.0: - resolution: {integrity: sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==} + /set-function-length@1.2.2: + resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} engines: {node: '>= 0.4'} dependencies: - define-data-property: 1.1.1 + define-data-property: 1.1.4 + es-errors: 1.3.0 function-bind: 1.1.2 - get-intrinsic: 1.2.2 + get-intrinsic: 1.2.4 gopd: 1.0.1 - has-property-descriptors: 1.0.1 + has-property-descriptors: 1.0.2 dev: false /setimmediate@1.0.5: @@ -3155,12 +3220,14 @@ packages: engines: {node: '>=8'} dev: false - /side-channel@1.0.4: - resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} + /side-channel@1.0.6: + resolution: {integrity: sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==} + engines: {node: '>= 0.4'} dependencies: - call-bind: 1.0.5 - get-intrinsic: 1.2.2 - object-inspect: 1.13.1 + call-bind: 1.0.7 + es-errors: 1.3.0 + get-intrinsic: 1.2.4 + object-inspect: 1.13.2 dev: false /signal-exit@3.0.7: @@ -3343,8 +3410,8 @@ packages: xtend: 4.0.2 dev: false - /tar@6.2.0: - resolution: {integrity: sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==} + /tar@6.2.1: + resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} dependencies: chownr: 2.0.0 @@ -3362,14 +3429,14 @@ packages: '@types/concat-stream': 1.6.1 '@types/form-data': 0.0.33 '@types/node': 8.10.66 - '@types/qs': 6.9.11 + '@types/qs': 6.9.15 caseless: 0.12.0 concat-stream: 1.6.2 form-data: 2.5.1 http-basic: 8.1.3 http-response-object: 3.0.2 promise: 8.3.0 - qs: 6.11.2 + qs: 6.13.0 dev: false /through@2.3.8: @@ -3387,14 +3454,12 @@ packages: /tmp-promise@3.0.3: resolution: {integrity: sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==} dependencies: - tmp: 0.2.1 + tmp: 0.2.3 dev: false - /tmp@0.2.1: - resolution: {integrity: sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==} - engines: {node: '>=8.17.0'} - dependencies: - rimraf: 3.0.2 + /tmp@0.2.3: + resolution: {integrity: sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==} + engines: {node: '>=14.14'} dev: false /to-buffer@1.1.1: @@ -3420,7 +3485,7 @@ packages: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} dev: false - /ts-node@10.9.2(@types/node@20.11.5)(typescript@5.3.3): + /ts-node@10.9.2(@types/node@22.5.0)(typescript@5.5.4): resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} hasBin: true peerDependencies: @@ -3435,24 +3500,24 @@ packages: optional: true dependencies: '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.9 + '@tsconfig/node10': 1.0.11 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.11.5 - acorn: 8.11.3 - acorn-walk: 8.3.2 + '@types/node': 22.5.0 + acorn: 8.12.1 + acorn-walk: 8.3.3 arg: 4.1.3 create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.3.3 + typescript: 5.5.4 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: false - /tslib@2.6.2: - resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + /tslib@2.7.0: + resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==} dev: false /tunnel-agent@0.6.0: @@ -3474,8 +3539,8 @@ packages: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} dev: false - /typescript@5.3.3: - resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} + /typescript@5.5.4: + resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==} engines: {node: '>=14.17'} hasBin: true dev: false @@ -3486,8 +3551,8 @@ packages: multiformats: 9.9.0 dev: false - /undici-types@5.26.5: - resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + /undici-types@6.19.8: + resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} dev: false /universalify@2.0.1: @@ -3552,8 +3617,8 @@ packages: defaults: 1.0.4 dev: false - /web-streams-polyfill@3.3.2: - resolution: {integrity: sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==} + /web-streams-polyfill@3.3.3: + resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} engines: {node: '>= 8'} dev: false @@ -3570,7 +3635,7 @@ packages: engines: {node: '>=8.0.0'} dependencies: bn.js: 4.12.0 - ethereum-bloom-filters: 1.0.10 + ethereum-bloom-filters: 1.2.0 ethereumjs-util: 7.1.5 ethjs-unit: 0.1.6 number-to-bn: 1.7.0 @@ -3578,14 +3643,14 @@ packages: utf8: 3.0.0 dev: false - /webcrypto-core@1.7.7: - resolution: {integrity: sha512-7FjigXNsBfopEj+5DV2nhNpfic2vumtjjgPmeDKk45z+MJwXKKfhPB7118Pfzrmh4jqOMST6Ch37iPAHoImg5g==} + /webcrypto-core@1.8.0: + resolution: {integrity: sha512-kR1UQNH8MD42CYuLzvibfakG5Ew5seG85dMMoAM/1LqvckxaF6pUiidLuraIu4V+YCIFabYecUZAW0TuxAoaqw==} dependencies: - '@peculiar/asn1-schema': 2.3.8 + '@peculiar/asn1-schema': 2.3.13 '@peculiar/json-schema': 1.1.12 asn1js: 3.0.5 pvtsutils: 1.3.5 - tslib: 2.6.2 + tslib: 2.7.0 dev: false /webidl-conversions@3.0.1: @@ -3631,8 +3696,8 @@ packages: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: false - /ws@7.5.9: - resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} + /ws@7.5.10: + resolution: {integrity: sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==} engines: {node: '>=8.3.0'} peerDependencies: bufferutil: ^4.0.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..caa74b1 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +packages: + - 'subgraphs/*' + - 'packages/*' \ No newline at end of file diff --git a/schema.graphql b/schema.graphql deleted file mode 100644 index 6cbd3e1..0000000 --- a/schema.graphql +++ /dev/null @@ -1,95 +0,0 @@ -type Vault @entity { - id: Bytes! - authorizer: Bytes! - isPaused: Boolean! - protocolSwapFee: BigDecimal! - protocolYieldFee: BigDecimal! - pools: [Pool!] @derivedFrom(field: "vault") -} - -type Pool @entity { - id: Bytes! - vault: Vault! - factory: Bytes! - address: Bytes! - totalShares: BigInt! - pauseManager: Bytes! - pauseWindowEndTime: BigInt! - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! - - tokens: [PoolToken!] @derivedFrom(field: "pool") - rateProviders: [RateProvider!] @derivedFrom(field: "pool") -} - -type PoolToken @entity { - id: Bytes! - pool: Pool! - address: Bytes! - balance: BigInt! - totalProtocolSwapFee: BigInt! - totalProtocolYieldFee: BigInt! -} - -type RateProvider @entity { - id: Bytes! - pool: Pool! - token: PoolToken! - address: Bytes! -} - -type Swap @entity(immutable: true) { - id: Bytes! - pool: Bytes! - tokenIn: Bytes! - tokenOut: Bytes! - tokenAmountIn: BigInt! - tokenAmountOut: BigInt! - swapFeeAmount: BigInt! - user: User! - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -enum InvestType { - Join - Exit -} - -type JoinExit @entity(immutable: true) { - id: ID! - type: InvestType! - sender: Bytes! - amounts: [BigInt!]! - pool: Pool! - user: User! - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -type PoolShare @entity { - id: ID! - pool: Pool! - user: User! - balance: BigInt! -} - -type PoolSnapshot @entity { - id: ID! - pool: Pool! - timestamp: Int! - totalShares: BigInt! - balances: [BigInt!]! - totalProtocolSwapFees: [BigInt!]! - totalProtocolYieldFees: [BigInt!]! -} - -type User @entity { - id: ID! - swaps: [Swap!] @derivedFrom(field: "user") - shares: [PoolShare!] @derivedFrom(field: "user") - joinExits: [JoinExit!] @derivedFrom(field: "user") -} diff --git a/scripts/generate-manifests.js b/scripts/generate-manifests.js new file mode 100644 index 0000000..edcfe9f --- /dev/null +++ b/scripts/generate-manifests.js @@ -0,0 +1,36 @@ +const fs = require('fs'); +const path = require('path'); +const yaml = require('js-yaml'); + +const networksData = JSON.parse(fs.readFileSync('networks.json', 'utf8')); + +function replacePlaceholders(template, network, networkData) { + let result = template.replace(/{{ network }}/g, network); + + for (const [contractName, contractData] of Object.entries(networkData)) { + result = result.replace(new RegExp(`{{ ${contractName}\\.address }}`, 'g'), contractData.address); + result = result.replace(new RegExp(`{{ ${contractName}\\.startBlock }}`, 'g'), contractData.startBlock.toString()); + } + + return result; +} + +['pools', 'vault'].forEach(subgraph => { + const templatePath = path.join('subgraphs', subgraph, 'template.yaml'); + + if (!fs.existsSync(templatePath)) { + console.log(`No template found for ${subgraph}, skipping...`); + return; + } + + const template = fs.readFileSync(templatePath, 'utf8'); + + Object.entries(networksData).forEach(([network, networkData]) => { + const config = replacePlaceholders(template, network, networkData); + const outputPath = path.join('subgraphs', subgraph, `subgraph.${network}.yaml`); + fs.writeFileSync(outputPath, config); + console.log(`Generated ${outputPath}`); + }); +}); + +console.log('🎉 v3 subgraphs successfully generated\n'); diff --git a/src/helpers/constants.ts b/src/helpers/constants.ts deleted file mode 100644 index 5138861..0000000 --- a/src/helpers/constants.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; - -export const ZERO_BI = BigInt.fromString('0'); -export const ZERO_BD = BigDecimal.fromString('0'); - -export const ZERO_ADDRESS = Address.fromString('0x0000000000000000000000000000000000000000'); \ No newline at end of file diff --git a/src/helpers/entities.ts b/src/helpers/entities.ts deleted file mode 100644 index 3059988..0000000 --- a/src/helpers/entities.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { Address, BigInt, Bytes } from "@graphprotocol/graph-ts"; -import { Pool, PoolSnapshot, PoolToken, RateProvider, Vault } from "../types/schema"; -import { PoolShare } from "../types/schema"; -import { ZERO_ADDRESS, ZERO_BD, ZERO_BI } from "./constants"; - -const DAY = 24 * 60 * 60; - -export function getVault(vaultAddress: Bytes): Vault { - let vault: Vault | null = Vault.load(vaultAddress); - if (vault != null) return vault; - - vault = new Vault(vaultAddress); - vault.isPaused = false; - vault.authorizer = ZERO_ADDRESS; - vault.protocolSwapFee = ZERO_BD; - vault.protocolYieldFee = ZERO_BD; - vault.save(); - - return vault; - } - -export function getPoolShareId(poolAddress: Address, userAddress: Address): string { - return poolAddress.toHex().concat('-').concat(userAddress.toHex()); -} - -export function getPoolShare(poolAddress: Address, userAddress: Address): PoolShare { - let poolShareId = getPoolShareId(poolAddress, userAddress); - let poolShare = PoolShare.load(poolShareId) as PoolShare; - return poolShare; -} - -export function createPoolSnapshot(pool: Pool, timestamp: i32): void { - let poolAddress = pool.id; - let dayTimestamp = timestamp - (timestamp % DAY); - - let snapshotId = poolAddress.toHex() + '-' + dayTimestamp.toString(); - let snapshot = PoolSnapshot.load(snapshotId); - - if (!snapshot) { - snapshot = new PoolSnapshot(snapshotId); - } - - let poolTokens = pool.tokens.load(); - let balances = new Array(poolTokens.length); - let totalProtocolSwapFees = new Array(poolTokens.length); - let totalProtocolYieldFees = new Array(poolTokens.length); - for (let i = 0; i < poolTokens.length; i++) { - balances[i] = poolTokens[i].balance; - totalProtocolSwapFees[i] = poolTokens[i].totalProtocolSwapFee; - totalProtocolYieldFees[i] = poolTokens[i].totalProtocolYieldFee; - } - - snapshot.pool = poolAddress; - snapshot.balances = balances; - snapshot.timestamp = dayTimestamp; - snapshot.totalShares = pool.totalShares; - snapshot.totalProtocolSwapFees = totalProtocolSwapFees; - snapshot.totalProtocolYieldFees = totalProtocolYieldFees; - snapshot.save(); -} - -export function createPoolToken(poolAddress: Address, tokenAddress: Address): void { - let poolTokenId = poolAddress.concat(tokenAddress); - let poolToken = PoolToken.load(poolTokenId); - - if (!poolToken) { - poolToken = new PoolToken(poolTokenId); - } - - poolToken.pool = poolAddress; - poolToken.address = tokenAddress; - poolToken.balance = ZERO_BI; - poolToken.totalProtocolSwapFee = ZERO_BI; - poolToken.totalProtocolYieldFee = ZERO_BI; - poolToken.save(); -} - -export function createRateProvider(poolAddress: Address, tokenAddress: Address, rateProviderAddress: Address): void { - let rateProviderId = poolAddress.concat(tokenAddress).concat(rateProviderAddress); - let rateProvider = RateProvider.load(rateProviderId); - - if (!rateProvider) { - rateProvider = new RateProvider(rateProviderId); - } - - rateProvider.pool = poolAddress; - rateProvider.token = tokenAddress; - rateProvider.address = rateProviderAddress; - rateProvider.save(); -} - -export function loadPoolToken(poolAddress: Address, tokenAddress: Address): PoolToken { - let poolTokenId = poolAddress.concat(tokenAddress); - let poolToken = PoolToken.load(poolTokenId) as PoolToken; - - return poolToken; -} \ No newline at end of file diff --git a/src/mappings/bpt.ts b/src/mappings/bpt.ts deleted file mode 100644 index 61f1db0..0000000 --- a/src/mappings/bpt.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Pool } from "../types/schema" -import { Transfer as TransferEvent } from "../types/templates/BPT/BPT" -import { ZERO_ADDRESS } from "../helpers/constants" -import { getPoolShare } from "../helpers/entities" - -/************************************ - ********** BPTS TRANSFERS ********** - ************************************/ - -export function handleTransfer(event: TransferEvent): void { - let isMint = event.params.from == ZERO_ADDRESS; - let isBurn = event.params.to == ZERO_ADDRESS; - - const poolAddress = event.address; - - let poolShareFrom = getPoolShare(poolAddress, event.params.from); - let poolShareTo = getPoolShare(poolAddress, event.params.to); - - let pool = Pool.load(event.address) as Pool; - - if (isMint) { - poolShareTo.balance = poolShareTo.balance.plus(event.params.value); - poolShareTo.save(); - pool.totalShares = pool.totalShares.plus(event.params.value); - } else if (isBurn) { - poolShareFrom.balance = poolShareFrom.balance.minus(event.params.value); - poolShareFrom.save(); - pool.totalShares = pool.totalShares.minus(event.params.value); - } else { - poolShareTo.balance = poolShareTo.balance.plus(event.params.value); - poolShareTo.save(); - - poolShareFrom.balance = poolShareFrom.balance.minus(event.params.value); - poolShareFrom.save(); - } - - pool.save(); -} \ No newline at end of file diff --git a/src/mappings/vault.ts b/src/mappings/vault.ts deleted file mode 100644 index 86634f9..0000000 --- a/src/mappings/vault.ts +++ /dev/null @@ -1,232 +0,0 @@ -import { BigInt, Bytes, log } from "@graphprotocol/graph-ts" -import { - PoolBalanceChanged as PoolBalanceChangedEvent, - PoolRegistered as PoolRegisteredEvent, - ProtocolSwapFeeCharged, - ProtocolSwapFeePercentageChanged, - ProtocolYieldFeeCharged, - ProtocolYieldFeePercentageChanged, - Swap as SwapEvent, -} from "../types/Vault/Vault" -import { - Pool, - Swap, - JoinExit -} from "../types/schema" -import { ZERO_BI } from "../helpers/constants" -import { createPoolSnapshot, createPoolToken, createRateProvider, getVault, loadPoolToken } from "../helpers/entities" -import { scaleDown } from "../helpers/misc" - -/************************************ - ******* POOLS REGISTRATIONS ******** - ************************************/ - -export function handlePoolRegistered(event: PoolRegisteredEvent): void { - let vault = getVault(event.address); - let poolAddress = event.params.pool; - - let pool = new Pool(poolAddress); - pool.vault = vault.id; - pool.address = poolAddress; - pool.factory = event.params.factory; - pool.pauseWindowEndTime = event.params.pauseWindowEndTime; - pool.pauseManager = event.params.pauseManager; - pool.totalShares = ZERO_BI; - - pool.blockNumber = event.block.number - pool.blockTimestamp = event.block.timestamp - pool.transactionHash = event.transaction.hash - - pool.save(); - - for (let i: i32 = 0; i < event.params.tokenConfig.length; i++) { - let tokenAddress = event.params.tokenConfig[i].token; - createPoolToken(poolAddress, tokenAddress); - let rateProviderAddress = event.params.tokenConfig[i].rateProvider; - createRateProvider(poolAddress, tokenAddress, rateProviderAddress); - } - - createPoolSnapshot(pool, event.block.timestamp.toI32()); -} - -/************************************ - ****** DEPOSITS & WITHDRAWALS ****** - ************************************/ - - export function handlePoolBalanceChanged(event: PoolBalanceChangedEvent): void { - let amounts: BigInt[] = event.params.deltas; - - if (amounts.length === 0) { - return; - } - - let total: BigInt = amounts.reduce((sum, amount) => sum.plus(amount), new BigInt(0)); - if (total.gt(ZERO_BI)) { - handlePoolJoined(event); - } else { - handlePoolExited(event); - } -} - -function handlePoolJoined(event: PoolBalanceChangedEvent): void { - let poolAddress = event.params.pool; - let amounts: BigInt[] = event.params.deltas; - - let transactionHash = event.transaction.hash; - let logIndex = event.logIndex; - - let pool = Pool.load(poolAddress); - if (pool == null) { - log.warning('Pool not found in handlePoolJoined: {} {}', [poolAddress.toHex(), transactionHash.toHex()]); - return; - } - - let joinId = transactionHash.toHexString().concat(logIndex.toString()); - let join = new JoinExit(joinId); - - let poolTokens = pool.tokens.load(); - let joinAmounts = new Array(amounts.length); - - for (let i: i32 = 0; i < poolTokens.length; i++) { - joinAmounts[i] = event.params.deltas[i]; - - let poolToken = poolTokens[i]; - poolToken.balance = poolToken.balance.plus(joinAmounts[i]); - poolToken.save(); - } - - join.type = 'Join'; - join.sender = event.params.liquidityProvider; - join.amounts = joinAmounts; - join.pool = poolAddress; - join.user = event.params.liquidityProvider.toHex(); - join.blockNumber = event.block.number; - join.blockTimestamp = event.block.timestamp; - join.transactionHash = transactionHash; - join.save(); - - createPoolSnapshot(pool, event.block.timestamp.toI32()); -} - -function handlePoolExited(event: PoolBalanceChangedEvent): void { - let poolAddress = event.params.pool; - let amounts: BigInt[] = event.params.deltas; - - let transactionHash = event.transaction.hash; - let logIndex = event.logIndex; - - let pool = Pool.load(poolAddress); - if (pool == null) { - log.warning('Pool not found in handlePoolJoined: {} {}', [poolAddress.toHex(), transactionHash.toHex()]); - return; - } - - let exitId = transactionHash.toHexString().concat(logIndex.toString()); - let exit = new JoinExit(exitId); - - let poolTokens = pool.tokens.load(); - let exitAmounts = new Array(amounts.length); - - for (let i: i32 = 0; i < poolTokens.length; i++) { - exitAmounts[i] = event.params.deltas[i].neg(); - - let poolToken = poolTokens[i]; - poolToken.balance = poolToken.balance.minus(exitAmounts[i]); - poolToken.save(); - } - - exit.type = 'Exit'; - exit.sender = event.params.liquidityProvider; - exit.amounts = exitAmounts; - exit.pool = poolAddress; - exit.user = event.params.liquidityProvider.toHex(); - exit.blockNumber = event.block.number; - exit.blockTimestamp = event.block.timestamp; - exit.transactionHash = transactionHash; - exit.save(); - - createPoolSnapshot(pool, event.block.timestamp.toI32()); -} - -/************************************ - ************** SWAPS *************** - ************************************/ - -export function handleSwap(event: SwapEvent): void { - let swap = new Swap( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ); - - swap.pool = event.params.pool; - swap.tokenIn = event.params.tokenIn; - swap.tokenOut = event.params.tokenOut; - swap.tokenAmountIn = event.params.amountIn; - swap.tokenAmountOut = event.params.amountOut; - swap.swapFeeAmount = event.params.swapFeeAmount; - swap.user = event.transaction.from.toHexString(); - - swap.blockNumber = event.block.number; - swap.blockTimestamp = event.block.timestamp; - swap.transactionHash = event.transaction.hash; - - swap.save(); - - let poolAddress = event.params.pool; - - let pool = Pool.load(poolAddress); - if (pool == null) { - log.warning('Pool not found in handleSwap: {} {}', [poolAddress.toHex(), event.transaction.hash.toHex()]); - return; - } - - let tokenInAddress = event.params.tokenIn; - let tokenOutAddress = event.params.tokenOut; - - let poolTokenIn = loadPoolToken(poolAddress, tokenInAddress); - let poolTokenOut = loadPoolToken(poolAddress, tokenOutAddress); - if (poolTokenIn == null || poolTokenOut == null) { - log.warning('PoolToken not found in handleSwap: (tokenIn: {}), (tokenOut: {})', [ - tokenInAddress.toHexString(), - tokenOutAddress.toHexString(), - ]); - return; - } - - let newInAmount = poolTokenIn.balance.plus(event.params.amountIn); - poolTokenIn.balance = newInAmount; - poolTokenIn.save(); - - let newOutAmount = poolTokenOut.balance.minus(event.params.amountOut); - poolTokenOut.balance = newOutAmount; - poolTokenOut.save(); - - createPoolSnapshot(pool, event.block.timestamp.toI32()); -} - -/************************************ - ********** PROTOCOL FEES *********** - ************************************/ - - export function handleProtocolSwapFeePercentageChanged(event: ProtocolSwapFeePercentageChanged): void { - let vault = getVault(event.address); - vault.protocolSwapFee = scaleDown(event.params.swapFeePercentage, 18); - vault.save(); -} - -export function handleProtocolYieldFeePercentageChanged(event: ProtocolYieldFeePercentageChanged): void { - let vault = getVault(event.address); - vault.protocolYieldFee = scaleDown(event.params.yieldFeePercentage, 18); - vault.save(); -} - -export function handleProtocolSwapFeeCharged(event: ProtocolSwapFeeCharged): void { - let poolToken = loadPoolToken(event.params.pool, event.params.token); - poolToken.totalProtocolSwapFee = poolToken.totalProtocolSwapFee.plus(event.params.amount); - poolToken.save(); -} - -export function handleProtocolYieldFeeCharged(event: ProtocolYieldFeeCharged): void { - let poolToken = loadPoolToken(event.params.pool, event.params.token); - poolToken.totalProtocolYieldFee = poolToken.totalProtocolYieldFee.plus(event.params.amount); - poolToken.save(); -} diff --git a/subgraphs/pools/README.md b/subgraphs/pools/README.md new file mode 100644 index 0000000..9a854b8 --- /dev/null +++ b/subgraphs/pools/README.md @@ -0,0 +1 @@ +# Pools v3 Subgraph diff --git a/subgraphs/pools/abis/StablePool.json b/subgraphs/pools/abis/StablePool.json new file mode 100644 index 0000000..2ea5281 --- /dev/null +++ b/subgraphs/pools/abis/StablePool.json @@ -0,0 +1,991 @@ +[ + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "amplificationParameter", + "type": "uint256" + }, + { + "internalType": "string", + "name": "version", + "type": "string" + } + ], + "internalType": "struct StablePool.NewPoolParams", + "name": "params", + "type": "tuple" + }, + { + "internalType": "contract IVault", + "name": "vault", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AmpUpdateAlreadyStarted", + "type": "error" + }, + { + "inputs": [], + "name": "AmpUpdateDurationTooShort", + "type": "error" + }, + { + "inputs": [], + "name": "AmpUpdateNotStarted", + "type": "error" + }, + { + "inputs": [], + "name": "AmpUpdateRateTooFast", + "type": "error" + }, + { + "inputs": [], + "name": "AmplificationFactorTooHigh", + "type": "error" + }, + { + "inputs": [], + "name": "AmplificationFactorTooLow", + "type": "error" + }, + { + "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" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "ERC2612ExpiredSignature", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signer", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "ERC2612InvalidSigner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "currentNonce", + "type": "uint256" + } + ], + "name": "InvalidAccountNonce", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidShortString", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "bits", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "SafeCastOverflowedUintDowncast", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "SenderIsNotVault", + "type": "error" + }, + { + "inputs": [], + "name": "SenderNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "StableGetBalanceDidntConverge", + "type": "error" + }, + { + "inputs": [], + "name": "StableInvariantDidntConverge", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "str", + "type": "string" + } + ], + "name": "StringTooLong", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroDivision", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "startValue", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "endValue", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "name": "AmpUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "currentValue", + "type": "uint256" + } + ], + "name": "AmpUpdateStopped", + "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": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "EIP712DomainChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "balancesLiveScaled18", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "tokenInIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "invariantRatio", + "type": "uint256" + } + ], + "name": "computeBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "balancesLiveScaled18", + "type": "uint256[]" + } + ], + "name": "computeInvariant", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "eip712Domain", + "outputs": [ + { + "internalType": "bytes1", + "name": "fields", + "type": "bytes1" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "version", + "type": "string" + }, + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifyingContract", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "extensions", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "emitApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "emitTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + } + ], + "name": "getActionId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAmplificationParameter", + "outputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isUpdating", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "precision", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentLiveBalances", + "outputs": [ + { + "internalType": "uint256[]", + "name": "balancesLiveScaled18", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaximumSwapFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getMinimumSwapFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStaticSwapFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTokenInfo", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "components": [ + { + "internalType": "enum TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "contract IRateProvider", + "name": "rateProvider", + "type": "address" + }, + { + "internalType": "bool", + "name": "paysYieldFees", + "type": "bool" + } + ], + "internalType": "struct TokenInfo[]", + "name": "tokenInfo", + "type": "tuple[]" + }, + { + "internalType": "uint256[]", + "name": "balancesRaw", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "lastLiveBalances", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTokens", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "amountGivenScaled18", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "balancesScaled18", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "indexIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "indexOut", + "type": "uint256" + }, + { + "internalType": "address", + "name": "router", + "type": "address" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "internalType": "struct IBasePool.PoolSwapParams", + "name": "request", + "type": "tuple" + } + ], + "name": "onSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "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": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "rawEndValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "name": "startAmplificationParameterUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stopAmplificationParameterUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/pools/abis/StablePoolFactory.json b/subgraphs/pools/abis/StablePoolFactory.json new file mode 100644 index 0000000..bd16df8 --- /dev/null +++ b/subgraphs/pools/abis/StablePoolFactory.json @@ -0,0 +1,371 @@ +[ + { + "inputs": [ + { + "internalType": "contract IVault", + "name": "vault", + "type": "address" + }, + { + "internalType": "uint32", + "name": "pauseWindowDuration", + "type": "uint32" + }, + { + "internalType": "string", + "name": "factoryVersion", + "type": "string" + }, + { + "internalType": "string", + "name": "poolVersion", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "Disabled", + "type": "error" + }, + { + "inputs": [], + "name": "PoolPauseWindowDurationOverflow", + "type": "error" + }, + { + "inputs": [], + "name": "SenderNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "StandardPoolWithCreator", + "type": "error" + }, + { + "anonymous": false, + "inputs": [], + "name": "FactoryDisabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "components": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "enum TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "contract IRateProvider", + "name": "rateProvider", + "type": "address" + }, + { + "internalType": "bool", + "name": "paysYieldFees", + "type": "bool" + } + ], + "internalType": "struct TokenConfig[]", + "name": "tokens", + "type": "tuple[]" + }, + { + "internalType": "uint256[]", + "name": "normalizedWeights", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "address", + "name": "pauseManager", + "type": "address" + }, + { + "internalType": "address", + "name": "swapFeeManager", + "type": "address" + }, + { + "internalType": "address", + "name": "poolCreator", + "type": "address" + } + ], + "internalType": "struct PoolRoleAccounts", + "name": "roleAccounts", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + }, + { + "internalType": "address", + "name": "poolHooksContract", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "create", + "outputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "disable", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + } + ], + "name": "getActionId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { + "internalType": "contract IAuthorizer", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDefaultLiquidityManagement", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "disableUnbalancedLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableAddLiquidityCustom", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableRemoveLiquidityCustom", + "type": "bool" + } + ], + "internalType": "struct LiquidityManagement", + "name": "liquidityManagement", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getDefaultPoolHooksContract", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "getDeploymentAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getNewPoolPauseWindowEndTime", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOriginalPauseWindowEndTime", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPauseWindowDuration", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolVersion", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isDisabled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "isPoolFromFactory", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/pools/abis/WeightedPool.json b/subgraphs/pools/abis/WeightedPool.json new file mode 100644 index 0000000..6ef0249 --- /dev/null +++ b/subgraphs/pools/abis/WeightedPool.json @@ -0,0 +1,892 @@ +[ + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "numTokens", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "normalizedWeights", + "type": "uint256[]" + }, + { + "internalType": "string", + "name": "version", + "type": "string" + } + ], + "internalType": "struct WeightedPool.NewPoolParams", + "name": "params", + "type": "tuple" + }, + { + "internalType": "contract IVault", + "name": "vault", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "BaseOutOfBounds", + "type": "error" + }, + { + "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" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "ERC2612ExpiredSignature", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signer", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "ERC2612InvalidSigner", + "type": "error" + }, + { + "inputs": [], + "name": "ExponentOutOfBounds", + "type": "error" + }, + { + "inputs": [], + "name": "InputLengthMismatch", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "currentNonce", + "type": "uint256" + } + ], + "name": "InvalidAccountNonce", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidExponent", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidShortString", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidToken", + "type": "error" + }, + { + "inputs": [], + "name": "MaxInRatio", + "type": "error" + }, + { + "inputs": [], + "name": "MaxOutRatio", + "type": "error" + }, + { + "inputs": [], + "name": "MinWeight", + "type": "error" + }, + { + "inputs": [], + "name": "NormalizedWeightInvariant", + "type": "error" + }, + { + "inputs": [], + "name": "ProductOutOfBounds", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "SenderIsNotVault", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "str", + "type": "string" + } + ], + "name": "StringTooLong", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroDivision", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroInvariant", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "EIP712DomainChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "balancesLiveScaled18", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "tokenInIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "invariantRatio", + "type": "uint256" + } + ], + "name": "computeBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "balancesLiveScaled18", + "type": "uint256[]" + } + ], + "name": "computeInvariant", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "eip712Domain", + "outputs": [ + { + "internalType": "bytes1", + "name": "fields", + "type": "bytes1" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "version", + "type": "string" + }, + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifyingContract", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "extensions", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "emitApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "emitTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentLiveBalances", + "outputs": [ + { + "internalType": "uint256[]", + "name": "balancesLiveScaled18", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaximumSwapFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getMinimumSwapFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getNormalizedWeights", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStaticSwapFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTokenInfo", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "components": [ + { + "internalType": "enum TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "contract IRateProvider", + "name": "rateProvider", + "type": "address" + }, + { + "internalType": "bool", + "name": "paysYieldFees", + "type": "bool" + } + ], + "internalType": "struct TokenInfo[]", + "name": "tokenInfo", + "type": "tuple[]" + }, + { + "internalType": "uint256[]", + "name": "balancesRaw", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "lastLiveBalances", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTokens", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "amountGivenScaled18", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "balancesScaled18", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "indexIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "indexOut", + "type": "uint256" + }, + { + "internalType": "address", + "name": "router", + "type": "address" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "internalType": "struct IBasePool.PoolSwapParams", + "name": "request", + "type": "tuple" + } + ], + "name": "onSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "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": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/pools/abis/WeightedPoolFactory.json b/subgraphs/pools/abis/WeightedPoolFactory.json new file mode 100644 index 0000000..bd16df8 --- /dev/null +++ b/subgraphs/pools/abis/WeightedPoolFactory.json @@ -0,0 +1,371 @@ +[ + { + "inputs": [ + { + "internalType": "contract IVault", + "name": "vault", + "type": "address" + }, + { + "internalType": "uint32", + "name": "pauseWindowDuration", + "type": "uint32" + }, + { + "internalType": "string", + "name": "factoryVersion", + "type": "string" + }, + { + "internalType": "string", + "name": "poolVersion", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "Disabled", + "type": "error" + }, + { + "inputs": [], + "name": "PoolPauseWindowDurationOverflow", + "type": "error" + }, + { + "inputs": [], + "name": "SenderNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "StandardPoolWithCreator", + "type": "error" + }, + { + "anonymous": false, + "inputs": [], + "name": "FactoryDisabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "components": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "enum TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "contract IRateProvider", + "name": "rateProvider", + "type": "address" + }, + { + "internalType": "bool", + "name": "paysYieldFees", + "type": "bool" + } + ], + "internalType": "struct TokenConfig[]", + "name": "tokens", + "type": "tuple[]" + }, + { + "internalType": "uint256[]", + "name": "normalizedWeights", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "address", + "name": "pauseManager", + "type": "address" + }, + { + "internalType": "address", + "name": "swapFeeManager", + "type": "address" + }, + { + "internalType": "address", + "name": "poolCreator", + "type": "address" + } + ], + "internalType": "struct PoolRoleAccounts", + "name": "roleAccounts", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + }, + { + "internalType": "address", + "name": "poolHooksContract", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "create", + "outputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "disable", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + } + ], + "name": "getActionId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { + "internalType": "contract IAuthorizer", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDefaultLiquidityManagement", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "disableUnbalancedLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableAddLiquidityCustom", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableRemoveLiquidityCustom", + "type": "bool" + } + ], + "internalType": "struct LiquidityManagement", + "name": "liquidityManagement", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getDefaultPoolHooksContract", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + } + ], + "name": "getDeploymentAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getNewPoolPauseWindowEndTime", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOriginalPauseWindowEndTime", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPauseWindowDuration", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolVersion", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isDisabled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "isPoolFromFactory", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraphs/pools/package.json b/subgraphs/pools/package.json new file mode 100644 index 0000000..627ccff --- /dev/null +++ b/subgraphs/pools/package.json @@ -0,0 +1,19 @@ +{ + "name": "@subgraphs/pools", + "private": true, + "scripts": { + "add-pool": "node scripts/cli.js", + "add-factory": "node scripts/cli.js", + "codegen": "graph codegen --output-dir src/types/", + "deploy": "graph deploy", + "build": "graph build", + "test": "graph test" + }, + "dependencies": { + "@graphprotocol/graph-cli": "0.66.0", + "@graphprotocol/graph-ts": "0.32.0" + }, + "devDependencies": { + "matchstick-as": "0.5.0" + } +} diff --git a/subgraphs/pools/schema.graphql b/subgraphs/pools/schema.graphql new file mode 100644 index 0000000..393fde5 --- /dev/null +++ b/subgraphs/pools/schema.graphql @@ -0,0 +1,30 @@ +enum PoolType { + Weighted + Stable +} + +type Factory @entity { + "Unique identifier for the Factory" + id: Bytes! + "Address of the Factory contract" + address: Bytes! + "Type of pools this Factory creates" + type: PoolType! + "Version number of the Factory" + version: Int! + "Pools created by this Factory" + pools: [Pool!] @derivedFrom(field: "factory") +} + +type Pool @entity { + "Unique identifier for the Pool" + id: Bytes! + "Address of the Pool contract" + address: Bytes! + "Factory that created this Pool" + factory: Factory! + "Amplification parameter for Stable Pools" + amp: BigInt + "Token weights for Weighted Pools" + weights: [BigDecimal!] +} diff --git a/subgraphs/pools/scripts/add-factory.js b/subgraphs/pools/scripts/add-factory.js new file mode 100755 index 0000000..738a52c --- /dev/null +++ b/subgraphs/pools/scripts/add-factory.js @@ -0,0 +1,46 @@ +#!/usr/bin/env node + +const { execSync } = require('child_process'); + +const [,, address, networkName] = process.argv; + +if (!address || !networkName) { + console.error('Usage: pnpm cli
'); + process.exit(1); +} + +const subgraphManifest = `subgraph.${networkName}.yaml`; + +try { + execSync('git stash push --include-untracked', { stdio: 'inherit' }); + + execSync(`graph add ${address} ${subgraphManifest}`, { stdio: 'inherit' }); + + const changedFiles = execSync('git diff --name-only').toString().trim().split('\n'); + + // Keep only the downloaded ABIs and the subgraph manifest + const filesToKeep = [ + subgraphManifest, + 'abis', + ]; + + changedFiles.forEach(file => { + if (!filesToKeep.includes(file)) { + execSync(`git checkout -- "${file}"`, { stdio: 'inherit' }); + } + }); + + console.log(`Added pool factory ${address} to ${subgraphManifest}`); + console.log('Kept changes in:', filesToKeep.join(', ')); + + execSync('git stash pop', { stdio: 'inherit' }); + +} catch (error) { + console.error(`Failed: ${error.message}`); + try { + execSync('git stash pop', { stdio: 'inherit' }); + } catch (stashError) { + console.error('Failed to restore stashed changes:', stashError.message); + } + process.exit(1); +} \ No newline at end of file diff --git a/subgraphs/pools/scripts/add-pool.js b/subgraphs/pools/scripts/add-pool.js new file mode 100644 index 0000000..c256655 --- /dev/null +++ b/subgraphs/pools/scripts/add-pool.js @@ -0,0 +1,45 @@ +#!/usr/bin/env node + +const { execSync } = require('child_process'); + +const [,, address, networkName] = process.argv; + +if (!address || !networkName) { + console.error('Usage: pnpm cli
'); + process.exit(1); +} + +const subgraphManifest = `subgraph.${networkName}.yaml`; + +try { + execSync('git stash push --include-untracked', { stdio: 'inherit' }); + + execSync(`graph add ${address} ${subgraphManifest}`, { stdio: 'inherit' }); + + const changedFiles = execSync('git diff --name-only').toString().trim().split('\n'); + + // Keep only the downloaded ABI + const filesToKeep = [ + 'abis', + ]; + + changedFiles.forEach(file => { + if (!filesToKeep.includes(file)) { + execSync(`git checkout -- "${file}"`, { stdio: 'inherit' }); + } + }); + + console.log(`Added pool factory ${address} to ${subgraphManifest}`); + console.log('Kept changes in:', filesToKeep.join(', ')); + + execSync('git stash pop', { stdio: 'inherit' }); + +} catch (error) { + console.error(`Failed: ${error.message}`); + try { + execSync('git stash pop', { stdio: 'inherit' }); + } catch (stashError) { + console.error('Failed to restore stashed changes:', stashError.message); + } + process.exit(1); +} \ No newline at end of file diff --git a/subgraphs/pools/src/contract.ts b/subgraphs/pools/src/contract.ts new file mode 100644 index 0000000..2fb5cd0 --- /dev/null +++ b/subgraphs/pools/src/contract.ts @@ -0,0 +1,30 @@ +import { + FactoryDisabled as FactoryDisabledEvent, + PoolCreated as PoolCreatedEvent, +} from "../generated/Contract/Contract" +import { FactoryDisabled, PoolCreated } from "../generated/schema" + +export function handleFactoryDisabled(event: FactoryDisabledEvent): void { + let entity = new FactoryDisabled( + event.transaction.hash.concatI32(event.logIndex.toI32()), + ) + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handlePoolCreated(event: PoolCreatedEvent): void { + let entity = new PoolCreated( + event.transaction.hash.concatI32(event.logIndex.toI32()), + ) + entity.pool = event.params.pool + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} diff --git a/subgraphs/pools/src/helpers/constants.ts b/subgraphs/pools/src/helpers/constants.ts new file mode 100644 index 0000000..b7b2a2a --- /dev/null +++ b/subgraphs/pools/src/helpers/constants.ts @@ -0,0 +1,4 @@ +export namespace PoolType { + export const Weighted = "Weighted"; + export const Stable = "Stable"; +} diff --git a/subgraphs/pools/src/helpers/entities.ts b/subgraphs/pools/src/helpers/entities.ts new file mode 100644 index 0000000..0140580 --- /dev/null +++ b/subgraphs/pools/src/helpers/entities.ts @@ -0,0 +1,20 @@ +import { Address } from "@graphprotocol/graph-ts"; +import { Factory } from "../types/schema"; + +export function getFactory( + factoryAddress: Address, + type: string, + version: i32 +): Factory { + let factory = Factory.load(factoryAddress); + + if (factory == null) { + factory = new Factory(factoryAddress); + factory.address = factoryAddress; + factory.type = type; + factory.version = version; + factory.save(); + } + + return factory; +} diff --git a/subgraphs/pools/src/helpers/misc.ts b/subgraphs/pools/src/helpers/misc.ts new file mode 100644 index 0000000..325db0d --- /dev/null +++ b/subgraphs/pools/src/helpers/misc.ts @@ -0,0 +1,5 @@ +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; + +export function scaleDown(num: BigInt, decimals: i32): BigDecimal { + return num.divDecimal(BigInt.fromI32(10).pow(u8(decimals)).toBigDecimal()); +} diff --git a/subgraphs/pools/src/mappings/factories.ts b/subgraphs/pools/src/mappings/factories.ts new file mode 100644 index 0000000..ab9f087 --- /dev/null +++ b/subgraphs/pools/src/mappings/factories.ts @@ -0,0 +1,57 @@ +import { BigDecimal } from "@graphprotocol/graph-ts"; +import { PoolCreated as WeightedPoolCreated } from "../types/WeightedPoolFactory/WeightedPoolFactory"; +import { WeightedPool } from "../types/WeightedPoolFactory/WeightedPool"; +import { StablePool } from "../types/StablePoolFactory/StablePool"; +import { scaleDown } from "../helpers/misc"; +import { getFactory } from "../helpers/entities"; +import { Pool } from "../types/schema"; + +namespace PoolType { + export const Weighted = "Weighted"; + export const Stable = "Stable"; +} + +/************************************ + ********* WEIGHTED POOLS *********** + ************************************/ + +export function handleWeightedPoolCreated(event: WeightedPoolCreated): void { + let poolAddress = event.params.pool; + let pool = new Pool(poolAddress); + pool.address = poolAddress; + + let factory = getFactory(event.address, PoolType.Weighted, 1); + pool.factory = factory.id; + + let weightedPool = WeightedPool.bind(poolAddress); + let weightsResult = weightedPool.try_getNormalizedWeights(); + if (weightsResult.reverted) return; + pool.weights = weightsResult.value.map((weight) => + scaleDown(weight, 18) + ); + + pool.save(); +} + +/************************************ + ********* STABLE POOLS ************* + ************************************/ + +export function handleStablePoolCreated(event: WeightedPoolCreated): void { + let poolAddress = event.params.pool; + let pool = new Pool(poolAddress); + pool.address = poolAddress; + + let factory = getFactory(event.address, PoolType.Stable, 1); + pool.factory = factory.id; + + let stablePool = StablePool.bind(poolAddress); + let ampResult = stablePool.try_getAmplificationParameter(); + if (ampResult.reverted) return; + + let ampValue = ampResult.value.value0; + let ampPrecision = ampResult.value.value2; + pool.amp = ampValue.div(ampPrecision); + + pool.save(); +} diff --git a/subgraphs/pools/template.yaml b/subgraphs/pools/template.yaml new file mode 100644 index 0000000..2fe2c6d --- /dev/null +++ b/subgraphs/pools/template.yaml @@ -0,0 +1,50 @@ +specVersion: 1.0.0 +schema: + file: ./schema.graphql +dataSources: + - kind: ethereum + name: WeightedPoolFactory + network: {{ network }} + source: + abi: WeightedPoolFactory + address: "{{ WeightedPoolFactory.address }}" + startBlock: {{ WeightedPoolFactory.startBlock }} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Factory + - Pool + abis: + - name: WeightedPool + file: ./abis/WeightedPool.json + - name: WeightedPoolFactory + file: ./abis/WeightedPoolFactory.json + eventHandlers: + - event: PoolCreated(indexed address) + handler: handleWeightedPoolCreated + file: ./src/mappings/factories.ts + - kind: ethereum + name: StablePoolFactory + network: {{ network }} + source: + abi: StablePoolFactory + address: "{{ StablePoolFactory.address }}" + startBlock: {{ StablePoolFactory.startBlock }} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Factory + - Pool + abis: + - name: StablePool + file: ./abis/StablePool.json + - name: StablePoolFactory + file: ./abis/StablePoolFactory.json + eventHandlers: + - event: PoolCreated(indexed address) + handler: handleStablePoolCreated + file: ./src/mappings/factories.ts diff --git a/tsconfig.json b/subgraphs/pools/tsconfig.json similarity index 100% rename from tsconfig.json rename to subgraphs/pools/tsconfig.json diff --git a/subgraphs/vault/README.md b/subgraphs/vault/README.md new file mode 100644 index 0000000..f5e1ee3 --- /dev/null +++ b/subgraphs/vault/README.md @@ -0,0 +1 @@ +# Vault v3 Subgraph diff --git a/abis/ERC20.json b/subgraphs/vault/abis/ERC20.json similarity index 100% rename from abis/ERC20.json rename to subgraphs/vault/abis/ERC20.json diff --git a/subgraphs/vault/abis/ERC4626.json b/subgraphs/vault/abis/ERC4626.json new file mode 100644 index 0000000..c8494cb --- /dev/null +++ b/subgraphs/vault/abis/ERC4626.json @@ -0,0 +1,614 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [ + { + "internalType": "address", + "name": "assetTokenAddress", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "convertToAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "convertToShares", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "maxDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "maxAssets", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "maxMint", + "outputs": [ + { + "internalType": "uint256", + "name": "maxShares", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "maxShares", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "maxWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "maxAssets", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewMint", + "outputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "previewRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "name": "previewWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAssets", + "outputs": [ + { + "internalType": "uint256", + "name": "totalManagedAssets", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assets", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/subgraphs/vault/abis/ProtocolFeeController.json b/subgraphs/vault/abis/ProtocolFeeController.json new file mode 100644 index 0000000..ac2e615 --- /dev/null +++ b/subgraphs/vault/abis/ProtocolFeeController.json @@ -0,0 +1,695 @@ +[ + { + "inputs": [ + { + "internalType": "contract IVault", + "name": "vault_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "caller", + "type": "address" + } + ], + "name": "CallerIsNotPoolCreator", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "FeePrecisionTooHigh", + "type": "error" + }, + { + "inputs": [], + "name": "PoolCreatorFeePercentageTooHigh", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolCreatorNotRegistered", + "type": "error" + }, + { + "inputs": [], + "name": "ProtocolSwapFeePercentageTooHigh", + "type": "error" + }, + { + "inputs": [], + "name": "ProtocolYieldFeePercentageTooHigh", + "type": "error" + }, + { + "inputs": [], + "name": "ReentrancyGuardReentrantCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "SenderIsNotVault", + "type": "error" + }, + { + "inputs": [], + "name": "SenderNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroDivision", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "GlobalProtocolSwapFeePercentageChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "yieldFeePercentage", + "type": "uint256" + } + ], + "name": "GlobalProtocolYieldFeePercentageChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "poolCreatorSwapFeePercentage", + "type": "uint256" + } + ], + "name": "PoolCreatorSwapFeePercentageChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "poolCreatorYieldFeePercentage", + "type": "uint256" + } + ], + "name": "PoolCreatorYieldFeePercentageChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ProtocolSwapFeeCollected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "ProtocolSwapFeePercentageChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ProtocolYieldFeeCollected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "yieldFeePercentage", + "type": "uint256" + } + ], + "name": "ProtocolYieldFeePercentageChanged", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "protocolFeePercentage", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolCreatorFeePercentage", + "type": "uint256" + } + ], + "name": "computeAggregateFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + } + ], + "name": "getActionId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { + "internalType": "contract IAuthorizer", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getGlobalProtocolSwapFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getGlobalProtocolYieldFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolCreatorFeeAmounts", + "outputs": [ + { + "internalType": "uint256[]", + "name": "feeAmounts", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolProtocolSwapFeeInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolProtocolYieldFeeInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getProtocolFeeAmounts", + "outputs": [ + { + "internalType": "uint256[]", + "name": "feeAmounts", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "swapFeeAmounts", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "yieldFeeAmounts", + "type": "uint256[]" + } + ], + "name": "receiveAggregateFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "poolCreator", + "type": "address" + }, + { + "internalType": "bool", + "name": "protocolFeeExempt", + "type": "bool" + } + ], + "name": "registerPool", + "outputs": [ + { + "internalType": "uint256", + "name": "aggregateSwapFeePercentage", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "aggregateYieldFeePercentage", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newProtocolSwapFeePercentage", + "type": "uint256" + } + ], + "name": "setGlobalProtocolSwapFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newProtocolYieldFeePercentage", + "type": "uint256" + } + ], + "name": "setGlobalProtocolYieldFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "poolCreatorSwapFeePercentage", + "type": "uint256" + } + ], + "name": "setPoolCreatorSwapFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "poolCreatorYieldFeePercentage", + "type": "uint256" + } + ], + "name": "setPoolCreatorYieldFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "newProtocolSwapFeePercentage", + "type": "uint256" + } + ], + "name": "setProtocolSwapFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "newProtocolYieldFeePercentage", + "type": "uint256" + } + ], + "name": "setProtocolYieldFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "updateProtocolSwapFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "updateProtocolYieldFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "withdrawPoolCreatorFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "withdrawPoolCreatorFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "withdrawProtocolFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file diff --git a/abis/Vault.json b/subgraphs/vault/abis/Vault.json similarity index 74% rename from abis/Vault.json rename to subgraphs/vault/abis/Vault.json index 35c4640..4ac4e1e 100644 --- a/abis/Vault.json +++ b/subgraphs/vault/abis/Vault.json @@ -10,6 +10,11 @@ "internalType": "contract IAuthorizer", "name": "authorizer", "type": "address" + }, + { + "internalType": "contract IProtocolFeeController", + "name": "protocolFeeController", + "type": "address" } ], "stateMutability": "nonpayable", @@ -37,6 +42,26 @@ "name": "AddressInsufficientBalance", "type": "error" }, + { + "inputs": [], + "name": "AfterAddLiquidityHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "AfterInitializeHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "AfterRemoveLiquidityHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "AfterSwapHookFailed", + "type": "error" + }, { "inputs": [], "name": "AllZeroInputs", @@ -94,6 +119,31 @@ "name": "BalanceNotSettled", "type": "error" }, + { + "inputs": [], + "name": "BalanceOverflow", + "type": "error" + }, + { + "inputs": [], + "name": "BeforeAddLiquidityHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "BeforeInitializeHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "BeforeRemoveLiquidityHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "BeforeSwapHookFailed", + "type": "error" + }, { "inputs": [ { @@ -141,6 +191,26 @@ "name": "DoesNotSupportAddLiquidityCustom", "type": "error" }, + { + "inputs": [], + "name": "DoesNotSupportDonation", + "type": "error" + }, + { + "inputs": [], + "name": "DoesNotSupportRemoveLiquidityCustom", + "type": "error" + }, + { + "inputs": [], + "name": "DoesNotSupportUnbalancedLiquidity", + "type": "error" + }, + { + "inputs": [], + "name": "DynamicSwapFeeHookFailed", + "type": "error" + }, { "inputs": [ { @@ -232,20 +302,88 @@ "name": "FailedInnerCall", "type": "error" }, + { + "inputs": [], + "name": "FeePrecisionTooHigh", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "HookAdjustedAmountInAboveMax", + "type": "error" + }, { "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, { "internalType": "uint256", - "name": "index", + "name": "limit", "type": "uint256" } ], - "name": "HandlerOutOfBounds", + "name": "HookAdjustedAmountOutBelowMin", "type": "error" }, { - "inputs": [], - "name": "HookFailed", + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "HookAdjustedSwapLimit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolHooksContract", + "type": "address" + }, + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "poolFactory", + "type": "address" + } + ], + "name": "HookRegistrationFailed", "type": "error" }, { @@ -278,6 +416,38 @@ "name": "InvalidTokenType", "type": "error" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "invariantRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxInvariantRatio", + "type": "uint256" + } + ], + "name": "InvariantRatioAboveMax", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "invariantRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minInvariantRatio", + "type": "uint256" + } + ], + "name": "InvariantRatioBelowMin", + "type": "error" + }, { "inputs": [], "name": "MaxTokens", @@ -295,7 +465,7 @@ }, { "inputs": [], - "name": "NoHandler", + "name": "NotEnoughBufferShares", "type": "error" }, { @@ -308,6 +478,11 @@ "name": "NotVaultDelegateCall", "type": "error" }, + { + "inputs": [], + "name": "OperationNotSupported", + "type": "error" + }, { "inputs": [], "name": "PauseBufferPeriodDurationTooLarge", @@ -414,17 +589,17 @@ }, { "inputs": [], - "name": "ProtocolSwapFeePercentageTooHigh", + "name": "ProtocolFeesExceedTotalCollected", "type": "error" }, { "inputs": [], - "name": "ProtocolYieldFeePercentageTooHigh", + "name": "QueriesDisabled", "type": "error" }, { "inputs": [], - "name": "QueriesDisabled", + "name": "QuoteResultSpoofed", "type": "error" }, { @@ -437,22 +612,6 @@ "name": "RouterNotTrusted", "type": "error" }, - { - "inputs": [ - { - "internalType": "uint8", - "name": "bits", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "SafeCastOverflowedUintDowncast", - "type": "error" - }, { "inputs": [ { @@ -475,17 +634,6 @@ "name": "SafeERC20FailedOperation", "type": "error" }, - { - "inputs": [ - { - "internalType": "address", - "name": "pool", - "type": "address" - } - ], - "name": "SenderIsNotPauseManager", - "type": "error" - }, { "inputs": [ { @@ -502,6 +650,11 @@ "name": "SwapFeePercentageTooHigh", "type": "error" }, + { + "inputs": [], + "name": "SwapFeePercentageTooLow", + "type": "error" + }, { "inputs": [ { @@ -530,7 +683,13 @@ "type": "error" }, { - "inputs": [], + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], "name": "TokenNotRegistered", "type": "error" }, @@ -571,11 +730,26 @@ "name": "TotalSupplyTooLow", "type": "error" }, + { + "inputs": [], + "name": "TradeAmountTooSmall", + "type": "error" + }, { "inputs": [], "name": "UserDataNotSupported", "type": "error" }, + { + "inputs": [], + "name": "VaultBuffersArePaused", + "type": "error" + }, + { + "inputs": [], + "name": "VaultIsNotUnlocked", + "type": "error" + }, { "inputs": [], "name": "VaultNotPaused", @@ -600,16 +774,32 @@ "inputs": [ { "internalType": "address", - "name": "handler", + "name": "wrappedToken", "type": "address" - }, + } + ], + "name": "WrapAmountTooSmall", + "type": "error" + }, + { + "inputs": [], + "name": "WrongProtocolFeeControllerDeployment", + "type": "error" + }, + { + "inputs": [ { "internalType": "address", - "name": "caller", + "name": "wrappedToken", "type": "address" } ], - "name": "WrongHandler", + "name": "WrongUnderlyingAmount", + "type": "error" + }, + { + "inputs": [], + "name": "WrongVaultAdminDeployment", "type": "error" }, { @@ -617,6 +807,28 @@ "name": "WrongVaultExtensionDeployment", "type": "error" }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrappedToken", + "type": "address" + } + ], + "name": "WrongWrappedAmount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "WrongWrappedTokenAsset", + "type": "error" + }, { "inputs": [], "name": "ZeroDivision", @@ -671,42 +883,110 @@ "inputs": [ { "indexed": true, - "internalType": "address", - "name": "pool", + "internalType": "contract IERC4626", + "name": "wrappedToken", "type": "address" }, { "indexed": true, "internalType": "address", - "name": "liquidityProvider", + "name": "sharesOwner", "type": "address" }, { "indexed": false, - "internalType": "contract IERC20[]", - "name": "tokens", - "type": "address[]" + "internalType": "uint256", + "name": "amountWrapped", + "type": "uint256" }, { "indexed": false, - "internalType": "int256[]", - "name": "deltas", - "type": "int256[]" + "internalType": "uint256", + "name": "amountUnderlying", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "issuedShares", + "type": "uint256" } ], - "name": "PoolBalanceChanged", + "name": "LiquidityAddedToBuffer", "type": "event" }, { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "contract IERC4626", + "name": "wrappedToken", + "type": "address" + }, { "indexed": true, "internalType": "address", - "name": "pool", + "name": "sharesOwner", "type": "address" - } - ], + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountWrapped", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountUnderlying", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "removedShares", + "type": "uint256" + } + ], + "name": "LiquidityRemovedFromBuffer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "liquidityProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256[]", + "name": "deltas", + "type": "int256[]" + } + ], + "name": "PoolBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], "name": "PoolInitialized", "type": "event" }, @@ -782,7 +1062,7 @@ }, { "internalType": "bool", - "name": "yieldFeeExempt", + "name": "paysYieldFees", "type": "bool" } ], @@ -794,17 +1074,45 @@ { "indexed": false, "internalType": "uint256", - "name": "pauseWindowEndTime", + "name": "swapFeePercentage", "type": "uint256" }, { "indexed": false, - "internalType": "address", - "name": "pauseManager", - "type": "address" + "internalType": "uint32", + "name": "pauseWindowEndTime", + "type": "uint32" + }, + { + "components": [ + { + "internalType": "address", + "name": "pauseManager", + "type": "address" + }, + { + "internalType": "address", + "name": "swapFeeManager", + "type": "address" + }, + { + "internalType": "address", + "name": "poolCreator", + "type": "address" + } + ], + "indexed": false, + "internalType": "struct PoolRoleAccounts", + "name": "roleAccounts", + "type": "tuple" }, { "components": [ + { + "internalType": "bool", + "name": "enableHookAdjustedAmounts", + "type": "bool" + }, { "internalType": "bool", "name": "shouldCallBeforeInitialize", @@ -815,6 +1123,11 @@ "name": "shouldCallAfterInitialize", "type": "bool" }, + { + "internalType": "bool", + "name": "shouldCallComputeDynamicSwapFee", + "type": "bool" + }, { "internalType": "bool", "name": "shouldCallBeforeSwap", @@ -844,23 +1157,38 @@ "internalType": "bool", "name": "shouldCallAfterRemoveLiquidity", "type": "bool" + }, + { + "internalType": "address", + "name": "hooksContract", + "type": "address" } ], "indexed": false, - "internalType": "struct PoolHooks", - "name": "hooks", + "internalType": "struct HooksConfig", + "name": "hooksConfig", "type": "tuple" }, { "components": [ { "internalType": "bool", - "name": "supportsAddLiquidityCustom", + "name": "disableUnbalancedLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableAddLiquidityCustom", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableRemoveLiquidityCustom", "type": "bool" }, { "internalType": "bool", - "name": "supportsRemoveLiquidityCustom", + "name": "enableDonation", "type": "bool" } ], @@ -878,18 +1206,12 @@ "inputs": [ { "indexed": true, - "internalType": "contract IERC20", - "name": "token", + "internalType": "contract IProtocolFeeController", + "name": "newProtocolFeeController", "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "amount", - "type": "uint256" } ], - "name": "ProtocolFeeCollected", + "name": "ProtocolFeeControllerChanged", "type": "event" }, { @@ -903,56 +1225,48 @@ }, { "indexed": true, - "internalType": "address", - "name": "token", + "internalType": "contract IERC20", + "name": "tokenIn", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "tokenOut", "type": "address" }, { "indexed": false, "internalType": "uint256", - "name": "amount", + "name": "amountIn", "type": "uint256" - } - ], - "name": "ProtocolSwapFeeCharged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ + }, { - "indexed": true, + "indexed": false, "internalType": "uint256", - "name": "swapFeePercentage", + "name": "amountOut", "type": "uint256" - } - ], - "name": "ProtocolSwapFeePercentageChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "pool", - "type": "address" }, { - "indexed": true, - "internalType": "address", - "name": "token", - "type": "address" + "indexed": false, + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" }, { "indexed": false, "internalType": "uint256", - "name": "amount", + "name": "swapFeeAmount", "type": "uint256" + }, + { + "indexed": false, + "internalType": "contract IERC20", + "name": "swapFeeToken", + "type": "address" } ], - "name": "ProtocolYieldFeeCharged", + "name": "Swap", "type": "event" }, { @@ -960,12 +1274,18 @@ "inputs": [ { "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, "internalType": "uint256", - "name": "yieldFeePercentage", + "name": "swapFeePercentage", "type": "uint256" } ], - "name": "ProtocolYieldFeePercentageChanged", + "name": "SwapFeePercentageChanged", "type": "event" }, { @@ -979,36 +1299,24 @@ }, { "indexed": true, - "internalType": "contract IERC20", - "name": "tokenIn", + "internalType": "address", + "name": "from", "type": "address" }, { "indexed": true, - "internalType": "contract IERC20", - "name": "tokenOut", + "internalType": "address", + "name": "to", "type": "address" }, { "indexed": false, "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "swapFeeAmount", + "name": "value", "type": "uint256" } ], - "name": "Swap", + "name": "Transfer", "type": "event" }, { @@ -1016,30 +1324,30 @@ "inputs": [ { "indexed": true, - "internalType": "address", - "name": "pool", + "internalType": "contract IERC4626", + "name": "wrappedToken", "type": "address" }, { "indexed": true, - "internalType": "address", - "name": "from", + "internalType": "contract IERC20", + "name": "underlyingToken", "type": "address" }, { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" + "indexed": false, + "internalType": "uint256", + "name": "burnedShares", + "type": "uint256" }, { "indexed": false, "internalType": "uint256", - "name": "value", + "name": "withdrawnUnderlying", "type": "uint256" } ], - "name": "Transfer", + "name": "Unwrap", "type": "event" }, { @@ -1056,34 +1364,39 @@ "type": "event" }, { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "MAX_BUFFER_PERIOD_DURATION", - "outputs": [ + "anonymous": false, + "inputs": [ { + "indexed": true, + "internalType": "contract IERC20", + "name": "underlyingToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC4626", + "name": "wrappedToken", + "type": "address" + }, + { + "indexed": false, "internalType": "uint256", - "name": "", + "name": "depositedUnderlying", "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "MAX_PAUSE_WINDOW_DURATION", - "outputs": [ + }, { + "indexed": false, "internalType": "uint256", - "name": "", + "name": "mintedShares", "type": "uint256" } ], - "stateMutability": "view", - "type": "function" + "name": "Wrap", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" }, { "inputs": [ @@ -1146,6 +1459,80 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "enum WrappingDirection", + "name": "direction", + "type": "uint8" + }, + { + "internalType": "contract IERC4626", + "name": "wrappedToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountGivenRaw", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limitRaw", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "internalType": "struct BufferWrapOrUnwrapParams", + "name": "params", + "type": "tuple" + } + ], + "name": "erc4626BufferWrapOrUnwrap", + "outputs": [ + { + "internalType": "uint256", + "name": "amountCalculatedRaw", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInRaw", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutRaw", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { + "internalType": "contract IAuthorizer", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -1188,25 +1575,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "invoke", - "outputs": [ - { - "internalType": "bytes", - "name": "result", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "function" - }, { "inputs": [], "name": "reentrancyGuardEntered", @@ -1281,35 +1649,6 @@ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [ - { - "internalType": "address", - "name": "pool", - "type": "address" - }, - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "uint256", - "name": "exactBptAmountIn", - "type": "uint256" - } - ], - "name": "removeLiquidityRecovery", - "outputs": [ - { - "internalType": "uint256[]", - "name": "amountsOutRaw", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -1319,7 +1658,7 @@ }, { "internalType": "address", - "name": "from", + "name": "to", "type": "address" }, { @@ -1328,7 +1667,7 @@ "type": "uint256" } ], - "name": "retrieve", + "name": "sendTo", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -1339,13 +1678,18 @@ "internalType": "contract IERC20", "name": "token", "type": "address" + }, + { + "internalType": "uint256", + "name": "amountHint", + "type": "uint256" } ], "name": "settle", "outputs": [ { "internalType": "uint256", - "name": "paid", + "name": "credit", "type": "uint256" } ], @@ -1421,23 +1765,19 @@ { "inputs": [ { - "internalType": "contract IERC20", - "name": "token", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "unlock", + "outputs": [ { - "internalType": "uint256", - "name": "amount", - "type": "uint256" + "internalType": "bytes", + "name": "result", + "type": "bytes" } ], - "name": "wire", - "outputs": [], "stateMutability": "nonpayable", "type": "function" }, diff --git a/subgraphs/vault/abis/VaultExtension.json b/subgraphs/vault/abis/VaultExtension.json new file mode 100644 index 0000000..d5c0d9d --- /dev/null +++ b/subgraphs/vault/abis/VaultExtension.json @@ -0,0 +1,2544 @@ +[ + { + "inputs": [ + { + "internalType": "contract IVault", + "name": "mainVault", + "type": "address" + }, + { + "internalType": "contract IVaultAdmin", + "name": "vaultAdmin", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "AfterAddLiquidityHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "AfterInitializeHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "AfterRemoveLiquidityHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "AfterSwapHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "AmountGivenZero", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "AmountInAboveMax", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "AmountOutBelowMin", + "type": "error" + }, + { + "inputs": [], + "name": "BalanceNotSettled", + "type": "error" + }, + { + "inputs": [], + "name": "BalanceOverflow", + "type": "error" + }, + { + "inputs": [], + "name": "BeforeAddLiquidityHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "BeforeInitializeHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "BeforeRemoveLiquidityHookFailed", + "type": "error" + }, + { + "inputs": [], + "name": "BeforeSwapHookFailed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "BptAmountInAboveMax", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "BptAmountOutBelowMin", + "type": "error" + }, + { + "inputs": [], + "name": "CannotReceiveEth", + "type": "error" + }, + { + "inputs": [], + "name": "CannotSwapSameToken", + "type": "error" + }, + { + "inputs": [], + "name": "CodecOverflow", + "type": "error" + }, + { + "inputs": [], + "name": "DoesNotSupportAddLiquidityCustom", + "type": "error" + }, + { + "inputs": [], + "name": "DoesNotSupportDonation", + "type": "error" + }, + { + "inputs": [], + "name": "DoesNotSupportRemoveLiquidityCustom", + "type": "error" + }, + { + "inputs": [], + "name": "DoesNotSupportUnbalancedLiquidity", + "type": "error" + }, + { + "inputs": [], + "name": "DynamicSwapFeeHookFailed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "inputs": [], + "name": "ErrorSelectorNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "FeePrecisionTooHigh", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "HookAdjustedAmountInAboveMax", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "HookAdjustedAmountOutBelowMin", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "HookAdjustedSwapLimit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolHooksContract", + "type": "address" + }, + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "poolFactory", + "type": "address" + } + ], + "name": "HookRegistrationFailed", + "type": "error" + }, + { + "inputs": [], + "name": "InputLengthMismatch", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddLiquidityKind", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "InvalidPercentage", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidRemoveLiquidityKind", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidToken", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTokenConfiguration", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTokenType", + "type": "error" + }, + { + "inputs": [], + "name": "MaxTokens", + "type": "error" + }, + { + "inputs": [], + "name": "MinTokens", + "type": "error" + }, + { + "inputs": [], + "name": "NotEnoughBufferShares", + "type": "error" + }, + { + "inputs": [], + "name": "NotStaticCall", + "type": "error" + }, + { + "inputs": [], + "name": "NotVaultDelegateCall", + "type": "error" + }, + { + "inputs": [], + "name": "OperationNotSupported", + "type": "error" + }, + { + "inputs": [], + "name": "OutOfBounds", + "type": "error" + }, + { + "inputs": [], + "name": "PauseBufferPeriodDurationTooLarge", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolAlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolAlreadyRegistered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolInRecoveryMode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolNotInRecoveryMode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolNotInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolNotPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolNotRegistered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolPauseWindowExpired", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolPaused", + "type": "error" + }, + { + "inputs": [], + "name": "ProtocolFeesExceedTotalCollected", + "type": "error" + }, + { + "inputs": [], + "name": "QueriesDisabled", + "type": "error" + }, + { + "inputs": [], + "name": "QuoteResultSpoofed", + "type": "error" + }, + { + "inputs": [], + "name": "ReentrancyGuardReentrantCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "name": "Result", + "type": "error" + }, + { + "inputs": [], + "name": "RouterNotTrusted", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "SafeCastOverflowedUintToInt", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "SenderIsNotVault", + "type": "error" + }, + { + "inputs": [], + "name": "SwapFeePercentageTooHigh", + "type": "error" + }, + { + "inputs": [], + "name": "SwapFeePercentageTooLow", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "SwapLimit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "TokenAlreadyRegistered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "TokenNotRegistered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "expectedToken", + "type": "address" + }, + { + "internalType": "address", + "name": "actualToken", + "type": "address" + } + ], + "name": "TokensMismatch", + "type": "error" + }, + { + "inputs": [], + "name": "TokensNotSorted", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + } + ], + "name": "TotalSupplyTooLow", + "type": "error" + }, + { + "inputs": [], + "name": "TradeAmountTooSmall", + "type": "error" + }, + { + "inputs": [], + "name": "UserDataNotSupported", + "type": "error" + }, + { + "inputs": [], + "name": "VaultBuffersArePaused", + "type": "error" + }, + { + "inputs": [], + "name": "VaultIsNotUnlocked", + "type": "error" + }, + { + "inputs": [], + "name": "VaultNotPaused", + "type": "error" + }, + { + "inputs": [], + "name": "VaultPauseWindowDurationTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "VaultPauseWindowExpired", + "type": "error" + }, + { + "inputs": [], + "name": "VaultPaused", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrappedToken", + "type": "address" + } + ], + "name": "WrapAmountTooSmall", + "type": "error" + }, + { + "inputs": [], + "name": "WrongProtocolFeeControllerDeployment", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrappedToken", + "type": "address" + } + ], + "name": "WrongUnderlyingAmount", + "type": "error" + }, + { + "inputs": [], + "name": "WrongVaultAdminDeployment", + "type": "error" + }, + { + "inputs": [], + "name": "WrongVaultExtensionDeployment", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrappedToken", + "type": "address" + } + ], + "name": "WrongWrappedAmount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "WrongWrappedTokenAsset", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IAuthorizer", + "name": "newAuthorizer", + "type": "address" + } + ], + "name": "AuthorizerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IERC4626", + "name": "wrappedToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sharesOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountWrapped", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountUnderlying", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "issuedShares", + "type": "uint256" + } + ], + "name": "LiquidityAddedToBuffer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IERC4626", + "name": "wrappedToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sharesOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountWrapped", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountUnderlying", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "removedShares", + "type": "uint256" + } + ], + "name": "LiquidityRemovedFromBuffer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "liquidityProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256[]", + "name": "deltas", + "type": "int256[]" + } + ], + "name": "PoolBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "PoolPausedStateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "recoveryMode", + "type": "bool" + } + ], + "name": "PoolRecoveryModeStateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "factory", + "type": "address" + }, + { + "components": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "enum TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "contract IRateProvider", + "name": "rateProvider", + "type": "address" + }, + { + "internalType": "bool", + "name": "paysYieldFees", + "type": "bool" + } + ], + "indexed": false, + "internalType": "struct TokenConfig[]", + "name": "tokenConfig", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "pauseWindowEndTime", + "type": "uint32" + }, + { + "components": [ + { + "internalType": "address", + "name": "pauseManager", + "type": "address" + }, + { + "internalType": "address", + "name": "swapFeeManager", + "type": "address" + }, + { + "internalType": "address", + "name": "poolCreator", + "type": "address" + } + ], + "indexed": false, + "internalType": "struct PoolRoleAccounts", + "name": "roleAccounts", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bool", + "name": "enableHookAdjustedAmounts", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallBeforeInitialize", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallAfterInitialize", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallComputeDynamicSwapFee", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallBeforeSwap", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallAfterSwap", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallBeforeAddLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallAfterAddLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallBeforeRemoveLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallAfterRemoveLiquidity", + "type": "bool" + }, + { + "internalType": "address", + "name": "hooksContract", + "type": "address" + } + ], + "indexed": false, + "internalType": "struct HooksConfig", + "name": "hooksConfig", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bool", + "name": "disableUnbalancedLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableAddLiquidityCustom", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableRemoveLiquidityCustom", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableDonation", + "type": "bool" + } + ], + "indexed": false, + "internalType": "struct LiquidityManagement", + "name": "liquidityManagement", + "type": "tuple" + } + ], + "name": "PoolRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IProtocolFeeController", + "name": "newProtocolFeeController", + "type": "address" + } + ], + "name": "ProtocolFeeControllerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "tokenIn", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "tokenOut", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "swapFeeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "contract IERC20", + "name": "swapFeeToken", + "type": "address" + } + ], + "name": "Swap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "SwapFeePercentageChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IERC4626", + "name": "wrappedToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "underlyingToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "burnedShares", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawnUnderlying", + "type": "uint256" + } + ], + "name": "Unwrap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "VaultPausedStateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IERC20", + "name": "underlyingToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC4626", + "name": "wrappedToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "depositedUnderlying", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintedShares", + "type": "uint256" + } + ], + "name": "Wrap", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "components": [ + { + "internalType": "enum SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "amountGivenScaled18", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "balancesScaled18", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "indexIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "indexOut", + "type": "uint256" + }, + { + "internalType": "address", + "name": "router", + "type": "address" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "internalType": "struct PoolSwapParams", + "name": "swapParams", + "type": "tuple" + } + ], + "name": "computeDynamicSwapFeePercentage", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "dynamicSwapFeePercentage", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "getAggregateSwapFeeAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "getAggregateYieldFeeAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getBptRate", + "outputs": [ + { + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getCurrentLiveBalances", + "outputs": [ + { + "internalType": "uint256[]", + "name": "balancesLiveScaled18", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getHooksConfig", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "enableHookAdjustedAmounts", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallBeforeInitialize", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallAfterInitialize", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallComputeDynamicSwapFee", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallBeforeSwap", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallAfterSwap", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallBeforeAddLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallAfterAddLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallBeforeRemoveLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "shouldCallAfterRemoveLiquidity", + "type": "bool" + }, + { + "internalType": "address", + "name": "hooksContract", + "type": "address" + } + ], + "internalType": "struct HooksConfig", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getNonzeroDeltaCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolConfig", + "outputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "bool", + "name": "disableUnbalancedLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableAddLiquidityCustom", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableRemoveLiquidityCustom", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableDonation", + "type": "bool" + } + ], + "internalType": "struct LiquidityManagement", + "name": "liquidityManagement", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "staticSwapFeePercentage", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "aggregateSwapFeePercentage", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "aggregateYieldFeePercentage", + "type": "uint256" + }, + { + "internalType": "uint40", + "name": "tokenDecimalDiffs", + "type": "uint40" + }, + { + "internalType": "uint32", + "name": "pauseWindowEndTime", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "isPoolRegistered", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isPoolInitialized", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isPoolPaused", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isPoolInRecoveryMode", + "type": "bool" + } + ], + "internalType": "struct PoolConfig", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolData", + "outputs": [ + { + "components": [ + { + "internalType": "PoolConfigBits", + "name": "poolConfigBits", + "type": "bytes32" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "components": [ + { + "internalType": "enum TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "contract IRateProvider", + "name": "rateProvider", + "type": "address" + }, + { + "internalType": "bool", + "name": "paysYieldFees", + "type": "bool" + } + ], + "internalType": "struct TokenInfo[]", + "name": "tokenInfo", + "type": "tuple[]" + }, + { + "internalType": "uint256[]", + "name": "balancesRaw", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "balancesLiveScaled18", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "tokenRates", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "decimalScalingFactors", + "type": "uint256[]" + } + ], + "internalType": "struct PoolData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolPausedState", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolRoleAccounts", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "pauseManager", + "type": "address" + }, + { + "internalType": "address", + "name": "swapFeeManager", + "type": "address" + }, + { + "internalType": "address", + "name": "poolCreator", + "type": "address" + } + ], + "internalType": "struct PoolRoleAccounts", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolTokenInfo", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "components": [ + { + "internalType": "enum TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "contract IRateProvider", + "name": "rateProvider", + "type": "address" + }, + { + "internalType": "bool", + "name": "paysYieldFees", + "type": "bool" + } + ], + "internalType": "struct TokenInfo[]", + "name": "tokenInfo", + "type": "tuple[]" + }, + { + "internalType": "uint256[]", + "name": "balancesRaw", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "lastBalancesLiveScaled18", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolTokenRates", + "outputs": [ + { + "internalType": "uint256[]", + "name": "decimalScalingFactors", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "tokenRates", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getPoolTokens", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getProtocolFeeController", + "outputs": [ + { + "internalType": "contract IProtocolFeeController", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "getReservesOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "getStaticSwapFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + } + ], + "name": "getTokenDelta", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVaultAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "exactAmountsIn", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "minBptAmountOut", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "name": "initialize", + "outputs": [ + { + "internalType": "uint256", + "name": "bptAmountOut", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "isPoolInRecoveryMode", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "isPoolInitialized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "isPoolPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "isPoolRegistered", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isQueryDisabled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isUnlocked", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "quote", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "quoteAndRevert", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "reentrancyGuardEntered", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "components": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "enum TokenType", + "name": "tokenType", + "type": "uint8" + }, + { + "internalType": "contract IRateProvider", + "name": "rateProvider", + "type": "address" + }, + { + "internalType": "bool", + "name": "paysYieldFees", + "type": "bool" + } + ], + "internalType": "struct TokenConfig[]", + "name": "tokenConfig", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "pauseWindowEndTime", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "protocolFeeExempt", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "pauseManager", + "type": "address" + }, + { + "internalType": "address", + "name": "swapFeeManager", + "type": "address" + }, + { + "internalType": "address", + "name": "poolCreator", + "type": "address" + } + ], + "internalType": "struct PoolRoleAccounts", + "name": "roleAccounts", + "type": "tuple" + }, + { + "internalType": "address", + "name": "poolHooksContract", + "type": "address" + }, + { + "components": [ + { + "internalType": "bool", + "name": "disableUnbalancedLiquidity", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableAddLiquidityCustom", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableRemoveLiquidityCustom", + "type": "bool" + }, + { + "internalType": "bool", + "name": "enableDonation", + "type": "bool" + } + ], + "internalType": "struct LiquidityManagement", + "name": "liquidityManagement", + "type": "tuple" + } + ], + "name": "registerPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "exactBptAmountIn", + "type": "uint256" + } + ], + "name": "removeLiquidityRecovery", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amountsOutRaw", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/subgraphs/vault/package.json b/subgraphs/vault/package.json new file mode 100644 index 0000000..f09d9d0 --- /dev/null +++ b/subgraphs/vault/package.json @@ -0,0 +1,17 @@ +{ + "name": "@subgraphs/vault", + "private": true, + "scripts": { + "codegen": "graph codegen --output-dir src/types/", + "deploy": "graph deploy", + "build": "graph build", + "test": "graph test" + }, + "dependencies": { + "@graphprotocol/graph-cli": "0.66.0", + "@graphprotocol/graph-ts": "0.32.0" + }, + "devDependencies": { + "matchstick-as": "0.5.0" + } +} diff --git a/subgraphs/vault/schema.graphql b/subgraphs/vault/schema.graphql new file mode 100644 index 0000000..0618cb2 --- /dev/null +++ b/subgraphs/vault/schema.graphql @@ -0,0 +1,310 @@ +type Vault @entity { + "Unique identifier for the Vault" + id: Bytes! + "Address of the authorizer" + authorizer: Bytes! + "Address of the protocol fee controller" + protocolFeeController: Bytes! + "Indicates whether the Vault is currently paused" + isPaused: Boolean! + "Protocol swap fee percentage" + protocolSwapFee: BigDecimal! + "Protocol yield fee percentage" + protocolYieldFee: BigDecimal! + "Pools associated with this Vault" + pools: [Pool!] @derivedFrom(field: "vault") +} + +type Pool @entity { + "Unique identifier for the Pool" + id: Bytes! + "The Vault this Pool belongs to" + vault: Vault! + "The Hook associated with this Pool" + hook: Hook! + "Configuration for the Hook of this Pool" + hookConfig: HookConfig! + "Liquidity management settings for this Pool" + liquidityManagement: LiquidityManagement! + "Address of the factory that created this Pool" + factory: Bytes! + "Address of the Pool" + address: Bytes! + "Name of the Pool" + name: String! + "Symbol of the Pool" + symbol: String! + "Swap fee percentage for this Pool" + swapFee: BigDecimal! + "Total shares of the Pool" + totalShares: BigDecimal! + "Address of the pause manager for this Pool" + pauseManager: Bytes! + "Timestamp when the pause window ends" + pauseWindowEndTime: BigInt! + "Block number when the Pool was created" + blockNumber: BigInt! + "Timestamp of the block when the Pool was created" + blockTimestamp: BigInt! + "Hash of the transaction that created the Pool" + transactionHash: Bytes! + "Indicates whether the Pool has been initialized" + isInitialized: Boolean! + + "Total number of swaps performed in this Pool" + swapsCount: BigInt! + "Number of unique holders of this Pool's tokens" + holdersCount: BigInt! + + "Tokens in this Pool" + tokens: [PoolToken!]! @derivedFrom(field: "pool") + "Rate providers associated with this Pool" + rateProviders: [RateProvider!]! @derivedFrom(field: "pool") + + "Snapshots of this Pool's state over time" + snapshots: [PoolSnapshot!]! @derivedFrom(field: "pool") +} + +type Hook @entity { + "Unique identifier for the Hook" + id: Bytes! + "Address of the Hook" + address: Bytes! + "Pools associated with this Hook" + pools: [Pool!] @derivedFrom(field: "hook") +} + +type HookConfig @entity { + "Unique identifier for the HookConfig" + id: Bytes! + "The Pool this HookConfig is associated with" + pool: Pool! + "The Hook this config is for" + hook: Hook! + "Indicates whether hook-adjusted amounts are enabled" + enableHookAdjustedAmounts: Boolean! + "Indicates whether the hook should be called before initialization" + shouldCallBeforeInitialize: Boolean! + "Indicates whether the hook should be called after initialization" + shouldCallAfterInitialize: Boolean! + "Indicates whether the hook should be called to compute dynamic swap fees" + shouldCallComputeDynamicSwapFee: Boolean! + "Indicates whether the hook should be called before a swap" + shouldCallBeforeSwap: Boolean! + "Indicates whether the hook should be called after a swap" + shouldCallAfterSwap: Boolean! + "Indicates whether the hook should be called before adding liquidity" + shouldCallBeforeAddLiquidity: Boolean! + "Indicates whether the hook should be called after adding liquidity" + shouldCallAfterAddLiquidity: Boolean! + "Indicates whether the hook should be called before removing liquidity" + shouldCallBeforeRemoveLiquidity: Boolean! + "Indicates whether the hook should be called after removing liquidity" + shouldCallAfterRemoveLiquidity: Boolean! +} + +type LiquidityManagement @entity { + "Unique identifier for the LiquidityManagement" + id: Bytes! + "The Pool this LiquidityManagement is associated with" + pool: Pool! + "Indicates whether unbalanced liquidity is disabled" + disableUnbalancedLiquidity: Boolean! + "Indicates whether custom add liquidity is enabled" + enableAddLiquidityCustom: Boolean! + "Indicates whether custom remove liquidity is enabled" + enableRemoveLiquidityCustom: Boolean! + "Indicates whether donation is enabled" + enableDonation: Boolean! +} + +type PoolToken @entity { + "Unique identifier for the PoolToken" + id: Bytes! + "The Pool this token belongs to" + pool: Pool! + "Index of this token in the Pool" + index: Int! + "Name of the token" + name: String! + "Symbol of the token" + symbol: String! + "Number of decimal places for the token" + decimals: Int! + "Address of the token" + address: Bytes! + "Current balance of this token in the Pool" + balance: BigDecimal! + "Total volume of this token traded in the Pool" + volume: BigDecimal! + "Buffer associated with this token, if any" + buffer: Buffer + "Nested Pool associated with this token, if any" + nestedPool: Pool + "Current price rate for this token" + priceRate: BigDecimal! + "Total protocol swap fees collected for this token" + totalProtocolSwapFee: BigDecimal! + "Total protocol yield fees collected for this token" + totalProtocolYieldFee: BigDecimal! + "Indicates whether this token pays yield fees" + paysYieldFees: Boolean! +} + +type Token @entity { + "Unique identifier for the Token" + id: Bytes! + "Name of the token" + name: String! + "Symbol of the token" + symbol: String! + "Number of decimal places for the token" + decimals: Int! + "Address of the token" + address: Bytes! +} + +type RateProvider @entity { + "Unique identifier for the RateProvider" + id: Bytes! + "The Pool this RateProvider is associated with" + pool: Pool! + "The token this RateProvider is for" + token: PoolToken! + "Address of the RateProvider" + address: Bytes! +} + +type Buffer @entity { + "Unique identifier for the Buffer" + id: Bytes! + "The wrapped token in this Buffer" + wrappedToken: Token! + "The underlying token in this Buffer" + underlyingToken: Token! + "Balance of the wrapped token in this Buffer" + wrappedBalance: BigDecimal! + "Balance of the underlying token in this Buffer" + underlyingBalance: BigDecimal! + "Total shares of this Buffer" + totalShares: BigDecimal! +} + +type BufferShare @entity { + "Unique identifier for the BufferShare" + id: Bytes! + "The user who owns this share" + user: User! + "The Buffer this share is for" + buffer: Buffer! + "Balance of this share" + balance: BigDecimal! +} + +type Swap @entity(immutable: true) { + "Unique identifier for the Swap" + id: Bytes! + "Address of the Pool where the swap occurred" + pool: Bytes! + "Address of the token being swapped in" + tokenIn: Bytes! + "Symbol of the token being swapped in" + tokenInSymbol: String! + "Symbol of the token being swapped out" + tokenOutSymbol: String! + "Amount of tokens swapped out" + tokenAmountOut: BigDecimal! + "Address of the token being swapped out" + tokenOut: Bytes! + "Amount of tokens swapped in" + tokenAmountIn: BigDecimal! + "Address of the token used for swap fees" + swapFeeToken: Bytes! + "Amount of swap fees" + swapFeeAmount: BigDecimal! + "User who performed the swap" + user: User! + "Block number when the swap occurred" + blockNumber: BigInt! + "Timestamp of the block when the swap occurred" + blockTimestamp: BigInt! + "Hash of the transaction containing the swap" + transactionHash: Bytes! + "Log index of the swap event in the transaction" + logIndex: BigInt! +} + +enum InvestType { + Add + Remove +} + +type AddRemove @entity(immutable: true) { + "Unique identifier for the AddRemove event" + id: Bytes! + "Type of investment (Add or Remove)" + type: InvestType! + "Address of the sender" + sender: Bytes! + "Amounts of tokens added or removed" + amounts: [BigDecimal!]! + "The Pool where liquidity was added or removed" + pool: Pool! + "User who performed the add or remove action" + user: User! + "Block number when the event occurred" + blockNumber: BigInt! + "Timestamp of the block when the event occurred" + blockTimestamp: BigInt! + "Hash of the transaction containing the event" + transactionHash: Bytes! + "Log index of the event in the transaction" + logIndex: BigInt! +} + +type PoolShare @entity { + "Unique identifier for the PoolShare" + id: ID! + "The Pool this share is for" + pool: Pool! + "The user who owns this share" + user: User! + "Balance of this share" + balance: BigDecimal! +} + +type PoolSnapshot @entity { + "Unique identifier for the PoolSnapshot" + id: ID! + "The Pool this snapshot is for" + pool: Pool! + "Timestamp when this snapshot was taken" + timestamp: Int! + "Total shares of the Pool at the time of the snapshot" + totalShares: BigDecimal! + "Number of swaps performed in the Pool at the time of the snapshot" + swapsCount: BigInt! + "Number of unique holders of the Pool's tokens at the time of the snapshot" + holdersCount: BigInt! + "Balances of each token in the Pool at the time of the snapshot" + balances: [BigDecimal!]! + "Total swap fees collected for each token at the time of the snapshot" + totalSwapFees: [BigDecimal!]! + "Total swap volumes for each token at the time of the snapshot" + totalSwapVolumes: [BigDecimal!]! + "Total protocol swap fees collected for each token at the time of the snapshot" + totalProtocolSwapFees: [BigDecimal!]! + "Total protocol yield fees collected for each token at the time of the snapshot" + totalProtocolYieldFees: [BigDecimal!]! +} + +type User @entity { + "Unique identifier for the User (typically their address)" + id: Bytes! + "Swaps performed by this user" + swaps: [Swap!] @derivedFrom(field: "user") + "Pool shares owned by this user" + shares: [PoolShare!] @derivedFrom(field: "user") + "Add/Remove liquidity events performed by this user" + addRemoves: [AddRemove!] @derivedFrom(field: "user") +} diff --git a/subgraphs/vault/src/helpers/constants.ts b/subgraphs/vault/src/helpers/constants.ts new file mode 100644 index 0000000..849c9cb --- /dev/null +++ b/subgraphs/vault/src/helpers/constants.ts @@ -0,0 +1,9 @@ +import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; + +export const ZERO_BI = BigInt.fromString("0"); +export const ZERO_BD = BigDecimal.fromString("0"); +export const ONE_BD = BigDecimal.fromString("1"); + +export const ZERO_ADDRESS = Address.fromString( + "0x0000000000000000000000000000000000000000" +); diff --git a/subgraphs/vault/src/helpers/entities.ts b/subgraphs/vault/src/helpers/entities.ts new file mode 100644 index 0000000..47f970b --- /dev/null +++ b/subgraphs/vault/src/helpers/entities.ts @@ -0,0 +1,248 @@ +import { Address, BigDecimal, BigInt, Bytes } from "@graphprotocol/graph-ts"; +import { + Buffer, + Pool, + PoolSnapshot, + PoolToken, + RateProvider, + Token, + User, + Vault, +} from "../types/schema"; +import { PoolShare } from "../types/schema"; +import { ONE_BD, ZERO_ADDRESS, ZERO_BD } from "./constants"; +import { PoolRegisteredTokenConfigStruct } from "../types/Vault/Vault"; +import { ERC20 } from "../types/Vault/ERC20"; +import { VaultExtension } from "../types/Vault/VaultExtension"; +import { ProtocolFeeController } from "../types/Vault/ProtocolFeeController"; +import { scaleDown } from "./misc"; + +const DAY = 24 * 60 * 60; + +export function getVault(vaultAddress: Bytes): Vault { + let vault: Vault | null = Vault.load(vaultAddress); + if (vault != null) return vault; + + let vaultContract = VaultExtension.bind(changetype
(vaultAddress)); + let protocolFeeControllerCall = vaultContract.try_getProtocolFeeController(); + + vault = new Vault(vaultAddress); + vault.isPaused = false; + vault.authorizer = ZERO_ADDRESS; + vault.protocolSwapFee = ZERO_BD; + vault.protocolYieldFee = ZERO_BD; + vault.protocolFeeController = protocolFeeControllerCall.reverted + ? ZERO_ADDRESS + : protocolFeeControllerCall.value; + vault.save(); + + return vault; +} + +export function getPoolShareId( + poolAddress: Address, + userAddress: Address +): string { + return poolAddress.toHex().concat("-").concat(userAddress.toHex()); +} + +export function getPoolShare( + poolAddress: Address, + userAddress: Address +): PoolShare { + let poolShareId = getPoolShareId(poolAddress, userAddress); + let poolShare = PoolShare.load(poolShareId); + + if (!poolShare) { + poolShare = createPoolShare(poolAddress, userAddress); + } + + return poolShare; +} + +export function createPoolSnapshot(pool: Pool, timestamp: i32): void { + let poolAddress = pool.id; + let dayTimestamp = timestamp - (timestamp % DAY); + + let snapshotId = poolAddress.toHex() + "-" + dayTimestamp.toString(); + let snapshot = PoolSnapshot.load(snapshotId); + + if (!snapshot) { + snapshot = new PoolSnapshot(snapshotId); + } + + let poolTokens = pool.tokens.load(); + let balances = new Array(poolTokens.length); + let totalSwapFees = new Array(poolTokens.length); + let totalSwapVolumes = new Array(poolTokens.length); + let totalProtocolSwapFees = new Array(poolTokens.length); + let totalProtocolYieldFees = new Array(poolTokens.length); + for (let i = 0; i < poolTokens.length; i++) { + totalSwapVolumes[i] = poolTokens[i].volume; + balances[i] = poolTokens[i].balance; + totalSwapFees[i] = poolTokens[i].totalProtocolSwapFee; + totalProtocolSwapFees[i] = poolTokens[i].totalProtocolSwapFee; + totalProtocolYieldFees[i] = poolTokens[i].totalProtocolYieldFee; + } + + snapshot.pool = poolAddress; + snapshot.balances = balances; + snapshot.timestamp = dayTimestamp; + snapshot.swapsCount = pool.swapsCount; + snapshot.totalShares = pool.totalShares; + snapshot.holdersCount = pool.holdersCount; + snapshot.totalSwapFees = totalSwapFees; + snapshot.totalSwapVolumes = totalSwapVolumes; + snapshot.totalProtocolSwapFees = totalProtocolSwapFees; + snapshot.totalProtocolYieldFees = totalProtocolYieldFees; + snapshot.save(); +} + +export function createPoolToken( + poolAddress: Address, + tokenConfig: PoolRegisteredTokenConfigStruct, + index: i32 +): void { + let poolTokenId = poolAddress.concat(tokenConfig.token); + let poolToken = PoolToken.load(poolTokenId); + + if (!poolToken) { + poolToken = new PoolToken(poolTokenId); + } + + let nestedPool = Pool.load(tokenConfig.token); + + let token = getToken(tokenConfig.token); + + poolToken.name = token.name; + poolToken.symbol = token.symbol; + poolToken.decimals = token.decimals; + + let buffer = Buffer.load(tokenConfig.token); + + poolToken.pool = poolAddress; + poolToken.address = tokenConfig.token; + poolToken.index = index; + poolToken.priceRate = ONE_BD; + poolToken.balance = ZERO_BD; + poolToken.volume = ZERO_BD; + poolToken.totalProtocolSwapFee = ZERO_BD; + poolToken.totalProtocolYieldFee = ZERO_BD; + poolToken.buffer = buffer ? buffer.id : null; + poolToken.nestedPool = nestedPool ? nestedPool.id : null; + poolToken.paysYieldFees = tokenConfig.paysYieldFees; + poolToken.save(); +} + +export function createRateProvider( + poolAddress: Address, + tokenConfig: PoolRegisteredTokenConfigStruct +): void { + let rateProviderId = poolAddress + .concat(tokenConfig.token) + .concat(tokenConfig.rateProvider); + let rateProvider = RateProvider.load(rateProviderId); + + if (!rateProvider) { + rateProvider = new RateProvider(rateProviderId); + } + + rateProvider.pool = poolAddress; + rateProvider.address = tokenConfig.rateProvider; + rateProvider.token = poolAddress.concat(tokenConfig.token); + rateProvider.save(); +} + +export function loadPoolToken( + poolAddress: Address, + tokenAddress: Address +): PoolToken { + let poolTokenId = poolAddress.concat(tokenAddress); + let poolToken = PoolToken.load(poolTokenId) as PoolToken; + + return poolToken; +} + +export function createUser(userAddress: Address): void { + let user = User.load(userAddress); + + if (!user) { + user = new User(userAddress); + user.save(); + } +} + +export function createToken(tokenAddress: Address): void { + let tokenContract = ERC20.bind(tokenAddress); + + let nameCall = tokenContract.try_name(); + let symbolCall = tokenContract.try_symbol(); + let decimalsCall = tokenContract.try_decimals(); + + let token = new Token(tokenAddress); + token.name = nameCall.reverted ? "" : nameCall.value; + token.symbol = symbolCall.reverted ? "" : symbolCall.value; + token.decimals = decimalsCall.reverted ? 0 : decimalsCall.value; + token.address = tokenAddress; + token.save(); +} + +export function getToken(tokenAddress: Address): Token { + let token = Token.load(tokenAddress); + + if (!token) { + createToken(tokenAddress); + token = Token.load(tokenAddress); + } + + return token as Token; +} + +export function createPoolShare( + poolAddress: Address, + userAddress: Address +): PoolShare { + createUser(userAddress); + + let poolShareId = getPoolShareId(poolAddress, userAddress); + let poolShare = new PoolShare(poolShareId); + poolShare.user = userAddress; + poolShare.pool = poolAddress; + poolShare.balance = ZERO_BD; + poolShare.save(); + + return poolShare; +} + +export function updateProtocolFeeAmounts(pool: Pool): void { + let poolAddress = changetype
(pool.address); + let vaultAddress = changetype
(pool.vault); + let vault = VaultExtension.bind(vaultAddress); + + let poolTokens = pool.tokens.load(); + for (let i = 0; i < poolTokens.length; i++) { + let poolToken = poolTokens[i]; + let poolTokenAddress = changetype
(poolToken.address); + + let swapFeeAmount = vault.try_getAggregateSwapFeeAmount( + poolAddress, + poolTokenAddress + ); + let yieldFeeAmount = vault.try_getAggregateYieldFeeAmount( + poolAddress, + poolTokenAddress + ); + + if (!swapFeeAmount.reverted) { + poolToken.totalProtocolSwapFee = poolToken.totalProtocolSwapFee.plus( + scaleDown(swapFeeAmount.value, poolToken.decimals) + ); + } + + if (!yieldFeeAmount.reverted) { + poolToken.totalProtocolYieldFee = poolToken.totalProtocolYieldFee.plus( + scaleDown(yieldFeeAmount.value, poolToken.decimals) + ); + } + } +} diff --git a/src/helpers/misc.ts b/subgraphs/vault/src/helpers/misc.ts similarity index 79% rename from src/helpers/misc.ts rename to subgraphs/vault/src/helpers/misc.ts index dd3903d..fd06a71 100644 --- a/src/helpers/misc.ts +++ b/subgraphs/vault/src/helpers/misc.ts @@ -1,10 +1,10 @@ import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; export function tokenToDecimal(amount: BigInt, decimals: i32): BigDecimal { - let scale = BigInt.fromI32(10) - .pow(decimals as u8) - .toBigDecimal(); - return amount.toBigDecimal().div(scale); + let scale = BigInt.fromI32(10) + .pow(decimals as u8) + .toBigDecimal(); + return amount.toBigDecimal().div(scale); } export function scaleDown(num: BigInt, decimals: i32): BigDecimal { @@ -18,4 +18,4 @@ export function scaleUp(num: BigDecimal, decimals: i32): BigInt { .times(BigInt.fromI32(10).pow(u8(decimals)).toBigDecimal()) .toString() ); -} \ No newline at end of file +} diff --git a/subgraphs/vault/src/mappings/bpt.ts b/subgraphs/vault/src/mappings/bpt.ts new file mode 100644 index 0000000..9c85d7d --- /dev/null +++ b/subgraphs/vault/src/mappings/bpt.ts @@ -0,0 +1,74 @@ +import { BigInt } from "@graphprotocol/graph-ts"; +import { ZERO_ADDRESS, ZERO_BD, ZERO_BI } from "../helpers/constants"; +import { getPoolShare } from "../helpers/entities"; +import { tokenToDecimal } from "../helpers/misc"; +import { Transfer as TransferEvent } from "../types/templates/BPT/BPT"; +import { Pool } from "../types/schema"; + +/************************************ + ********** BPTS TRANSFERS ********** + ************************************/ + +export function handleTransfer(event: TransferEvent): void { + let isMint = event.params.from == ZERO_ADDRESS; + let isBurn = event.params.to == ZERO_ADDRESS; + + const poolAddress = event.address; + + let poolShareFrom = getPoolShare(poolAddress, event.params.from); + let poolShareFromBalance = + poolShareFrom == null ? ZERO_BD : poolShareFrom.balance; + + let poolShareTo = getPoolShare(poolAddress, event.params.to); + let poolShareToBalance = poolShareTo == null ? ZERO_BD : poolShareTo.balance; + + let pool = Pool.load(event.address) as Pool; + + let BPT_DECIMALS = 18; + + if (isMint) { + poolShareTo.balance = poolShareTo.balance.plus( + tokenToDecimal(event.params.value, BPT_DECIMALS) + ); + poolShareTo.save(); + pool.totalShares = pool.totalShares.plus( + tokenToDecimal(event.params.value, BPT_DECIMALS) + ); + } else if (isBurn) { + poolShareFrom.balance = poolShareFrom.balance.minus( + tokenToDecimal(event.params.value, BPT_DECIMALS) + ); + poolShareFrom.save(); + pool.totalShares = pool.totalShares.minus( + tokenToDecimal(event.params.value, BPT_DECIMALS) + ); + } else { + poolShareTo.balance = poolShareTo.balance.plus( + tokenToDecimal(event.params.value, BPT_DECIMALS) + ); + poolShareTo.save(); + + poolShareFrom.balance = poolShareFrom.balance.minus( + tokenToDecimal(event.params.value, BPT_DECIMALS) + ); + poolShareFrom.save(); + } + + if ( + poolShareTo !== null && + poolShareTo.balance.notEqual(ZERO_BD) && + poolShareToBalance.equals(ZERO_BD) + ) { + pool.holdersCount = pool.holdersCount.plus(BigInt.fromI32(1)); + } + + if ( + poolShareFrom !== null && + poolShareFrom.balance.equals(ZERO_BD) && + poolShareFromBalance.notEqual(ZERO_BD) + ) { + pool.holdersCount = pool.holdersCount.minus(BigInt.fromI32(1)); + } + + pool.save(); +} diff --git a/subgraphs/vault/src/mappings/vault.ts b/subgraphs/vault/src/mappings/vault.ts new file mode 100644 index 0000000..223f373 --- /dev/null +++ b/subgraphs/vault/src/mappings/vault.ts @@ -0,0 +1,432 @@ +import { BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; +import { + LiquidityAddedToBuffer, + LiquidityRemovedFromBuffer, + PoolBalanceChanged, + PoolRegistered, + Swap as SwapEvent, +} from "../types/Vault/Vault"; +import { + Buffer, + BufferShare, + Pool, + Swap, + AddRemove, + Hook, + HookConfig, + LiquidityManagement, +} from "../types/schema"; +import { + createPoolSnapshot, + createPoolToken, + createRateProvider, + createUser, + getToken, + getVault, + loadPoolToken, + updateProtocolFeeAmounts, +} from "../helpers/entities"; +import { ZERO_BD, ZERO_BI } from "../helpers/constants"; +import { scaleDown } from "../helpers/misc"; +import { BPT } from "../types/templates"; +import { ERC20 } from "../types/Vault/ERC20"; +import { VaultExtension } from "../types/Vault/VaultExtension"; +import { ERC4626 } from "../types/Vault/ERC4626"; + +/************************************ + ******* POOLS REGISTRATIONS ******** + ************************************/ + +export function handlePoolRegistered(event: PoolRegistered): void { + let vault = getVault(event.address); + let poolAddress = event.params.pool; + + let pool = new Pool(poolAddress); + pool.vault = vault.id; + pool.address = poolAddress; + pool.factory = event.params.factory; + pool.pauseWindowEndTime = event.params.pauseWindowEndTime; + pool.pauseManager = event.params.roleAccounts.pauseManager; + pool.totalShares = ZERO_BD; + pool.isInitialized = false; + pool.swapsCount = ZERO_BI; + pool.holdersCount = ZERO_BI; + + let poolContract = ERC20.bind(poolAddress); + let symbolCall = poolContract.try_symbol(); + let nameCall = poolContract.try_name(); + + pool.name = nameCall.reverted ? "" : nameCall.value; + pool.symbol = symbolCall.reverted ? "" : symbolCall.value; + + let vaultContract = VaultExtension.bind(event.address); + let swapFeeCall = vaultContract.try_getStaticSwapFeePercentage(poolAddress); + + pool.swapFee = swapFeeCall.reverted + ? ZERO_BD + : scaleDown(swapFeeCall.value, 18); + + pool.blockNumber = event.block.number; + pool.blockTimestamp = event.block.timestamp; + pool.transactionHash = event.transaction.hash; + + for (let i: i32 = 0; i < event.params.tokenConfig.length; i++) { + let tokenConfig = event.params.tokenConfig[i]; + createPoolToken(poolAddress, tokenConfig, i); + createRateProvider(poolAddress, tokenConfig); + } + + let hookAddress = event.params.hooksConfig.hooksContract; + let hook = Hook.load(hookAddress); + if (!hook) { + hook = new Hook(hookAddress); + hook.address = hookAddress; + hook.save(); + } + + let hookConfig = new HookConfig(hookAddress.concat(poolAddress)); + hookConfig.pool = poolAddress; + hookConfig.hook = hookAddress; + hookConfig.enableHookAdjustedAmounts = + event.params.hooksConfig.enableHookAdjustedAmounts; + hookConfig.shouldCallBeforeInitialize = + event.params.hooksConfig.shouldCallBeforeInitialize; + hookConfig.shouldCallAfterInitialize = + event.params.hooksConfig.shouldCallAfterInitialize; + hookConfig.shouldCallComputeDynamicSwapFee = + event.params.hooksConfig.shouldCallComputeDynamicSwapFee; + hookConfig.shouldCallBeforeSwap = + event.params.hooksConfig.shouldCallBeforeSwap; + hookConfig.shouldCallAfterSwap = event.params.hooksConfig.shouldCallAfterSwap; + hookConfig.shouldCallBeforeAddLiquidity = + event.params.hooksConfig.shouldCallBeforeAddLiquidity; + hookConfig.shouldCallAfterAddLiquidity = + event.params.hooksConfig.shouldCallAfterAddLiquidity; + hookConfig.shouldCallBeforeRemoveLiquidity = + event.params.hooksConfig.shouldCallBeforeRemoveLiquidity; + hookConfig.shouldCallAfterRemoveLiquidity = + event.params.hooksConfig.shouldCallAfterRemoveLiquidity; + hookConfig.save(); + + let liquidityManagement = new LiquidityManagement(poolAddress); + liquidityManagement.pool = poolAddress; + liquidityManagement.enableRemoveLiquidityCustom = + event.params.liquidityManagement.enableRemoveLiquidityCustom; + liquidityManagement.disableUnbalancedLiquidity = + event.params.liquidityManagement.disableUnbalancedLiquidity; + liquidityManagement.enableAddLiquidityCustom = + event.params.liquidityManagement.enableAddLiquidityCustom; + liquidityManagement.enableDonation = + event.params.liquidityManagement.enableDonation; + liquidityManagement.save(); + + pool.liquidityManagement = liquidityManagement.id; + pool.hookConfig = hookConfig.id; + pool.hook = hook.id; + pool.save(); + + createPoolSnapshot(pool, event.block.timestamp.toI32()); + + BPT.create(poolAddress); +} + +/************************************ + ****** DEPOSITS & WITHDRAWALS ****** + ************************************/ + +export function handlePoolBalanceChanged(event: PoolBalanceChanged): void { + let amounts: BigInt[] = event.params.deltas; + + if (amounts.length === 0) { + return; + } + + createUser(event.params.liquidityProvider); + + let total: BigInt = amounts.reduce( + (sum, amount) => sum.plus(amount), + new BigInt(0) + ); + if (total.gt(ZERO_BI)) { + handlePoolJoined(event); + } else { + handlePoolExited(event); + } +} + +function handlePoolJoined(event: PoolBalanceChanged): void { + let poolAddress = event.params.pool; + let amounts: BigInt[] = event.params.deltas; + + let transactionHash = event.transaction.hash; + let logIndex = event.logIndex; + + let pool = Pool.load(poolAddress); + if (pool == null) { + log.warning("Pool not found in handlePoolJoined: {} {}", [ + poolAddress.toHex(), + transactionHash.toHex(), + ]); + return; + } + + pool.isInitialized = true; + pool.save(); + + let joinId = transactionHash.concatI32(logIndex.toI32()); + let join = new AddRemove(joinId); + + let poolTokens = pool.tokens.load(); + let joinAmounts = new Array(amounts.length); + + for (let i: i32 = 0; i < poolTokens.length; i++) { + let poolToken = poolTokens[i]; + let joinAmount = scaleDown(event.params.deltas[i], poolToken.decimals); + joinAmounts[i] = joinAmount; + poolToken.balance = poolToken.balance.plus(joinAmount); + poolToken.save(); + } + + join.type = "Add"; + join.sender = event.params.liquidityProvider; + join.amounts = joinAmounts; + join.pool = poolAddress; + join.user = event.params.liquidityProvider; + join.logIndex = logIndex; + join.blockNumber = event.block.number; + join.blockTimestamp = event.block.timestamp; + join.transactionHash = transactionHash; + join.save(); + + createPoolSnapshot(pool, event.block.timestamp.toI32()); +} + +function handlePoolExited(event: PoolBalanceChanged): void { + let poolAddress = event.params.pool; + let amounts: BigInt[] = event.params.deltas; + + let transactionHash = event.transaction.hash; + let logIndex = event.logIndex; + + let pool = Pool.load(poolAddress); + if (pool == null) { + log.warning("Pool not found in handlePoolJoined: {} {}", [ + poolAddress.toHex(), + transactionHash.toHex(), + ]); + return; + } + + let exitId = transactionHash.concatI32(logIndex.toI32()); + let exit = new AddRemove(exitId); + + let poolTokens = pool.tokens.load(); + let exitAmounts = new Array(amounts.length); + + for (let i: i32 = 0; i < poolTokens.length; i++) { + let poolToken = poolTokens[i]; + let exitAmount = scaleDown( + event.params.deltas[i].neg(), + poolToken.decimals + ); + exitAmounts[i] = exitAmount; + poolToken.balance = poolToken.balance.minus(exitAmount); + poolToken.save(); + } + + exit.type = "Remove"; + exit.sender = event.params.liquidityProvider; + exit.amounts = exitAmounts; + exit.pool = poolAddress; + exit.user = event.params.liquidityProvider; + exit.logIndex = logIndex; + exit.blockNumber = event.block.number; + exit.blockTimestamp = event.block.timestamp; + exit.transactionHash = transactionHash; + exit.save(); + + createPoolSnapshot(pool, event.block.timestamp.toI32()); +} + +/************************************ + ************** SWAPS *************** + ************************************/ + +export function handleSwap(event: SwapEvent): void { + createUser(event.transaction.from); + + let swap = new Swap(event.transaction.hash.concatI32(event.logIndex.toI32())); + + let tokenIn = getToken(event.params.tokenIn); + let tokenOut = getToken(event.params.tokenOut); + let swapFeeToken = getToken(event.params.swapFeeToken); + + let tokenAmountIn = scaleDown(event.params.amountIn, tokenIn.decimals); + let tokenAmountOut = scaleDown(event.params.amountOut, tokenOut.decimals); + let swapFeeAmount = scaleDown( + event.params.swapFeeAmount, + swapFeeToken.decimals + ); + + swap.pool = event.params.pool; + swap.tokenIn = event.params.tokenIn; + swap.tokenInSymbol = tokenIn.symbol; + swap.tokenAmountIn = tokenAmountIn; + swap.tokenOut = event.params.tokenOut; + swap.tokenOutSymbol = tokenOut.symbol; + swap.tokenAmountOut = tokenAmountOut; + swap.swapFeeToken = event.params.swapFeeToken; + swap.swapFeeAmount = swapFeeAmount; + swap.user = event.transaction.from; + + swap.logIndex = event.logIndex; + swap.blockNumber = event.block.number; + swap.blockTimestamp = event.block.timestamp; + swap.transactionHash = event.transaction.hash; + + swap.save(); + + let poolAddress = event.params.pool; + + let pool = Pool.load(poolAddress); + if (pool == null) { + log.warning("Pool not found in handleSwap: {} {}", [ + poolAddress.toHex(), + event.transaction.hash.toHex(), + ]); + return; + } + + pool.swapsCount = pool.swapsCount.plus(BigInt.fromI32(1)); + pool.save(); + + let tokenInAddress = event.params.tokenIn; + let tokenOutAddress = event.params.tokenOut; + + let poolTokenIn = loadPoolToken(poolAddress, tokenInAddress); + let poolTokenOut = loadPoolToken(poolAddress, tokenOutAddress); + if (poolTokenIn == null || poolTokenOut == null) { + log.warning( + "PoolToken not found in handleSwap: (tokenIn: {}), (tokenOut: {})", + [tokenInAddress.toHexString(), tokenOutAddress.toHexString()] + ); + return; + } + + let newInAmount = poolTokenIn.balance.plus(tokenAmountIn); + poolTokenIn.balance = newInAmount; + poolTokenIn.volume = poolTokenIn.volume.plus(tokenAmountIn); + poolTokenIn.save(); + + let newOutAmount = poolTokenOut.balance.minus(tokenAmountOut); + poolTokenOut.balance = newOutAmount; + poolTokenOut.volume = poolTokenOut.volume.plus(tokenAmountOut); + poolTokenOut.save(); + + updateProtocolFeeAmounts(pool); + createPoolSnapshot(pool, event.block.timestamp.toI32()); +} + +/************************************ + ************* BUFFERS ************** + ************************************/ + +export function handleLiquidityAddedToBuffer( + event: LiquidityAddedToBuffer +): void { + let erc4626 = ERC4626.bind(event.params.wrappedToken); + let asset = erc4626.try_asset(); + if (asset.reverted) return; + + let wrappedToken = getToken(event.params.wrappedToken); + let underlyingToken = getToken(asset.value); + + let buffer = Buffer.load(wrappedToken.address); + + if (!buffer) { + buffer = new Buffer(wrappedToken.address); + buffer.wrappedToken = wrappedToken.id; + buffer.underlyingToken = underlyingToken.id; + buffer.wrappedBalance = ZERO_BD; + buffer.underlyingBalance = ZERO_BD; + buffer.totalShares = ZERO_BD; + } + + let issuedShares = scaleDown(event.params.issuedShares, 18); + let amountWrapped = scaleDown( + event.params.amountWrapped, + wrappedToken.decimals + ); + let amountUnderlying = scaleDown( + event.params.amountUnderlying, + wrappedToken.decimals + ); + + buffer.totalShares = buffer.totalShares.plus(issuedShares); + buffer.wrappedBalance = buffer.wrappedBalance.plus(amountWrapped); + buffer.underlyingBalance = buffer.underlyingBalance.plus(amountUnderlying); + + buffer.save(); + + createUser(event.params.sharesOwner); + + let bufferShareId = wrappedToken.address.concat(event.params.sharesOwner); + let bufferShare = BufferShare.load(bufferShareId); + + if (!bufferShare) { + bufferShare = new BufferShare(bufferShareId); + bufferShare.user = event.params.sharesOwner; + bufferShare.buffer = buffer.id; + bufferShare.balance = ZERO_BD; + } + + bufferShare.balance = bufferShare.balance.plus(issuedShares); + bufferShare.save(); +} + +export function handleLiquidityRemovedFromBuffer( + event: LiquidityRemovedFromBuffer +): void { + let wrappedToken = getToken(event.params.wrappedToken); + + let buffer = Buffer.load(wrappedToken.address); + + if (!buffer) { + buffer = new Buffer(wrappedToken.address); + buffer.wrappedToken = wrappedToken.id; + buffer.wrappedBalance = ZERO_BD; + buffer.underlyingBalance = ZERO_BD; + buffer.totalShares = ZERO_BD; + } + + let removedShares = scaleDown(event.params.removedShares, 18); + let amountWrapped = scaleDown( + event.params.amountWrapped, + wrappedToken.decimals + ); + let amountUnderlying = scaleDown( + event.params.amountUnderlying, + wrappedToken.decimals + ); + + buffer.totalShares = buffer.totalShares.minus(removedShares); + buffer.wrappedBalance = buffer.wrappedBalance.minus(amountWrapped); + buffer.underlyingBalance = buffer.underlyingBalance.minus(amountUnderlying); + + buffer.save(); + + createUser(event.params.sharesOwner); + + let bufferShareId = wrappedToken.address.concat(event.params.sharesOwner); + let bufferShare = BufferShare.load(bufferShareId); + + if (!bufferShare) { + bufferShare = new BufferShare(bufferShareId); + bufferShare.user = event.params.sharesOwner; + bufferShare.buffer = buffer.id; + bufferShare.balance = ZERO_BD; + } + + bufferShare.balance = bufferShare.balance.minus(removedShares); + bufferShare.save(); +} diff --git a/subgraph.yaml b/subgraphs/vault/template.yaml similarity index 55% rename from subgraph.yaml rename to subgraphs/vault/template.yaml index d6d756f..470cd4c 100644 --- a/subgraph.yaml +++ b/subgraphs/vault/template.yaml @@ -1,16 +1,14 @@ specVersion: 1.0.0 -indexerHints: - prune: auto schema: file: ./schema.graphql dataSources: - kind: ethereum name: Vault - network: sepolia + network: { { network } } source: abi: Vault - address: "0xDaa273AeEc06e9CCb7428a77E2abb1E4659B16D2" - startBlock: 5274748 + address: "{{ Vault.address }}" + startBlock: { { Vault.startBlock } } mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -19,28 +17,32 @@ dataSources: - Vault - Pool abis: + - name: ERC20 + file: ./abis/ERC20.json + - name: ERC4626 + file: ./abis/ERC4626.json - name: Vault file: ./abis/Vault.json + - name: VaultExtension + file: ./abis/VaultExtension.json + - name: ProtocolFeeController + file: ./abis/ProtocolFeeController.json eventHandlers: - - event: PoolRegistered(indexed address,indexed address,(address,uint8,address,bool)[],uint256,address,(bool,bool,bool,bool,bool,bool,bool,bool),(bool,bool)) + - event: PoolRegistered(indexed address,indexed address,(address,uint8,address,bool)[],uint256,uint32,(address,address,address),(bool,bool,bool,bool,bool,bool,bool,bool,bool,bool,address),(bool,bool,bool,bool)) handler: handlePoolRegistered - - event: PoolBalanceChanged(indexed address,indexed address,address[],int256[]) + - event: PoolBalanceChanged(indexed address,indexed address,int256[]) handler: handlePoolBalanceChanged - - event: Swap(indexed address,indexed address,indexed address,uint256,uint256,uint256) + - event: Swap(indexed address,indexed address,indexed address,uint256,uint256,uint256,uint256,address) handler: handleSwap - - event: ProtocolSwapFeePercentageChanged(indexed uint256) - handler: handleProtocolSwapFeePercentageChanged - - event: ProtocolYieldFeePercentageChanged(indexed uint256) - handler: handleProtocolYieldFeePercentageChanged - - event: ProtocolSwapFeeCharged(indexed address,indexed address,uint256) - handler: handleProtocolSwapFeeCharged - - event: ProtocolYieldFeeCharged(indexed address,indexed address,uint256) - handler: handleProtocolYieldFeeCharged + - event: LiquidityAddedToBuffer(indexed address,indexed address,uint256,uint256,uint256) + handler: handleLiquidityAddedToBuffer + - event: LiquidityRemovedFromBuffer(indexed address,indexed address,uint256,uint256,uint256) + handler: handleLiquidityRemovedFromBuffer file: ./src/mappings/vault.ts templates: - kind: ethereum/contract name: BPT - network: sepolia + network: { { network } } source: abi: BPT mapping: diff --git a/subgraphs/vault/tsconfig.json b/subgraphs/vault/tsconfig.json new file mode 100644 index 0000000..4e86672 --- /dev/null +++ b/subgraphs/vault/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", + "include": ["src", "tests"] +}