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

Performance converters #24

Merged
merged 3 commits into from
Oct 19, 2023
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
35 changes: 0 additions & 35 deletions .github/workflows/update-badges.yml

This file was deleted.

98 changes: 48 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The official SDK designed for effortless data retrieval from the StakeWise platform. This SDK provides a streamlined interface over GraphQL requests and contract interactions.

![Version](https://img.shields.io/badge/version-1.2.6-blue)
![Version](https://img.shields.io/badge/version-1.2.7-blue)
![Unit Tests](https://github.com/stakewise/v3-sdk/actions/workflows/unit-tests.yml/badge.svg)
![GitHub issues](https://img.shields.io/github/issues-raw/stakewise/v3-sdk)
![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/stakewise/v3-sdk)
Expand Down Expand Up @@ -71,11 +71,11 @@ const sdk = new StakeWiseSDK({ network: Network.Mainnet })
| [sdk.vault.getAllocatorActions](#sdkvaultgetallocatoractions) | [sdk.osToken.getBurnAmount](#sdkostokengetburnamount) | [sdk.utils.getRewardsPerYear](#sdkutilsgetrewardsperyear) |
| [sdk.vault.getDaySnapshots](#sdkvaultgetdaysnapshots) | [sdk.osToken.getHealthFactor](#sdkostokengethealthfactor) | [sdk.utils.getSwiseUsdPrice](#sdkutilsgetswiseusdprice) |
| [sdk.vault.getExitQueue](#sdkvaultgetexitqueue) | [sdk.osToken.getAPY](#sdkostokengetapy) | [sdk.utils.getTransactions](#sdkutilsgettransactions) |
| [sdk.vault.getValidators](#sdkvaultgetvalidators) | [sdk.osToken.getPosition](#sdkostokengetposition) | [sdk.utils.getAssetsFromShares](#sdkutilsgetassetsfromshares) |
| [sdk.vault.getVault](#sdkvaultgetvault) | [sdk.osToken.getMaxMint](#sdkostokengetmaxmint) | [sdk.utils.getSharesFromAssets](#sdkutilsgetsharesfromassets) |
| [sdk.vault.getValidators](#sdkvaultgetvalidators) | [sdk.osToken.getPosition](#sdkostokengetposition) |
| [sdk.vault.getVault](#sdkvaultgetvault) | [sdk.osToken.getMaxMint](#sdkostokengetmaxmint) |
| [sdk.vault.getWithdrawData](#sdkvaultgetwithdrawdata) | [sdk.osToken.getBaseData](#sdkostokengetbasedata) |
| [sdk.vault.getHarvestParams](#sdkvaultgetharvestparams) |
| [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) |
| [sdk.vault.getHarvestParams](#sdkvaultgetharvestparams) | [sdk.utils.getSharesFromAssets](#sdkutilsgetsharesfromassets) |
| [sdk.vault.getStakeBalance](#sdkvaultgetstakebalance) | [sdk.utils.getAssetsFromShares](#sdkutilsgetassetsfromshares) |

## API-Vault

Expand Down Expand Up @@ -296,9 +296,7 @@ type Output = {
createdAt: number
address: string
}> | null
performance: {
total: number
}
performance: number
}
```

Expand All @@ -325,7 +323,7 @@ type Output = {
| `displayName` | Name of vault |
| `description` | Description of vault |
| `whitelist` | List of authorized users for deposits |
| `performance` | Vault performance indicator |
| `performance` | Vault performance indicator (percent) |

#### Example:

Expand Down Expand Up @@ -634,126 +632,126 @@ type Output = {
await sdk.osToken.getBaseData()
```
---
## API-utils

### `sdk.utils.getRewardsPerYear`
### `sdk.osToken.getAssetsFromShares`

#### Description:

Get a list of interactions with the vault.
Convert osToken to ETH

#### Arguments:

| Name | Type | Type | Description |
|------|------|-------------|---------|
| amount | `string` | **Require** | Deposit amount |
| averageRewardsPerSecond | `string` | **Require** | [getAPY](#sdkostokengetapy) |
| Name | Type | Type |
|------|------|-------------|
| amount | `bigint` | **Require** |

#### Returns:

```ts
type Output = string
type Output = bigint
```

#### Example:

```ts
sdk.utils.getRewardsPerYear({
averageRewardsPerSecond: 0n,
amount: 0n,
})
await sdk.utils.getAssetsFromShares({ amount: 0n })
```
---
### `sdk.utils.getSwiseUsdPrice`
### `sdk.osToken.getSharesFromAssets`

#### Description:

Current price of SWISE token to USD.
Convert ETH to osToken

#### Arguments:

| Name | Type | Type |
|------|------|-------------|
| amount | `bigint` | **Require** |

#### Returns:

```ts
type Output = string
type Output = bigint
```

#### Example:

```ts
await sdk.utils.getSwiseUsdPrice()
await sdk.utils.getSharesFromAssets({ amount: 0n })
```
---
### `sdk.utils.getTransactions`
## API-utils

### `sdk.utils.getRewardsPerYear`

#### Description:

Retrieving a transaction to verify that the data went into the subgraph after the transaction
Get a list of interactions with the vault.

#### Arguments:

| Name | Type | Type | Description |
|------|------|-------------|---------|
| hash | `string` | **Require** | Transaction hash |
| amount | `string` | **Require** | Deposit amount |
| averageRewardsPerSecond | `string` | **Require** | [getAPY](#sdkostokengetapy) |

#### Returns:

```ts
type Output = Array<{
id: string
}>
type Output = string
```

#### Example:

```ts
await sdk.utils.getTransactions({ hash: '0x...' })
sdk.utils.getRewardsPerYear({
averageRewardsPerSecond: 0n,
amount: 0n,
})
```
---
### `sdk.utils.getAssetsFromShares`
### `sdk.utils.getSwiseUsdPrice`

#### Description:

Convert osToken to ETH

#### Arguments:

| Name | Type | Type |
|------|------|-------------|
| amount | `bigint` | **Require** |
Current price of SWISE token to USD.

#### Returns:

```ts
type Output = bigint
type Output = string
```

#### Example:

```ts
await sdk.utils.getAssetsFromShares({ amount: 0n })
await sdk.utils.getSwiseUsdPrice()
```
---
### `sdk.utils.getSharesFromAssets`
### `sdk.utils.getTransactions`

#### Description:

Convert ETH to osToken
Retrieving a transaction to verify that the data went into the subgraph after the transaction

#### Arguments:

| Name | Type | Type |
|------|------|-------------|
| amount | `bigint` | **Require** |
| Name | Type | Type | Description |
|------|------|-------------|---------|
| hash | `string` | **Require** | Transaction hash |

#### Returns:

```ts
type Output = bigint
type Output = Array<{
id: string
}>
```

#### Example:

```ts
await sdk.utils.getSharesFromAssets({ amount: 0n })
await sdk.utils.getTransactions({ hash: '0x...' })
```
---
## Description of other parts of the api
Expand Down
2 changes: 2 additions & 0 deletions src/methods/osToken/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ export { default as getBaseData } from './requests/getOsTokenData'
export { default as getBurnAmount } from './helpers/getBurnAmount'
export { default as getPosition } from './requests/getOsTokenPosition'
export { default as getHealthFactor } from './helpers/getHealthFactor'
export { default as getSharesFromAssets } from './requests/getSharesFromAssets'
export { default as getAssetsFromShares } from './requests/getAssetsFromShares'
2 changes: 0 additions & 2 deletions src/methods/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export { default as getSharesFromAssets } from './getSharesFromAssets'
export { default as getAssetsFromShares } from './getAssetsFromShares'
export { default as getRewardsPerYear } from './getRewardsPerYear'
export { default as getSwiseUsdPrice } from './getSwiseUsdPrice'
export { default as getTransactions } from './getTransactions'
4 changes: 1 addition & 3 deletions src/methods/vault/requests/getVault/modifyVault.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('modifyVault', () => {
isErc20: true,
feePercent: 2,
verified: true,
performance: 10,
isPrivate: false,
capacity: '0.001',
tokenSymbol: 'mTKN',
Expand All @@ -61,9 +62,6 @@ describe('modifyVault', () => {
feeRecipient: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
mevRecipient: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
vaultKeysManager: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663',
performance: {
total: 10,
},
whitelist: [
{
createdAt: 1693395816000,
Expand Down
4 changes: 1 addition & 3 deletions src/methods/vault/requests/getVault/modifyVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ const modifyVault = (input: ModifyVaultInput): ModifiedVault => {

return {
...rest,
performance: {
total: Number(performance),
},
isSmoothingPool: !mevEscrow,
feePercent: feePercent / 100,
vaultAdmin: getAddress(admin),
performance: Number(performance),
vaultAddress: getAddress(address),
createdAt: Number(createdAt) * 1000,
totalAssets: formatEther(totalAssets),
Expand Down
4 changes: 1 addition & 3 deletions src/methods/vault/requests/getVault/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type ModifiedVault = Omit<
apy: number
createdAt: number
vaultAdmin: string
performance: number
vaultAddress: string
mevRecipient: string
vaultKeysManager: string
Expand All @@ -16,7 +17,4 @@ export type ModifiedVault = Omit<
createdAt: number
address: string
}>
performance: {
total: number
}
}
Loading