Skip to content

Commit

Permalink
Smr 2859 auto gas multiplier (#1858)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjimmutable authored Jun 6, 2024
1 parent 31930da commit dfc4bca
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/checkout/sdk/src/gasEstimate/bridgeGasEstimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function getBridgeFeeEstimate(

return await tokenBridge.getFee({
action: bridgeFeeAction,
gasMultiplier: 1.1,
gasMultiplier: 'auto',
sourceChainId: fromChainId.toString(),
destinationChainId: toChainId.toString(),
token: NATIVE.toUpperCase(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const getBridgeFeeEstimate = async (
const bridgeFeeResponse = await bridge.getFee(
{
action: BridgeFeeActions.DEPOSIT,
gasMultiplier: 1.1,
gasMultiplier: 'auto',
sourceChainId: fromChainId.toString(),
destinationChainId: toChainId.toString(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export function BridgeReviewSummary() {
amount: utils.parseUnits(amount, token.decimals),
sourceChainId: from?.network.toString(),
destinationChainId: to?.network.toString(),
gasMultiplier: 1.1,
gasMultiplier: 'auto',
});

const unsignedApproveTransaction = {
Expand Down
8 changes: 4 additions & 4 deletions packages/internal/bridge/bridge-sample-app/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function getBridgeTxs() {
amount: params.amount,
sourceChainId: bridgeConfig.bridgeInstance.rootChainID,
destinationChainId: bridgeConfig.bridgeInstance.childChainID,
gasMultiplier: 1.1,
gasMultiplier: 'auto',
}

console.log('depositReq', depositReq)
Expand All @@ -54,7 +54,7 @@ async function getBridgeTxs() {
amount: params.amount,
sourceChainId: bridgeConfig.bridgeInstance.rootChainID,
destinationChainId: bridgeConfig.bridgeInstance.childChainID,
gasMultiplier: 1.1,
gasMultiplier: 'auto',
}

console.log('depositNativeReq', depositNativeReq)
Expand All @@ -73,7 +73,7 @@ async function getBridgeTxs() {
amount: params.amount,
sourceChainId: bridgeConfig.bridgeInstance.childChainID,
destinationChainId: bridgeConfig.bridgeInstance.rootChainID,
gasMultiplier: 1.1,
gasMultiplier: 'auto',
}

console.log('withdrawReq', withdrawReq)
Expand All @@ -92,7 +92,7 @@ async function getBridgeTxs() {
amount: params.amount,
sourceChainId: bridgeConfig.bridgeInstance.childChainID,
destinationChainId: bridgeConfig.bridgeInstance.rootChainID,
gasMultiplier: 1.1,
gasMultiplier: 'auto',
}

console.log('withdrawNativeReq', withdrawNativeReq)
Expand Down
4 changes: 2 additions & 2 deletions packages/internal/bridge/bridge-sample-app/src/fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function getBridgeFees() {

const depositReq: BridgeFeeRequest = {
action: BridgeFeeActions.DEPOSIT,
gasMultiplier: 1.1,
gasMultiplier: 'auto',
sourceChainId: bridgeConfig.bridgeInstance.rootChainID,
destinationChainId: bridgeConfig.bridgeInstance.childChainID,
}
Expand All @@ -44,7 +44,7 @@ async function getBridgeFees() {

const withdrawReq: BridgeFeeRequest = {
action: BridgeFeeActions.WITHDRAW,
gasMultiplier: 1.1,
gasMultiplier: 'auto',
sourceChainId: bridgeConfig.bridgeInstance.childChainID,
destinationChainId: bridgeConfig.bridgeInstance.rootChainID,
}
Expand Down
6 changes: 3 additions & 3 deletions packages/internal/bridge/sdk/src/tokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export class TokenBridge {
recipient: string,
token: FungibleToken,
amount: ethers.BigNumber,
gasMultiplier: number,
gasMultiplier: number | string,
): Promise<BridgeBundledTxResponse> {
const [allowance, feeData, rootGas, axelarFee] = await Promise.all([
this.getAllowance(direction, token, sender),
Expand Down Expand Up @@ -723,7 +723,7 @@ export class TokenBridge {
recipient: string,
token: FungibleToken,
amount: ethers.BigNumber,
gasMultiplier: number,
gasMultiplier: number | string,
): Promise<BridgeBundledTxResponse> {
const [allowance, feeData, rootGas] = await Promise.all([
this.getAllowance(direction, token, sender),
Expand Down Expand Up @@ -977,7 +977,7 @@ export class TokenBridge {
sourceChainId: string,
destinationChainId: string,
destinationChainGaslimit: number,
gasMultiplier: number = 1.1,
gasMultiplier: number | string = 'auto',
): Promise<ethers.BigNumber> {
const sourceAxelar:AxelarChainDetails = axelarChains[sourceChainId];
const destinationAxelar:AxelarChainDetails = axelarChains[destinationChainId];
Expand Down
18 changes: 9 additions & 9 deletions packages/internal/bridge/sdk/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,29 @@ export type BridgeFeeRequest = DepositNativeFeeRequest
/**
* @typedef {Object} DepositNativeFeeRequest
* @property {BridgeFeeActions} method - The method for which the bridge fee is being requested.
* @property {number} gasMultiplier - How much buffer to add to the gas fee.
* @property {number} gasMultiplier - How much buffer to add to the gas fee, or 'auto' to use Axelar's automatic gas multiplier
* @property {string} sourceChainId - The chain ID of the source chain.
* @property {string} destinationChainId - The chain ID of the destination chain.
*/
export interface DepositNativeFeeRequest {
action: BridgeFeeActions.DEPOSIT,
gasMultiplier: number;
gasMultiplier: number | string;
sourceChainId: string;
destinationChainId: string;
}

/**
* @typedef {Object} DepositERC20FeeRequest
* @property {BridgeFeeActions} method - The method for which the bridge fee is being requested.
* @property {number} gasMultiplier - How much buffer to add to the gas fee.
* @property {number} gasMultiplier - How much buffer to add to the gas fee, or 'auto' to use Axelar's automatic gas multiplier
* @property {string} sourceChainId - The chain ID of the source chain.
* @property {string} destinationChainId - The chain ID of the destination chain.
* @property {FungibleToken} token - The token to be deposited.
* @property {ethers.BigNumber} amount - The amount to be deposited.
*/
export interface DepositERC20FeeRequest {
action: BridgeFeeActions.DEPOSIT,
gasMultiplier: number;
gasMultiplier: number | string;
sourceChainId: string;
destinationChainId: string;
token: FungibleToken;
Expand All @@ -165,29 +165,29 @@ export interface DepositERC20FeeRequest {
/**
* @typedef {Object} WithdrawNativeFeeRequest
* @property {BridgeFeeActions} method - The method for which the bridge fee is being requested.
* @property {number} gasMultiplier - How much buffer to add to the gas fee.
* @property {number} gasMultiplier - How much buffer to add to the gas fee, or 'auto' to use Axelar's automatic gas multiplier
* @property {string} sourceChainId - The chain ID of the source chain.
* @property {string} destinationChainId - The chain ID of the destination chain.
*/
export interface WithdrawNativeFeeRequest {
action: BridgeFeeActions.WITHDRAW,
gasMultiplier: number;
gasMultiplier: number | string;
sourceChainId: string;
destinationChainId: string;
}

/**
* @typedef {Object} WithdrawERC20FeeRequest
* @property {BridgeFeeActions} method - The method for which the bridge fee is being requested.
* @property {number} gasMultiplier - How much buffer to add to the gas fee.
* @property {number} gasMultiplier - How much buffer to add to the gas fee, or 'auto' to use Axelar's automatic gas multiplier
* @property {string} sourceChainId - The chain ID of the source chain.
* @property {string} destinationChainId - The chain ID of the destination chain.
* @property {FungibleToken} token - The token to be withdrawn.
* @property {ethers.BigNumber} amount - The amount to be withdrawn.
*/
export interface WithdrawERC20FeeRequest {
action: BridgeFeeActions.WITHDRAW,
gasMultiplier: number;
gasMultiplier: number | string;
sourceChainId: string;
destinationChainId: string;
token: FungibleToken;
Expand Down Expand Up @@ -298,7 +298,7 @@ export interface BridgeBundledTxRequest {
amount: ethers.BigNumber;
sourceChainId: string;
destinationChainId: string;
gasMultiplier: number;
gasMultiplier: number | string;
}

/**
Expand Down

0 comments on commit dfc4bca

Please sign in to comment.