From 464e1fce88331fea14ae919a23a62edd3a7d7e15 Mon Sep 17 00:00:00 2001 From: MikeDiam Date: Mon, 29 Jan 2024 16:43:54 +0300 Subject: [PATCH 1/4] [block-list] add blocklist request --- README.md | 53 +++++++++++-------- src/graphql/subgraph/vault/vaultQuery.graphql | 5 ++ .../requests/getVault/modifyVault.spec.ts | 28 ++++++++++ .../vault/requests/getVault/modifyVault.ts | 14 +++-- src/utils/configs/holesky.ts | 2 +- src/utils/configs/mainnet.ts | 2 +- 6 files changed, 74 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 169c7fe3..1ad623dc 100644 --- a/README.md +++ b/README.md @@ -407,6 +407,7 @@ type Output = { vaultAddress: string mevRecipient: string imageUrl: string | null + blocklistManager: string vaultKeysManager: string isSmoothingPool: boolean tokenName: string | null @@ -417,33 +418,39 @@ type Output = { createdAt: number address: string }> | null + blocklist: Array<{ + createdAt: number + address: string + }> | null performance: number } ``` -| Name | Description | -|------|-------------| -| `apy` | Current vault apy | -| `isErc20` | Does the vault have its own ERC20 token | -| `capacity` | Maximum TVL of Vault | -| `createdAt` | Date of Creation | -| `feePercent` | Commission rate | -| `isPrivate` | Whether the storage is private | -| `vaultAdmin` | Vault administrator address | -| `totalAssets` | TVL of Vault | -| `feeRecipient` | Vault fee address | -| `whitelister` | Whitelist manager | -| `vaultAddress` | Address of vault | -| `mevRecipient` | Validator fee recipient | -| `imageUrl` | Link for vault logo | -| `vaultKeysManager` | Keys manager address | -| `isSmoothingPool` | Smoothing poll or Vault escrow | -| `tokenName` | ERC20 token name | -| `tokenSymbol` | ERC20 token symbol | -| `displayName` | Name of vault | -| `description` | Description of vault | -| `whitelist` | List of authorized users for deposits | -| `performance` | Vault performance indicator (percent) | +| Name | Description | +|--------------------|-----------------------------------------| +| `apy` | Current vault apy | +| `isErc20` | Does the vault have its own ERC20 token | +| `capacity` | Maximum TVL of Vault | +| `createdAt` | Date of Creation | +| `feePercent` | Commission rate | +| `isPrivate` | Whether the storage is private | +| `vaultAdmin` | Vault administrator address | +| `totalAssets` | TVL of Vault | +| `feeRecipient` | Vault fee address | +| `whitelister` | Whitelist manager | +| `vaultAddress` | Address of vault | +| `mevRecipient` | Validator fee recipient | +| `imageUrl` | Link for vault logo | +| `blocklistManager` | Blocklist manager | +| `vaultKeysManager` | Keys manager address | +| `isSmoothingPool` | Smoothing poll or Vault escrow | +| `tokenName` | ERC20 token name | +| `tokenSymbol` | ERC20 token symbol | +| `displayName` | Name of vault | +| `description` | Description of vault | +| `whitelist` | List of authorized users for deposits | +| `blocklist` | List of blocked users for deposits | +| `performance` | Vault performance indicator (percent) | #### Example: diff --git a/src/graphql/subgraph/vault/vaultQuery.graphql b/src/graphql/subgraph/vault/vaultQuery.graphql index dc3581d9..4be93f72 100644 --- a/src/graphql/subgraph/vault/vaultQuery.graphql +++ b/src/graphql/subgraph/vault/vaultQuery.graphql @@ -20,6 +20,7 @@ query Vault($address: ID!) { tokenSymbol feeRecipient validatorsRoot + blocklistManager weeklyApy } privateVaultAccounts( @@ -28,4 +29,8 @@ query Vault($address: ID!) { createdAt address } + vaultBlockedAccounts(where: { vault: $address }) { + createdAt + address + } } diff --git a/src/methods/vault/requests/getVault/modifyVault.spec.ts b/src/methods/vault/requests/getVault/modifyVault.spec.ts index 9c7d474f..de66484f 100644 --- a/src/methods/vault/requests/getVault/modifyVault.spec.ts +++ b/src/methods/vault/requests/getVault/modifyVault.spec.ts @@ -35,6 +35,10 @@ describe('modifyVault', () => { { createdAt: '1693395816', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663' }, { createdAt: '1693395816', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663' }, ], + vaultBlockedAccounts: [ + { createdAt: '1693395817', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663' }, + { createdAt: '1693395817', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663' }, + ], } it('should correctly transform the vault data', () => { @@ -70,6 +74,16 @@ describe('modifyVault', () => { address: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', }, ], + blocklist: [ + { + createdAt: 1693395817000, + address: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', + }, + { + createdAt: 1693395817000, + address: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', + }, + ], } const result = modifyVault({ @@ -111,6 +125,20 @@ describe('modifyVault', () => { expect(result.whitelist).toEqual([]) }) + it('should handle empty vaultBlockedAccounts correctly', () => { + const mockDataWithoutBlockedAccounts: VaultQueryPayload = { + ...mockVaultQueryPayload, + vaultBlockedAccounts: [], + } + + const result = modifyVault({ + data: mockDataWithoutBlockedAccounts, + network, + }) + + expect(result.blocklist).toEqual([]) + }) + it('should handle feePercent being 0', () => { const mockDataWithZeroFee: VaultQueryPayload = { ...mockVaultQueryPayload, diff --git a/src/methods/vault/requests/getVault/modifyVault.ts b/src/methods/vault/requests/getVault/modifyVault.ts index 9bba6595..ba2717da 100644 --- a/src/methods/vault/requests/getVault/modifyVault.ts +++ b/src/methods/vault/requests/getVault/modifyVault.ts @@ -10,9 +10,14 @@ type ModifyVaultInput = { network: Network } +const modifyAddress = ({ createdAt, address }: { createdAt: string, address: string }) => ({ + createdAt: Number(createdAt) * 1000, + address: getAddress(address), +}) + const modifyVault = (input: ModifyVaultInput): ModifiedVault => { const { data, network } = input - const { vault, privateVaultAccounts } = data + const { vault, privateVaultAccounts, vaultBlockedAccounts } = data const { admin, @@ -41,10 +46,9 @@ const modifyVault = (input: ModifyVaultInput): ModifiedVault => { vaultKeysManager: getAddress(keysManager), apy: Number(weeklyApy), whitelister: vault.whitelister ? getAddress(vault.whitelister) : '', - whitelist: privateVaultAccounts.map(({ createdAt, address }) => ({ - createdAt: Number(createdAt) * 1000, - address: getAddress(address), - })) || [], + blocklistManager: vault.blocklistManager ? getAddress(vault.blocklistManager) : '', + whitelist: privateVaultAccounts.map(modifyAddress), + blocklist: vaultBlockedAccounts.map(modifyAddress), mevRecipient: mevEscrow ? getAddress(mevEscrow) : configs[network].addresses.base.sharedMevEscrow, diff --git a/src/utils/configs/holesky.ts b/src/utils/configs/holesky.ts index 79c77edf..4b95f24e 100644 --- a/src/utils/configs/holesky.ts +++ b/src/utils/configs/holesky.ts @@ -6,7 +6,7 @@ import tokens from '../constants/tokens' export default { api: { backend: 'https://holesky-api.stakewise.io/graphql', - subgraph: 'https://holesky-graph.stakewise.io/subgraphs/name/stakewise/stakewise1', + subgraph: 'https://holesky-graph.stakewise.io/subgraphs/name/stakewise/stakewise', }, network: { chainId: 17000, diff --git a/src/utils/configs/mainnet.ts b/src/utils/configs/mainnet.ts index b418c2ad..edd3d559 100644 --- a/src/utils/configs/mainnet.ts +++ b/src/utils/configs/mainnet.ts @@ -4,7 +4,7 @@ import tokens from '../constants/tokens' export default { api: { backend: 'https://mainnet-api.stakewise.io/graphql', - subgraph: 'https://mainnet-graph.stakewise.io/subgraphs/name/stakewise/stakewise1', + subgraph: 'https://mainnet-graph.stakewise.io/subgraphs/name/stakewise/stakewise', }, network: { chainId: 1, From c616ee48b53a6c65748c89a62db5110dad62f3ac Mon Sep 17 00:00:00 2001 From: MikeDiam Date: Mon, 29 Jan 2024 16:58:06 +0300 Subject: [PATCH 2/4] [block-list] add blocklist conditions --- README.md | 1 + src/graphql/subgraph/vault/vaultQuery.graphql | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 1ad623dc..75f7fa9f 100644 --- a/README.md +++ b/README.md @@ -434,6 +434,7 @@ type Output = { | `createdAt` | Date of Creation | | `feePercent` | Commission rate | | `isPrivate` | Whether the storage is private | +| `isBlocklist` | Whether the storage has blocklist | | `vaultAdmin` | Vault administrator address | | `totalAssets` | TVL of Vault | | `feeRecipient` | Vault fee address | diff --git a/src/graphql/subgraph/vault/vaultQuery.graphql b/src/graphql/subgraph/vault/vaultQuery.graphql index 4be93f72..94562386 100644 --- a/src/graphql/subgraph/vault/vaultQuery.graphql +++ b/src/graphql/subgraph/vault/vaultQuery.graphql @@ -13,6 +13,7 @@ query Vault($address: ID!) { tokenName feePercent totalAssets + isBlocklist displayName description whitelister From d4d6ed3dfac5d39902d115f3bb4f030704141faa Mon Sep 17 00:00:00 2001 From: MikeDiam Date: Tue, 30 Jan 2024 10:59:23 +0300 Subject: [PATCH 3/4] [blocklist] fix types --- src/methods/vault/requests/getVault/types.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/methods/vault/requests/getVault/types.ts b/src/methods/vault/requests/getVault/types.ts index 9cdede14..998b1bf6 100644 --- a/src/methods/vault/requests/getVault/types.ts +++ b/src/methods/vault/requests/getVault/types.ts @@ -1,6 +1,11 @@ import type { VaultQueryPayload } from '../../../../graphql/subgraph/vault' +type ListItem = { + createdAt: number + address: string +} + export type ModifiedVault = Omit< VaultQueryPayload['vault'], 'admin' | 'address' | 'mevEscrow' | 'keysManager' | 'weeklyApy' | 'performance' | 'createdAt' @@ -13,8 +18,6 @@ export type ModifiedVault = Omit< mevRecipient: string vaultKeysManager: string isSmoothingPool: boolean - whitelist: Array<{ - createdAt: number - address: string - }> + whitelist: ListItem[] + blocklist: ListItem[] } From ce95d7e66f527f30ba97b70a3113242b758ef281 Mon Sep 17 00:00:00 2001 From: MikeDiam Date: Tue, 30 Jan 2024 11:03:37 +0300 Subject: [PATCH 4/4] [blocklist] fix types --- src/methods/vault/requests/getVault/modifyVault.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/methods/vault/requests/getVault/modifyVault.spec.ts b/src/methods/vault/requests/getVault/modifyVault.spec.ts index de66484f..7a20ccd4 100644 --- a/src/methods/vault/requests/getVault/modifyVault.spec.ts +++ b/src/methods/vault/requests/getVault/modifyVault.spec.ts @@ -13,6 +13,7 @@ describe('modifyVault', () => { isErc20: true, feePercent: 200, isPrivate: false, + isBlocklist: false, performance: '10', tokenSymbol: 'mTKN', imageUrl: 'mockUrl', @@ -30,6 +31,7 @@ describe('modifyVault', () => { whitelister: '0xeefffd4c23d2e8c845870e273861e7d60df49663', keysManager: '0xeefffd4c23d2e8c845870e273861e7d60df49663', feeRecipient: '0xeefffd4c23d2e8c845870e273861e7d60df49663', + blocklistManager: '0xeefffd4c23d2e8c845870e273861e7d60df49663', }, privateVaultAccounts: [ { createdAt: '1693395816', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663' }, @@ -48,6 +50,7 @@ describe('modifyVault', () => { feePercent: 2, performance: 10, isPrivate: false, + isBlocklist: false, capacity: '0.001', tokenSymbol: 'mTKN', imageUrl: 'mockUrl', @@ -64,6 +67,7 @@ describe('modifyVault', () => { feeRecipient: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', mevRecipient: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', vaultKeysManager: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', + blocklistManager: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', whitelist: [ { createdAt: 1693395816000,