Skip to content

Commit

Permalink
fix: retry and reverse gas limit estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
palace22 committed Sep 24, 2024
1 parent ad50e31 commit 5e21aad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-peas-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@folks-finance/xchain-sdk": patch
---

Added increase by 5% in retry and reverse gas limit estimation
1 change: 1 addition & 0 deletions src/chains/evm/common/constants/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export const defaultEventParams: EventParams = {
export const GAS_LIMIT_ESTIMATE_INCREASE = 10_000n;
export const SEND_TOKEN_ACTION_RETURN_GAS_LIMIT = 500_000n;
export const RECEIVER_VALUE_SLIPPAGE = 0.01;
export const RETRY_REVERSE_GAS_LIMIT_SLIPPAGE = 0.05;
7 changes: 4 additions & 3 deletions src/chains/evm/hub/modules/folks-hub-gmp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { FINALITY } from "../../../../common/constants/message.js";
import { getRandomGenericAddress } from "../../../../common/utils/address.js";
import { getRandomBytes } from "../../../../common/utils/bytes.js";
import { GAS_LIMIT_ESTIMATE_INCREASE } from "../../common/constants/contract.js";
import { increaseByPercent } from "../../../../common/utils/math-lib.js";
import { RETRY_REVERSE_GAS_LIMIT_SLIPPAGE } from "../../common/constants/contract.js";
import { getEvmSignerAccount } from "../../common/utils/chain.js";
import { buildMessageParams, buildSendTokenExtraArgsWhenRemoving } from "../../common/utils/message.js";
import { getBridgeRouterHubContract } from "../utils/contract.js";
Expand Down Expand Up @@ -38,7 +39,7 @@ export const prepare = {
});

return {
gasLimit: gasLimit + GAS_LIMIT_ESTIMATE_INCREASE,
gasLimit: increaseByPercent(gasLimit, RETRY_REVERSE_GAS_LIMIT_SLIPPAGE),
msgValue: value,
isHub: true,
message,
Expand Down Expand Up @@ -68,7 +69,7 @@ export const prepare = {
});

return {
gasLimit: gasLimit + GAS_LIMIT_ESTIMATE_INCREASE,
gasLimit: increaseByPercent(gasLimit, RETRY_REVERSE_GAS_LIMIT_SLIPPAGE),
msgValue: value,
isHub: true,
message,
Expand Down

0 comments on commit 5e21aad

Please sign in to comment.