From c1abf09114e4b730cb95ddf7745a55960699d9a9 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Tue, 3 Oct 2023 15:43:29 +0500 Subject: [PATCH 01/13] [validate-methods] improve exitQueue logic --- src/contracts/vaultMulticall.ts | 12 +++--- .../subgraph/exitQueue/exitQueueQuery.graphql | 4 +- .../modifyAllocatorActions.ts | 2 +- .../getExitQueue/fetchExitQueuePositions.ts | 2 +- .../getExitQueue/parseExitRequests.ts | 39 ++++++++++--------- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/contracts/vaultMulticall.ts b/src/contracts/vaultMulticall.ts index 2a40bf34..47afd596 100644 --- a/src/contracts/vaultMulticall.ts +++ b/src/contracts/vaultMulticall.ts @@ -12,7 +12,6 @@ type VaultMulticallRequestInput = { }> callStatic?: boolean estimateGas?: boolean - updateState?: boolean } type VaultMulticallInput = { @@ -26,7 +25,7 @@ type VaultMulticallInput = { const vaultMulticall = async (values: VaultMulticallInput): Promise => { const { options, vaultAddress, userAddress, request, vaultContract, keeperContract } = values - const { params, callStatic, estimateGas, updateState } = request + const { params, callStatic, estimateGas } = request const calls: string[] = [] @@ -36,11 +35,10 @@ const vaultMulticall = async (values: VaultMulticallInput): P const signer = new VoidSigner(userAddress, library) const signedContract = vaultContract.connect(signer) - const harvestParams = await getHarvestParams({ options, vaultAddress }) - - const canHarvest = updateState - ? Object.values(harvestParams).every(Boolean) - : await keeperContract.canHarvest(vaultAddress) + const [ harvestParams, canHarvest ] = await Promise.all([ + getHarvestParams({ options, vaultAddress }), + keeperContract.canHarvest(vaultAddress), + ]) if (canHarvest) { const fragment = signedContract.interface.encodeFunctionData('updateState', [ harvestParams ]) diff --git a/src/graphql/subgraph/exitQueue/exitQueueQuery.graphql b/src/graphql/subgraph/exitQueue/exitQueueQuery.graphql index f35d5a52..684ea2ca 100644 --- a/src/graphql/subgraph/exitQueue/exitQueueQuery.graphql +++ b/src/graphql/subgraph/exitQueue/exitQueueQuery.graphql @@ -1,6 +1,6 @@ -query exitQueue($owner: Bytes, $vault: String!) { +query exitQueue($receiver: Bytes, $vault: String!) { exitRequests(where: { - owner: $owner, + receiver: $receiver, vault: $vault, }) { positionTicket diff --git a/src/methods/vault/requests/getAllocatorActions/modifyAllocatorActions.ts b/src/methods/vault/requests/getAllocatorActions/modifyAllocatorActions.ts index 05c9e068..716237dc 100644 --- a/src/methods/vault/requests/getAllocatorActions/modifyAllocatorActions.ts +++ b/src/methods/vault/requests/getAllocatorActions/modifyAllocatorActions.ts @@ -15,7 +15,7 @@ const modifyAllocatorActions = (input: ModifyAllocatorActionsInput): ModifiedAll return data.allocatorActions.map((item) => ({ ...item, - assets: formatEther(item.assets), + assets: formatEther(item.assets || 0), createdAt: Number(item.createdAt) * 1000, link: `${configs[network].network.blockExplorerUrl}/tx/${item.id.replace(/-.*/, '')}`, })) diff --git a/src/methods/vault/requests/getExitQueue/fetchExitQueuePositions.ts b/src/methods/vault/requests/getExitQueue/fetchExitQueuePositions.ts index cb8b513a..9fd4c941 100644 --- a/src/methods/vault/requests/getExitQueue/fetchExitQueuePositions.ts +++ b/src/methods/vault/requests/getExitQueue/fetchExitQueuePositions.ts @@ -14,8 +14,8 @@ const fetchExitQueuePositions = async (values: FetchExitQueuePositionsInput) => const data = await subgraph.exitQueue.fetchExitQueueQuery({ url: apiUrls.getSubgraphqlUrl(options), variables: { - owner: userAddress.toLowerCase(), vault: vaultAddress.toLowerCase(), + receiver: userAddress.toLowerCase(), }, }) diff --git a/src/methods/vault/requests/getExitQueue/parseExitRequests.ts b/src/methods/vault/requests/getExitQueue/parseExitRequests.ts index 1e1b8241..f739ed76 100644 --- a/src/methods/vault/requests/getExitQueue/parseExitRequests.ts +++ b/src/methods/vault/requests/getExitQueue/parseExitRequests.ts @@ -24,6 +24,12 @@ type ParseExitRequestsOutput = { withdrawable: bigint } +type ExitedAssetsResponse = Array<{ + newPositionTicket: bigint, + claimedShares: bigint, + claimedAssets: bigint +}> + const parseExitRequests = async (values: ParseExitRequestsInput): Promise => { const { options, contracts, userAddress, vaultAddress, totalShares, exitRequests } = values @@ -47,7 +53,6 @@ const parseExitRequests = async (values: ParseExitRequestsInput): Promise>({ - ...commonMulticallParams, - request: { - params: claims.map(({ positionTicket, exitQueueIndex }) => ({ - method: 'claimExitedAssets', - args: [ positionTicket, exitQueueIndex ], - })), - updateState: true, - callStatic: true, - }, - }) || [] + let exitedAssetsResponse: ExitedAssetsResponse = [] + + if (claims.length) { + // We need to get the data of the contract after the claim. + exitedAssetsResponse = await vaultMulticall({ + ...commonMulticallParams, + request: { + params: claims.map(({ positionTicket, exitQueueIndex }) => ({ + method: 'claimExitedAssets', + args: [ positionTicket, exitQueueIndex ], + })), + callStatic: true, + }, + }) || [] + } let remainingShares = totalShares, totalExitingAssets = 0n, @@ -115,7 +119,6 @@ const parseExitRequests = async (values: ParseExitRequestsInput): Promise Date: Tue, 3 Oct 2023 17:52:58 +0500 Subject: [PATCH 02/13] [validate-methods] move getTransactions to utils --- src/methods/{vault/requests => utils}/getTransactions.ts | 0 src/methods/utils/index.ts | 1 + src/methods/vault/index.ts | 1 - 3 files changed, 1 insertion(+), 1 deletion(-) rename src/methods/{vault/requests => utils}/getTransactions.ts (100%) diff --git a/src/methods/vault/requests/getTransactions.ts b/src/methods/utils/getTransactions.ts similarity index 100% rename from src/methods/vault/requests/getTransactions.ts rename to src/methods/utils/getTransactions.ts diff --git a/src/methods/utils/index.ts b/src/methods/utils/index.ts index 000d9156..639d3216 100644 --- a/src/methods/utils/index.ts +++ b/src/methods/utils/index.ts @@ -1,2 +1,3 @@ export { default as getRewardsPerYear } from './getRewardsPerYear' export { default as getSwiseUsdPrice } from './getSwiseUsdPrice' +export { default as getTransactions } from './getTransactions' diff --git a/src/methods/vault/index.ts b/src/methods/vault/index.ts index 7b2d11cb..8a9e1f81 100644 --- a/src/methods/vault/index.ts +++ b/src/methods/vault/index.ts @@ -1,7 +1,6 @@ export { default as getVault } from './requests/getVault' export { default as getExitQueue } from './requests/getExitQueue' export { default as getValidators } from './requests/getValidators' -export { default as getTransactions } from './requests/getTransactions' export { default as getDaySnapshots } from './requests/getDaySnapshots' export { default as getStakeBalance } from './requests/getStakeBalance' export { default as getWithdrawData } from './requests/getWithdrawData' From 16d137de42e97c8dc5588fd0c158c76376dd042f Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Tue, 3 Oct 2023 17:53:33 +0500 Subject: [PATCH 03/13] [validate-methods] improve getSwiseUsdPrice --- src/methods/utils/getSwiseUsdPrice.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/methods/utils/getSwiseUsdPrice.ts b/src/methods/utils/getSwiseUsdPrice.ts index 34f26f7b..c2ac387f 100644 --- a/src/methods/utils/getSwiseUsdPrice.ts +++ b/src/methods/utils/getSwiseUsdPrice.ts @@ -13,7 +13,7 @@ const getSwiseUsdPrice = async (input: GetSwiseUsdPriceInput) => { url: apiUrls.getBackendUrl(options), }) - return data?.swiseStats?.price + return data?.swiseStats?.price || '0' } From f1feab7ca6f11c6f6772516df85dbfb5d60d2b77 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Tue, 3 Oct 2023 18:15:09 +0500 Subject: [PATCH 04/13] [validate-methods] create getMaxMinte --- .../{ => helpers}/getBurnAmount.spec.ts | 0 .../osToken/{ => helpers}/getBurnAmount.ts | 0 .../osToken/helpers/getMaxMint.spec.ts | 67 +++++++++++++++++++ src/methods/osToken/helpers/getMaxMint.ts | 40 +++++++++++ src/methods/osToken/index.ts | 5 +- .../osToken/{ => requests}/getOsTokenData.ts | 0 6 files changed, 110 insertions(+), 2 deletions(-) rename src/methods/osToken/{ => helpers}/getBurnAmount.spec.ts (100%) rename src/methods/osToken/{ => helpers}/getBurnAmount.ts (100%) create mode 100644 src/methods/osToken/helpers/getMaxMint.spec.ts create mode 100644 src/methods/osToken/helpers/getMaxMint.ts rename src/methods/osToken/{ => requests}/getOsTokenData.ts (100%) diff --git a/src/methods/osToken/getBurnAmount.spec.ts b/src/methods/osToken/helpers/getBurnAmount.spec.ts similarity index 100% rename from src/methods/osToken/getBurnAmount.spec.ts rename to src/methods/osToken/helpers/getBurnAmount.spec.ts diff --git a/src/methods/osToken/getBurnAmount.ts b/src/methods/osToken/helpers/getBurnAmount.ts similarity index 100% rename from src/methods/osToken/getBurnAmount.ts rename to src/methods/osToken/helpers/getBurnAmount.ts diff --git a/src/methods/osToken/helpers/getMaxMint.spec.ts b/src/methods/osToken/helpers/getMaxMint.spec.ts new file mode 100644 index 00000000..8c36d258 --- /dev/null +++ b/src/methods/osToken/helpers/getMaxMint.spec.ts @@ -0,0 +1,67 @@ +import getMaxMint from './getMaxMint' + + +describe('getMaxMint', () => { + let mockContracts: any + + beforeEach(() => { + mockContracts = { + tokens: { + mintToken: { + avgRewardPerSecond: jest.fn(), + convertToShares: jest.fn(), + }, + }, + } + }) + + it('should return 0n if ltvPercent is <= 0', async () => { + const result = await getMaxMint({ + ltvPercent: 0n, + mintedShares: 100n, + stakedAssets: 100n, + contracts: mockContracts, + }) + + expect(result).toEqual(0n) + }) + + it('should return 0n if stakedAssets is <= 0', async () => { + const result = await getMaxMint({ + ltvPercent: 5000n, + mintedShares: 100n, + stakedAssets: 0n, + contracts: mockContracts, + }) + + expect(result).toEqual(0n) + }) + + it('should return max mint shares based on calculations', async () => { + mockContracts.tokens.mintToken.avgRewardPerSecond.mockResolvedValue(2n) + mockContracts.tokens.mintToken.convertToShares.mockResolvedValue(1500n) + + const result = await getMaxMint({ + ltvPercent: 5000n, + mintedShares: 1000n, + stakedAssets: 2000n, + contracts: mockContracts, + }) + + expect(result).toEqual(500n) + }) + + it('should return 0n if max mint shares is less than or equal to minted shares', async () => { + mockContracts.tokens.mintToken.avgRewardPerSecond.mockResolvedValue(2n) + mockContracts.tokens.mintToken.convertToShares.mockResolvedValue(900n) + + const result = await getMaxMint({ + ltvPercent: 5000n, + mintedShares: 1000n, + stakedAssets: 2000n, + contracts: mockContracts, + }) + + expect(result).toEqual(0n) + }) +}) diff --git a/src/methods/osToken/helpers/getMaxMint.ts b/src/methods/osToken/helpers/getMaxMint.ts new file mode 100644 index 00000000..5dba09bf --- /dev/null +++ b/src/methods/osToken/helpers/getMaxMint.ts @@ -0,0 +1,40 @@ +import { BigDecimal } from 'helpers' + + +type GetMaxMintInput = { + ltvPercent: bigint + mintedShares: bigint + stakedAssets: bigint + contracts: StakeWise.Contracts +} + +const getMaxMint = async (values: GetMaxMintInput) => { + const { contracts, ltvPercent, mintedShares, stakedAssets } = values + + if (ltvPercent <= 0 || stakedAssets <= 0) { + return 0n + } + + const rewardPerSecond = await contracts.tokens.mintToken.avgRewardPerSecond() + const avgRewardPerHour = rewardPerSecond * 60n * 60n + + const result = new BigDecimal(stakedAssets) + .multiply(ltvPercent) + .divide(10_000) + .minus(avgRewardPerHour) + .decimals(0) + .toString() + + let maxMintShares = await contracts.tokens.mintToken.convertToShares(result) + + if (maxMintShares > mintedShares) { + maxMintShares = maxMintShares - mintedShares + + return maxMintShares + } + + return 0n +} + + +export default getMaxMint diff --git a/src/methods/osToken/index.ts b/src/methods/osToken/index.ts index 5d313fba..4ad44d06 100644 --- a/src/methods/osToken/index.ts +++ b/src/methods/osToken/index.ts @@ -1,5 +1,6 @@ -export { default as getBaseData } from './getOsTokenData' -export { default as getBurnAmount } from './getBurnAmount' export { default as getAPY } from './requests/getOsTokenAPY' +export { default as getMaxMint } from './helpers/getMaxMint' +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' diff --git a/src/methods/osToken/getOsTokenData.ts b/src/methods/osToken/requests/getOsTokenData.ts similarity index 100% rename from src/methods/osToken/getOsTokenData.ts rename to src/methods/osToken/requests/getOsTokenData.ts From 431a551b6483be1a0cab709082caa1cb3f6d52fd Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Wed, 4 Oct 2023 14:48:25 +0500 Subject: [PATCH 05/13] [validate-methods] validate arguments --- src/contracts/vaultMulticall.ts | 8 +++- src/helpers/index.ts | 1 + src/helpers/validateArgs.ts | 42 +++++++++++++++++++ src/methods/osToken/helpers/getBurnAmount.ts | 5 +++ .../osToken/helpers/getHealthFactor.ts | 4 +- src/methods/osToken/helpers/getMaxMint.ts | 4 +- .../osToken/requests/getMaxMintShares.ts | 4 +- .../requests/getOsTokenPosition/index.ts | 5 +++ src/methods/utils/getRewardsPerYear.ts | 4 +- src/methods/utils/getTransactions.ts | 6 ++- .../requests/getAllocatorActions/index.ts | 23 +++++++++- .../vault/requests/getDaySnapshots/index.ts | 7 +++- .../vault/requests/getExitQueue/index.ts | 4 ++ .../vault/requests/getHarvestParams.ts | 4 +- src/methods/vault/requests/getStakeBalance.ts | 3 ++ .../vault/requests/getValidators/index.ts | 4 +- src/methods/vault/requests/getVault/index.ts | 4 +- .../vault/requests/getWithdrawData/index.ts | 5 +++ 18 files changed, 123 insertions(+), 14 deletions(-) create mode 100644 src/helpers/validateArgs.ts diff --git a/src/contracts/vaultMulticall.ts b/src/contracts/vaultMulticall.ts index 47afd596..40bca610 100644 --- a/src/contracts/vaultMulticall.ts +++ b/src/contracts/vaultMulticall.ts @@ -30,9 +30,13 @@ const vaultMulticall = async (values: VaultMulticallInput): P const calls: string[] = [] const config = configs[options.network] - const library = new JsonRpcProvider(config.network.url) - const signer = new VoidSigner(userAddress, library) + const library = options.provider || new JsonRpcProvider(config.network.url) + + const signer = options.provider + ? await library.getSigner(userAddress) + : new VoidSigner(userAddress, library) + const signedContract = vaultContract.connect(signer) const [ harvestParams, canHarvest ] = await Promise.all([ diff --git a/src/helpers/index.ts b/src/helpers/index.ts index 003bd21a..e0aa22c6 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -3,3 +3,4 @@ export * as constants from './constants' export { default as apiUrls } from './apiUrls' export { default as configs } from './configs' export { default as BigDecimal } from './BigDecimal' +export { default as validateArgs } from './validateArgs' diff --git a/src/helpers/validateArgs.ts b/src/helpers/validateArgs.ts new file mode 100644 index 00000000..4a89fcfc --- /dev/null +++ b/src/helpers/validateArgs.ts @@ -0,0 +1,42 @@ +import { isAddress } from 'ethers' + + +const bigint = (values: Record) => { + Object.keys(values).forEach((key) => { + if (typeof values[key] !== 'bigint') { + throw new Error(`The "${key}" argument must be of type bigint`) + } + }) +} + +const address = (values: Record) => { + Object.keys(values).forEach((key) => { + if (!isAddress(values[key])) { + throw new Error(`The "${key}" argument must be a valid address`) + } + }) +} + +const string = (values: Record) => { + Object.keys(values).forEach((key) => { + if (typeof values[key] !== 'string') { + throw new Error(`The "${key}" argument must be a string`) + } + }) +} + +const number = (values: Record) => { + Object.keys(values).forEach((key) => { + if (typeof values[key] !== 'number') { + throw new Error(`The "${key}" argument must be a number`) + } + }) +} + + +export default { + bigint, + string, + number, + address, +} diff --git a/src/methods/osToken/helpers/getBurnAmount.ts b/src/methods/osToken/helpers/getBurnAmount.ts index b2df4d55..c9e4a5f9 100644 --- a/src/methods/osToken/helpers/getBurnAmount.ts +++ b/src/methods/osToken/helpers/getBurnAmount.ts @@ -1,3 +1,6 @@ +import { validateArgs } from 'helpers' + + type GetBurnAmountInput = { ltvPercent: bigint mintedAssets: bigint @@ -9,6 +12,8 @@ type GetBurnAmountInput = { const getBurnAmount = async (values: GetBurnAmountInput) => { const { contracts, ltvPercent, mintedAssets, stakedAssets, newStakedAssets } = values + validateArgs.bigint({ ltvPercent, mintedAssets, stakedAssets, newStakedAssets }) + const hasMinted = mintedAssets && mintedAssets > 0 if (!hasMinted) { diff --git a/src/methods/osToken/helpers/getHealthFactor.ts b/src/methods/osToken/helpers/getHealthFactor.ts index 47f05bd2..42f92948 100644 --- a/src/methods/osToken/helpers/getHealthFactor.ts +++ b/src/methods/osToken/helpers/getHealthFactor.ts @@ -1,4 +1,4 @@ -import { OsTokenPositionHealth, BigDecimal } from 'helpers' +import { OsTokenPositionHealth, BigDecimal, validateArgs } from 'helpers' type GetHealthFactorInput = { @@ -10,6 +10,8 @@ type GetHealthFactorInput = { const getHealthFactor = (values: GetHealthFactorInput) => { const { mintedAssets, stakedAssets, thresholdPercent } = values + validateArgs.bigint({ mintedAssets, stakedAssets, thresholdPercent }) + if (mintedAssets === 0n || stakedAssets === 0n) { return { value: 0, diff --git a/src/methods/osToken/helpers/getMaxMint.ts b/src/methods/osToken/helpers/getMaxMint.ts index 5dba09bf..a67a8a72 100644 --- a/src/methods/osToken/helpers/getMaxMint.ts +++ b/src/methods/osToken/helpers/getMaxMint.ts @@ -1,4 +1,4 @@ -import { BigDecimal } from 'helpers' +import { BigDecimal, validateArgs } from 'helpers' type GetMaxMintInput = { @@ -11,6 +11,8 @@ type GetMaxMintInput = { const getMaxMint = async (values: GetMaxMintInput) => { const { contracts, ltvPercent, mintedShares, stakedAssets } = values + validateArgs.bigint({ ltvPercent, mintedShares, stakedAssets }) + if (ltvPercent <= 0 || stakedAssets <= 0) { return 0n } diff --git a/src/methods/osToken/requests/getMaxMintShares.ts b/src/methods/osToken/requests/getMaxMintShares.ts index fe0c40b4..d95006c9 100644 --- a/src/methods/osToken/requests/getMaxMintShares.ts +++ b/src/methods/osToken/requests/getMaxMintShares.ts @@ -1,4 +1,4 @@ -import { BigDecimal } from 'helpers' +import { BigDecimal, validateArgs } from 'helpers' type GetMaxMintSharesInput = { @@ -11,6 +11,8 @@ type GetMaxMintSharesInput = { const getMaxMintShares = async (values: GetMaxMintSharesInput) => { const { contracts, stakedAssets, mintedShares, ltvPercent } = values + validateArgs.bigint({ stakedAssets, mintedShares, ltvPercent }) + if (ltvPercent <= 0 || stakedAssets <= 0) { return 0n } diff --git a/src/methods/osToken/requests/getOsTokenPosition/index.ts b/src/methods/osToken/requests/getOsTokenPosition/index.ts index 902764fe..d05db66b 100644 --- a/src/methods/osToken/requests/getOsTokenPosition/index.ts +++ b/src/methods/osToken/requests/getOsTokenPosition/index.ts @@ -1,3 +1,5 @@ +import { validateArgs } from 'helpers' + import getHealthFactor from '../../helpers/getHealthFactor' import getOsTokenPositionShares from './getOsTokenPositionShares' @@ -14,6 +16,9 @@ type GetOsTokenPositionInput = { const getOsTokenPosition = async (values: GetOsTokenPositionInput) => { const { options, contracts, vaultAddress, userAddress, stakedAssets, thresholdPercent } = values + validateArgs.address({ vaultAddress, userAddress }) + validateArgs.bigint({ stakedAssets, thresholdPercent }) + const vaultContract = contracts.helpers.createVaultContract(vaultAddress) const gqlShares = await getOsTokenPositionShares({ options, vaultAddress, userAddress }) diff --git a/src/methods/utils/getRewardsPerYear.ts b/src/methods/utils/getRewardsPerYear.ts index 9cf38651..d3f0bec3 100644 --- a/src/methods/utils/getRewardsPerYear.ts +++ b/src/methods/utils/getRewardsPerYear.ts @@ -1,4 +1,4 @@ -import { BigDecimal, constants } from 'helpers' +import { BigDecimal, constants, validateArgs } from 'helpers' type GetRewardsPerYearInput = { @@ -9,6 +9,8 @@ type GetRewardsPerYearInput = { const getRewardsPerYear = (values: GetRewardsPerYearInput) => { const { amount, averageRewardsPerSecond } = values + validateArgs.bigint({ averageRewardsPerSecond }) + const rewards = new BigDecimal(averageRewardsPerSecond) .multiply(constants.blockchain.secondsInYear) .multiply(amount) diff --git a/src/methods/utils/getTransactions.ts b/src/methods/utils/getTransactions.ts index e9168245..51d24818 100644 --- a/src/methods/utils/getTransactions.ts +++ b/src/methods/utils/getTransactions.ts @@ -1,6 +1,6 @@ -import { apiUrls } from 'helpers' -import { subgraph } from 'graphql' import { TransactionsQueryVariables } from 'graphql/subgraph/transactions' +import { apiUrls, validateArgs } from 'helpers' +import { subgraph } from 'graphql' type GetTransactionsInput = { @@ -11,6 +11,8 @@ type GetTransactionsInput = { const getTransactions = async (input: GetTransactionsInput) => { const { options, hash } = input + validateArgs.string({ hash }) + const data = await subgraph.transactions.fetchTransactionsQuery({ url: apiUrls.getSubgraphqlUrl(options), variables: { diff --git a/src/methods/vault/requests/getAllocatorActions/index.ts b/src/methods/vault/requests/getAllocatorActions/index.ts index 06f5948b..9dbca2ad 100644 --- a/src/methods/vault/requests/getAllocatorActions/index.ts +++ b/src/methods/vault/requests/getAllocatorActions/index.ts @@ -1,5 +1,5 @@ import type { AllocatorActionsQueryVariables, AllocatorActionsQueryPayload } from 'graphql/subgraph/allocatorActions' -import { AllocatorActionType, apiUrls } from 'helpers' +import { AllocatorActionType, apiUrls, validateArgs } from 'helpers' import { subgraph } from 'graphql' import { ModifiedAllocatorActions } from './types' @@ -18,6 +18,27 @@ type GetAllocatorActionsInput = { const getAllocatorActions = async (input: GetAllocatorActionsInput) => { const { options, skip, limit, types, vaultAddress, userAddress } = input + validateArgs.address({ vaultAddress }) + validateArgs.number({ skip, limit }) + + if (userAddress) { + validateArgs.address({ userAddress }) + } + + if (types) { + if (!Array.isArray(types)) { + throw new Error(`The "types" argument must be a array`) + } + + types.forEach((value) => { + if (value in AllocatorActionType) { + return + } + + throw new Error(`The "types" argument must contain enum AllocatorActionType values`) + }) + } + const data = await subgraph.allocatorActions.fetchAllocatorActionsQuery({ url: apiUrls.getSubgraphqlUrl(options), variables: { diff --git a/src/methods/vault/requests/getDaySnapshots/index.ts b/src/methods/vault/requests/getDaySnapshots/index.ts index 84c37482..8c9ae24f 100644 --- a/src/methods/vault/requests/getDaySnapshots/index.ts +++ b/src/methods/vault/requests/getDaySnapshots/index.ts @@ -1,5 +1,5 @@ -import { apiUrls } from 'helpers' import { subgraph } from 'graphql' +import { apiUrls, validateArgs } from 'helpers' import { DaySnapshotsQueryVariables } from 'graphql/subgraph/daySnapshots' import { ModifiedDaySnapshots } from './types' @@ -13,7 +13,10 @@ type GetDaySnapshotsInput = { } const getDaySnapshots = async (input: GetDaySnapshotsInput) => { - const { vaultAddress, unixStartOfDay, options } = input + const { options, vaultAddress, unixStartOfDay } = input + + validateArgs.address({ vaultAddress }) + validateArgs.number({ unixStartOfDay }) const data = await subgraph.daySnapshots.fetchDaySnapshotsQuery({ url: apiUrls.getSubgraphqlUrl(options), diff --git a/src/methods/vault/requests/getExitQueue/index.ts b/src/methods/vault/requests/getExitQueue/index.ts index 8101647b..b0b2fe29 100644 --- a/src/methods/vault/requests/getExitQueue/index.ts +++ b/src/methods/vault/requests/getExitQueue/index.ts @@ -1,3 +1,5 @@ +import { validateArgs } from 'helpers' + import parseExitRequests from './parseExitRequests' import fetchExitQueuePositions from './fetchExitQueuePositions' import type { FetchExitQueuePositionsInput } from './fetchExitQueuePositions' @@ -17,6 +19,8 @@ const mock = { const getExitQueue = async (input: GetExitQueueInput) => { const { options, contracts, vaultAddress, userAddress } = input + validateArgs.address({ vaultAddress, userAddress }) + const data = await fetchExitQueuePositions({ options, vaultAddress, userAddress }) if (!data) { diff --git a/src/methods/vault/requests/getHarvestParams.ts b/src/methods/vault/requests/getHarvestParams.ts index 14609a87..f130b1cd 100644 --- a/src/methods/vault/requests/getHarvestParams.ts +++ b/src/methods/vault/requests/getHarvestParams.ts @@ -1,4 +1,4 @@ -import { apiUrls } from 'helpers' +import { apiUrls, validateArgs } from 'helpers' import { subgraph } from 'graphql' @@ -10,6 +10,8 @@ type GetHarvestParamsInput = { const getHarvestParams = async (values: GetHarvestParamsInput) => { const { options, vaultAddress } = values + validateArgs.address({ vaultAddress }) + const result = await subgraph.vault.fetchHarvestParamsQuery({ url: apiUrls.getSubgraphqlUrl(options), variables: { diff --git a/src/methods/vault/requests/getStakeBalance.ts b/src/methods/vault/requests/getStakeBalance.ts index 36e8eb3c..77e79a47 100644 --- a/src/methods/vault/requests/getStakeBalance.ts +++ b/src/methods/vault/requests/getStakeBalance.ts @@ -1,3 +1,4 @@ +import { validateArgs } from 'helpers' import { vaultMulticall } from 'contracts' @@ -11,6 +12,8 @@ type GetStakeBalanceInput = { const getStakeBalance = async (values: GetStakeBalanceInput) => { const { contracts, options, vaultAddress, userAddress } = values + validateArgs.address({ vaultAddress, userAddress }) + const vaultContract = contracts.helpers.createVaultContract(vaultAddress) const balanceShares = await vaultContract.balanceOf(userAddress) diff --git a/src/methods/vault/requests/getValidators/index.ts b/src/methods/vault/requests/getValidators/index.ts index cec59b7f..16c7cb49 100644 --- a/src/methods/vault/requests/getValidators/index.ts +++ b/src/methods/vault/requests/getValidators/index.ts @@ -1,5 +1,5 @@ -import { apiUrls } from 'helpers' import { backend } from 'graphql' +import { apiUrls, validateArgs } from 'helpers' import { VaultValidatorsQueryVariables, VaultValidatorsQueryPayload } from 'graphql/backend/vault' import type { ModifiedValidators } from './types' @@ -14,6 +14,8 @@ type GetValidatorsInput = { const getValidators = async (input: GetValidatorsInput) => { const { options, vaultAddress } = input + validateArgs.address({ vaultAddress }) + const data = await backend.vault.fetchVaultValidatorsQuery({ url: apiUrls.getBackendUrl(options), variables: { address: vaultAddress.toLowerCase() }, diff --git a/src/methods/vault/requests/getVault/index.ts b/src/methods/vault/requests/getVault/index.ts index 5a65f214..dfa92abb 100644 --- a/src/methods/vault/requests/getVault/index.ts +++ b/src/methods/vault/requests/getVault/index.ts @@ -1,5 +1,5 @@ -import { apiUrls } from 'helpers' import { subgraph } from 'graphql' +import { apiUrls, validateArgs } from 'helpers' import { VaultQueryVariables, VaultQueryPayload } from 'graphql/subgraph/vault' import { ModifiedVault } from './types' @@ -14,6 +14,8 @@ type GetVaultInput = { const getVault = async (input: GetVaultInput) => { const { vaultAddress, options } = input + validateArgs.address({ vaultAddress }) + const data = await subgraph.vault.fetchVaultQuery({ url: apiUrls.getSubgraphqlUrl(options), variables: { diff --git a/src/methods/vault/requests/getWithdrawData/index.ts b/src/methods/vault/requests/getWithdrawData/index.ts index 81df93fb..a0115f82 100644 --- a/src/methods/vault/requests/getWithdrawData/index.ts +++ b/src/methods/vault/requests/getWithdrawData/index.ts @@ -1,3 +1,5 @@ +import { validateArgs } from 'helpers' + import getMaxWithdraw from './getMaxWithdraw' import getAvailableAssets from './getAvailableAssets' @@ -15,6 +17,9 @@ type GetWithdrawDataInput = { const getWithdrawData = async (values: GetWithdrawDataInput) => { const { options, contracts, ltvPercent, mintedAssets, stakedAssets, vaultAddress, userAddress } = values + validateArgs.address({ vaultAddress, userAddress }) + validateArgs.bigint({ ltvPercent, mintedAssets, stakedAssets }) + const availableAssets = await getAvailableAssets({ options, contracts, vaultAddress, userAddress }) const maxWithdrawAssets = await getMaxWithdraw({ contracts, ltvPercent, mintedAssets, stakedAssets }) From ab6ba81a8ed0562475bfc72b956aaafa9c68e4b0 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Wed, 4 Oct 2023 19:20:32 +0500 Subject: [PATCH 06/13] [validate-methods] add abis --- package-lock.json | 92 +++++++++++++++++++ package.json | 5 +- rollup.config.ts | 6 ++ src/StakeWiseSDK.ts | 8 +- src/contracts/abis/VestingEscrowAbi.json | 1 + .../abis/VestingEscrowFactoryAbi.json | 1 + src/contracts/abis/{index.ts => index.js} | 4 + src/contracts/index.ts | 1 + src/index.ts | 1 + src/types/global.ts | 6 ++ 10 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 src/contracts/abis/VestingEscrowAbi.json create mode 100644 src/contracts/abis/VestingEscrowFactoryAbi.json rename src/contracts/abis/{index.ts => index.js} (87%) diff --git a/package-lock.json b/package-lock.json index f33c6ff2..4726ab1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,6 +38,7 @@ "jest-fetch-mock": "3.0.3", "regenerator-runtime": "0.14.0", "rollup": "3.29.1", + "rollup-plugin-copy": "^3.5.0", "rollup-plugin-delete": "2.0.0", "rollup-plugin-dts": "6.0.2", "rollup-plugin-peer-deps-external": "2.2.4", @@ -7965,6 +7966,15 @@ "integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==", "dev": true }, + "node_modules/@types/fs-extra": { + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.1.3.tgz", + "integrity": "sha512-7IdV01N0u/CaVO0fuY1YmEg14HQN3+EW8mpNgg6NEfxEl/lzCa5OxlBu3iFsCAdamnYOcTQ7oEi43Xc/67Rgzw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", @@ -26323,6 +26333,15 @@ "node": ">=8" } }, + "node_modules/is-plain-object": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-3.0.1.tgz", + "integrity": "sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", @@ -33682,6 +33701,79 @@ "fsevents": "~2.3.2" } }, + "node_modules/rollup-plugin-copy": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-copy/-/rollup-plugin-copy-3.5.0.tgz", + "integrity": "sha512-wI8D5dvYovRMx/YYKtUNt3Yxaw4ORC9xo6Gt9t22kveWz1enG9QrhVlagzwrxSC455xD1dHMKhIJkbsQ7d48BA==", + "dev": true, + "dependencies": { + "@types/fs-extra": "^8.0.1", + "colorette": "^1.1.0", + "fs-extra": "^8.1.0", + "globby": "10.0.1", + "is-plain-object": "^3.0.0" + }, + "engines": { + "node": ">=8.3" + } + }, + "node_modules/rollup-plugin-copy/node_modules/colorette": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.4.0.tgz", + "integrity": "sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==", + "dev": true + }, + "node_modules/rollup-plugin-copy/node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/rollup-plugin-copy/node_modules/globby": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-10.0.1.tgz", + "integrity": "sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==", + "dev": true, + "dependencies": { + "@types/glob": "^7.1.1", + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.0.3", + "glob": "^7.1.3", + "ignore": "^5.1.1", + "merge2": "^1.2.3", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/rollup-plugin-copy/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/rollup-plugin-copy/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/rollup-plugin-delete": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/rollup-plugin-delete/-/rollup-plugin-delete-2.0.0.tgz", diff --git a/package.json b/package.json index aed9568c..6f9e6e31 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,9 @@ "dist/" ], "exports": { - "default": "./dist/index.js" + ".": "./dist/index.js", + "./abis/*": "./dist/abis/*", + "./abis": "./dist/abis/index.js" }, "keywords": [ "ethereum", @@ -60,6 +62,7 @@ "jest-fetch-mock": "3.0.3", "regenerator-runtime": "0.14.0", "rollup": "3.29.1", + "rollup-plugin-copy": "3.5.0", "rollup-plugin-delete": "2.0.0", "rollup-plugin-dts": "6.0.2", "rollup-plugin-peer-deps-external": "2.2.4", diff --git a/rollup.config.ts b/rollup.config.ts index f5e8883b..40475c44 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -1,3 +1,4 @@ +import copy from 'rollup-plugin-copy' import json from '@rollup/plugin-json' import del from 'rollup-plugin-delete' import { dts } from 'rollup-plugin-dts' @@ -42,6 +43,11 @@ const config: RollupOptions[] = [ comments: false, }, }), + copy({ + targets: [ + { src: 'src/contracts/abis', dest: 'dist' }, + ], + }), ], }, { diff --git a/src/StakeWiseSDK.ts b/src/StakeWiseSDK.ts index b99f271c..be33d859 100644 --- a/src/StakeWiseSDK.ts +++ b/src/StakeWiseSDK.ts @@ -8,7 +8,9 @@ type VaultMulticallInput = Pick[0], 'request' class StakeWiseSDK { readonly utils: StakeWise.Utils + readonly config: StakeWise.Config readonly options: StakeWise.Options + readonly provider: StakeWise.Provider readonly vault: StakeWise.VaultMethods readonly contracts: StakeWise.Contracts readonly osToken: StakeWise.OsTokenMethods @@ -18,7 +20,9 @@ class StakeWiseSDK { const config = configs[options.network] const provider = options.provider || new JsonRpcProvider(apiUrls.getWeb3Url(options)) + this.config = config this.options = options + this.provider = provider this.rateContracts = this.#initRateContracts() this.contracts = createContracts({ provider, config }) @@ -52,10 +56,6 @@ class StakeWiseSDK { get network() { return this.options.network } - - get provider() { - return this.options.provider - } } diff --git a/src/contracts/abis/VestingEscrowAbi.json b/src/contracts/abis/VestingEscrowAbi.json new file mode 100644 index 00000000..d43b01c9 --- /dev/null +++ b/src/contracts/abis/VestingEscrowAbi.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vestedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] diff --git a/src/contracts/abis/VestingEscrowFactoryAbi.json b/src/contracts/abis/VestingEscrowFactoryAbi.json new file mode 100644 index 00000000..df3894e5 --- /dev/null +++ b/src/contracts/abis/VestingEscrowFactoryAbi.json @@ -0,0 +1 @@ +[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"admin","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"address","name":"escrow","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cliffLength","type":"uint256"}],"name":"VestingEscrowCreated","type":"event"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"total","type":"uint256"}],"stateMutability":"view","type":"function"}] diff --git a/src/contracts/abis/index.ts b/src/contracts/abis/index.js similarity index 87% rename from src/contracts/abis/index.ts rename to src/contracts/abis/index.js index 6545ddf2..45d6191f 100644 --- a/src/contracts/abis/index.ts +++ b/src/contracts/abis/index.js @@ -1,9 +1,11 @@ import RewardSplitterFactoryAbi from './RewardSplitterFactoryAbi.json' +import VestingEscrowFactoryAbi from './VestingEscrowFactoryAbi.json' import Erc20PrivateVaultAbi from './Erc20PrivateVaultAbi.json' import MintTokenConfigAbi from './MintTokenConfigAbi.json' import VaultsRegistryAbi from './VaultsRegistryAbi.json' import RewardSplitterAbi from './RewardSplitterAbi.json' import V2RewardTokenAbi from './V2RewardTokenAbi.json' +import VestingEscrowAbi from './VestingEscrowAbi.json' import PrivateVaultAbi from './PrivateVaultAbi.json' import VaultFactoryAbi from './VaultFactoryAbi.json' import PriceOracleAbi from './PriceOracleAbi.json' @@ -20,11 +22,13 @@ import Erc20Abi from './Erc20Abi.json' export { RewardSplitterFactoryAbi, + VestingEscrowFactoryAbi, Erc20PrivateVaultAbi, MintTokenConfigAbi, VaultsRegistryAbi, RewardSplitterAbi, V2RewardTokenAbi, + VestingEscrowAbi, PrivateVaultAbi, VaultFactoryAbi, PriceOracleAbi, diff --git a/src/contracts/index.ts b/src/contracts/index.ts index 4d374776..aa598068 100644 --- a/src/contracts/index.ts +++ b/src/contracts/index.ts @@ -1,4 +1,5 @@ export { default as createRatesContracts } from './createRatesContracts' export { default as createContracts } from './createContracts' export { default as vaultMulticall } from './vaultMulticall' +export { default as createContract } from './createContract' export { default as multicall } from './multicall' diff --git a/src/index.ts b/src/index.ts index d95a416d..d50588c2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,5 +2,6 @@ import './types/global' export * from 'helpers/enums' +export { createContract } from 'contracts' export { BigDecimal, configs } from 'helpers' export { default as StakeWiseSDK } from './StakeWiseSDK' diff --git a/src/types/global.ts b/src/types/global.ts index 359a375e..4f5a02ba 100644 --- a/src/types/global.ts +++ b/src/types/global.ts @@ -1,4 +1,5 @@ import { createContracts, createRatesContracts } from 'contracts' +import { BrowserProvider, JsonRpcProvider } from 'ethers' import { Network, configs } from 'helpers' import methods from 'methods' @@ -16,10 +17,12 @@ import type { VaultFactoryAbi, PrivateVaultAbi, V2RewardTokenAbi, + VestingEscrowAbi, VaultsRegistryAbi, RewardSplitterAbi, MintTokenConfigAbi, Erc20PrivateVaultAbi, + VestingEscrowFactoryAbi, RewardSplitterFactoryAbi, } from '../contracts/types' @@ -31,6 +34,7 @@ declare global { type Contracts = ReturnType type RateContracts = ReturnType + type Provider = BrowserProvider | JsonRpcProvider type Utils = ReturnType type VaultMethods = ReturnType type OsTokenMethods = ReturnType @@ -59,10 +63,12 @@ declare global { type PrivateVault = PrivateVaultAbi type VaultFactory = VaultFactoryAbi type V2RewardToken = V2RewardTokenAbi + type VestingEscrow = VestingEscrowAbi type RewardSplitter = RewardSplitterAbi type VaultsRegistry = VaultsRegistryAbi type MintTokenConfig = MintTokenConfigAbi type Erc20PrivateVault = Erc20PrivateVaultAbi + type VestingEscrowFactory = VestingEscrowFactoryAbi type RewardSplitterFactory = RewardSplitterFactoryAbi } } From ffce642033831042be002dda8e831132c19e627b Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Wed, 4 Oct 2023 19:20:46 +0500 Subject: [PATCH 07/13] 1.1.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4726ab1f..e919f2e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@stakewise/v3-sdk", - "version": "1.0.1", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@stakewise/v3-sdk", - "version": "1.0.1", + "version": "1.1.0", "license": "AGPL-3.0-only", "dependencies": { "bignumber.js": "9.1.2" diff --git a/package.json b/package.json index 6f9e6e31..9648f2ab 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.0.1", + "version": "1.1.0", "sideEffects": false, "main": "dist/index.js", "module": "dist/index.js", From 9a4906e70abd1923959c66557ad4d4292cc3bc34 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Wed, 4 Oct 2023 19:51:03 +0500 Subject: [PATCH 08/13] [validate-methods] improves --- package.json | 3 ++- rollup.config.ts | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9648f2ab..d54c17b3 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "rollup": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs" }, "files": [ - "dist/" + "dist/index.js", + "dist/abis/index.js" ], "exports": { ".": "./dist/index.js", diff --git a/rollup.config.ts b/rollup.config.ts index 40475c44..f857117f 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -72,6 +72,29 @@ const config: RollupOptions[] = [ }), ], }, + { + input: 'dist/abis/index.js', + output: [ + { + file: 'dist/abis/index.d.ts', + sourcemap: false, + format: 'es', + }, + ], + plugins: [ + dts({ + tsconfig: './tsconfig.json', + }), + json(), + del({ + hook: 'buildEnd', + targets: [ + './dist/src', + './dist/rollup*', + ], + }), + ], + }, ] From a94c6eedd736d47f562d918349bbb8457a327849 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Wed, 4 Oct 2023 20:24:11 +0500 Subject: [PATCH 09/13] [validate-methods] fix rollup --- package.json | 2 +- rollup.config.ts | 23 ----------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/package.json b/package.json index d54c17b3..85dd9a68 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "access": "public" }, "peerDependencies": { - "ethers": "^6.6.7" + "ethers": "^6.7.1" }, "devDependencies": { "@graphql-codegen/cli": "5.0.0", diff --git a/rollup.config.ts b/rollup.config.ts index f857117f..40475c44 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -72,29 +72,6 @@ const config: RollupOptions[] = [ }), ], }, - { - input: 'dist/abis/index.js', - output: [ - { - file: 'dist/abis/index.d.ts', - sourcemap: false, - format: 'es', - }, - ], - plugins: [ - dts({ - tsconfig: './tsconfig.json', - }), - json(), - del({ - hook: 'buildEnd', - targets: [ - './dist/src', - './dist/rollup*', - ], - }), - ], - }, ] From acf2f30a0ee3cb607788f3caee5fd94246f82239 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Wed, 4 Oct 2023 20:24:26 +0500 Subject: [PATCH 10/13] 1.2.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e919f2e1..73235414 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@stakewise/v3-sdk", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@stakewise/v3-sdk", - "version": "1.1.0", + "version": "1.2.0", "license": "AGPL-3.0-only", "dependencies": { "bignumber.js": "9.1.2" diff --git a/package.json b/package.json index 85dd9a68..75b549d5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.1.0", + "version": "1.2.0", "sideEffects": false, "main": "dist/index.js", "module": "dist/index.js", From 85c87b5596e693bb0a0b60f91836bc1761fe9a27 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Thu, 5 Oct 2023 11:46:22 +0500 Subject: [PATCH 11/13] 1.2.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 73235414..695a8bbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@stakewise/v3-sdk", - "version": "1.2.0", + "version": "1.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@stakewise/v3-sdk", - "version": "1.2.0", + "version": "1.2.1", "license": "AGPL-3.0-only", "dependencies": { "bignumber.js": "9.1.2" diff --git a/package.json b/package.json index 75b549d5..8eebfcfe 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.2.0", + "version": "1.2.1", "sideEffects": false, "main": "dist/index.js", "module": "dist/index.js", From 3e299b999fe9b4dd951f3b5de90245519180ac68 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Thu, 5 Oct 2023 12:12:35 +0500 Subject: [PATCH 12/13] [validate-methods] remove files --- package.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/package.json b/package.json index 8eebfcfe..7579081a 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,6 @@ "graphql": "graphql-codegen && ts-node -O '{\"module\": \"commonjs\"}' ./scripts/generateGraphqlExports", "rollup": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs" }, - "files": [ - "dist/index.js", - "dist/abis/index.js" - ], "exports": { ".": "./dist/index.js", "./abis/*": "./dist/abis/*", From 564b82d88f18488032da15001800b82ffeac45e4 Mon Sep 17 00:00:00 2001 From: Andrey Kopylov Date: Thu, 5 Oct 2023 12:12:49 +0500 Subject: [PATCH 13/13] 1.2.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 695a8bbc..4c01732b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@stakewise/v3-sdk", - "version": "1.2.1", + "version": "1.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@stakewise/v3-sdk", - "version": "1.2.1", + "version": "1.2.2", "license": "AGPL-3.0-only", "dependencies": { "bignumber.js": "9.1.2" diff --git a/package.json b/package.json index 7579081a..00bb78f8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.2.1", + "version": "1.2.2", "sideEffects": false, "main": "dist/index.js", "module": "dist/index.js",