Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get max input don't keep ed #130

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading