Skip to content

Commit

Permalink
[subgraph update] update multicall
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-diamond committed Sep 5, 2024
1 parent cb8de8f commit c75c758
Show file tree
Hide file tree
Showing 22 changed files with 131 additions and 84 deletions.
78 changes: 42 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,41 +640,46 @@ type Output = {
description: string | null
restakeOperatorsManager: string
restakeWithdrawalsManager: string
osTokenConfig: {
ltvPercent: bigint
thresholdPercent: bigint
}
}
```
| 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 |
| `isRestake` | Indicates whether the Vault is a restaking vault |
| `isBlocklist` | Whether the storage has blocklist |
| `vaultAdmin` | Vault administrator address |
| `totalAssets` | TVL of Vault |
| `feeRecipient` | Vault fee address |
| `whitelistManager` | Whitelist manager |
| `vaultAddress` | Address of vault |
| `mevRecipient` | Validator fee recipient |
| `whitelistCount` | Number of addresses in the [whitelist](#sdkvaultgetwhitelist) |
| `blocklistCount` | Number of addresses in the [blocklist](#sdkvaultgetblocklist) |
| `imageUrl` | Link for vault logo |
| `blocklistManager` | Blocklist manager |
| `depositDataManager` | 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) |
| `version` | Vault version |
| `restakeOperatorsManager` | If the Vault is a restaking vault, restake operators manager can add/remove restake operators |
| `restakeWithdrawalsManager` | If the Vault is a restaking vault, restake withdrawals manager can manage EigenLayer withdrawals |
| 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 |
| `isRestake` | Indicates whether the Vault is a restaking vault |
| `isBlocklist` | Whether the storage has blocklist |
| `vaultAdmin` | Vault administrator address |
| `totalAssets` | TVL of Vault |
| `feeRecipient` | Vault fee address |
| `whitelistManager` | Whitelist manager |
| `vaultAddress` | Address of vault |
| `mevRecipient` | Validator fee recipient |
| `whitelistCount` | Number of addresses in the [whitelist](#sdkvaultgetwhitelist) |
| `blocklistCount` | Number of addresses in the [blocklist](#sdkvaultgetblocklist) |
| `imageUrl` | Link for vault logo |
| `blocklistManager` | Blocklist manager |
| `depositDataManager` | 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) |
| `version` | Vault version |
| `restakeOperatorsManager` | If the Vault is a restaking vault, restake operators manager can add/remove restake operators |
| `restakeWithdrawalsManager` | If the Vault is a restaking vault, restake withdrawals manager can manage EigenLayer withdrawals |
| `osTokenConfig` | contains the ltvPercent, which is the percentage used to calculate how much a user can mint in OsToken shares, and thresholdPercent, which is the liquidation threshold percentage used to calculate the health factor for the OsToken position |
#### Example:
Expand Down Expand Up @@ -726,6 +731,7 @@ Necessary to update the vault state
type Output = {
reward: string
proof: Array<string>
canHarvest: boolean
rewardsRoot: string
unlockedMevReward: string
}
Expand All @@ -745,10 +751,10 @@ Getting user's balance in the vault
#### Arguments:
| Name | Type | Required |
|------|------|-------------|
| userAddress | `string` | **Yes** |
| vaultAddress | `string` | **Yes** |
| Name | Type | Required |
|--------------|----------|----------|
| userAddress | `string` | **Yes** |
| vaultAddress | `string` | **Yes** |
#### Returns:
Expand Down
35 changes: 35 additions & 0 deletions changelog/next-release.md
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
- Breaking change: Removed `sdk.osToken.getConfig`. Use `sdk.vault.getVault` instead to get osToken config data `{ osTokenConfig: { ltvPercent, thresholdPercent } }`.
- Added canHarvest: boolean to `sdk.vault.getHarvestParams` response.

# Updates
### 1. `sdk.vault.getVault`

#### New output field:

```ts
type AddedOutput = {
osTokenConfig: {
ltvPercent: string
thresholdPercent: string
}
}
```
| Name | Description |
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `osTokenConfig` | contains the `ltvPercent`, which is the percentage used to calculate how much a user can mint in OsToken shares, and `thresholdPercent`, which is the liquidation threshold percentage used to calculate the health factor for the OsToken position |
---
### 2. `sdk.vault.getHarvestParams`
#### New output field:
```ts
type AddedOutput = {
canHarvest: boolean
}
```
---
### 3. Removed method
### `sdk.vault.getVault`
2 changes: 0 additions & 2 deletions src/StakeWiseSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class StakeWiseSDK {
vaultMulticall<T extends unknown>({ userAddress, vaultAddress, request }: VaultMulticallInput) {
return vaultMulticall<T>({
vaultContract: this.contracts.helpers.createVault(vaultAddress),
keeperContract: this.contracts.base.keeper,
options: this.options,
vaultAddress,
userAddress,
Expand All @@ -67,7 +66,6 @@ class StakeWiseSDK {

return rewardSplitterMulticall<T>({
rewardSplitterContract: this.contracts.helpers.createRewardSplitter(rewardSplitterAddress),
keeperContract: this.contracts.base.keeper,
options: this.options,
vaultAddress,
userAddress,
Expand Down
5 changes: 3 additions & 2 deletions src/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { default as createContracts } from './createContracts'
export { default as createContract } from './createContract'
export { default as multicall } from './multicall/commonMulticall'
export { default as vaultMulticall } from './multicall/vaultMulticall'
export { default as eigenPodOwnerMulticall } from './multicall/eigenPodOwnerMulticall'
export { default as rewardSplitterMulticall } from './multicall/rewardSplitterMulticall'

export { vaultMulticall, rewardSplitterMulticall } from './multicall'
export type { VaultMulticallBaseInput, RewardSplitterMulticallBaseInput } from './multicall'
7 changes: 5 additions & 2 deletions src/contracts/multicall/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export { default as vaultMulticall } from './vaultMulticall'
export { default as commonMulticall } from './commonMulticall'
export { default as rewardSplitterMulticall } from './rewardSplitterMulticall'

export { default as vaultMulticall } from './vaultMulticall'
export type { VaultMulticallBaseInput } from './vaultMulticall'

export { default as rewardSplitterMulticall } from './rewardSplitterMulticall'
export type { RewardSplitterMulticallBaseInput } from './rewardSplitterMulticall'
17 changes: 9 additions & 8 deletions src/contracts/multicall/rewardSplitterMulticall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@ import {
handleTransactionData,
} from './util'

import type { KeeperAbi, RewardSplitterAbi } from '../types'
import type { RewardSplitterAbi } from '../types'
import type { MulticallRequestInput } from './types'


type RewardSplittersMulticallInput = {
export type RewardSplitterMulticallBaseInput = {
userAddress: string
vaultAddress: string
options: StakeWise.Options
request: MulticallRequestInput
keeperContract: KeeperAbi
rewardSplitterContract: RewardSplitterAbi
}

const rewardSplittersMulticall = async <T extends unknown>(values: RewardSplittersMulticallInput): Promise<T> => {
const { request, options, userAddress, vaultAddress, keeperContract, rewardSplitterContract } = values
type RewardSplitterMulticallInput = RewardSplitterMulticallBaseInput & {
request: MulticallRequestInput
}

const rewardSplitterMulticall = async <T extends unknown>(values: RewardSplitterMulticallInput): Promise<T> => {
const { request, options, userAddress, vaultAddress, rewardSplitterContract } = values
const { params, callStatic, estimateGas, transactionData } = request

let multicallParams = [ ...params ]
Expand All @@ -36,7 +38,6 @@ const rewardSplittersMulticall = async <T extends unknown>(values: RewardSplitte
const harvestArgs = await getHarvestArgs<RewardSplitterAbi>({
options,
vaultAddress,
keeperContract,
})

if (harvestArgs) {
Expand Down Expand Up @@ -70,4 +71,4 @@ const rewardSplittersMulticall = async <T extends unknown>(values: RewardSplitte
}


export default rewardSplittersMulticall
export default rewardSplitterMulticall
14 changes: 6 additions & 8 deletions src/contracts/multicall/util/getHarvestArgs.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import getHarvestParams from '../../../methods/vault/requests/getHarvestParams'
import type { KeeperAbi } from '../../types'
import type { HarvestParamsQueryPayload } from '../../../graphql/subgraph/vault'


type Input<T> = {
options: StakeWise.Options
vaultAddress: string
keeperContract: KeeperAbi
}

const getHarvestArgs = async <T>(props: Input<T>): Promise<HarvestParamsQueryPayload['harvestParams'] | null> => {
const { options, vaultAddress, keeperContract } = props
const { options, vaultAddress } = props

const [ harvestParams, canHarvest ] = await Promise.all([
getHarvestParams({ options, vaultAddress }),
keeperContract.canHarvest(vaultAddress),
])
const harvestParams = await getHarvestParams({
options,
vaultAddress,
})

if (canHarvest) {
if (harvestParams?.canHarvest) {
return harvestParams
}

Expand Down
13 changes: 7 additions & 6 deletions src/contracts/multicall/vaultMulticall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@ import {
} from './util'

import type { MulticallRequestInput } from './types'
import type { KeeperAbi, OtherTokenVaultAbi, VaultAbi } from '../types'
import type { OtherTokenVaultAbi, VaultAbi } from '../types'
import { Network } from '../../utils'


type VaultContractAbi = VaultAbi | OtherTokenVaultAbi

type VaultMulticallInput = {
export type VaultMulticallBaseInput = {
userAddress: string
vaultAddress: string
keeperContract: KeeperAbi
options: StakeWise.Options
request: MulticallRequestInput
vaultContract: VaultContractAbi
}

type VaultMulticallInput = VaultMulticallBaseInput & {
request: MulticallRequestInput
}

// Methods with _checkHarvested() call
const harvestCheckMethods = [
'deposit',
Expand All @@ -43,7 +45,7 @@ const harvestCheckMethods = [
* This method will also add swapXdaiToGno execution if needed.
*/
const vaultMulticall = async <T extends unknown>(values: VaultMulticallInput): Promise<T> => {
const { options, vaultAddress, userAddress, request, vaultContract, keeperContract } = values
const { options, vaultAddress, userAddress, request, vaultContract } = values
const { params, callStatic, estimateGas, transactionData } = request

const contract = await getSignedContract({
Expand All @@ -61,7 +63,6 @@ const vaultMulticall = async <T extends unknown>(values: VaultMulticallInput): P
const harvestArgs = await getHarvestArgs<VaultContractAbi>({
options,
vaultAddress,
keeperContract,
})

if (harvestArgs) {
Expand Down
1 change: 1 addition & 0 deletions src/graphql/subgraph/vault/harvestParamsQuery.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
query HarvestParams($address: ID!) {
harvestParams: vault(id: $address) {
proof
canHarvest
rewardsRoot
reward: proofReward
unlockedMevReward: proofUnlockedMevReward
Expand Down
Loading

0 comments on commit c75c758

Please sign in to comment.