Skip to content

Commit

Permalink
chore: define HopParams interface
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Nov 8, 2024
1 parent c3af408 commit 417b383
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions src/libs/AxelarQueryAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,75 @@ export interface AxelarQueryAPIFeeResponse {
apiResponse: any;
isExpressSupported: boolean;
}

interface HopParams {
/** The destination chain for the GMP transaction */
destinationChain: string;

/** The source chain for the GMP transaction */
sourceChain: string;

/**
* The gasLimit needed for execution on the destination chain.
* For OP Stack chains (Optimism, Base, Scroll, Fraxtal, Blast, Mantle, etc.),
* only specify the gasLimit for L2 (L2GasLimit).
* The endpoint estimates and bundles the gas needed for L1 (L1GasLimit) automatically.
*/
gasLimit: string;

/**
* The multiplier of gas to be used on execution
* @default 'auto' (multiplier used by relayer)
*/
gasMultiplier?: number;

/**
* Minimum destination gas price
* @default minimum gas price used by relayer
*/
minGasPrice?: string;

/** The token symbol on the source chain */
sourceTokenSymbol?: string;

/**
* The token address on the source chain
* @default "ZeroAddress"
*/
sourceTokenAddress?: string;

/** Source address for checking if express is supported */
sourceContractAddress?: string;

/** The payload that will be used on destination */
executeData?: string;

/** Destination contract address for checking if express is supported */
destinationContractAddress?: string;

/** Symbol that is used in callContractWithToken for checking if express is supported */
symbol?: string;

/**
* Token amount (in units) that is used in callContractWithToken for checking if express is supported
*/
amountInUnits?: string;
}

interface EstimateMultihopFeeOptions {
showDetailedFees?: boolean;
}

export class AxelarQueryAPI {
readonly environment: Environment;
readonly lcdApi: RestService;
readonly rpcApi: RestService;
readonly axelarGMPServiceApi: RestService;
readonly axelarscanApi: RestService;
readonly axelarRpcUrl: string;
readonly axelarLcdUrl: string;
readonly axelarGMPServiceUrl: string;
readonly axelarscanBaseApiUrl: string;
private allAssets: AssetConfig[];
private axelarQueryClient: AxelarQueryClientType;
private chainsList: ChainInfo[] = [];
Expand All @@ -74,11 +135,13 @@ export class AxelarQueryAPI {
this.axelarRpcUrl = axelarRpcUrl || links.axelarRpcUrl;
this.axelarLcdUrl = axelarLcdUrl || links.axelarLcdUrl;
this.axelarGMPServiceUrl = links.axelarGMPApiUrl;
this.axelarscanBaseApiUrl = links.axelarscanBaseApiUrl;
this.environment = environment;

this.lcdApi = new RestService(this.axelarLcdUrl);
this.rpcApi = new RestService(this.axelarRpcUrl);
this.axelarGMPServiceApi = new RestService(this.axelarGMPServiceUrl);
this.axelarscanApi = new RestService(this.axelarscanBaseApiUrl);

this._initializeAssets();
}
Expand Down Expand Up @@ -436,6 +499,10 @@ export class AxelarQueryAPI {
: l1ExecutionFeeWithMultiplier.add(executionFeeWithMultiplier).add(baseFee).toString();
}

public async estimateMultihopFee(params: HopParams, options: EstimateMultihopFeeOptions) {
const response = this.axelarscanApi.post("estimateGasFeeForNHops", {});
}

/**
* Get the denom for an asset given its symbol on a chain
* @param symbol
Expand Down

0 comments on commit 417b383

Please sign in to comment.