diff --git a/typescript/sdk/src/token/IToken.ts b/typescript/sdk/src/token/IToken.ts index f5ea769556..943d3881a4 100644 --- a/typescript/sdk/src/token/IToken.ts +++ b/typescript/sdk/src/token/IToken.ts @@ -83,5 +83,5 @@ export interface IToken extends TokenArgs { removeConnection(token: IToken): IToken; equals(token?: IToken): boolean; - equalsAsset(token?: IToken): boolean; + isFungibleWith(token?: IToken): boolean; } diff --git a/typescript/sdk/src/token/Token.ts b/typescript/sdk/src/token/Token.ts index 3f4b4fffed..6603644dcf 100644 --- a/typescript/sdk/src/token/Token.ts +++ b/typescript/sdk/src/token/Token.ts @@ -383,9 +383,11 @@ export class Token implements IToken { * 1) A HypCollateral contract token and its wrapped token (eg. EvmHypCollateral and ERC20) * 2) A HypNative contract and its native currency (eg. EvmHypNative and Ether) * 3) An IBC token and its native equivalent + * This is useful during fee estimation to determine if a TokenAmount for the transfer and the fee + * are actually fungible (represent the same asset). * @returns true if the tokens represent the same underlying asset */ - equalsAsset(token?: IToken): boolean { + isFungibleWith(token?: IToken): boolean { if (!token || token.chainName !== this.chainName) return false; if (this.equals(token)) return true; diff --git a/typescript/sdk/src/warp/WarpCore.ts b/typescript/sdk/src/warp/WarpCore.ts index d81ff479d5..ec31780b3b 100644 --- a/typescript/sdk/src/warp/WarpCore.ts +++ b/typescript/sdk/src/warp/WarpCore.ts @@ -385,11 +385,11 @@ export class WarpCore { const { localQuote, interchainQuote } = feeEstimate; let maxAmount = balance; - if (originToken.equalsAsset(localQuote.token)) { + if (originToken.isFungibleWith(localQuote.token)) { maxAmount = maxAmount.minus(localQuote.amount); } - if (originToken.equalsAsset(interchainQuote.token)) { + if (originToken.isFungibleWith(interchainQuote.token)) { maxAmount = maxAmount.minus(interchainQuote.amount); }