@zerodev/sdk 5.3.19 → 5.3.20
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.
- package/_cjs/actions/account-client/getUserOperationGasPrice.js +26 -0
- package/_cjs/actions/account-client/getUserOperationGasPrice.js.map +1 -1
- package/_esm/actions/account-client/getUserOperationGasPrice.js +28 -0
- package/_esm/actions/account-client/getUserOperationGasPrice.js.map +1 -1
- package/_types/actions/account-client/getUserOperationGasPrice.d.ts +1 -1
- package/_types/actions/account-client/getUserOperationGasPrice.d.ts.map +1 -1
- package/actions/account-client/getUserOperationGasPrice.ts +38 -1
- package/package.json +10 -32
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUserOperationGasPrice = void 0;
|
|
4
|
+
const actions_1 = require("viem/actions");
|
|
5
|
+
const chains_1 = require("viem/chains");
|
|
6
|
+
const utils_js_1 = require("../../clients/utils.js");
|
|
4
7
|
const getUserOperationGasPrice = async (client) => {
|
|
8
|
+
if (client.transport?.url &&
|
|
9
|
+
((0, utils_js_1.isProviderSet)(client.transport.url, "ALCHEMY") ||
|
|
10
|
+
(0, utils_js_1.isProviderSet)(client.transport.url, "ZERODEV") ||
|
|
11
|
+
(0, utils_js_1.isProviderSet)(client.transport.url, "CONDUIT"))) {
|
|
12
|
+
const [fee, block] = await Promise.all([
|
|
13
|
+
client.request({
|
|
14
|
+
method: "rundler_maxPriorityFeePerGas",
|
|
15
|
+
params: []
|
|
16
|
+
}),
|
|
17
|
+
(0, actions_1.getBlock)(client, { blockTag: "latest" })
|
|
18
|
+
]);
|
|
19
|
+
const chainId = client.chain
|
|
20
|
+
? client.chain.id
|
|
21
|
+
: await (0, actions_1.getChainId)(client);
|
|
22
|
+
const baseFeeMultiplier = chainId === chains_1.arbitrum.id ? 1.05 : 1.5;
|
|
23
|
+
const priorityFeeMultiplier = chainId === chains_1.arbitrum.id ? 1.0 : 1.25;
|
|
24
|
+
const denominator = 100;
|
|
25
|
+
const multiply = (base, multiplier) => (base * BigInt(multiplier * denominator)) / BigInt(denominator);
|
|
26
|
+
const maxPriorityFeePerGas = multiply(BigInt(fee), priorityFeeMultiplier);
|
|
27
|
+
const baseFeePerGas = multiply(block.baseFeePerGas, baseFeeMultiplier);
|
|
28
|
+
const maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas;
|
|
29
|
+
return { maxFeePerGas, maxPriorityFeePerGas };
|
|
30
|
+
}
|
|
5
31
|
const gasPrice = await client.request({
|
|
6
32
|
method: "zd_getUserOperationGasPrice",
|
|
7
33
|
params: []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":";;;AACA,0CAAmD;AACnD,wCAAqD;AACrD,qDAAsD;AAQ/C,MAAM,wBAAwB,GAAG,KAAK,EAKzC,MAA2E,EACtB,EAAE;IACvD,IACI,MAAM,CAAC,SAAS,EAAE,GAAG;QACrB,CAAC,IAAA,wBAAa,EAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC;YAC3C,IAAA,wBAAa,EAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC;YAC9C,IAAA,wBAAa,EAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,EACrD,CAAC;QACC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACnC,MAAM,CAAC,OAAO,CAAC;gBAEX,MAAM,EAAE,8BAA8B;gBACtC,MAAM,EAAE,EAAE;aAEb,CAAQ;YACT,IAAA,kBAAQ,EAAC,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CAAA;AAnDY,QAAA,wBAAwB,4BAmDpC"}
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
+
import { getBlock, getChainId } from "viem/actions";
|
|
2
|
+
import { arbitrum } from "viem/chains";
|
|
3
|
+
import { isProviderSet } from "../../clients/utils.js";
|
|
1
4
|
export const getUserOperationGasPrice = async (client) => {
|
|
5
|
+
if (client.transport?.url &&
|
|
6
|
+
(isProviderSet(client.transport.url, "ALCHEMY") ||
|
|
7
|
+
isProviderSet(client.transport.url, "ZERODEV") ||
|
|
8
|
+
isProviderSet(client.transport.url, "CONDUIT"))) {
|
|
9
|
+
const [fee, block] = await Promise.all([
|
|
10
|
+
client.request({
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
method: "rundler_maxPriorityFeePerGas",
|
|
13
|
+
params: []
|
|
14
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
15
|
+
}),
|
|
16
|
+
getBlock(client, { blockTag: "latest" })
|
|
17
|
+
]);
|
|
18
|
+
const chainId = client.chain
|
|
19
|
+
? client.chain.id
|
|
20
|
+
: await getChainId(client);
|
|
21
|
+
const baseFeeMultiplier = chainId === arbitrum.id ? 1.05 : 1.5;
|
|
22
|
+
const priorityFeeMultiplier = chainId === arbitrum.id ? 1.0 : 1.25;
|
|
23
|
+
const denominator = 100;
|
|
24
|
+
const multiply = (base, multiplier) => (base * BigInt(multiplier * denominator)) / BigInt(denominator);
|
|
25
|
+
const maxPriorityFeePerGas = multiply(BigInt(fee), priorityFeeMultiplier);
|
|
26
|
+
const baseFeePerGas = multiply(block.baseFeePerGas, baseFeeMultiplier);
|
|
27
|
+
const maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas;
|
|
28
|
+
return { maxFeePerGas, maxPriorityFeePerGas };
|
|
29
|
+
}
|
|
2
30
|
const gasPrice = await client.request({
|
|
3
31
|
method: "zd_getUserOperationGasPrice",
|
|
4
32
|
params: []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAQtD,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAKzC,MAA2E,EACtB,EAAE;IACvD,IACI,MAAM,CAAC,SAAS,EAAE,GAAG;QACrB,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC;YAC3C,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC;YAC9C,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,EACrD,CAAC;QACC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACnC,MAAM,CAAC,OAAO,CAAC;gBACX,aAAa;gBACb,MAAM,EAAE,8BAA8B;gBACtC,MAAM,EAAE,EAAE;gBACV,4DAA4D;aAC/D,CAAQ;YACT,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;SAC3C,CAAC,CAAA;QACF,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK;YACxB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YACjB,CAAC,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,CAAA;QAC9B,MAAM,iBAAiB,GAAG,OAAO,KAAK,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAA;QAC9D,MAAM,qBAAqB,GAAG,OAAO,KAAK,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;QAClE,MAAM,WAAW,GAAG,GAAG,CAAA;QACvB,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,UAAkB,EAAE,EAAE,CAClD,CAAC,IAAI,GAAG,MAAM,CAAC,UAAU,GAAG,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;QAEnE,MAAM,oBAAoB,GAAG,QAAQ,CACjC,MAAM,CAAC,GAAG,CAAC,EACX,qBAAqB,CACxB,CAAA;QAED,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAA;QACtE,MAAM,YAAY,GAAG,aAAa,GAAG,oBAAoB,CAAA;QAEzD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAA;IACjD,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,6BAA6B;QACrC,MAAM,EAAE,EAAE;KACb,CAAC,CAAA;IAEF,OAAO;QACH,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC;QACpD,oBAAoB,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,CAAC;KACvE,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Account, Chain, Client, Transport } from "viem";
|
|
2
|
-
import type
|
|
2
|
+
import { type Prettify } from "viem/chains";
|
|
3
3
|
import type { ZeroDevAccountClientRpcSchema } from "../../types/kernel.js";
|
|
4
4
|
export type GetUserOperationGasPriceReturnType = {
|
|
5
5
|
maxFeePerGas: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationGasPrice.d.ts","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"getUserOperationGasPrice.d.ts","sourceRoot":"","sources":["../../../actions/account-client/getUserOperationGasPrice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAE7D,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,aAAa,CAAA;AAErD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAA;AAE1E,MAAM,MAAM,kCAAkC,GAAG;IAC7C,YAAY,EAAE,MAAM,CAAA;IACpB,oBAAoB,EAAE,MAAM,CAAA;CAC/B,CAAA;AAED,eAAO,MAAM,wBAAwB,+OAMlC,QAAQ,SAAS,kCAAkC,CAAC,CA6CtD,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Account, Chain, Client, Transport } from "viem"
|
|
2
|
-
import
|
|
2
|
+
import { getBlock, getChainId } from "viem/actions"
|
|
3
|
+
import { type Prettify, arbitrum } from "viem/chains"
|
|
4
|
+
import { isProviderSet } from "../../clients/utils.js"
|
|
3
5
|
import type { ZeroDevAccountClientRpcSchema } from "../../types/kernel.js"
|
|
4
6
|
|
|
5
7
|
export type GetUserOperationGasPriceReturnType = {
|
|
@@ -14,6 +16,41 @@ export const getUserOperationGasPrice = async <
|
|
|
14
16
|
>(
|
|
15
17
|
client: Client<TTransport, TChain, TAccount, ZeroDevAccountClientRpcSchema>
|
|
16
18
|
): Promise<Prettify<GetUserOperationGasPriceReturnType>> => {
|
|
19
|
+
if (
|
|
20
|
+
client.transport?.url &&
|
|
21
|
+
(isProviderSet(client.transport.url, "ALCHEMY") ||
|
|
22
|
+
isProviderSet(client.transport.url, "ZERODEV") ||
|
|
23
|
+
isProviderSet(client.transport.url, "CONDUIT"))
|
|
24
|
+
) {
|
|
25
|
+
const [fee, block] = await Promise.all([
|
|
26
|
+
client.request({
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
method: "rundler_maxPriorityFeePerGas",
|
|
29
|
+
params: []
|
|
30
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
31
|
+
}) as any,
|
|
32
|
+
getBlock(client, { blockTag: "latest" })
|
|
33
|
+
])
|
|
34
|
+
const chainId = client.chain
|
|
35
|
+
? client.chain.id
|
|
36
|
+
: await getChainId(client)
|
|
37
|
+
const baseFeeMultiplier = chainId === arbitrum.id ? 1.05 : 1.5
|
|
38
|
+
const priorityFeeMultiplier = chainId === arbitrum.id ? 1.0 : 1.25
|
|
39
|
+
const denominator = 100
|
|
40
|
+
const multiply = (base: bigint, multiplier: number) =>
|
|
41
|
+
(base * BigInt(multiplier * denominator)) / BigInt(denominator)
|
|
42
|
+
|
|
43
|
+
const maxPriorityFeePerGas = multiply(
|
|
44
|
+
BigInt(fee),
|
|
45
|
+
priorityFeeMultiplier
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const baseFeePerGas = multiply(block.baseFeePerGas, baseFeeMultiplier)
|
|
49
|
+
const maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas
|
|
50
|
+
|
|
51
|
+
return { maxFeePerGas, maxPriorityFeePerGas }
|
|
52
|
+
}
|
|
53
|
+
|
|
17
54
|
const gasPrice = await client.request({
|
|
18
55
|
method: "zd_getUserOperationGasPrice",
|
|
19
56
|
params: []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodev/sdk",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.20",
|
|
4
4
|
"author": "ZeroDev",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
@@ -9,13 +9,7 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"description": "A utility library for working with ERC-4337",
|
|
12
|
-
"keywords": [
|
|
13
|
-
"ethereum",
|
|
14
|
-
"erc-4337",
|
|
15
|
-
"eip-4337",
|
|
16
|
-
"paymaster",
|
|
17
|
-
"bundler"
|
|
18
|
-
],
|
|
12
|
+
"keywords": ["ethereum", "erc-4337", "eip-4337", "paymaster", "bundler"],
|
|
19
13
|
"license": "MIT",
|
|
20
14
|
"files": [
|
|
21
15
|
"_esm",
|
|
@@ -96,30 +90,14 @@
|
|
|
96
90
|
},
|
|
97
91
|
"typesVersions": {
|
|
98
92
|
"*": {
|
|
99
|
-
"accounts": [
|
|
100
|
-
|
|
101
|
-
],
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
],
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
],
|
|
108
|
-
"types": [
|
|
109
|
-
"./_types/types/index.d.ts"
|
|
110
|
-
],
|
|
111
|
-
"actions/kernel": [
|
|
112
|
-
"./_types/actions/kernel/index.d.ts"
|
|
113
|
-
],
|
|
114
|
-
"clients": [
|
|
115
|
-
"./_types/clients/index.d.ts"
|
|
116
|
-
],
|
|
117
|
-
"clients/kernel": [
|
|
118
|
-
"./_types/clients/kernel/index.d.ts"
|
|
119
|
-
],
|
|
120
|
-
"providers": [
|
|
121
|
-
"./_types/providers/index.d.ts"
|
|
122
|
-
]
|
|
93
|
+
"accounts": ["./_types/accounts/index.d.ts"],
|
|
94
|
+
"plugins": ["./_types/plugins/index.d.ts"],
|
|
95
|
+
"actions": ["./_types/actions/index.d.ts"],
|
|
96
|
+
"types": ["./_types/types/index.d.ts"],
|
|
97
|
+
"actions/kernel": ["./_types/actions/kernel/index.d.ts"],
|
|
98
|
+
"clients": ["./_types/clients/index.d.ts"],
|
|
99
|
+
"clients/kernel": ["./_types/clients/kernel/index.d.ts"],
|
|
100
|
+
"providers": ["./_types/providers/index.d.ts"]
|
|
123
101
|
}
|
|
124
102
|
},
|
|
125
103
|
"peerDependencies": {
|