Skip to content
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

Add blocklist #63

Merged
merged 6 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ type Output = {
vaultAddress: string
mevRecipient: string
imageUrl: string | null
blocklistManager: string
vaultKeysManager: string
isSmoothingPool: boolean
tokenName: string | null
Expand All @@ -417,33 +418,40 @@ 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 |
| `isBlocklist` | Whether the storage has blocklist |
| `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:

Expand Down
6 changes: 6 additions & 0 deletions src/graphql/subgraph/vault/vaultQuery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ query Vault($address: ID!) {
tokenName
feePercent
totalAssets
isBlocklist
displayName
description
whitelister
keysManager
tokenSymbol
feeRecipient
validatorsRoot
blocklistManager
weeklyApy
}
privateVaultAccounts(
Expand All @@ -28,4 +30,8 @@ query Vault($address: ID!) {
createdAt
address
}
vaultBlockedAccounts(where: { vault: $address }) {
createdAt
address
}
}
32 changes: 32 additions & 0 deletions src/methods/vault/requests/getVault/modifyVault.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('modifyVault', () => {
isErc20: true,
feePercent: 200,
isPrivate: false,
isBlocklist: false,
performance: '10',
tokenSymbol: 'mTKN',
imageUrl: 'mockUrl',
Expand All @@ -30,11 +31,16 @@ describe('modifyVault', () => {
whitelister: '0xeefffd4c23d2e8c845870e273861e7d60df49663',
keysManager: '0xeefffd4c23d2e8c845870e273861e7d60df49663',
feeRecipient: '0xeefffd4c23d2e8c845870e273861e7d60df49663',
blocklistManager: '0xeefffd4c23d2e8c845870e273861e7d60df49663',
},
privateVaultAccounts: [
{ createdAt: '1693395816', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663' },
{ createdAt: '1693395816', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663' },
],
vaultBlockedAccounts: [
{ createdAt: '1693395817', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663' },
{ createdAt: '1693395817', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663' },
],
}

it('should correctly transform the vault data', () => {
Expand All @@ -44,6 +50,7 @@ describe('modifyVault', () => {
feePercent: 2,
performance: 10,
isPrivate: false,
isBlocklist: false,
capacity: '0.001',
tokenSymbol: 'mTKN',
imageUrl: 'mockUrl',
Expand All @@ -60,6 +67,7 @@ describe('modifyVault', () => {
feeRecipient: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
mevRecipient: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
vaultKeysManager: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
blocklistManager: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
whitelist: [
{
createdAt: 1693395816000,
Expand All @@ -70,6 +78,16 @@ describe('modifyVault', () => {
address: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
},
],
blocklist: [
{
createdAt: 1693395817000,
address: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
},
{
createdAt: 1693395817000,
address: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
},
],
}

const result = modifyVault({
Expand Down Expand Up @@ -111,6 +129,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,
Expand Down
14 changes: 9 additions & 5 deletions src/methods/vault/requests/getVault/modifyVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions src/methods/vault/requests/getVault/types.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -13,8 +18,6 @@ export type ModifiedVault = Omit<
mevRecipient: string
vaultKeysManager: string
isSmoothingPool: boolean
whitelist: Array<{
createdAt: number
address: string
}>
whitelist: ListItem[]
blocklist: ListItem[]
}
Loading