@oydual31/more-vaults-sdk 1.1.25 → 1.1.26
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/dist/ethers/index.cjs +177 -6
- package/dist/ethers/index.cjs.map +1 -1
- package/dist/ethers/index.d.cts +75 -2
- package/dist/ethers/index.d.ts +75 -2
- package/dist/ethers/index.js +165 -7
- package/dist/ethers/index.js.map +1 -1
- package/dist/gasBuffer-BMHxT7CX.d.cts +35 -0
- package/dist/gasBuffer-BMHxT7CX.d.ts +35 -0
- package/dist/react/index.cjs +40 -4
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +40 -4
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +219 -22
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +88 -3
- package/dist/viem/index.d.ts +88 -3
- package/dist/viem/index.js +207 -24
- package/dist/viem/index.js.map +1 -1
- package/package.json +3 -2
- package/src/common/gasBuffer.test.ts +70 -0
- package/src/common/gasBuffer.ts +51 -0
- package/src/ethers/chains.ts +15 -0
- package/src/ethers/crossChainFlows.test.ts +77 -0
- package/src/ethers/crossChainFlows.ts +241 -9
- package/src/ethers/index.ts +16 -1
- package/src/ethers/redeemFlows.ts +2 -1
- package/src/viem/chains.ts +20 -0
- package/src/viem/crossChainFlows.test.ts +96 -0
- package/src/viem/crossChainFlows.ts +258 -20
- package/src/viem/curatorMulticall.ts +28 -0
- package/src/viem/curatorSwaps.ts +1 -1
- package/src/viem/depositFlows.ts +3 -2
- package/src/viem/index.ts +17 -1
- package/src/viem/redeemFlows.ts +3 -2
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configurable gas buffer for on-chain transactions.
|
|
3
|
+
*
|
|
4
|
+
* On-chain gas estimates can fall short for deep call stacks or LayerZero Read
|
|
5
|
+
* operations, causing out-of-gas reverts. We pad the raw estimate by a buffer
|
|
6
|
+
* expressed in basis points (bps): 4000 bps = +40%.
|
|
7
|
+
*
|
|
8
|
+
* The default is process-wide configurable via {@link setDefaultGasBufferBps},
|
|
9
|
+
* and {@link applyGasBuffer} also accepts a per-call override.
|
|
10
|
+
*
|
|
11
|
+
* @module gasBuffer
|
|
12
|
+
*/
|
|
13
|
+
/** Default gas buffer in basis points. 4000 = +40% on top of the estimate. */
|
|
14
|
+
declare const DEFAULT_GAS_BUFFER_BPS = 4000n;
|
|
15
|
+
/**
|
|
16
|
+
* Override the process-wide default gas buffer.
|
|
17
|
+
*
|
|
18
|
+
* @param bps Buffer in basis points (must be >= 0). e.g. 4000n = +40%.
|
|
19
|
+
* @throws RangeError if `bps` is negative.
|
|
20
|
+
*/
|
|
21
|
+
declare function setDefaultGasBufferBps(bps: bigint): void;
|
|
22
|
+
/** Read the current process-wide default gas buffer, in basis points. */
|
|
23
|
+
declare function getDefaultGasBufferBps(): bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Apply a gas buffer to a raw gas estimate.
|
|
26
|
+
*
|
|
27
|
+
* @param estimate Raw gas estimate (units of gas).
|
|
28
|
+
* @param bufferBps Optional per-call override in basis points; falls back to
|
|
29
|
+
* the process-wide default when omitted.
|
|
30
|
+
* @returns `estimate * (10000 + bps) / 10000`, rounded down (bigint).
|
|
31
|
+
* @throws RangeError if the effective buffer is negative.
|
|
32
|
+
*/
|
|
33
|
+
declare function applyGasBuffer(estimate: bigint, bufferBps?: bigint): bigint;
|
|
34
|
+
|
|
35
|
+
export { DEFAULT_GAS_BUFFER_BPS as D, applyGasBuffer as a, getDefaultGasBufferBps as g, setDefaultGasBufferBps as s };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configurable gas buffer for on-chain transactions.
|
|
3
|
+
*
|
|
4
|
+
* On-chain gas estimates can fall short for deep call stacks or LayerZero Read
|
|
5
|
+
* operations, causing out-of-gas reverts. We pad the raw estimate by a buffer
|
|
6
|
+
* expressed in basis points (bps): 4000 bps = +40%.
|
|
7
|
+
*
|
|
8
|
+
* The default is process-wide configurable via {@link setDefaultGasBufferBps},
|
|
9
|
+
* and {@link applyGasBuffer} also accepts a per-call override.
|
|
10
|
+
*
|
|
11
|
+
* @module gasBuffer
|
|
12
|
+
*/
|
|
13
|
+
/** Default gas buffer in basis points. 4000 = +40% on top of the estimate. */
|
|
14
|
+
declare const DEFAULT_GAS_BUFFER_BPS = 4000n;
|
|
15
|
+
/**
|
|
16
|
+
* Override the process-wide default gas buffer.
|
|
17
|
+
*
|
|
18
|
+
* @param bps Buffer in basis points (must be >= 0). e.g. 4000n = +40%.
|
|
19
|
+
* @throws RangeError if `bps` is negative.
|
|
20
|
+
*/
|
|
21
|
+
declare function setDefaultGasBufferBps(bps: bigint): void;
|
|
22
|
+
/** Read the current process-wide default gas buffer, in basis points. */
|
|
23
|
+
declare function getDefaultGasBufferBps(): bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Apply a gas buffer to a raw gas estimate.
|
|
26
|
+
*
|
|
27
|
+
* @param estimate Raw gas estimate (units of gas).
|
|
28
|
+
* @param bufferBps Optional per-call override in basis points; falls back to
|
|
29
|
+
* the process-wide default when omitted.
|
|
30
|
+
* @returns `estimate * (10000 + bps) / 10000`, rounded down (bigint).
|
|
31
|
+
* @throws RangeError if the effective buffer is negative.
|
|
32
|
+
*/
|
|
33
|
+
declare function applyGasBuffer(estimate: bigint, bufferBps?: bigint): bigint;
|
|
34
|
+
|
|
35
|
+
export { DEFAULT_GAS_BUFFER_BPS as D, applyGasBuffer as a, getDefaultGasBufferBps as g, setDefaultGasBufferBps as s };
|
package/dist/react/index.cjs
CHANGED
|
@@ -1310,6 +1310,16 @@ var UnsupportedAssetError = class extends MoreVaultsError {
|
|
|
1310
1310
|
}
|
|
1311
1311
|
};
|
|
1312
1312
|
|
|
1313
|
+
// src/common/gasBuffer.ts
|
|
1314
|
+
var DEFAULT_GAS_BUFFER_BPS = 4000n;
|
|
1315
|
+
var BPS_DENOMINATOR = 10000n;
|
|
1316
|
+
var currentDefaultBps = DEFAULT_GAS_BUFFER_BPS;
|
|
1317
|
+
function applyGasBuffer(estimate, bufferBps) {
|
|
1318
|
+
const bps = currentDefaultBps;
|
|
1319
|
+
if (bps < 0n) throw new RangeError(`gas buffer bps must be >= 0, got ${bps}`);
|
|
1320
|
+
return estimate * (BPS_DENOMINATOR + bps) / BPS_DENOMINATOR;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1313
1323
|
// src/viem/utils.ts
|
|
1314
1324
|
async function waitForTx(publicClient, hash, maxRetries = 3) {
|
|
1315
1325
|
const timeouts = [6e4, 12e4, 18e4];
|
|
@@ -2227,7 +2237,7 @@ async function depositAsync(walletClient, publicClient, addresses, assets, recei
|
|
|
2227
2237
|
} catch (err) {
|
|
2228
2238
|
parseContractError(err, vault, account.address);
|
|
2229
2239
|
}
|
|
2230
|
-
const gas = gasEstimate
|
|
2240
|
+
const gas = applyGasBuffer(gasEstimate);
|
|
2231
2241
|
const txHash = await walletClient.writeContract({
|
|
2232
2242
|
address: vault,
|
|
2233
2243
|
abi: BRIDGE_ABI,
|
|
@@ -2308,7 +2318,7 @@ async function redeemAsync(walletClient, publicClient, addresses, shares, receiv
|
|
|
2308
2318
|
} catch (err) {
|
|
2309
2319
|
parseContractError(err, vault, account.address);
|
|
2310
2320
|
}
|
|
2311
|
-
const gas = gasEstimate
|
|
2321
|
+
const gas = applyGasBuffer(gasEstimate);
|
|
2312
2322
|
const txHash = await walletClient.writeContract({
|
|
2313
2323
|
address: vault,
|
|
2314
2324
|
abi: BRIDGE_ABI,
|
|
@@ -2985,13 +2995,26 @@ async function submitActions(walletClient, publicClient, vault, actions) {
|
|
|
2985
2995
|
} catch (err) {
|
|
2986
2996
|
parseContractError(err, v, account.address);
|
|
2987
2997
|
}
|
|
2998
|
+
let gasLimit;
|
|
2999
|
+
try {
|
|
3000
|
+
const estimated = await publicClient.estimateContractGas({
|
|
3001
|
+
address: v,
|
|
3002
|
+
abi: MULTICALL_ABI,
|
|
3003
|
+
functionName: "submitActions",
|
|
3004
|
+
args: [actions],
|
|
3005
|
+
account: account.address
|
|
3006
|
+
});
|
|
3007
|
+
gasLimit = applyGasBuffer(estimated);
|
|
3008
|
+
} catch {
|
|
3009
|
+
}
|
|
2988
3010
|
const txHash = await walletClient.writeContract({
|
|
2989
3011
|
address: v,
|
|
2990
3012
|
abi: MULTICALL_ABI,
|
|
2991
3013
|
functionName: "submitActions",
|
|
2992
3014
|
args: [actions],
|
|
2993
3015
|
account,
|
|
2994
|
-
chain: walletClient.chain
|
|
3016
|
+
chain: walletClient.chain,
|
|
3017
|
+
gas: gasLimit
|
|
2995
3018
|
});
|
|
2996
3019
|
const nextNonce = await publicClient.readContract({
|
|
2997
3020
|
address: v,
|
|
@@ -3015,13 +3038,26 @@ async function executeActions(walletClient, publicClient, vault, nonce) {
|
|
|
3015
3038
|
} catch (err) {
|
|
3016
3039
|
parseContractError(err, v, account.address);
|
|
3017
3040
|
}
|
|
3041
|
+
let gasLimit;
|
|
3042
|
+
try {
|
|
3043
|
+
const estimated = await publicClient.estimateContractGas({
|
|
3044
|
+
address: v,
|
|
3045
|
+
abi: MULTICALL_ABI,
|
|
3046
|
+
functionName: "executeActions",
|
|
3047
|
+
args: [nonce],
|
|
3048
|
+
account: account.address
|
|
3049
|
+
});
|
|
3050
|
+
gasLimit = applyGasBuffer(estimated);
|
|
3051
|
+
} catch {
|
|
3052
|
+
}
|
|
3018
3053
|
const txHash = await walletClient.writeContract({
|
|
3019
3054
|
address: v,
|
|
3020
3055
|
abi: MULTICALL_ABI,
|
|
3021
3056
|
functionName: "executeActions",
|
|
3022
3057
|
args: [nonce],
|
|
3023
3058
|
account,
|
|
3024
|
-
chain: walletClient.chain
|
|
3059
|
+
chain: walletClient.chain,
|
|
3060
|
+
gas: gasLimit
|
|
3025
3061
|
});
|
|
3026
3062
|
return { txHash };
|
|
3027
3063
|
}
|