Skip to content

Sub vaults#339

Open
dfkadyr wants to merge 24 commits into
mainfrom
sub-vaults
Open

Sub vaults#339
dfkadyr wants to merge 24 commits into
mainfrom
sub-vaults

Conversation

@dfkadyr
Copy link
Copy Markdown
Contributor

@dfkadyr dfkadyr commented Jan 20, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 20, 2026 08:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces functionality to retrieve and manage sub-vaults within a meta vault structure, allowing users to query information about vaults that are allocated within a parent meta vault.

Changes:

  • Added getSubVaults method to retrieve sub-vault information including APY, assets, and exit queue data
  • Extended the allocator GraphQL query to include APY field
  • Added isStateUpdateRequired function to the DefaultVaultAbi contract

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/services/vault/requests/index.ts Exports the new getSubVaults function and its input type
src/services/vault/requests/getSubVaults/index.ts Implements the main logic for fetching and aggregating sub-vault data
src/services/vault/requests/getSubVaults/getSubVaults.md Provides API documentation for the getSubVaults method
src/services/vault/index.ts Adds the public getSubVaults method to the Vault service class
src/graphql/subgraph/vault/subVaultsQuery.graphql Defines the GraphQL query for fetching sub-vaults
src/graphql/subgraph/vault/index.ts Exports the SubVaults query types and fetch function
src/graphql/subgraph/allocator/allocatorsQuery.graphql Adds apy field to the allocators query
src/contracts/vault/abis/DefaultVaultAbi.json Adds isStateUpdateRequired function to the vault ABI
changelog/next-release.md Documents the addition of the getSubVaults method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/services/vault/requests/getSubVaults/getSubVaults.md Outdated
Comment thread src/services/vault/requests/getSubVaults/index.ts Outdated
Comment thread src/contracts/vault/abis/DefaultVaultAbi.json Outdated
Copilot AI review requested due to automatic review settings January 20, 2026 11:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mike-diamond
mike-diamond previously approved these changes Jan 21, 2026
}
]


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty lines?

Cast0001
Cast0001 previously approved these changes Jan 21, 2026
Copilot AI review requested due to automatic review settings January 30, 2026 13:41
@dfkadyr dfkadyr dismissed stale reviews from mike-diamond and Cast0001 via 1a8a7c8 January 30, 2026 13:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings February 3, 2026 13:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings February 20, 2026 13:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

Copilot AI review requested due to automatic review settings March 17, 2026 07:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 85 out of 89 changed files in this pull request and generated 11 comments.

Comments suppressed due to low confidence (3)

codegen.ts:10

  • codegen.ts now defaults network to Network.Hoodi with a TODO. This will change generated GraphQL/types for anyone running codegen without NETWORK set, which is risky for a published SDK. Consider reverting the default back to Network.Mainnet and using env vars (or a separate script/flag) for generating Hoodi/stage schemas.
// TODO change
let network: Network = Network.Hoodi

if (process.env.NETWORK === 'mainnet') {
  network = Network.Mainnet
}

