Skip to content

Latest commit

 

History

History
394 lines (234 loc) · 13.8 KB

OpusPool.md

File metadata and controls

394 lines (234 loc) · 13.8 KB

Class: OpusPool

Pooling solution

Table of contents

Properties

Constructors

Methods

Properties

userAccount

userAccount: `0x${string}`

Currently connected Ethereum address

Constructors

constructor

new OpusPool(params): OpusPool

Instantiates pooling solution facade that provides convenience methods to allow staking for individual user.

Parameters

Name Type Description
params Object Parameters to configure the pooling solution interface.
params.address `0x${string}` An address of currently connected user wallet. If user connects different wallet, pooling solution implementation must be re-instantiated with a new user address.
params.network Networks One of holesky, ethereum, hardhat
params.rpcUrl? string RPC Url to interact with If not defined, either public node

Returns

OpusPool

Methods

getVaultDetails

getVaultDetails(vaults): Promise<VaultDetails[]>

Exposes information regarding vault details such as TVL, APY, description and logotype, and also balance of connected customer in that Vault.

Parameters

Name Type Description
vaults `0x${string}`[] an array of vault addresses to query the details for

Returns

Promise<VaultDetails[]>

An array of OpusVaultDetails corresponding to given details


getTransactionsHistory

getTransactionsHistory(vaults): Promise<VaultTransaction[]>

Returns up to 1000 Stake or Unstake interactions of current user with given Vault.

Parameters

Name Type Description
vaults `0x${string}`[] an array of vault addresses to query the interactions for

Returns

Promise<VaultTransaction[]>

An array of OpusVaultDetails corresponding to given details


buildStakeTransaction

buildStakeTransaction(params): Promise<StakeTransactionData>

Generates stake transaction to deposit into chosen Vault

Integrations should utilize wallet interface of their own choosing to broadcast the transaction via RPC nodes of their preference. This method is stateless and only generates transaction bytes, leaving sign and broadcast up to the code integrating SDK.

Parameters

Name Type Description
params Object params for request
params.vault `0x${string}` A vault address
params.amount bigint Amount of Eth to deposit, denominated in wei
params.referrer? `0x${string}` Address of the referrer. Optional.

Returns

Promise<StakeTransactionData>

  • StakeTransactionData

  • StakeTransactionData.transaction - Transaction to sign and broadcast

  • StakeTransactionData.amount - Amount of Eth to deposit, denominated in wei

  • StakeTransactionData.gasEstimation - Gas estimation in wei

  • StakeTransactionData.maxPriorityFeePerGas - Max priority fee per gas to use for network

  • StakeTransactionData.maxFeePerGas - Max fee per gas to use for network


buildUnstakeTransaction

buildUnstakeTransaction(params): Promise<UnstakeTransactionData>

Generates unstake transaction to withdraw from chosen Vault.

Integrations should utilize wallet interface of their own choosing to broadcast the transaction via RPC nodes of their preference. This method is stateless and only generates transaction bytes, leaving sign and broadcast up to the code integrating SDK.

Parameters

Name Type Description
params Object params for request
params.vault `0x${string}` A vault address
params.amount bigint Amount of Eth to deposit, denominated in wei

Returns

Promise<UnstakeTransactionData>

UnstakeTransactionData for transaction to sign and broadcast


getUnstakeQueueForVault

getUnstakeQueueForVault(vault): Promise<UnstakeQueueItem[]>

Retrieves the unstake queue for the vault, including the user's position in the queue and shares waiting to be unstaked

Parameters

Name Type Description
vault `0x${string}` A vault address

Returns

Promise<UnstakeQueueItem[]>

Array of UnstakeQueueItem objects corresponding to the queue, which are needed to withdraw from the queue


buildWithdrawUnstakedTransaction

buildWithdrawUnstakedTransaction(params): Promise<UnstakeQueueTransactionData>

Generates transaction to withdraw from the unstake queue.

