btc-wallet 0.5.44-beta → 0.5.45-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -8
- package/dist/index.js.map +2 -2
- package/esm/index.js +15 -8
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -3801,19 +3801,23 @@ function getDepositAmount(amount, option) {
|
|
3801
3801
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3802
3802
|
const debtAction = yield checkGasTokenDebt(csna, env, false);
|
3803
3803
|
const repayAmount = (debtAction == null ? void 0 : debtAction.amount) || 0;
|
3804
|
+
const depositAmount = Number(amount);
|
3804
3805
|
const {
|
3805
3806
|
deposit_bridge_fee: { fee_min, fee_rate },
|
3806
3807
|
min_deposit_amount
|
3807
3808
|
} = yield getBridgeConfig({ env });
|
3808
|
-
const
|
3809
|
-
const protocolFee = Math.max(Number(fee_min), Number(depositAmount) * fee_rate);
|
3809
|
+
const protocolFee = Math.max(Number(fee_min), depositAmount * fee_rate);
|
3810
3810
|
const newAccountMinDepositAmount = !(accountInfo == null ? void 0 : accountInfo.nonce) && _newAccountMinDepositAmount ? NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT : 0;
|
3811
|
-
|
3811
|
+
let receiveAmount = new import_big2.default(depositAmount).minus(protocolFee).minus(repayAmount).round(0, import_big2.default.roundDown).toNumber();
|
3812
|
+
receiveAmount = Math.max(receiveAmount, 0);
|
3812
3813
|
if (Number(newAccountMinDepositAmount) > 0 && receiveAmount < Number(newAccountMinDepositAmount)) {
|
3813
|
-
|
3814
|
-
`Receive amount (${receiveAmount}) is less than minimum required amount for new account (${newAccountMinDepositAmount})`
|
3814
|
+
console.error(
|
3815
|
+
`Receive amount (${receiveAmount}) is less than minimum required amount for new account (${newAccountMinDepositAmount} sat)`
|
3815
3816
|
);
|
3816
3817
|
}
|
3818
|
+
if (receiveAmount <= 0) {
|
3819
|
+
console.error(`Receive amount (${receiveAmount}) is less than 0`);
|
3820
|
+
}
|
3817
3821
|
return {
|
3818
3822
|
depositAmount,
|
3819
3823
|
receiveAmount,
|
@@ -3873,17 +3877,20 @@ function executeBTCDepositAndAction(_0) {
|
|
3873
3877
|
throw new Error("BTC Public Key is not available.");
|
3874
3878
|
}
|
3875
3879
|
if (!amount && !action) {
|
3876
|
-
throw new Error("amount or action is required");
|
3880
|
+
throw new Error("Deposit amount or action is required");
|
3877
3881
|
}
|
3878
3882
|
const csna = yield getCsnaAccountId(env);
|
3879
3883
|
const depositAmount = (_a = action ? action.amount : amount) != null ? _a : "0";
|
3880
3884
|
if (new import_big2.default(depositAmount).lt(0)) {
|
3881
|
-
throw new Error("amount must be greater than 0");
|
3885
|
+
throw new Error("Deposit amount must be greater than 0");
|
3882
3886
|
}
|
3883
3887
|
const { receiveAmount, protocolFee, repayAmount } = yield getDepositAmount(depositAmount, {
|
3884
3888
|
env,
|
3885
3889
|
newAccountMinDepositAmount
|
3886
3890
|
});
|
3891
|
+
if (receiveAmount <= 0) {
|
3892
|
+
throw new Error("Invalid deposit amount, too small");
|
3893
|
+
}
|
3887
3894
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3888
3895
|
const newActions = [];
|
3889
3896
|
const debtAction = yield checkGasTokenDebt(csna, env, false);
|
@@ -4925,7 +4932,7 @@ function getGroup(state) {
|
|
4925
4932
|
|
4926
4933
|
// src/index.ts
|
4927
4934
|
var getVersion = () => {
|
4928
|
-
return "0.5.
|
4935
|
+
return "0.5.45-beta";
|
4929
4936
|
};
|
4930
4937
|
if (typeof window !== "undefined") {
|
4931
4938
|
window.__BTC_WALLET_VERSION = getVersion();
|