-
Notifications
You must be signed in to change notification settings - Fork 6
Sub vaults #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Sub vaults #339
Changes from all commits
5a384b5
bd89745
d293448
dff7431
f5adb5a
7a0692b
3c09390
2e92cdd
661401a
39241b9
78a39c1
94d3b4b
047ee99
4abc61d
5b52db2
bceb1cd
e904379
e4b1cf8
42a9bd7
b873d54
e3c6dc2
01b26e7
d9a66b5
2032bee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,3 +17,5 @@ schema.graphql | |
| src/types/graphql | ||
| src/contracts/types | ||
| src/contracts/vault/types | ||
|
|
||
| CLAUDE.md | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| sh ./scripts/pre-push.sh | ||
|
|
||
| npm run lint | ||
| pnpm run check:docLinks | ||
| pnpm run lint | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ## Added methods | ||
|
|
||
| - [sdk.vault.getSubVaults](https://docs.stakewise.io/sdk/api/vault/requests/getsubvaults) | ||
| - [sdk.vault.addSubVault](https://docs.stakewise.io/sdk/api/vault/transactions/addsubvault) | ||
| - [sdk.vault.rejectSubVault](https://docs.stakewise.io/sdk/api/vault/transactions/rejectsubvault) | ||
| - [sdk.vault.ejectSubVault](https://docs.stakewise.io/sdk/api/vault/transactions/ejectsubvault) | ||
| - [sdk.vault.updateState](https://docs.stakewise.io/sdk/api/vault/transactions/updatestate) | ||
|
|
||
| ## Modified methods | ||
|
|
||
| ### 1. [sdk.vault.getVault](https://docs.stakewise.io/sdk/api/vault/requests/getvault) | ||
|
|
||
| #### Add output field: | ||
| ```ts | ||
| type Output = { | ||
| canHarvest: boolean | ||
| exitingAssets: string | ||
| exitingTickets: string | ||
| ejectingSubVault: string | ||
| subVaultsRegistry: string | ||
| pendingMetaSubVault: string | ||
| } | ||
| ``` |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,8 @@ import type { CodegenConfig } from '@graphql-codegen/cli' | |||||||||||||||
| import { Network } from './src/helpers/enums' | ||||||||||||||||
| import configs from './src/helpers/configs' | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| let network: Network = Network.Mainnet | ||||||||||||||||
| // TODO change | ||||||||||||||||
| let network: Network = Network.Hoodi | ||||||||||||||||
|
Comment on lines
+5
to
+6
|
||||||||||||||||
| // TODO change | |
| let network: Network = Network.Hoodi | |
| let network: Network = Network.Mainnet |
Copilot
AI
Apr 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the default codegen network from Mainnet to Hoodi (and leaving a TODO) can silently generate the wrong GraphQL types/operations when NETWORK is not set (e.g., local dev, CI scripts). Consider restoring Mainnet as the default and making Hoodi opt-in via env/config, or fail fast when NETWORK is missing to avoid accidental wrong builds.
| // TODO change | |
| let network: Network = Network.Hoodi | |
| let network: Network = Network.Mainnet | |
| if (process.env.NETWORK === 'hoodi') { | |
| network = Network.Hoodi | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "$schema": "https://context7.com/schema/context7.json", | ||
| "projectTitle": "StakeWise V3 SDK", | ||
| "description": "Official TypeScript SDK for StakeWise V3 liquid staking on Ethereum and Gnosis. Typed access to vaults, osToken (osETH/osGNO), boost leverage, rewards via subgraph and on-chain calls.", | ||
| "url": "https://context7.com/stakewise/v3-sdk", | ||
| "public_key": "pk_wpaUy9UwJWjviJip1LFYx", | ||
| "branch": "sub-vaults", | ||
| "folders": ["documentation", "src/services"], | ||
| "excludeFolders": [ | ||
| "scripts", | ||
| "dist", | ||
| "node_modules", | ||
| "changelog", | ||
| "documentation/_drafts" | ||
| ], | ||
| "excludeFiles": [ | ||
| "_category_.json", | ||
| "README.md", | ||
| "package.json", | ||
| "tsconfig.json", | ||
| "pnpm-lock.yaml", | ||
| "rollup.config.js", | ||
| "jest.config.ts", | ||
| "codegen.ts", | ||
| "hardhat.config.js", | ||
| "eslint.config.mjs", | ||
| "LICENSE", | ||
| "CHANGELOG.md" | ||
| ], | ||
| "rules": [ | ||
| "Init: `new StakeWiseSDK({ network, provider })` for read+write, or `{ network, endpoints: { web3: rpcUrl } }` for read-only.", | ||
| "After every write, `await sdk.utils.waitForSubgraph({ hash })` before refetching reads. Subgraph indexing lags transaction confirmation.", | ||
| "Writes have 3 forms: default sends a tx, `.encode(args)` returns `{data,to,value}` for multisig, `.estimateGas(args)` returns bigint. `sdk.vault.multicall<T>` lacks `.encode`/`.estimateGas`.", | ||
| "`Network.Mainnet=1` (osETH), `Network.Gnosis=100` (osGNO), `Network.Hoodi=560048`. SDK instances are immutable per network; recreate to switch.", | ||
| "V3 uses `osToken` (osETH/osGNO). `sETH2`/`rETH2` are V2, never reference in V3 code.", | ||
| "Reads return `AbortPromise<T>`; call `.abort()` to cancel. `.then`/`.catch` are silently suppressed after abort.", | ||
| "Contracts outside `sdk.contracts`: import top-level `createContract<T>(address, abi, sdk.provider)` from `@stakewise/v3-sdk`.", | ||
| "Batch independent reads with `Promise.all` / `AbortPromise.all`. Never parallelise writes; wallets serialise signing." | ||
| ], | ||
| "previousVersions": [] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| --- | ||
| id: endpoints | ||
| title: Available Endpoints | ||
| sidebar_position: 4 | ||
| description: RPC, API and Subgraph endpoints for Mainnet, Gnosis and Hoodi networks. | ||
| --- | ||
|
|
||
| # Available Endpoints | ||
|
|
||
| --- | ||
|
|
||
| ## How to retrieve the subgraph endpoint URL | ||
|
|
||
| The StakeWise V3 subgraph URL depends on the network the SDK is bound to. For SDK-driven workflows the subgraph URL is configured at construction time and the SDK queries it transparently - you do not need to read the URL yourself for typical reads. For direct GraphQL calls (custom queries, dashboards, monitoring), use the production URLs listed below under [Subgraph Endpoint](#subgraph-endpoint). | ||
|
|
||
| ```typescript | ||
| import { StakeWiseSDK, Network } from '@stakewise/v3-sdk' | ||
|
|
||
| const sdk = new StakeWiseSDK({ | ||
| network: Network.Mainnet, | ||
| endpoints: { web3: 'https://main-rpc.io' }, | ||
| }) | ||
|
|
||
| const stats = await sdk.utils.getStakewiseStats() | ||
| ``` | ||
|
|
||
| The SDK ships with the StakeWise V3 subgraph URL baked in for each `Network` (Mainnet, Hoodi, Gnosis), so all read methods (`getVault`, `getStakeBalance`, `getStakewiseStats`, etc.) hit the right subgraph automatically. | ||
|
|
||
| --- | ||
|
|
||
| ## RPC Endpoint | ||
|
|
||
| The RPC endpoint is the JSON-RPC URL of an Ethereum node for the selected network. You can use any public RPC provider - a curated list with public nodes for each chain is available at: | ||
|
|
||
| 🔗 **[chainlist.org](https://chainlist.org/)** | ||
|
|
||
| ✅ **Tip:** For production, prefer a dedicated provider (Infura, Alchemy, QuickNode, etc.) over a free public RPC - public RPCs are rate-limited and may go down. | ||
|
|
||
| --- | ||
|
|
||
| ## API Endpoint | ||
|
|
||
| GraphQL endpoint of the StakeWise backend. | ||
|
|
||
| | Network | Endpoint | | ||
| |---------|----------| | ||
| | **Mainnet** | `https://mainnet-api.stakewise.io/graphql` | | ||
| | **Gnosis** | `https://gnosis-api.stakewise.io/graphql` | | ||
| | **Hoodi** | `https://hoodi-api.stakewise.io/graphql` | | ||
|
|
||
| --- | ||
|
|
||
| ## Subgraph Endpoint | ||
|
|
||
| GraphQL endpoint of the StakeWise subgraph. | ||
|
|
||
| ### Production | ||
|
|
||
| Use the **`prod`** endpoint for production environments. | ||
|
|
||
| | Network | Endpoint | | ||
| |---------|----------| | ||
| | **Mainnet** | `https://graphs.stakewise.io/mainnet/subgraphs/name/stakewise/prod` | | ||
| | **Gnosis** | `https://graphs.stakewise.io/gnosis/subgraphs/name/stakewise/prod` | | ||
| | **Hoodi** | `https://graphs.stakewise.io/hoodi/subgraphs/name/stakewise/prod` | | ||
|
|
||
| ### Stage | ||
|
|
||
| Mirrors the production schema but tracks the staging deployment - use it only when reproducing issues against a non-production environment. | ||
|
|
||
| | Network | Endpoint | | ||
| |---------|----------| | ||
| | **Mainnet** | `https://graphs.stakewise.io/mainnet/subgraphs/name/stakewise/stage` | | ||
| | **Gnosis** | `https://graphs.stakewise.io/gnosis/subgraphs/name/stakewise/stage` | | ||
| | **Hoodi** | `https://graphs.stakewise.io/hoodi/subgraphs/name/stakewise/stage` | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "position": 2, | ||
| "label": "Fundamentals" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| --- | ||
| id: aggregate-queries | ||
| title: Network-wide aggregates | ||
| sidebar_position: 3 | ||
| description: Use sdk.utils.getStakewiseStats() to fetch total ETH staked, user count, and total earned rewards across all StakeWise V3 vaults on the configured chain. | ||
| --- | ||
|
|
||
| # Network-wide aggregates | ||
|
|
||
|
|
||
| To answer "how much is staked across all StakeWise V3 vaults?" use `sdk.utils.getStakewiseStats()`. It returns the protocol-wide aggregate for the network the SDK is bound to. | ||
|
|
||
| ## Total ETH staked across all V3 vaults | ||
|
|
||
| ```typescript | ||
| import { formatEther } from 'ethers' | ||
| import { StakeWiseSDK, Network } from '@stakewise/v3-sdk' | ||
|
|
||
| const sdk = new StakeWiseSDK({ | ||
| network: Network.Mainnet, | ||
| endpoints: { web3: 'https://main-rpc.io' }, | ||
| }) | ||
|
|
||
| const stats = await sdk.utils.getStakewiseStats() | ||
|
|
||
| console.log(`Total: ${formatEther(stats.totalAssets)} ETH`) | ||
| console.log(`Users: ${stats.usersCount}`) | ||
| console.log(`Earned: ${formatEther(stats.totalEarnedAssets)} ETH`) | ||
| ``` | ||
|
|
||
| `stats.totalAssets` and `stats.totalEarnedAssets` are wei strings; convert with `BigInt` for math, with `formatEther` for display. On Gnosis swap `Network.Mainnet` for `Network.Gnosis` and the value is in GNO. | ||
|
|
||
| ## Cross-chain TVL | ||
|
|
||
| Instantiate one SDK per chain, run them concurrently: | ||
|
|
||
| ```typescript | ||
| import { formatEther } from 'ethers' | ||
| import { StakeWiseSDK, Network } from '@stakewise/v3-sdk' | ||
|
|
||
| const mainnet = new StakeWiseSDK({ | ||
| network: Network.Mainnet, | ||
| endpoints: { web3: 'https://main-rpc.io' }, | ||
| }) | ||
|
|
||
| const gnosis = new StakeWiseSDK({ | ||
| network: Network.Gnosis, | ||
| endpoints: { web3: 'https://gnosis-rpc.io' }, | ||
| }) | ||
|
|
||
| const [ mainnetStats, gnosisStats ] = await Promise.all([ | ||
| mainnet.utils.getStakewiseStats(), | ||
| gnosis.utils.getStakewiseStats(), | ||
| ]) | ||
|
|
||
| console.log(`Mainnet TVL: ${formatEther(mainnetStats.totalAssets)} ETH`) | ||
| console.log(`Gnosis TVL: ${formatEther(gnosisStats.totalAssets)} GNO`) | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check:docLinksfetches the live docs sitemap over the network; running this in a pre-commit hook can be slow and may fail for contributors who are offline or behind restrictive networks. Consider moving it to CI (pre-push or workflow) or adding an opt-out (e.g., env flag) so local commits don’t become flaky.