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/README.md +8 -9
- package/dist/core/btcUtils.d.ts +1 -1
- package/dist/index.js +11 -6
- package/dist/index.js.map +2 -2
- package/esm/index.js +11 -6
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -129,18 +129,17 @@ const result = await getDepositAmount(
|
|
129
129
|
|
130
130
|
// Returns
|
131
131
|
interface DepositAmountResult {
|
132
|
-
depositAmount: number; // Original deposit amount
|
133
|
-
|
134
|
-
protocolFee: number;
|
135
|
-
repayAmount: number;
|
132
|
+
depositAmount: number; // Original deposit amount to be sent
|
133
|
+
receiveAmount: number; // Amount to be received after deducting fees and repayments
|
134
|
+
protocolFee: number; // Protocol fee
|
135
|
+
repayAmount: number; // Amount to repay if there's debt
|
136
136
|
newAccountMinDepositAmount: number; // Minimum deposit amount for new accounts
|
137
137
|
}
|
138
138
|
|
139
|
-
|
140
|
-
-
|
141
|
-
-
|
142
|
-
-
|
143
|
-
- New account minimum deposit (for first-time users)
|
139
|
+
When making a deposit:
|
140
|
+
- The user sends the `depositAmount` of BTC
|
141
|
+
- After deducting protocol fees and repayment amounts, the user receives `receiveAmount` on NEAR
|
142
|
+
- For new accounts, the function will throw an error if the `receiveAmount` is less than the minimum required amount
|
144
143
|
```
|
145
144
|
|
146
145
|
### `getWithdrawTransaction`
|
package/dist/core/btcUtils.d.ts
CHANGED
@@ -37,7 +37,7 @@ export declare function getDepositAmount(amount: string, option?: {
|
|
37
37
|
newAccountMinDepositAmount?: boolean;
|
38
38
|
}): Promise<{
|
39
39
|
depositAmount: number;
|
40
|
-
|
40
|
+
receiveAmount: number;
|
41
41
|
protocolFee: number;
|
42
42
|
repayAmount: string | number;
|
43
43
|
newAccountMinDepositAmount: string | number;
|
package/dist/index.js
CHANGED
@@ -3999,10 +3999,15 @@ function getDepositAmount(amount, option) {
|
|
3999
3999
|
const depositAmount = Math.max(Number(min_deposit_amount), Number(amount));
|
4000
4000
|
const protocolFee = Math.max(Number(fee_min), Number(depositAmount) * fee_rate);
|
4001
4001
|
const newAccountMinDepositAmount = !(accountInfo == null ? void 0 : accountInfo.nonce) && _newAccountMinDepositAmount ? NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT : 0;
|
4002
|
-
const
|
4002
|
+
const receiveAmount = new import_big2.default(depositAmount).minus(protocolFee).minus(repayAmount).round(0, import_big2.default.roundDown).toNumber();
|
4003
|
+
if (Number(newAccountMinDepositAmount) > 0 && receiveAmount < Number(newAccountMinDepositAmount)) {
|
4004
|
+
throw new Error(
|
4005
|
+
`Receive amount (${receiveAmount}) is less than minimum required amount for new account (${newAccountMinDepositAmount})`
|
4006
|
+
);
|
4007
|
+
}
|
4003
4008
|
return {
|
4004
4009
|
depositAmount,
|
4005
|
-
|
4010
|
+
receiveAmount,
|
4006
4011
|
protocolFee,
|
4007
4012
|
repayAmount,
|
4008
4013
|
newAccountMinDepositAmount
|
@@ -4066,7 +4071,7 @@ function executeBTCDepositAndAction(_0) {
|
|
4066
4071
|
if (new import_big2.default(depositAmount).lt(0)) {
|
4067
4072
|
throw new Error("amount must be greater than 0");
|
4068
4073
|
}
|
4069
|
-
const {
|
4074
|
+
const { receiveAmount, protocolFee, repayAmount } = yield getDepositAmount(depositAmount, {
|
4070
4075
|
env,
|
4071
4076
|
newAccountMinDepositAmount
|
4072
4077
|
});
|
@@ -4116,7 +4121,7 @@ function executeBTCDepositAndAction(_0) {
|
|
4116
4121
|
"Deposit Amount": depositAmount,
|
4117
4122
|
"Protocol Fee": protocolFee,
|
4118
4123
|
"Repay Amount": repayAmount,
|
4119
|
-
"
|
4124
|
+
"Receive Amount": receiveAmount,
|
4120
4125
|
"Fee Rate": _feeRate
|
4121
4126
|
});
|
4122
4127
|
const postActionsStr = newActions.length > 0 ? JSON.stringify(newActions) : void 0;
|
@@ -4126,7 +4131,7 @@ function executeBTCDepositAndAction(_0) {
|
|
4126
4131
|
postActions: postActionsStr,
|
4127
4132
|
extraMsg: depositMsg.extra_msg
|
4128
4133
|
});
|
4129
|
-
const txHash = yield sendBitcoin(userDepositAddress,
|
4134
|
+
const txHash = yield sendBitcoin(userDepositAddress, Number(depositAmount), _feeRate);
|
4130
4135
|
yield receiveDepositMsg(config.base_url, {
|
4131
4136
|
btcPublicKey,
|
4132
4137
|
txHash,
|
@@ -4916,7 +4921,7 @@ function getGroup(state) {
|
|
4916
4921
|
|
4917
4922
|
// src/index.ts
|
4918
4923
|
var getVersion = () => {
|
4919
|
-
return "0.5.
|
4924
|
+
return "0.5.41-beta";
|
4920
4925
|
};
|
4921
4926
|
if (typeof window !== "undefined") {
|
4922
4927
|
window.__BTC_WALLET_VERSION = getVersion();
|