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

[blocklist sync] fix sync #83

Merged
merged 4 commits into from
Mar 22, 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
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,14 @@ Fetch the whitelist for private vaults. Only addresses included in this list are

#### Arguments:

| Name | Type | Type | Description |
|------|-------------------|-------------|---|
| vaultAddress | `string` | **Yes** | - |
| orderDirection | `'asc' \| 'desc'` | **No** | Sort, by default `desc` (descending order) |
| search | `string` | **No** | Filters results by the address field |
| limit | `number` | **No** | Limit the number of addresses, default is 100 |
| skip | `number` | **No** | Skip the number of addresses, default is 0 |
| Name | Type | Type | Description |
|------|-------------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| vaultAddress | `string` | **Yes** | - |
| addressIn | `string[]` | **No** | Filters results to include only addresses in the provided list. Helps to check, for example, if several addresses are added to the whitelist |
| orderDirection | `'asc' \| 'desc'` | **No** | Specifies the sorting order. Defaults to `desc` (descending order) |
| search | `string` | **No** | Filters results by the address field |
| limit | `number` | **No** | Limits the number of addresses returned. Defaults to 100 |
| skip | `number` | **No** | Skips the specified number of addresses. Defaults to 0 |

#### Returns:

Expand Down Expand Up @@ -359,13 +360,14 @@ Fetch the blocklist for blocklisted vaults. Addresses included in this list are

#### Arguments:

| Name | Type | Type | Description |
|------|---------------|-------------|---|
| vaultAddress | `string` | **Yes** | - |
| orderDirection | `'asc' \| 'desc'` | **No** | Sort, by default `desc` (descending order) |
| search | `string` | **No** | Filters results by the address field |
| limit | `number` | **No** | Limit the number of addresses, default is 100 |
| skip | `number` | **No** | Skip the number of addresses, default is 0 |
| Name | Type | Type | Description |
|------|-------------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------|
| vaultAddress | `string` | **Yes** | - |
| addressIn | `string[]` | **No** | Filters results to include only addresses in the provided list. Helps to check, for example, if all OFAC addresses are added to the blocklist |
| orderDirection | `'asc' \| 'desc'` | **No** | Specifies the sorting order. Defaults to `desc` (descending order) |
| search | `string` | **No** | Filters results by the address field |
| limit | `number` | **No** | Limits the number of addresses returned. Defaults to 100 |
| skip | `number` | **No** | Skips the specified number of addresses. Defaults to 0 |

#### Returns:

Expand Down
2 changes: 2 additions & 0 deletions src/contracts/createContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ export const createContracts = (input: CreateContractsInput) => {
vault: getVaultFactory(provider, config.addresses.factories.vault),
erc20Vault: getVaultFactory(provider, config.addresses.factories.erc20Vault),
privateVault: getVaultFactory(provider, config.addresses.factories.privateVault),
blocklistVault: getVaultFactory(provider, config.addresses.factories.blocklistVault),
erc20PrivateVault: getVaultFactory(provider, config.addresses.factories.erc20PrivateVault),
erc20BlocklistVault: getVaultFactory(provider, config.addresses.factories.erc20BlocklistVault),
},
uniswap: {
positionManager: getUniswapPositionManager(provider, config),
Expand Down
21 changes: 18 additions & 3 deletions src/methods/vault/requests/getBlocklist/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isAddress } from 'ethers'
import type { BlocklistAccountsQueryVariables, BlocklistAccountsQueryPayload } from '../../../../graphql/subgraph/vault'
import { apiUrls, validateArgs } from '../../../../utils'
import graphql from '../../../../graphql'
Expand All @@ -11,11 +12,20 @@ type GetBlocklistInput = {
search?: string
limit?: number
skip?: number
addressIn?: BlocklistAccountsQueryVariables['where']['address_in']
options: StakeWise.Options
}

const validateList = (addressIn: string[]) => {
const isValid = addressIn.every((address) => isAddress(address))

if (!isValid) {
throw new Error('The "addressIn" argument must be an array of valid addresses')
}
}

const getBlocklist = (input: GetBlocklistInput) => {
const { vaultAddress, orderDirection, search, limit, skip, options } = input
const { vaultAddress, orderDirection, search, limit, skip, addressIn, options } = input

validateArgs.address({ vaultAddress })

Expand All @@ -37,11 +47,16 @@ const getBlocklist = (input: GetBlocklistInput) => {
}
}

