Skip to content

Commit

Permalink
feat: fillDeadline doesn't need to be strict when estimating gas
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandomg committed Jan 31, 2025
1 parent 9c93e2c commit 7c99698
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions typescript/sdk/src/warp/WarpCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,12 @@ export class WarpCore {
sender,
senderPubKey,
interchainFee,
fillDeadline,
}: {
originToken: IToken;
destination: ChainNameOrId;
sender: Address;
senderPubKey?: HexString;
interchainFee?: TokenAmount;
fillDeadline?: number;
}): Promise<TransactionFeeEstimate> {
this.logger.debug(`Estimating local transfer gas to ${destination}`);
const originMetadata = this.multiProvider.getChainMetadata(
Expand Down Expand Up @@ -227,7 +225,6 @@ export class WarpCore {
sender,
recipient,
interchainFee,
fillDeadline,
});

// Typically the transfers require a single transaction
Expand Down Expand Up @@ -279,14 +276,12 @@ export class WarpCore {
sender,
senderPubKey,
interchainFee,
fillDeadline,
}: {
originToken: IToken;
destination: ChainNameOrId;
sender: Address;
senderPubKey?: HexString;
interchainFee?: TokenAmount;
fillDeadline?: number;
}): Promise<TokenAmount> {
const originMetadata = this.multiProvider.getChainMetadata(
originToken.chainName,
Expand All @@ -305,7 +300,6 @@ export class WarpCore {
sender,
senderPubKey,
interchainFee,
fillDeadline,
});

// Get the local gas token. This assumes the chain's native token will pay for local gas
Expand All @@ -324,7 +318,7 @@ export class WarpCore {
sender,
recipient,
interchainFee,
fillDeadline,
fillDeadline = Math.floor(Date.now() / 1000) + 60 * 60 * 24, // default for gas estimation
}: {
originTokenAmount: TokenAmount;
destination: ChainNameOrId;
Expand All @@ -342,9 +336,8 @@ export class WarpCore {
const hypAdapter = token.getHypAdapter(this.multiProvider, destinationName);

if (
fillDeadline &&
(hypAdapter instanceof EvmIntentMultiChainAdapter ||
hypAdapter instanceof EvmIntentNativeMultiChainAdapter)
hypAdapter instanceof EvmIntentMultiChainAdapter ||
hypAdapter instanceof EvmIntentNativeMultiChainAdapter
) {
hypAdapter.deadline = fillDeadline;
}
Expand Down Expand Up @@ -403,13 +396,11 @@ export class WarpCore {
destination,
sender,
senderPubKey,
fillDeadline,
}: {
originToken: IToken;
destination: ChainNameOrId;
sender: Address;
senderPubKey?: HexString;
fillDeadline?: number;
}): Promise<WarpCoreFeeEstimate> {
this.logger.debug('Fetching remote transfer fee estimates');

Expand All @@ -428,7 +419,6 @@ export class WarpCore {
sender,
senderPubKey,
interchainFee: interchainQuote,
fillDeadline,
});

return {
Expand All @@ -447,14 +437,12 @@ export class WarpCore {
sender,
senderPubKey,
feeEstimate,
fillDeadline,
}: {
balance: TokenAmount;
destination: ChainNameOrId;
sender: Address;
senderPubKey?: HexString;
feeEstimate?: WarpCoreFeeEstimate;
fillDeadline?: number;
}): Promise<TokenAmount> {
const originToken = balance.token;

Expand All @@ -464,7 +452,6 @@ export class WarpCore {
destination,
sender,
senderPubKey,
fillDeadline,
});
}
const { localQuote, interchainQuote } = feeEstimate;
Expand Down Expand Up @@ -578,14 +565,12 @@ export class WarpCore {
recipient,
sender,
senderPubKey,
fillDeadline,
}: {
originTokenAmount: TokenAmount;
destination: ChainNameOrId;
recipient: Address;
sender: Address;
senderPubKey?: HexString;
fillDeadline?: number;
}): Promise<Record<string, string> | null> {
const chainError = this.validateChains(
originTokenAmount.token.chainName,
Expand Down Expand Up @@ -619,7 +604,6 @@ export class WarpCore {
destination,
sender,
senderPubKey,
fillDeadline,
);
if (balancesError) return balancesError;

Expand Down Expand Up @@ -735,7 +719,6 @@ export class WarpCore {
destination: ChainNameOrId,
sender: Address,
senderPubKey?: HexString,
fillDeadline?: number,
): Promise<Record<string, string> | null> {
const { token: originToken, amount } = originTokenAmount;

Expand Down Expand Up @@ -774,7 +757,6 @@ export class WarpCore {
sender,
senderPubKey,
interchainFee: interchainQuote,
fillDeadline,
});

const feeEstimate = { interchainQuote, localQuote };
Expand All @@ -786,7 +768,6 @@ export class WarpCore {
sender,
senderPubKey,
feeEstimate,
fillDeadline,
});
if (amount > maxTransfer.amount) {
return { amount: 'Insufficient balance for gas and transfer' };
Expand Down

0 comments on commit 7c99698

Please sign in to comment.