Skip to content

Commit

Permalink
[fixes-after-release] improve gas
Browse files Browse the repository at this point in the history
  • Loading branch information
Cast0001 committed Nov 29, 2023
1 parent db477f5 commit a28fe62
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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.4.0-blue)
![Version](https://img.shields.io/badge/version-1.4.1-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
17 changes: 17 additions & 0 deletions src/contracts/vaultMulticall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,17 @@ const vaultMulticall = async <T extends unknown>(values: VaultMulticallInput): P
}) as T
}

// If we don't need to update a vault state, we can just call the method, no multicall. This will save the user gas
const isSoloCall = calls.length === 1 && params.length === 1

if (estimateGas) {
if (isSoloCall) {
const { method, args } = params[0]

// @ts-ignore: no types to describe
return contract[method].estimateGas(...args)
}

return contract.multicall.estimateGas(calls) as T
}

Expand All @@ -94,6 +104,13 @@ const vaultMulticall = async <T extends unknown>(values: VaultMulticallInput): P
} as T
}

if (isSoloCall) {
const { method, args } = params[0]

// @ts-ignore: no types to describe
return contract[method](...args)
}

return contract.multicall(calls) as T
}

Expand Down
4 changes: 2 additions & 2 deletions src/methods/osToken/requests/getMaxMint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const getMaxMint = async (values: GetMaxMintInput) => {
const canMintAssets = maxMintedAssets - maxMintedAssetsHourReward - mintedAssets

if (canMintAssets > 0) {
const maxMintShares2 = await contracts.base.mintTokenController.convertToShares(canMintAssets)
const maxMintShares = await contracts.base.mintTokenController.convertToShares(canMintAssets)

return maxMintShares2
return maxMintShares
}

return 0n
Expand Down

0 comments on commit a28fe62

Please sign in to comment.