From c9966d86242314ce54934af90a0c349c9e22df78 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Thu, 19 Oct 2023 17:44:48 +0500 Subject: [PATCH 1/3] [performance-converters] move converters --- README.md | 90 +++++++++---------- src/methods/osToken/index.ts | 2 + .../requests}/getAssetsFromShares.ts | 0 .../requests}/getSharesFromAssets.ts | 0 src/methods/utils/index.ts | 2 - 5 files changed, 47 insertions(+), 47 deletions(-) rename src/methods/{utils => osToken/requests}/getAssetsFromShares.ts (100%) rename src/methods/{utils => osToken/requests}/getSharesFromAssets.ts (100%) diff --git a/README.md b/README.md index d9285053..33c30204 100644 --- a/README.md +++ b/README.md @@ -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 @@ -634,126 +634,126 @@ type Output = { await sdk.osToken.getBaseData() ``` --- -## API-utils - -### `sdk.utils.getRewardsPerYear` +### `sdk.utils.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.utils.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 diff --git a/src/methods/osToken/index.ts b/src/methods/osToken/index.ts index 6f5f3540..494e0b11 100644 --- a/src/methods/osToken/index.ts +++ b/src/methods/osToken/index.ts @@ -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' diff --git a/src/methods/utils/getAssetsFromShares.ts b/src/methods/osToken/requests/getAssetsFromShares.ts similarity index 100% rename from src/methods/utils/getAssetsFromShares.ts rename to src/methods/osToken/requests/getAssetsFromShares.ts diff --git a/src/methods/utils/getSharesFromAssets.ts b/src/methods/osToken/requests/getSharesFromAssets.ts similarity index 100% rename from src/methods/utils/getSharesFromAssets.ts rename to src/methods/osToken/requests/getSharesFromAssets.ts diff --git a/src/methods/utils/index.ts b/src/methods/utils/index.ts index d09170b3..639d3216 100644 --- a/src/methods/utils/index.ts +++ b/src/methods/utils/index.ts @@ -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' From d6fcb144d1a699ed06a955e47403e1859dd44c0d Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Thu, 19 Oct 2023 17:45:27 +0500 Subject: [PATCH 2/3] [performance-converters] change vault structure --- src/methods/vault/requests/getVault/modifyVault.spec.ts | 4 +--- src/methods/vault/requests/getVault/modifyVault.ts | 4 +--- src/methods/vault/requests/getVault/types.ts | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/methods/vault/requests/getVault/modifyVault.spec.ts b/src/methods/vault/requests/getVault/modifyVault.spec.ts index ac199ccb..d5318638 100644 --- a/src/methods/vault/requests/getVault/modifyVault.spec.ts +++ b/src/methods/vault/requests/getVault/modifyVault.spec.ts @@ -44,6 +44,7 @@ describe('modifyVault', () => { isErc20: true, feePercent: 2, verified: true, + performance: 10, isPrivate: false, capacity: '0.001', tokenSymbol: 'mTKN', @@ -61,9 +62,6 @@ describe('modifyVault', () => { feeRecipient: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', mevRecipient: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', vaultKeysManager: '0xeEFFFD4C23D2E8c845870e273861e7d60Df49663', - performance: { - total: 10, - }, whitelist: [ { createdAt: 1693395816000, diff --git a/src/methods/vault/requests/getVault/modifyVault.ts b/src/methods/vault/requests/getVault/modifyVault.ts index 6f36350a..a39e2fac 100644 --- a/src/methods/vault/requests/getVault/modifyVault.ts +++ b/src/methods/vault/requests/getVault/modifyVault.ts @@ -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), diff --git a/src/methods/vault/requests/getVault/types.ts b/src/methods/vault/requests/getVault/types.ts index ddaa2880..e23f9d85 100644 --- a/src/methods/vault/requests/getVault/types.ts +++ b/src/methods/vault/requests/getVault/types.ts @@ -8,6 +8,7 @@ export type ModifiedVault = Omit< apy: number createdAt: number vaultAdmin: string + performance: number vaultAddress: string mevRecipient: string vaultKeysManager: string @@ -16,7 +17,4 @@ export type ModifiedVault = Omit< createdAt: number address: string }> - performance: { - total: number - } } From ac77c2a3d314b2ca7f25a7f3a5ef1c40099b527f Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Thu, 19 Oct 2023 18:16:26 +0500 Subject: [PATCH 3/3] [performance-converters] change readme --- .github/workflows/update-badges.yml | 35 ----------------------------- README.md | 12 +++++----- 2 files changed, 5 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/update-badges.yml diff --git a/.github/workflows/update-badges.yml b/.github/workflows/update-badges.yml deleted file mode 100644 index 1c404377..00000000 --- a/.github/workflows/update-badges.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Update version badge - -on: - release: - types: [published] - -jobs: - update_readme: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Get current version - id: package_version - run: | - VERSION=$(jq -r .version ./package.json) - echo "::set-output name=version::$VERSION" - - - name: Update README file - run: | - sed -i "s|badge/version-.*-blue|badge/version-${{ github.event.release.tag_name }}-blue|g" README.md - - - name: Setup git - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git switch -c main - git commit -am "Update README badges" - - - name: Push changes - run: git push origin main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 33c30204..e60a7785 100644 --- a/README.md +++ b/README.md @@ -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) @@ -296,9 +296,7 @@ type Output = { createdAt: number address: string }> | null - performance: { - total: number - } + performance: number } ``` @@ -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: @@ -634,7 +632,7 @@ type Output = { await sdk.osToken.getBaseData() ``` --- -### `sdk.utils.getAssetsFromShares` +### `sdk.osToken.getAssetsFromShares` #### Description: @@ -658,7 +656,7 @@ type Output = bigint await sdk.utils.getAssetsFromShares({ amount: 0n }) ``` --- -### `sdk.utils.getSharesFromAssets` +### `sdk.osToken.getSharesFromAssets` #### Description: