diff --git a/.graphqlconfig b/.graphqlconfig index 6654cf03..fc4f3519 100644 --- a/.graphqlconfig +++ b/.graphqlconfig @@ -11,7 +11,7 @@ "extensions": { "endpoints": { "Subgraph GraphQL": { - "url": "https://holesky-graph.stakewise.io/subgraphs/name/stakewise/stakewise/graphql", + "url": "https://mainnet-graph-stage.stakewise.io/subgraphs/name/stakewise/stakewise/graphql", "headers": { "user-agent": "JS GraphQL" }, diff --git a/README.md b/README.md index 865f0852..f5c1709c 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ const sdk = new StakeWiseSDK({ | [vault.getMaxWithdraw](#sdkvaultgetmaxwithdraw) | [osToken.getSharesFromAssets](#sdkostokengetsharesfromassets) | | | [vault.getHarvestParams](#sdkvaultgetharvestparams) | [osToken.getAssetsFromShares](#sdkostokengetassetsfromshares) | | | [vault.getStakeBalance](#sdkvaultgetstakebalance) | [osToken.getRate](#sdkostokengetrate) | | -| [vault.getScorePercentiles](#sdkvaultgetscorepercentiles) | [osToken.getConfig](#sdkostokengetconfig) | | +| [vault.getScorePercentiles](#sdkvaultgetscorepercentiles) | | | | [vault.getUserRewards](#sdkvaultgetuserrewards) | | | | [vault.getWhitelist](#sdkvaultgetwhitelist) | | | | [vault.getBlocklist](#sdkvaultgetblocklist) | | | @@ -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: @@ -690,12 +695,12 @@ How much a user can withdraw. Use this method if the user has mintedAssets, if m #### Arguments: -| Name | Type | Required | Info | -|------|------|-------------|-------| -| vaultAddress | `string` | **Yes** | Address of vault | -| ltvPercent | `bigint` | **Yes** | [sdk.osToken.getConfig](#sdkostokengetconfig) | -| mintedAssets | `bigint` | **Yes** | [sdk.osToken.getPosition](#sdkostokengetposition) | -| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | +| Name | Type | Required | Info | +|--------------|----------|----------|-------------------------------------------------------| +| vaultAddress | `string` | **Yes** | Address of vault | +| ltvPercent | `bigint` | **Yes** | [sdk.vault.getVault](#sdkvaultgetvault) | +| mintedAssets | `bigint` | **Yes** | [sdk.osToken.getPosition](#sdkostokengetposition) | +| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | #### Returns: @@ -726,6 +731,7 @@ Necessary to update the vault state type Output = { reward: string proof: Array + canHarvest: boolean rewardsRoot: string unlockedMevReward: string } @@ -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: @@ -782,13 +788,13 @@ await sdk.vault.getStakeBalance({ How many osToken burn do you need to make to withdraw all deposit. #### Arguments: -| Name | Type | Required | Description | -|------|------|-------------|---------| -| vaultAddress | `string` | **Yes** | Address of vault | -| ltvPercent | `bigint` | **Yes** | [sdk.osToken.getConfig](#sdkostokengetconfig) | -| mintedAssets | `bigint` | **Yes** | [sdk.osToken.getPosition](#sdkostokengetposition) | -| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | -| newStakedAssets | `bigint` | **Yes** | The future amount of stake after the deposit | +| Name | Type | Required | Description | +|-----------------|----------|----------|-------------------------------------------------------| +| vaultAddress | `string` | **Yes** | Address of vault | +| ltvPercent | `bigint` | **Yes** | [sdk.vault.getVault](#sdkvaultgetvault) | +| mintedAssets | `bigint` | **Yes** | [sdk.osToken.getPosition](#sdkostokengetposition) | +| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | +| newStakedAssets | `bigint` | **Yes** | The future amount of stake after the deposit | #### Returns: @@ -815,11 +821,11 @@ sdk.osToken.getBurnAmount({ Get the health of the position #### Arguments: -| Name | Type | Required | Description | -|------|------|-------------|---------| -| thresholdPercent | `bigint` | **Yes** | [sdk.osToken.getConfig](#sdkostokengetconfig) | -| mintedAssets | `bigint` | **Yes** | [sdk.osToken.getPosition](#sdkostokengetposition) | -| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | +| Name | Type | Required | Description | +|------------------|----------|----------|-------------------------------------------------------| +| thresholdPercent | `bigint` | **Yes** | [sdk.vault.getVault](#sdkvaultgetvault) | +| mintedAssets | `bigint` | **Yes** | [sdk.osToken.getPosition](#sdkostokengetposition) | +| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | #### Returns: @@ -888,12 +894,12 @@ const averageRewardsPerSecond = await sdk.osToken.getAvgRewardsPerSecond() User position data #### Arguments: -| Name | Type | Required | Description | -|------|------|-------------|---------| -| thresholdPercent | `bigint` | **Yes** | [sdk.osToken.getConfig](#sdkostokengetconfig) | -| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | -| userAddress | `string` | **Yes** | - | -| vaultAddress | `string` | **Yes** | - | +| Name | Type | Required | Description | +|------------------|----------|----------|-------------------------------------------------------| +| thresholdPercent | `bigint` | **Yes** | [sdk.vault.getVault](#sdkvaultgetvault) | +| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | +| userAddress | `string` | **Yes** | - | +| vaultAddress | `string` | **Yes** | - | #### Returns: @@ -938,12 +944,12 @@ await sdk.osToken.getPosition({ Maximum number of **shares** for minting #### Arguments: -| Name | Type | Required | Description | -|------|------|-------------|---------| -| vaultAddress | `string` | **Yes** | Address of vault | -| ltvPercent | `bigint` | **Yes** | [sdk.osToken.getConfig](#sdkostokengetconfig) | -| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | -| mintedAssets | `bigint` | **Yes** | [sdk.osToken.getPosition](#sdkostokengetposition) | +| Name | Type | Required | Description | +|--------------|----------|----------|-------------------------------------------------------| +| vaultAddress | `string` | **Yes** | Address of vault | +| ltvPercent | `bigint` | **Yes** | [sdk.vault.getVault](#sdkvaultgetvault) | +| stakedAssets | `bigint` | **Yes** | [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | +| mintedAssets | `bigint` | **Yes** | [sdk.osToken.getPosition](#sdkostokengetposition) | #### Returns: @@ -1027,37 +1033,6 @@ type Output = string await sdk.utils.getRate() ``` --- -### `sdk.osToken.getConfig` - -#### Description: - -Basic information on the token - -#### Arguments: - -| Name | Type | Required | Description | -|--------------|----------|----------|---------------| -| vaultAddress | `string` | **Yes** | Vault address | - -#### Returns: - -```ts -type Output = { - ltvPercent: bigint - thresholdPercent: bigint -} -``` -| Name | Description | -|------|-------------| -| `ltvPercent` | The percent used to calculate how much user can mint OsToken shares | -| `thresholdPercent` | The liquidation threshold percent used to calculate health factor for OsToken position | - -#### Example: - -```ts -await sdk.osToken.getConfig({ vaultAddress: '0x...' }) -``` ---- ## RewardSplitter ### `sdk.rewardSplitter.create` @@ -1364,10 +1339,12 @@ Withdrawal of funds from a vault const amountAssets = 200n // from input mb const [ - { ltvPercent, thresholdPercent }, + { osTokenConfig: { ltvPercent, thresholdPercent } }, stake, ] = await Promise.all([ - sdk.osToken.getConfig(), + sdk.vault.getVault({ + vaultAddress: '0x...', + }), sdk.vault.getStakeBalance({ vaultAddress: '0x...', userAddress: '0x...', @@ -1726,10 +1703,12 @@ import { OsTokenPositionHealth } from '@stakewise/v3-sdk' const amountShares = 200n // from input mb const [ - { ltvPercent, thresholdPercent }, + { osTokenConfig: { ltvPercent, thresholdPercent } }, stake, ] = await Promise.all([ - sdk.osToken.getConfig(), + sdk.vault.getVault({ + vaultAddress: '0x...', + }), sdk.vault.getStakeBalance({ vaultAddress: '0x...', userAddress: '0x...', diff --git a/changelog/next-release.md b/changelog/next-release.md index e69de29b..40ed4e34 100644 --- a/changelog/next-release.md +++ b/changelog/next-release.md @@ -0,0 +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` diff --git a/src/StakeWiseSDK.ts b/src/StakeWiseSDK.ts index 91d8bbe6..36506887 100644 --- a/src/StakeWiseSDK.ts +++ b/src/StakeWiseSDK.ts @@ -54,7 +54,6 @@ class StakeWiseSDK { vaultMulticall({ userAddress, vaultAddress, request }: VaultMulticallInput) { return vaultMulticall({ vaultContract: this.contracts.helpers.createVault(vaultAddress), - keeperContract: this.contracts.base.keeper, options: this.options, vaultAddress, userAddress, @@ -67,7 +66,6 @@ class StakeWiseSDK { return rewardSplitterMulticall({ rewardSplitterContract: this.contracts.helpers.createRewardSplitter(rewardSplitterAddress), - keeperContract: this.contracts.base.keeper, options: this.options, vaultAddress, userAddress, diff --git a/src/contracts/index.ts b/src/contracts/index.ts index 5b29cd3a..2f204437 100644 --- a/src/contracts/index.ts +++ b/src/contracts/index.ts @@ -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' diff --git a/src/contracts/multicall/index.ts b/src/contracts/multicall/index.ts index d11ea99b..2b5ebee7 100644 --- a/src/contracts/multicall/index.ts +++ b/src/contracts/multicall/index.ts @@ -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' diff --git a/src/contracts/multicall/rewardSplitterMulticall.ts b/src/contracts/multicall/rewardSplitterMulticall.ts index 57e15d5b..464b872c 100644 --- a/src/contracts/multicall/rewardSplitterMulticall.ts +++ b/src/contracts/multicall/rewardSplitterMulticall.ts @@ -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 (values: RewardSplittersMulticallInput): Promise => { - const { request, options, userAddress, vaultAddress, keeperContract, rewardSplitterContract } = values +type RewardSplitterMulticallInput = RewardSplitterMulticallBaseInput & { + request: MulticallRequestInput +} + +const rewardSplitterMulticall = async (values: RewardSplitterMulticallInput): Promise => { + const { request, options, userAddress, vaultAddress, rewardSplitterContract } = values const { params, callStatic, estimateGas, transactionData } = request let multicallParams = [ ...params ] @@ -36,7 +38,6 @@ const rewardSplittersMulticall = async (values: RewardSplitte const harvestArgs = await getHarvestArgs({ options, vaultAddress, - keeperContract, }) if (harvestArgs) { @@ -70,4 +71,4 @@ const rewardSplittersMulticall = async (values: RewardSplitte } -export default rewardSplittersMulticall +export default rewardSplitterMulticall diff --git a/src/contracts/multicall/util/getHarvestArgs.ts b/src/contracts/multicall/util/getHarvestArgs.ts index ba1726d0..351c78eb 100644 --- a/src/contracts/multicall/util/getHarvestArgs.ts +++ b/src/contracts/multicall/util/getHarvestArgs.ts @@ -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 = { options: StakeWise.Options vaultAddress: string - keeperContract: KeeperAbi } const getHarvestArgs = async (props: Input): Promise => { - 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 } diff --git a/src/contracts/multicall/vaultMulticall.ts b/src/contracts/multicall/vaultMulticall.ts index 0cf7c291..2691ba15 100644 --- a/src/contracts/multicall/vaultMulticall.ts +++ b/src/contracts/multicall/vaultMulticall.ts @@ -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', @@ -43,7 +45,7 @@ const harvestCheckMethods = [ * This method will also add swapXdaiToGno execution if needed. */ const vaultMulticall = async (values: VaultMulticallInput): Promise => { - 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({ @@ -61,7 +63,6 @@ const vaultMulticall = async (values: VaultMulticallInput): P const harvestArgs = await getHarvestArgs({ options, vaultAddress, - keeperContract, }) if (harvestArgs) { diff --git a/src/graphql/subgraph/vault/harvestParamsQuery.graphql b/src/graphql/subgraph/vault/harvestParamsQuery.graphql index 9a35fed6..9af08379 100644 --- a/src/graphql/subgraph/vault/harvestParamsQuery.graphql +++ b/src/graphql/subgraph/vault/harvestParamsQuery.graphql @@ -1,6 +1,7 @@ query HarvestParams($address: ID!) { harvestParams: vault(id: $address) { proof + canHarvest rewardsRoot reward: proofReward unlockedMevReward: proofUnlockedMevReward diff --git a/src/graphql/subgraph/vault/vaultQuery.graphql b/src/graphql/subgraph/vault/vaultQuery.graphql index 4e09ac60..6e6d2f16 100644 --- a/src/graphql/subgraph/vault/vaultQuery.graphql +++ b/src/graphql/subgraph/vault/vaultQuery.graphql @@ -2,6 +2,10 @@ query Vault($address: ID!) { vault(id: $address) { address: id performance: score + osTokenConfig { + ltvPercent + liqThresholdPercent + } apy admin version @@ -26,6 +30,7 @@ query Vault($address: ID!) { validatorsRoot blocklistCount whitelistCount + isCollateralized blocklistManager validatorsManager depositDataManager diff --git a/src/methods/osToken/transactions/mint/common.ts b/src/methods/osToken/transactions/mint/common.ts index 5a906856..c39696bd 100644 --- a/src/methods/osToken/transactions/mint/common.ts +++ b/src/methods/osToken/transactions/mint/common.ts @@ -13,7 +13,6 @@ export const commonLogic = (values: MintInput) => { const multicallArgs: Omit[0], 'request'> = { vaultContract: contracts.helpers.createVault(vaultAddress), - keeperContract: contracts.base.keeper, vaultAddress, userAddress, options, diff --git a/src/methods/rewardSplitter/requests/getClaimAmount/getAssetsFromShares.ts b/src/methods/rewardSplitter/requests/getClaimAmount/getAssetsFromShares.ts index ed1ee599..6ea0f7ec 100644 --- a/src/methods/rewardSplitter/requests/getClaimAmount/getAssetsFromShares.ts +++ b/src/methods/rewardSplitter/requests/getClaimAmount/getAssetsFromShares.ts @@ -24,7 +24,6 @@ const getAssetsFromShares = async (input: GetAssetsFromSharesInput) => { options, userAddress, vaultAddress, - keeperContract: contracts.base.keeper, vaultContract: contracts.helpers.createVault(vaultAddress), }) diff --git a/src/methods/rewardSplitter/requests/getClaimAmount/getShares.ts b/src/methods/rewardSplitter/requests/getClaimAmount/getShares.ts index 28264c74..be29c174 100644 --- a/src/methods/rewardSplitter/requests/getClaimAmount/getShares.ts +++ b/src/methods/rewardSplitter/requests/getClaimAmount/getShares.ts @@ -25,7 +25,6 @@ const getShares = async (input: GetSharesInput) => { options, userAddress, vaultAddress, - keeperContract: contracts.base.keeper, rewardSplitterContract: contracts.helpers.createRewardSplitter(rewardSplitterAddress), }) diff --git a/src/methods/rewardSplitter/transactions/claimRewards/common.ts b/src/methods/rewardSplitter/transactions/claimRewards/common.ts index b3471dfc..0b45fed0 100644 --- a/src/methods/rewardSplitter/transactions/claimRewards/common.ts +++ b/src/methods/rewardSplitter/transactions/claimRewards/common.ts @@ -1,5 +1,6 @@ import { validateArgs } from '../../../../utils' import { rewardSplitterMulticall } from '../../../../contracts' +import type { RewardSplitterMulticallBaseInput } from '../../../../contracts' import type { ClaimRewardsInput } from './types' import getSharesFromAssets from './getSharesFromAssets' @@ -14,9 +15,8 @@ export const commonLogic = async (values: ClaimRewardsInput) => { validateArgs.address({ vaultAddress, userAddress, rewardSplitterAddress }) validateArgs.bigint({ assets }) - const baseMulticall = { + const baseMulticall: RewardSplitterMulticallBaseInput = { rewardSplitterContract: contracts.helpers.createRewardSplitter(rewardSplitterAddress), - keeperContract: contracts.base.keeper, vaultAddress, userAddress, options, diff --git a/src/methods/rewardSplitter/transactions/claimRewards/getSharesFromAssets.ts b/src/methods/rewardSplitter/transactions/claimRewards/getSharesFromAssets.ts index 1bf59362..ebec80e7 100644 --- a/src/methods/rewardSplitter/transactions/claimRewards/getSharesFromAssets.ts +++ b/src/methods/rewardSplitter/transactions/claimRewards/getSharesFromAssets.ts @@ -24,7 +24,6 @@ const getSharesFromAssets = async (input: GetSharesFromAssetsInput) => { options, userAddress, vaultAddress, - keeperContract: contracts.base.keeper, vaultContract: contracts.helpers.createVault(vaultAddress), }) diff --git a/src/methods/rewardSplitter/transactions/updateFeeRecipients/common.ts b/src/methods/rewardSplitter/transactions/updateFeeRecipients/common.ts index 3bf6d601..a7e48819 100644 --- a/src/methods/rewardSplitter/transactions/updateFeeRecipients/common.ts +++ b/src/methods/rewardSplitter/transactions/updateFeeRecipients/common.ts @@ -3,6 +3,7 @@ import { isAddress } from 'ethers' import vault from '../../../vault' import { validateArgs } from '../../../../utils' import { rewardSplitterMulticall } from '../../../../contracts' +import type { RewardSplitterMulticallBaseInput } from '../../../../contracts' import { checkAdminAccess } from '../../../vault/transactions/util' import type { FeeRecipient, UpdateFeeRecipientsInput } from './types' @@ -41,9 +42,8 @@ export const commonLogic = async (values: UpdateFeeRecipientsInput) => { await checkAdminAccess(values) - const baseMulticall = { + const baseMulticall: RewardSplitterMulticallBaseInput = { rewardSplitterContract: contracts.helpers.createRewardSplitter(rewardSplitterAddress), - keeperContract: contracts.base.keeper, vaultAddress, userAddress, options, diff --git a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts index d6fb3f40..e81771af 100644 --- a/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts +++ b/src/methods/vault/requests/getExitQueuePositions/parseExitRequests.spec.ts @@ -20,7 +20,7 @@ describe('parseExitRequests function', () => { const network = Network.Holesky const config = configs[network] - const provider = new JsonRpcProvider(config.network.url) + const provider = new JsonRpcProvider('') const contracts = createContracts({ provider, config }) const input: ParseExitRequestsInput = { diff --git a/src/methods/vault/requests/getStakeBalance.ts b/src/methods/vault/requests/getStakeBalance.ts index a1ac5b76..59eaedeb 100644 --- a/src/methods/vault/requests/getStakeBalance.ts +++ b/src/methods/vault/requests/getStakeBalance.ts @@ -29,7 +29,6 @@ const getStakeBalance = async (values: GetStakeBalanceInput) => { userAddress, vaultAddress, vaultContract, - keeperContract: contracts.base.keeper, request: { callStatic: true, params: [ diff --git a/src/methods/vault/requests/getVault/index.ts b/src/methods/vault/requests/getVault/index.ts index d0791b76..d8c3246c 100644 --- a/src/methods/vault/requests/getVault/index.ts +++ b/src/methods/vault/requests/getVault/index.ts @@ -1,5 +1,4 @@ import type { VaultQueryVariables, VaultQueryPayload } from '../../../../graphql/subgraph/vault' -import { wrapAbortPromise } from '../../../../modules/gql-module' import { apiUrls, validateArgs } from '../../../../utils' import graphql from '../../../../graphql' import { ModifiedVault } from './types' @@ -8,35 +7,22 @@ import modifyVault from './modifyVault' type GetVaultInput = { options: StakeWise.Options - contracts: StakeWise.Contracts vaultAddress: VaultQueryVariables['address'] } -type GetVaultOutput = ModifiedVault & { - isCollateralized: boolean -} - const getVault = async (input: GetVaultInput) => { - const { contracts, options, vaultAddress } = input + const { options, vaultAddress } = input validateArgs.address({ vaultAddress }) - const [ data, isCollateralized ] = await Promise.all([ - graphql.subgraph.vault.fetchVaultQuery({ - url: apiUrls.getSubgraphqlUrl(options), - variables: { - address: vaultAddress.toLowerCase(), - }, - modifyResult: (data: VaultQueryPayload) => modifyVault({ data, network: options.network }), - }), - contracts.base.keeper.isCollateralized(vaultAddress), - ]) - - return { - ...data, - isCollateralized, - } + return graphql.subgraph.vault.fetchVaultQuery({ + url: apiUrls.getSubgraphqlUrl(options), + variables: { + address: vaultAddress.toLowerCase(), + }, + modifyResult: (data: VaultQueryPayload) => modifyVault({ data, network: options.network }), + }) } -export default wrapAbortPromise(getVault) +export default getVault diff --git a/src/methods/vault/requests/getVault/modifyVault.spec.ts b/src/methods/vault/requests/getVault/modifyVault.spec.ts index 03b8effd..784e31b9 100644 --- a/src/methods/vault/requests/getVault/modifyVault.spec.ts +++ b/src/methods/vault/requests/getVault/modifyVault.spec.ts @@ -29,6 +29,7 @@ describe('modifyVault', () => { capacity: '1000000000000000', validatorsRoot: 'mockValidators', description: 'This is a mock vault', + isCollateralized: true, admin: '0xeefffd4c23d2e8c845870e273861e7d60df49663', address: '0xeefffd4c23d2e8c845870e273861e7d60df49663', mevEscrow: '0xeefffd4c23d2e8c845870e273861e7d60df49663', @@ -40,6 +41,10 @@ describe('modifyVault', () => { depositDataManager: '0xeefffd4c23d2e8c845870e273861e7d60df49663', restakeOperatorsManager: '0xeefffd4c23d2e8c845870e273861e7d60df49663', restakeWithdrawalsManager: '0xeefffd4c23d2e8c845870e273861e7d60df49663', + osTokenConfig: { + ltvPercent: '0', + liqThresholdPercent: '0', + }, }, } diff --git a/src/methods/vault/requests/getVault/modifyVault.ts b/src/methods/vault/requests/getVault/modifyVault.ts index 437d53ca..48b6ac35 100644 --- a/src/methods/vault/requests/getVault/modifyVault.ts +++ b/src/methods/vault/requests/getVault/modifyVault.ts @@ -30,6 +30,7 @@ const modifyVault = (input: ModifyVaultInput): ModifiedVault => { performance, totalAssets, feeRecipient, + osTokenConfig, blocklistCount, whitelistCount, validatorsManager, @@ -69,6 +70,10 @@ const modifyVault = (input: ModifyVaultInput): ModifiedVault => { capacity: vault.capacity !== MaxUint256.toString() ? formatEther(vault.capacity) : '∞', + osTokenConfig: { + ltvPercent: BigInt(osTokenConfig.ltvPercent), + thresholdPercent: BigInt(osTokenConfig.liqThresholdPercent), + }, } } diff --git a/src/methods/vault/requests/getVault/types.ts b/src/methods/vault/requests/getVault/types.ts index 5216e414..327a9a47 100644 --- a/src/methods/vault/requests/getVault/types.ts +++ b/src/methods/vault/requests/getVault/types.ts @@ -12,6 +12,7 @@ export type ModifiedVault = Omit< | 'keysManager' | 'performance' | 'whitelister' + | 'osTokenConfig' | 'blocklistCount' | 'whitelistCount' > & { @@ -26,6 +27,10 @@ export type ModifiedVault = Omit< whitelistCount: number isSmoothingPool: boolean whitelistManager: string + osTokenConfig: { + ltvPercent: bigint // The percent used to calculate how much user can mint OsToken shares + thresholdPercent: bigint // The liquidation threshold percent used to calculate health factor for OsToken position + } /** * @deprecated use depositDataManager diff --git a/src/methods/vault/transactions/claimExitQueue/common.ts b/src/methods/vault/transactions/claimExitQueue/common.ts index d03f8542..17424917 100644 --- a/src/methods/vault/transactions/claimExitQueue/common.ts +++ b/src/methods/vault/transactions/claimExitQueue/common.ts @@ -1,5 +1,6 @@ import { validateArgs } from '../../../../utils' import { vaultMulticall } from '../../../../contracts' +import type { VaultMulticallBaseInput } from '../../../../contracts' import type { ClaimExitQueueInput } from './types' @@ -17,9 +18,8 @@ export const commonLogic = (values: ClaimExitQueueInput) => { validatePositions(positions) - const baseMulticallArgs = { + const baseMulticallArgs: VaultMulticallBaseInput = { vaultContract: contracts.helpers.createVault(vaultAddress), - keeperContract: contracts.base.keeper, vaultAddress, userAddress, options, diff --git a/src/methods/vault/transactions/deposit/otherToken/common.ts b/src/methods/vault/transactions/deposit/otherToken/common.ts index 7262c1aa..0b02d0a2 100644 --- a/src/methods/vault/transactions/deposit/otherToken/common.ts +++ b/src/methods/vault/transactions/deposit/otherToken/common.ts @@ -3,6 +3,7 @@ import { ZeroAddress } from 'ethers' import type { DepositInput } from '../types' import { validateArgs } from '../../../../../utils' import { vaultMulticall } from '../../../../../contracts' +import type { VaultMulticallBaseInput } from '../../../../../contracts' export const commonLogic = (values: DepositInput) => { @@ -18,12 +19,15 @@ export const commonLogic = (values: DepositInput) => { }, ] - return { + const baseInput: VaultMulticallBaseInput = { vaultContract: contracts.helpers.createOtherTokenVault(vaultAddress), - keeperContract: contracts.base.keeper, - request: { params }, vaultAddress, userAddress, options, } + + return { + ...baseInput, + request: { params }, + } } diff --git a/src/methods/vault/transactions/operate/common.ts b/src/methods/vault/transactions/operate/common.ts index 3c08e247..2f5d4663 100644 --- a/src/methods/vault/transactions/operate/common.ts +++ b/src/methods/vault/transactions/operate/common.ts @@ -1,6 +1,7 @@ import type { MulticallTransactionInput } from './types' import { validateArgs } from '../../../../utils' import { vaultMulticall } from '../../../../contracts' +import type { VaultMulticallBaseInput } from '../../../../contracts' import { getMetadataParams, @@ -62,8 +63,7 @@ export const commonLogic = async (values: MulticallTransactionInput) => { } } - const baseMulticall = { - keeperContract: contracts.base.keeper, + const baseMulticall: VaultMulticallBaseInput = { vaultContract, vaultAddress, userAddress, diff --git a/src/methods/vault/transactions/withdraw/common.ts b/src/methods/vault/transactions/withdraw/common.ts index 845707c2..517a8097 100644 --- a/src/methods/vault/transactions/withdraw/common.ts +++ b/src/methods/vault/transactions/withdraw/common.ts @@ -1,6 +1,6 @@ import type { WithdrawInput } from './types' import { validateArgs } from '../../../../utils' -import { vaultMulticall } from '../../../../contracts' +import { vaultMulticall, VaultMulticallBaseInput } from '../../../../contracts' export const commonLogic = async (values: WithdrawInput) => { @@ -19,8 +19,7 @@ export const commonLogic = async (values: WithdrawInput) => { // the funds are always withdrawn via a queue const isV1Version = version === 1 - const baseMulticallArgs: Omit[0], 'request'> = { - keeperContract: contracts.base.keeper, + const baseMulticallArgs: VaultMulticallBaseInput = { vaultContract, vaultAddress, userAddress, diff --git a/src/utils/configs/holesky.ts b/src/utils/configs/holesky.ts index 40260900..a446d5f0 100644 --- a/src/utils/configs/holesky.ts +++ b/src/utils/configs/holesky.ts @@ -7,7 +7,7 @@ export default { network: constants.chains.holesky, api: { backend: 'https://holesky-api.stakewise.io/graphql', - subgraph: 'https://holesky-graph.stakewise.io/subgraphs/name/stakewise/stakewise', + subgraph: 'https://mainnet-graph-stage.stakewise.io/subgraphs/name/stakewise/stakewise', }, pages: { beaconchain: 'https://holesky.beaconcha.in',