@gearbox-protocol/sdk 13.5.2 → 13.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,8 @@ __export(simulateWithPriceUpdates_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(simulateWithPriceUpdates_exports);
26
26
  var import_viem = require("viem");
27
+ var import_actions = require("viem/actions");
28
+ var import_utils = require("viem/utils");
27
29
  var import_errors = require("../../../abi/errors.js");
28
30
  var import_iUpdatablePriceFeed = require("../../../abi/iUpdatablePriceFeed.js");
29
31
  var import_cast = require("./cast.js");
@@ -53,6 +55,41 @@ async function simulateWithPriceUpdates(client, parameters) {
53
55
  "client chain not configured. multicallAddress is required."
54
56
  );
55
57
  }
58
+ if (priceUpdates.length === 0 && restContracts.length === 1) {
59
+ const contract = restContracts[0];
60
+ const { abi, address, args, functionName } = contract;
61
+ const callData = (0, import_viem.encodeFunctionData)({ abi, args, functionName });
62
+ const request2 = {
63
+ batch: false,
64
+ data: callData,
65
+ to: address,
66
+ blockNumber: rest.blockNumber,
67
+ blockTag: rest.blockTag,
68
+ gas: rest.gas,
69
+ account: rest.account ? (0, import_utils.parseAccount)(rest.account) : client.account,
70
+ value: rest.value
71
+ };
72
+ try {
73
+ const { data } = await (0, import_utils.getAction)(client, import_actions.call, "call")(request2);
74
+ const result = (0, import_viem.decodeFunctionResult)({
75
+ abi,
76
+ args,
77
+ data: data || "0x",
78
+ functionName
79
+ });
80
+ return [
81
+ result
82
+ ];
83
+ } catch (e) {
84
+ throw getSimulateWithPriceUpdatesError(
85
+ e,
86
+ priceUpdates,
87
+ restContracts,
88
+ void 0,
89
+ request2
90
+ );
91
+ }
92
+ }
56
93
  let request;
57
94
  try {
58
95
  const contracts = [
@@ -173,8 +210,8 @@ function getSimulateWithPriceUpdatesError(cause, priceUpdates, calls, results, r
173
210
  return [extractCallError(result), p.pretty, tsValid].filter(Boolean).join(" ");
174
211
  });
175
212
  const prettyCalls = callsResults.map((c, i) => {
176
- const call = calls[i];
177
- return [extractCallError(c), `${call.address}.${call.functionName}`].filter(Boolean).join(" ");
213
+ const call2 = calls[i];
214
+ return [extractCallError(c), `${call2.address}.${call2.functionName}`].filter(Boolean).join(" ");
178
215
  });
179
216
  if (results[0]?.status === "failure") {
180
217
  prettyCalls.unshift(
@@ -3,8 +3,12 @@ import {
3
3
  CallExecutionError,
4
4
  ContractFunctionRevertedError,
5
5
  decodeFunctionData,
6
+ decodeFunctionResult,
7
+ encodeFunctionData,
6
8
  parseAbi
7
9
  } from "viem";
10
+ import { call } from "viem/actions";
11
+ import { getAction, parseAccount } from "viem/utils";
8
12
  import { errorAbis } from "../../../abi/errors.js";
9
13
  import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
10
14
  import { generateCastTraceCall } from "./cast.js";
@@ -34,6 +38,41 @@ async function simulateWithPriceUpdates(client, parameters) {
34
38
  "client chain not configured. multicallAddress is required."
35
39
  );
36
40
  }
41
+ if (priceUpdates.length === 0 && restContracts.length === 1) {
42
+ const contract = restContracts[0];
43
+ const { abi, address, args, functionName } = contract;
44
+ const callData = encodeFunctionData({ abi, args, functionName });
45
+ const request2 = {
46
+ batch: false,
47
+ data: callData,
48
+ to: address,
49
+ blockNumber: rest.blockNumber,
50
+ blockTag: rest.blockTag,
51
+ gas: rest.gas,
52
+ account: rest.account ? parseAccount(rest.account) : client.account,
53
+ value: rest.value
54
+ };
55
+ try {
56
+ const { data } = await getAction(client, call, "call")(request2);
57
+ const result = decodeFunctionResult({
58
+ abi,
59
+ args,
60
+ data: data || "0x",
61
+ functionName
62
+ });
63
+ return [
64
+ result
65
+ ];
66
+ } catch (e) {
67
+ throw getSimulateWithPriceUpdatesError(
68
+ e,
69
+ priceUpdates,
70
+ restContracts,
71
+ void 0,
72
+ request2
73
+ );
74
+ }
75
+ }
37
76
  let request;
38
77
  try {
39
78
  const contracts = [
@@ -154,8 +193,8 @@ function getSimulateWithPriceUpdatesError(cause, priceUpdates, calls, results, r
154
193
  return [extractCallError(result), p.pretty, tsValid].filter(Boolean).join(" ");
155
194
  });
156
195
  const prettyCalls = callsResults.map((c, i) => {
157
- const call = calls[i];
158
- return [extractCallError(c), `${call.address}.${call.functionName}`].filter(Boolean).join(" ");
196
+ const call2 = calls[i];
197
+ return [extractCallError(c), `${call2.address}.${call2.functionName}`].filter(Boolean).join(" ");
159
198
  });
160
199
  if (results[0]?.status === "failure") {
161
200
  prettyCalls.unshift(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "13.5.2",
3
+ "version": "13.5.3",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",