btc-wallet 0.5.40-beta → 0.5.41-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/esm/index.js CHANGED
@@ -3930,10 +3930,15 @@ function getDepositAmount(amount, option) {
3930
3930
  const depositAmount = Math.max(Number(min_deposit_amount), Number(amount));
3931
3931
  const protocolFee = Math.max(Number(fee_min), Number(depositAmount) * fee_rate);
3932
3932
  const newAccountMinDepositAmount = !(accountInfo == null ? void 0 : accountInfo.nonce) && _newAccountMinDepositAmount ? NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT : 0;
3933
- const totalDepositAmount = new Big2(depositAmount).plus(protocolFee).plus(repayAmount).plus(newAccountMinDepositAmount).round(0, Big2.roundDown).toNumber();
3933
+ const receiveAmount = new Big2(depositAmount).minus(protocolFee).minus(repayAmount).round(0, Big2.roundDown).toNumber();
3934
+ if (Number(newAccountMinDepositAmount) > 0 && receiveAmount < Number(newAccountMinDepositAmount)) {
3935
+ throw new Error(
3936
+ `Receive amount (${receiveAmount}) is less than minimum required amount for new account (${newAccountMinDepositAmount})`
3937
+ );
3938
+ }
3934
3939
  return {
3935
3940
  depositAmount,
3936
- totalDepositAmount,
3941
+ receiveAmount,
3937
3942
  protocolFee,
3938
3943
  repayAmount,
3939
3944
  newAccountMinDepositAmount
@@ -3997,7 +4002,7 @@ function executeBTCDepositAndAction(_0) {
3997
4002
  if (new Big2(depositAmount).lt(0)) {
3998
4003
  throw new Error("amount must be greater than 0");
3999
4004
  }
4000
- const { totalDepositAmount, protocolFee, repayAmount } = yield getDepositAmount(depositAmount, {
4005
+ const { receiveAmount, protocolFee, repayAmount } = yield getDepositAmount(depositAmount, {
4001
4006
  env,
4002
4007
  newAccountMinDepositAmount
4003
4008
  });
@@ -4047,7 +4052,7 @@ function executeBTCDepositAndAction(_0) {
4047
4052
  "Deposit Amount": depositAmount,
4048
4053
  "Protocol Fee": protocolFee,
4049
4054
  "Repay Amount": repayAmount,
4050
- "Total Deposit Amount": totalDepositAmount,
4055
+ "Receive Amount": receiveAmount,
4051
4056
  "Fee Rate": _feeRate
4052
4057
  });
4053
4058
  const postActionsStr = newActions.length > 0 ? JSON.stringify(newActions) : void 0;
@@ -4057,7 +4062,7 @@ function executeBTCDepositAndAction(_0) {
4057
4062
  postActions: postActionsStr,
4058
4063
  extraMsg: depositMsg.extra_msg
4059
4064
  });
4060
- const txHash = yield sendBitcoin(userDepositAddress, totalDepositAmount, _feeRate);
4065
+ const txHash = yield sendBitcoin(userDepositAddress, Number(depositAmount), _feeRate);
4061
4066
  yield receiveDepositMsg(config.base_url, {
4062
4067
  btcPublicKey,
4063
4068
  txHash,
@@ -4849,7 +4854,7 @@ function getGroup(state) {
4849
4854
 
4850
4855
  // src/index.ts
4851
4856
  var getVersion = () => {
4852
- return "0.5.40-beta";
4857
+ return "0.5.41-beta";
4853
4858
  };
4854
4859
  if (typeof window !== "undefined") {
4855
4860
  window.__BTC_WALLET_VERSION = getVersion();