if (typeof addressIn !== 'undefined') {
validateArgs.array({ addressIn })
validateList(addressIn)
}

const vault = vaultAddress.toLowerCase()

const where = search
? { vault, address_contains: search.toLowerCase() } as BlocklistAccountsQueryVariables['where']
: { vault } as BlocklistAccountsQueryVariables['where']
? { vault, address_in: addressIn, address_contains: search.toLowerCase() } as BlocklistAccountsQueryVariables['where']
: { vault, address_in: addressIn } as BlocklistAccountsQueryVariables['where']

return graphql.subgraph.vault.fetchBlocklistAccountsQuery<ModifiedBlocklist>({
url: apiUrls.getSubgraphqlUrl(options),
Expand Down
20 changes: 17 additions & 3 deletions src/methods/vault/requests/getWhitelist/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isAddress } from 'ethers'
import type { WhitelistAccountsQueryVariables, WhitelistAccountsQueryPayload } from '../../../../graphql/subgraph/vault'
import { apiUrls, validateArgs } from '../../../../utils'
import graphql from '../../../../graphql'
Expand All @@ -11,12 +12,20 @@ type GetWhitelistInput = {
search?: string
limit?: number
skip?: number
addressIn?: WhitelistAccountsQueryVariables['where']['address_in']
options: StakeWise.Options
}

const validateList = (addressIn: string[]) => {
const isValid = addressIn.every((address) => isAddress(address))

if (!isValid) {
throw new Error('The "addressIn" argument must be an array of valid addresses')
}
}

const getWhitelist = (input: GetWhitelistInput) => {
const { vaultAddress, orderDirection, search, limit, skip, options } = input
const { vaultAddress, orderDirection, search, limit, skip, addressIn, options } = input

validateArgs.address({ vaultAddress })

Expand All @@ -38,11 +47,16 @@ const getWhitelist = (input: GetWhitelistInput) => {
}
}

if (typeof addressIn !== 'undefined') {
validateArgs.array({ addressIn })
validateList(addressIn)
}

const vault = vaultAddress.toLowerCase()

const where = search
? { vault, address_contains: search.toLowerCase() } as WhitelistAccountsQueryVariables['where']
: { vault } as WhitelistAccountsQueryVariables['where']
? { vault, address_in: addressIn, address_contains: search.toLowerCase() } as WhitelistAccountsQueryVariables['where']
: { vault, address_in: addressIn } as WhitelistAccountsQueryVariables['where']

return graphql.subgraph.vault.fetchWhitelistAccountsQuery<ModifiedWhitelist>({
url: apiUrls.getSubgraphqlUrl(options),
Expand Down
2 changes: 2 additions & 0 deletions src/utils/configs/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export default {
vault: ZeroAddress,
erc20Vault: ZeroAddress,
privateVault: ZeroAddress,
blocklistVault: ZeroAddress,
erc20PrivateVault: ZeroAddress,
erc20BlocklistVault: ZeroAddress,
},
uniswap: {
positionManager: ZeroAddress,
Expand Down
2 changes: 2 additions & 0 deletions src/utils/configs/holesky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export default {
vault: '0x1428BB71261f01BbC03ce4eC7cEEA674f94b5F18',
erc20Vault: '0x4C1140F4A5E3DD459De642A46bd1df6FBe287e1B',
privateVault: '0x9741f8e49fFa322714511b5D17bD052698eAFA43',
blocklistVault: '0x0a57971758644A61279756591100c19e1691D068',
erc20PrivateVault: '0x930A2D0ADEbF4E69Bb929F6456C3D4bcabf52796',
erc20BlocklistVault: '0x0F8c209445282d937DaC0eA0a6706590250F9aFD',
},
uniswap: {
positionManager: ZeroAddress,
Expand Down
2 changes: 2 additions & 0 deletions src/utils/configs/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export default {
vault: '0xDada5a8E3703B1e3EA2bAe5Ab704627eb2659fCC',
erc20Vault: '0x6DDc10eEeEBbBcF00E784bA44Fe4B038af26cB53',
privateVault: '0x170618936cd96B1eD8112eC3D3778374B38DFe5e',
blocklistVault: ZeroAddress,
erc20PrivateVault: '0xe84183EfFbcc76D022Cccc31b95EAa332bB5Bb11',
erc20BlocklistVault: ZeroAddress,
},
uniswap: {
positionManager: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
Expand Down
Loading