src/services/vault/transactions/createVault/helpers/validateCreateVaultArgs.ts:98

  • metaVault() validation logic is inverted: it returns when type is a MetaVault, so the subsequent MetaVault-only restrictions are applied to non-MetaVault vaults instead (e.g., it would throw on isOwnMevEscrow for normal vaults, and on Gnosis it could incorrectly block ERC20/private non-MetaVault vault creation). Flip the condition so these checks run only when type is MetaVault/PrivateMetaVault (and consider renaming isMainnet since it includes Hoodi).
    .graphqlconfig:18
  • .graphqlconfig is updated to point at the Hoodi stage subgraph endpoint. This looks like a local/dev change and can cause confusion for contributors and CI tooling that relies on this config. Consider keeping .graphqlconfig pointed at the canonical/prod endpoint and overriding locally via environment or editor settings.
      "Subgraph GraphQL": {
        "url": "https://graphs.stakewise.io/hoodi/subgraphs/name/stakewise/stage",
        "headers": {
          "user-agent": "JS GraphQL"
        },
        "introspect": false

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

isSmoothingPool: boolean
tokenName: string | null
whitelistManager: string
whitelistManager: string
Comment thread src/helpers/configs/hoodi.ts Outdated
Comment on lines +10 to +11
// TODO change (+ change .graphqlconfig)
subgraph: 'https://graphs.stakewise.io/hoodi/subgraphs/name/stakewise/stage',
Comment on lines +54 to +83
const results = await Promise.all(
subVaults.map(async (subVaultId) => {
const vaultId = subVaultId.toLowerCase()

const [ allocatorData, vaultData, exitQueue ] = await Promise.all([
graphql.subgraph.allocator.fetchAllocatorsQuery({
url,
variables: {
address: metaVaultId,
vaultAddress: vaultId,
},
modifyResult: (data) => {
const first = data?.allocators?.[0]

return {
assets: BigInt(first?.assets || 0),
apy: (Number(first?.apy) || 0).toFixed(2),
}
},
}),

getVault({ ...commonParams, vaultAddress: vaultId }),

getExitQueuePositions({
...commonParams,
isClaimed: false,
vaultAddress: vaultId,
userAddress: metaVaultId,
}),
])
Comment on lines +16 to +17
| limit | `number` | **No** | Limits the number of sub vaults returned. Defaults to 100 |
| skip | `number` | **No** | Skips the specified number of sub vaults. Defaults to 0 |
Comment on lines +4 to +13
import { checkAccess } from '../../../vault/transactions/util'


const updateFeeRecipients = async (values: UpdateFeeRecipientsInput) => {
const updateFeeRecipients = checkAccess<UpdateFeeRecipientsInput>(async (values) => {
const multicallArgs = await commonLogic(values)

const result = await rewardSplitterMulticall<{ hash: string }>(multicallArgs)

return result.hash
}
})
Comment thread changelog/next-release.md Outdated
#### Add output field:
```ts
type Output = {
canHarvest: boolen
Comment on lines 4 to +16
@@ -12,7 +13,7 @@ const createRewardSplitter = async (values: CreateRewardSplitterInput) => {
)

return result.hash
}
})
Comment on lines +23 to 27
const harvestArgs = await getHarvestArgs(values)

const baseParams: BaseParams = [ userAddress, referrerAddress, overrides ]
const updateStateParams: UpdateStateParams = [ userAddress, referrerAddress, harvestParams, overrides ]
const updateStateParams: UpdateStateParams = [ userAddress, referrerAddress, harvestArgs as HarvestArgs, overrides ]

Comment on lines +22 to +29
const vaultFactory = getVaultFactory({
...values,
isErc20: Boolean(vaultToken),
vaultType: type,
}) as typeof isMetaVault extends true
? StakeWise.ABI.MetaVaultFactory
: StakeWise.ABI.VaultFactory

Comment on lines +15 to +21
const result = await wrapErrorHandler(
signedContract.addSubVault(subVaultAddress),
'transaction'
)

return result?.hash
})
Copilot AI review requested due to automatic review settings March 24, 2026 10:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

Cast0001 and others added 3 commits March 24, 2026 16:44
* Docs description (#349)

* [docs-description] add description to .md files

* [docs-description] fix doc

* fix (#350)

* [change-docs-links] change slug (#351)

* [fix-slug] fixed (#352)

* [abort-callback] open AbortCallback
* Remove sync docs git action (#354)

* [remove-sync-docs] remove git action and change script

* change git action

* add link checker script and update documentation references

* fix broken links

* add md files to check

* small improve

* update GitHub Actions to use latest checkout and cache actions (#356)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* add script to check documentation links and update pre-commit hook

* update

* update

* update

* add warning for slug changes in staged md files

* rename markdown files and update slug checking logic in link checker

* Add script to check documentation links (#357)

* add script to check documentation links

* fix after review

* rename documentation files and improve slug validation in checkDocLinks

* add category configuration for Quick Start

* improve slug processing and include _category_.json in documentation file search

* 4.2.3 (#358)

* merge

---------

Co-authored-by: CAst <programmer.andrey@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 7, 2026 07:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 106 out of 118 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (9)

src/services/vault/transactions/util/check/roles/index.ts:1

  • These imports resolve to files inside the new roles/ directory, but the access-check implementations shown in this PR are located in src/services/vault/transactions/util/check/ (one level up). This will break module resolution at build time. Update the import paths (e.g., ../checkAdminAccess, etc.) or move the access-check files into the roles/ folder to match the new structure.
    src/services/vault/transactions/util/check/checkAccess.ts:1
  • The refactor changes other role-check files to import CheckInput from ../types, but checkAccess.ts still imports from ./types, which is inconsistent and likely incorrect after the folder re-org. Also, Action is hard-coded to Promise<string>, but several wrapped actions in this PR return string | undefined (e.g., result?.hash) or other shapes (encode/estimateGas helpers). Make checkAccess generic over the action output (e.g., <Output, Input extends CheckInput>(action: (values: Input) => Promise<Output>, ...)) and align CheckInput import path with the new types location.
    src/services/vault/transactions/util/check/checkAccess.ts:1
  • The refactor changes other role-check files to import CheckInput from ../types, but checkAccess.ts still imports from ./types, which is inconsistent and likely incorrect after the folder re-org. Also, Action is hard-coded to Promise<string>, but several wrapped actions in this PR return string | undefined (e.g., result?.hash) or other shapes (encode/estimateGas helpers). Make checkAccess generic over the action output (e.g., <Output, Input extends CheckInput>(action: (values: Input) => Promise<Output>, ...)) and align CheckInput import path with the new types location.
    src/services/vault/transactions/createVault/helpers/index.ts:1
  • This barrel export points to ./validateCreateVaultArgs inside the helpers/ directory, but the diff shows validateCreateVaultArgs.ts living in src/services/vault/transactions/createVault/validateCreateVaultArgs.ts (parent directory), not in helpers/. As written, this will fail to compile. Either move validateCreateVaultArgs.ts into helpers/, or change the export path to reference the parent file.
    src/services/vault/transactions/createVault/common.ts:1
  • The conditional type assertion typeof isMetaVault extends true ? ... : ... won’t narrow based on the runtime boolean isMetaVault (its type is boolean, so this conditional typically collapses to the false branch). Prefer typing vaultFactory as a union (StakeWise.ABI.VaultFactory | StakeWise.ABI.MetaVaultFactory) and narrowing at runtime with if (isMetaVault) { ... }, or use overloads/generics tied to type rather than a runtime boolean.
    src/services/vault/requests/getSubVaults/index.ts:1
  • getVault() commonly returns nullable metadata fields (e.g., imageUrl and displayName can be null). Here OutputSubVault types them as non-null string, but the implementation forwards the possibly-null values directly. Update the OutputSubVault type to allow null for these fields or normalize them in the return object to guarantee strings.
    src/services/vault/requests/getSubVaults/index.ts:1
  • getVault() commonly returns nullable metadata fields (e.g., imageUrl and displayName can be null). Here OutputSubVault types them as non-null string, but the implementation forwards the possibly-null values directly. Update the OutputSubVault type to allow null for these fields or normalize them in the return object to guarantee strings.
    src/services/vault/requests/getVault/getVault.md:1
  • The Output type lists whitelistManager twice, and the file ends with a stray # test line. Remove the duplicate field and the extraneous line to keep the API docs accurate and clean.
    src/services/vault/requests/getVault/getVault.md:1
  • The Output type lists whitelistManager twice, and the file ends with a stray # test line. Remove the duplicate field and the extraneous line to keep the API docs accurate and clean.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread codegen.ts
Comment on lines +5 to +6
// TODO change
let network: Network = Network.Hoodi
Copy link

Copilot AI Apr 7, 2026

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 to Hoodi (with a TODO) makes builds/codegen sensitive to local defaults and can accidentally generate types against a staging endpoint. Prefer keeping the default as Mainnet (or requiring an explicit NETWORK env var) so generated outputs are deterministic across environments.

Suggested change
// TODO change
let network: Network = Network.Hoodi
let network: Network = Network.Mainnet

Copilot uses AI. Check for mistakes.
Comment thread changelog/next-release.md Outdated
#### Add output field:
```ts
type Output = {
canHarvest: boolen
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'boolen' to 'boolean'.

Suggested change
canHarvest: boolen
canHarvest: boolean

Copilot uses AI. Check for mistakes.
Comment thread .husky/pre-commit
sh ./scripts/pre-push.sh

npm run lint
pnpm run check:docLinks
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check:docLinks fetches 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.

Suggested change
pnpm run check:docLinks
if [ "${SKIP_DOC_LINKS:-0}" != "1" ]; then
pnpm run check:docLinks
fi

Copilot uses AI. Check for mistakes.
dfkadyr and others added 2 commits April 8, 2026 10:57
* [subgraph updates] update sub vaults request

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [subgraph updates] update cancellable type

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [subgraph updates] refactor sub vaults query and mapping logic

Signed-off-by: MikeDiam <info@mdiamond.ru>

---------

Signed-off-by: MikeDiam <info@mdiamond.ru>
Copilot AI review requested due to automatic review settings April 21, 2026 09:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 120 out of 132 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (10)

src/services/vault/transactions/util/check/checkAccess.ts:1

  • CheckInput imports in the other checkers were updated to ../types, but checkAccess.ts still imports from ./types. This will likely break module resolution/compilation if types was moved up one level. Update this import to match the new location (e.g., ../types).
    src/services/vault/transactions/updateState/common.ts:1
  • UpdateStateInput is imported as a runtime value import, but it appears to be declared in a .d.ts types file (types.d.ts). This can cause runtime/bundling errors because there may be no emitted JS module at ./types. Change this to a type-only import (import type { UpdateStateInput } from './types'). The same issue appears in other new common.ts files for sub-vault transactions.
    src/services/vault/transactions/addSubVault/common.ts:1
  • AddSubVaultInput is used as a type, but it's imported as a runtime value import. If ./types is a .d.ts-only module, this can break at runtime. Use a type-only import (import type { AddSubVaultInput } from './types'). Apply the same fix in ejectSubVault/common.ts and rejectSubVault/common.ts.
    src/services/vault/transactions/createVault/common.ts:1
  • The conditional type cast typeof isMetaVault extends true ? ... does not work as intended because isMetaVault is a runtime boolean, so the cast will not correctly narrow to MetaVaultFactory. This risks incorrect typing for createVault arguments and can hide real call-site issues. Prefer an explicit runtime branch that selects/casts the factory based on isMetaVault, or use overloads/generics driven by the type parameter to ensure the correct ABI type is returned.
    src/services/vault/transactions/operate/getRolesList.ts:1
  • Role detection uses truthiness checks, which can incorrectly skip required role checks when setting values to falsy-but-valid inputs (e.g., feePercent: 0 to set fee to 0). Use explicit presence checks (e.g., feePercent !== undefined) for fields where 0, empty string, or empty arrays are meaningful updates.
    src/services/vault/requests/getVault/getVault.md:1
  • This doc now contains a duplicated whitelistManager field in the output type and an extraneous # test line at the end. Remove the duplicate field and the # test line to avoid confusing SDK consumers and automated doc tooling.
    src/services/vault/requests/getVault/getVault.md:1
  • This doc now contains a duplicated whitelistManager field in the output type and an extraneous # test line at the end. Remove the duplicate field and the # test line to avoid confusing SDK consumers and automated doc tooling.
    src/services/assertCancellable.ts:1
  • This file is intended as a compile-time assertion, but it imports many runtime modules and is executed via src/services/index.ts, which can inflate bundle size and increase risk of circular dependencies. Prefer import type for the service/transactions classes and structure the assertion so it has zero runtime footprint (e.g., purely type-level aliases or a declare const pattern) while still failing compilation when methods are not cancellable.
    src/services/vault/requests/getSubVaults/modifySubVaults.ts:1
  • New request shaping logic is introduced here (BigInt parsing, allocator selection, exitRequests aggregation), but there are no accompanying unit tests in this PR. Add tests covering: (1) empty allocators, (2) empty exitRequests, and (3) aggregation across multiple exit requests to ensure stable output formatting.
    src/services/vault/transactions/createVault/helpers/getEncodeBytes.ts:1
  • feePercent is computed via floating point multiplication. Values like 15.35 * 100 can produce 1534.999999... due to IEEE-754 rounding, which can result in an invalid/non-integer ABI value for uint16. Prefer an explicit integer conversion (e.g., rounding to nearest int after validation) to ensure the encoded tuple always contains an integer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread codegen.ts
Comment on lines +5 to 7
// TODO change
let network: Network = Network.Hoodi

Copy link

Copilot AI Apr 21, 2026

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.

Suggested change
// TODO change
let network: Network = Network.Hoodi
let network: Network = Network.Mainnet
if (process.env.NETWORK === 'hoodi') {
network = Network.Hoodi
}

Copilot uses AI. Check for mistakes.
Comment thread scripts/checkDocLinks.js
Comment on lines +42 to +45
const output = execSync(
`grep -r "^slug:" "${srcDir}" --include="*.md"`,
{ encoding: 'utf-8' }
)
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc link checker relies on grep, which is not available by default on Windows environments. Since this script is now enforced via Husky on pre-commit, it can block contributors on non-Unix platforms. Consider rewriting the scan using Node filesystem/glob APIs (cross-platform), or run this check only in CI where the environment is controlled.

Copilot uses AI. Check for mistakes.
Comment thread scripts/checkDocLinks.js
Comment on lines +71 to +76
const output = execSync(
`grep -roh "https://docs\\.stakewise\\.io/[^\\"' )\\\`>]*" "${rootDir}" `
+ '--include="*.ts" --include="*.tsx" --include="*.md" --include="*.mdx" '
+ '--exclude-dir=node_modules',
{ encoding: 'utf-8' }
)
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc link checker relies on grep, which is not available by default on Windows environments. Since this script is now enforced via Husky on pre-commit, it can block contributors on non-Unix platforms. Consider rewriting the scan using Node filesystem/glob APIs (cross-platform), or run this check only in CI where the environment is controlled.

Copilot uses AI. Check for mistakes.
dfkadyr and others added 2 commits April 22, 2026 11:03
* Remove sync docs git action (#354)

* [remove-sync-docs] remove git action and change script

* change git action

* update GitHub Actions to use latest checkout and cache actions (#356)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Add script to check documentation links (#357)

* add script to check documentation links

* fix after review

* rename documentation files and improve slug validation in checkDocLinks

* add category configuration for Quick Start

* improve slug processing and include _category_.json in documentation file search

* 4.2.3 (#358)

* [fix-encode] fix transactionWrapper (#360)

* up-version (#361)

* [handle-429] add retry-after header support (#364)

* fix

---------

Co-authored-by: CAst <programmer.andrey@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 24, 2026 09:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 123 out of 135 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (3)

src/services/vault/transactions/createVault/helpers/validateCreateVaultArgs.ts:88

  • metaVault validation logic is inverted: it returns early when type is a MetaVault, so it doesn't enforce the MetaVault restrictions (e.g. disallowing isOwnMevEscrow). Conversely, for non-MetaVault types it can incorrectly throw "MetaVault does not support..." when isOwnMevEscrow is set. Flip the early-return condition so restrictions are applied only when type is a MetaVault/PrivateMetaVault (and do nothing otherwise).
    src/services/vault/requests/getVault/getVault.md:115
  • The return type docs contain a duplicated whitelistManager field and there is a stray # test line at the end of the file. Please remove the duplicate field entry and delete the leftover test text to avoid confusing generated/linked docs.
    codegen.ts:13
  • codegen.ts now defaults to Network.Hoodi (marked TODO). This changes the default behavior of pnpm graphql/codegen when NETWORK isn’t set and can generate types against the wrong subgraph/backend in CI or local dev. Consider reverting the default to Mainnet (or require process.env.NETWORK explicitly and fail fast if unset).
// TODO change
let network: Network = Network.Hoodi

if (process.env.NETWORK === 'mainnet') {
  network = Network.Mainnet
}
if (process.env.NETWORK === 'gnosis') {
  network = Network.Gnosis
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +32
const modifySubVaults = (data: SubVaultsQueryPayload): ModifiedSubVault[] => {
return data.subVaults.map(({ subVault }) => {
const { id, imageUrl, displayName, allocators, exitRequests } = subVault

const [ allocator ] = allocators
const exitingAssets = exitRequests.reduce((acc, { totalAssets }) => (
acc + BigInt(totalAssets)
), 0n)

const apy = Number(allocator?.apy) || 0

return {
id,
apy: apy.toFixed(2),
imageUrl: imageUrl || '',
displayName: displayName || '',
stakingAssets: BigInt(allocator?.assets || 0),
exitingAssets,
}
})
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifySubVaults introduces non-trivial parsing logic (BigInt aggregation of exitRequests, allocator selection, APY formatting), but there is no accompanying unit test. The vault request modifiers in this area typically have *.spec.ts coverage; please add a modifySubVaults.spec.ts to lock down edge cases (no allocators, empty exitRequests, large totals).

Copilot uses AI. Check for mistakes.
Comment on lines 19 to +61
@@ -28,42 +49,17 @@ export const commonLogic = async (values: CreateVaultTransactionInput) => {
validateCreateVaultArgs.keysManagerFee(keysManagerFee)
}

const vaultFactories = vaultToken ? {
[VaultType.Default]: contracts.factories.erc20Vault,
[VaultType.Private]: contracts.factories.erc20PrivateVault,
[VaultType.Blocklist]: contracts.factories.erc20BlocklistVault,
} : {
[VaultType.Default]: contracts.factories.vault,
[VaultType.Private]: contracts.factories.privateVault,
[VaultType.Blocklist]: contracts.factories.blocklistVault,
}

const vaultFactory = vaultFactories[type]
const defaultAbiCoder = AbiCoder.defaultAbiCoder()
const encodedParams = getEncodeBytes({ ...values, isMetaVault })

const formattedParams = {
feePercent: (keysManagerFee || 0) * 100,
capacity: capacity || MaxUint256,
symbol: vaultToken?.symbol,
name: vaultToken?.name,
}

const encodedParams = vaultToken
? defaultAbiCoder.encode(
[ 'tuple(uint256 capacity, uint16 feePercent, string name, string symbol, string metadataIpfsHash)' ],
[ [ formattedParams.capacity, formattedParams.feePercent, formattedParams.name, formattedParams.symbol, metadataIpfsHash ] ]
)
: defaultAbiCoder.encode(
[ 'tuple(uint256 capacity, uint16 feePercent, string metadataIpfsHash)' ],
[ [ formattedParams.capacity, formattedParams.feePercent, metadataIpfsHash ] ]
)

const isStakeNativeToken = [ Network.Mainnet, Network.Hoodi ].includes(options.network)

const params: [ string, boolean, PayableOverrides ] = isStakeNativeToken
const params: [ string, boolean, PayableOverrides ] = isMainnet
? [ encodedParams, isOwnMevEscrow, { value: constants.blockchain.gwei } ]
: [ encodedParams, isOwnMevEscrow, {} ]

if (isMetaVault) {
// MetaVault does not support isOwnMevEscrow
params.splice(1, 1)
}
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vaultFactory cast uses as typeof isMetaVault extends true ? ... but typeof isMetaVault is just boolean, so the conditional type won’t narrow and effectively hides the real factory type differences. Consider using a proper union/overload keyed off type (VaultType) and make params a discriminated union as well (MetaVault vs non-MetaVault), instead of mutating a fixed tuple via splice.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +14
validateArgs.address({ vaultAddress, userAddress, subVaultAddress })

const { subVaultsRegistry } = await getVault(values)

return values.contracts.helpers.createSubVaultsRegistry(subVaultsRegistry)
}
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getVault() can return subVaultsRegistry as an empty string when the vault isn’t a MetaVault. Since createSubVaultsRegistry('') doesn’t validate the address, this will later fail with a low-level ethers error. Add an explicit check/validation for subVaultsRegistry (and throw a clear error like “subVaultsRegistry is not set; this action is only supported for MetaVaults”).

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +14
validateArgs.address({ vaultAddress, userAddress, subVaultAddress })

const { subVaultsRegistry } = await getVault(values)

return values.contracts.helpers.createSubVaultsRegistry(subVaultsRegistry)
}
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getVault() can return subVaultsRegistry as an empty string when the vault isn’t a MetaVault. Since createSubVaultsRegistry('') doesn’t validate the address, this will later fail with a low-level ethers error. Add an explicit check/validation for subVaultsRegistry (and throw a clear error like “subVaultsRegistry is not set; this action is only supported for MetaVaults”).

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +14
validateArgs.address({ vaultAddress, userAddress, subVaultAddress })

const { subVaultsRegistry } = await getVault(values)

return values.contracts.helpers.createSubVaultsRegistry(subVaultsRegistry)
}
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getVault() can return subVaultsRegistry as an empty string when the vault isn’t a MetaVault. Since createSubVaultsRegistry('') doesn’t validate the address, this will later fail with a low-level ethers error. Add an explicit check/validation for subVaultsRegistry (and throw a clear error like “subVaultsRegistry is not set; this action is only supported for MetaVaults”).

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 29, 2026 06:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

dfkadyr and others added 2 commits May 4, 2026 16:12
* add endpoints file

* update position

* update endpoints docs
* Remove sync docs git action (#354)

* [remove-sync-docs] remove git action and change script

* change git action

* update GitHub Actions to use latest checkout and cache actions (#356)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Add script to check documentation links (#357)

* add script to check documentation links

* fix after review

* rename documentation files and improve slug validation in checkDocLinks

* add category configuration for Quick Start

* improve slug processing and include _category_.json in documentation file search

* 4.2.3 (#358)

* [fix-encode] fix transactionWrapper (#360)

* up-version (#361)

* [handle-429] add retry-after header support (#364)

* add context7 public key (#370)

* remove old files

---------

Co-authored-by: Kadyr Dzhemaledinov <dfkadyr@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 6, 2026 12:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

mike-diamond and others added 2 commits May 11, 2026 09:21
* Remove sync docs git action (#354)

* [remove-sync-docs] remove git action and change script

* change git action

* Add script to check documentation links (#357)

* add script to check documentation links

* fix after review

* rename documentation files and improve slug validation in checkDocLinks

* add category configuration for Quick Start

* improve slug processing and include _category_.json in documentation file search

* [context7] test

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] test

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context7.json

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update context

Signed-off-by: MikeDiam <info@mdiamond.ru>

* [context7] update structure

Signed-off-by: MikeDiam <info@mdiamond.ru>

---------

Signed-off-by: MikeDiam <info@mdiamond.ru>
Co-authored-by: CAst <programmer.andrey@gmail.com>
Co-authored-by: Kadyr Dzhemaledinov <dfkadyr@gmail.com>
Signed-off-by: MikeDiam <info@mdiamond.ru>
Copilot AI review requested due to automatic review settings May 11, 2026 06:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 163 out of 168 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

src/services/vault/transactions/createVault/helpers/validateCreateVaultArgs.ts:88

  • metaVault() has inverted logic: it returns early when isMetaVault is true, so the meta-vault-specific validations (disallow isOwnMevEscrow, Gnosis ERC20 vaultToken, and PrivateMetaVault on Gnosis) are currently applied to non-meta vaults instead of meta vaults. This will incorrectly block regular vaults with isOwnMevEscrow: true and fail to block invalid meta vault combinations.
    src/services/vault/requests/getVault/getVault.md:115
  • There is a stray # test line at the end of the document, which looks accidental and will render into the published docs. Please remove it.

Comment on lines +19 to +29
const isMainnet = [ Network.Mainnet, Network.Hoodi ].includes(options.network)
const isMetaVault = [ VaultType.MetaVault, VaultType.PrivateMetaVault ].includes(type)

const vaultFactory = getVaultFactory({
...values,
isErc20: Boolean(vaultToken),
vaultType: type,
}) as typeof isMetaVault extends true
? StakeWise.ABI.MetaVaultFactory
: StakeWise.ABI.VaultFactory

@@ -0,0 +1,110 @@
import { AbiCoder, MaxUint256, getAddress } from 'ethers'
Comment on lines 45 to +50
isSmoothingPool: boolean
tokenName: string | null
whitelistManager: string
whitelistManager: string
blocklistManager: string
ejectingSubVault: string
Comment on lines +14 to +21
const block = () => {
throw new Error('To send this transaction, please provide BrowserProvider to the StakeWiseSDK')
}) as T
}

const newMethod = block as unknown as T

newMethod.estimateGas = block as T['estimateGas']
newMethod.encode = method.encode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants