Skip to content

Commit

Permalink
feat: get max input don't keep ed (#130)
Browse files Browse the repository at this point in the history
* feat: get max input remove ed

* update
  • Loading branch information
qiweiii committed May 10, 2024
1 parent d78beb1 commit e861b39
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -55,5 +55,5 @@
"jest": "^28.1.1",
"typescript": "^4.7.4"
},
"stableVersion": "0.1.5"
"stableVersion": "0.1.6"
}
10 changes: 9 additions & 1 deletion src/adapters/acala/acala.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
);
})
);
}
Expand Down
10 changes: 10 additions & 0 deletions src/base-chain-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FN> {
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
):
Expand Down

0 comments on commit e861b39

Please sign in to comment.