@ocap/tx-protocols 1.13.75 → 1.13.79
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/lib/protocols/token/deposit-v2.js +1 -1
- package/lib/util.js +20 -8
- package/package.json +13 -13
|
@@ -101,7 +101,7 @@ runner.use((context, next) => {
|
|
|
101
101
|
return next(new Error('INVALID_STAKE_STATE', `Staking not locked for deposit: ${stakeState.address}`));
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
const depositAmount = new BN(itx.token.value);
|
|
104
|
+
const depositAmount = new BN(itx.token.value).add(new BN(itx.actualFee));
|
|
105
105
|
const minDepositAmount = new BN(rollupState.minDepositAmount);
|
|
106
106
|
const maxDepositAmount = new BN(rollupState.maxDepositAmount);
|
|
107
107
|
if (depositAmount.lt(minDepositAmount)) {
|
package/lib/util.js
CHANGED
|
@@ -197,20 +197,22 @@ const ensureBlockReward = (rollupState, minReward, txStates) => {
|
|
|
197
197
|
const totalMissingFee = minRequiredReward.sub(totalFixedFee);
|
|
198
198
|
|
|
199
199
|
// 2. calculate actual reward for each dynamic reward tx, mark tx to be updated
|
|
200
|
+
const minTxFee = minRequiredReward.div(new BN(txStates.length));
|
|
200
201
|
const changes = { stake: [], account: [] };
|
|
201
202
|
dynamicFeeTxs.forEach((x) => {
|
|
202
203
|
const maxFee = new BN(x.tx.itxJson.maxFee);
|
|
204
|
+
const defaults = getTxFee({
|
|
205
|
+
amount: x.tx.itxJson.token.value,
|
|
206
|
+
feeRate: withdrawFeeRate,
|
|
207
|
+
maxFee: maxWithdrawFee,
|
|
208
|
+
minFee: minWithdrawFee,
|
|
209
|
+
stringify: false,
|
|
210
|
+
});
|
|
211
|
+
|
|
203
212
|
let actualFee = new BN(0);
|
|
204
213
|
// If totalMissingFee is less than 0, then the tx will be charged for fixedFee
|
|
205
214
|
if (totalMissingFee.lt(ZERO)) {
|
|
206
|
-
|
|
207
|
-
amount: x.tx.itxJson.token.value,
|
|
208
|
-
feeRate: withdrawFeeRate,
|
|
209
|
-
maxFee: maxWithdrawFee,
|
|
210
|
-
minFee: minWithdrawFee,
|
|
211
|
-
stringify: false,
|
|
212
|
-
});
|
|
213
|
-
actualFee = fee.reward;
|
|
215
|
+
actualFee = defaults.reward;
|
|
214
216
|
} else {
|
|
215
217
|
// Else the tx is charged for a portion of totalMissingFee
|
|
216
218
|
actualFee = totalMissingFee.mul(maxFee).div(totalDynamicFee);
|
|
@@ -220,6 +222,16 @@ const ensureBlockReward = (rollupState, minReward, txStates) => {
|
|
|
220
222
|
throw new Error('NEGATIVE_ACTUAL_FEE', 'Got negative actualFee for tx, abort!');
|
|
221
223
|
}
|
|
222
224
|
|
|
225
|
+
// If the actualFee is less than default fee, user will be charged the default fee
|
|
226
|
+
if (actualFee.lt(defaults.reward)) {
|
|
227
|
+
actualFee = defaults.reward;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// If the actualFee is less than minTxFee, user will be charged the minTxFee
|
|
231
|
+
if (actualFee.lt(minTxFee)) {
|
|
232
|
+
actualFee = minTxFee;
|
|
233
|
+
}
|
|
234
|
+
|
|
223
235
|
// If the actualFee is less than the maxFee, user will have a refund
|
|
224
236
|
if (actualFee.lt(maxFee)) {
|
|
225
237
|
const refundFee = maxFee.sub(actualFee).toString(10);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.13.
|
|
6
|
+
"version": "1.13.79",
|
|
7
7
|
"description": "Predefined tx pipeline sets to execute certain type of transactions",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@arcblock/did": "1.13.
|
|
23
|
-
"@arcblock/did-util": "1.13.
|
|
24
|
-
"@ocap/asset": "1.13.
|
|
25
|
-
"@ocap/mcrypto": "1.13.
|
|
26
|
-
"@ocap/merkle-tree": "1.13.
|
|
27
|
-
"@ocap/message": "1.13.
|
|
28
|
-
"@ocap/state": "1.13.
|
|
29
|
-
"@ocap/tx-pipeline": "1.13.
|
|
30
|
-
"@ocap/util": "1.13.
|
|
31
|
-
"@ocap/validator": "1.13.
|
|
32
|
-
"@ocap/wallet": "1.13.
|
|
22
|
+
"@arcblock/did": "1.13.79",
|
|
23
|
+
"@arcblock/did-util": "1.13.79",
|
|
24
|
+
"@ocap/asset": "1.13.79",
|
|
25
|
+
"@ocap/mcrypto": "1.13.79",
|
|
26
|
+
"@ocap/merkle-tree": "1.13.79",
|
|
27
|
+
"@ocap/message": "1.13.79",
|
|
28
|
+
"@ocap/state": "1.13.79",
|
|
29
|
+
"@ocap/tx-pipeline": "1.13.79",
|
|
30
|
+
"@ocap/util": "1.13.79",
|
|
31
|
+
"@ocap/validator": "1.13.79",
|
|
32
|
+
"@ocap/wallet": "1.13.79",
|
|
33
33
|
"debug": "^4.3.2",
|
|
34
34
|
"empty-value": "^1.0.1",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"jest": "^27.3.1"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "e349a68b05ae8c6975517c8b43c66f9120a9b99f"
|
|
46
46
|
}
|