Integrations should utilize wallet interface of their own choosing to broadcast the transaction via RPC nodes of their preference. This method is stateless and only generates transaction bytes, leaving sign and broadcast up to the code integrating SDK.

Parameters

Name Type Description
params Object params for request
params.vault `0x${string}` A vault address
params.queueItems UnstakeQueueItem[] Array of UnstakeQueueItem objects corresponding to the queue(see getUnstakeQueueForVault)

Returns

Promise<UnstakeQueueTransactionData>

UnstakeQueueTransactionData for transaction to sign and broadcast


getRewardsHistory

getRewardsHistory(params): Promise<RewardsDataPoint[]>

Retrieves rewards history for customer, earned via specific Vaults

Parameters

Name Type Description
params Object params for request
params.from Date Starting date for the rewards retrieval query
params.to Date End date for the rewards retrieval query
params.vault `0x${string}` Address of the vault to retrieve rewards for

Returns

Promise<RewardsDataPoint[]>

Array of daily rewards amount data points


buildMintTransaction

buildMintTransaction(params): Promise<MintTransactionData>

Generates mint transaction to mint osTokens from chosen Vault.

Parameters

Name Type Description
params Object params for request
params.shares bigint Amount of osTokens to mint
params.vault `0x${string}` A vault address
params.referrer? `0x${string}` Address of the referrer. Optional.

Returns

Promise<MintTransactionData>

MintTransactionData for transaction to sign and broadcast


getMaxMintForVault

getMaxMintForVault(vault): Promise<bigint>

Retrieves maximum amount of osTokens that can be minted by the user

Parameters

Name Type Description
vault `0x${string}` A vault address

Returns

Promise<bigint>

Max amount of osTokens that can be minted


getHealthFactorForUser

getHealthFactorForUser(mintedAssets, stakedAssets): Promise<OsTokenPositionHealth>

Retrieves health factor for the user

Parameters

Name Type Description
mintedAssets bigint Amount of osTokens minted by the user
stakedAssets bigint Amount of ETH staked by the user

Returns

Promise<OsTokenPositionHealth>

Position Health (enum)


getStakeBalanceForUser

getStakeBalanceForUser(vault): Promise<StakeBalanceReturnType>

Retrieves stake balance for user in the vault

Parameters

Name Type Description
vault `0x${string}` A vault address

Returns

Promise<StakeBalanceReturnType>

  • StakeBalanceReturnType.assets - Balance in ETH

  • StakeBalanceReturnType.shares - Balance in vault tokens


getOsTokenPositionForVault

getOsTokenPositionForVault(vault): Promise<OsTokenPositionReturnType>

Retrieves osToken position for the vault

Parameters

Name Type Description
vault `0x${string}` A vault address

Returns

Promise<OsTokenPositionReturnType>

  • OsTokenPositionReturnType.minted

  • OsTokenPositionReturnType.minted.assets - Balance in ETH

  • OsTokenPositionReturnType.minted.shares - Balance

  • OsTokenPositionReturnType.minted.fee - Usage fee amount

  • OsTokenPositionReturnType.health - Position Health (enum)

  • OsTokenPositionReturnType.protocolFeePercent - Usage fee percent


getMaxUnstakeForUserForVault

getMaxUnstakeForUserForVault(vault): Promise<bigint>

Retrieves the max amount of ETH that can be unstaked

Parameters

Name Type Description
vault `0x${string}` A vault address

Returns

Promise<bigint>

Max amount of ETH that can be unstaked


buildBurnTransaction

buildBurnTransaction(params): Promise<BurnTransactionData>

Generates burn transaction to burn osTokens from chosen Vault.

Parameters

Name Type Description
params Object params for request
params.shares bigint Amount of osTokens to burn
params.vault `0x${string}` A vault address

Returns

Promise<BurnTransactionData>

BurnTransactionData for transaction to sign and broadcast