diff --git a/package.json b/package.json index 6be771f..1ffc416 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polkawallet/bridge", - "version": "0.1.6", + "version": "0.1.7-1", "description": "polkawallet bridge sdk", "main": "index.js", "types": "index.d.ts", @@ -55,5 +55,5 @@ "jest": "^28.1.1", "typescript": "^4.7.4" }, - "stableVersion": "0.1.5" + "stableVersion": "0.1.6" } diff --git a/src/adapters/acala/acala.ts b/src/adapters/acala/acala.ts index df109db..cfcf223 100644 --- a/src/adapters/acala/acala.ts +++ b/src/adapters/acala/acala.ts @@ -123,12 +123,20 @@ class BaseAcalaAdapter extends BaseCrossChainAdapter { }).pipe( map(({ balance, txFee }) => { const feeFactor = 1.2; + const tokenMeta = this.getToken(token); const fee = FixedPointNumber.fromInner( txFee, nativeToken.decimals || 12 ).mul(new FixedPointNumber(feeFactor)); - return balance.minus(fee); + return balance + .minus(fee) + .minus( + FixedPointNumber.fromInner( + tokenMeta?.ed || "0", + tokenMeta?.decimals + ) + ); }) ); } diff --git a/src/base-chain-adapter.ts b/src/base-chain-adapter.ts index 9fe93f7..48d3339 100644 --- a/src/base-chain-adapter.ts +++ b/src/base-chain-adapter.ts @@ -349,6 +349,16 @@ export abstract class BaseCrossChainAdapter { return firstValueFrom(this.subscribeMaxInput(token, address, to)); } + public async getMaxInputIgnoreED( + token: string, + address: string, + to: ChainId + ): Promise { + const maxInputKeepEd = await this.getMaxInput(token, address, to); + const { ed, decimals } = this.getToken(token); + return maxInputKeepEd.plus(FN.fromInner(ed, decimals)); + } + public abstract createTx( params: TransferParams ):