Skip to content

Commit ddea90f

Browse files
authored
Merge pull request #7260 from BitGo/WIN-7548-use-ada-sdk-for-token-fee
feat(sdk-coin-ada) - remove fallback logic for token fee calculation
2 parents 43d7c5a + daef78e commit ddea90f

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

modules/sdk-coin-ada/src/lib/transactionBuilder.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ const FEE_COEFFICIENTS = {
2626
B_COEFFICIENT: '155381',
2727
/** Additional safety margin for the fee */
2828
SAFETY_MARGIN: '440',
29-
/* Min fee required for token transaction */
30-
MIN_TOKEN_TRANSACTION_FEE: '1000000',
3129
};
3230

3331
export abstract class TransactionBuilder extends BaseTransactionBuilder {
@@ -379,15 +377,7 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
379377
);
380378

381379
// Calculate the fee based off our dummy transaction
382-
let fee = CardanoWasm.min_fee(txDraft, linearFee).checked_add(BigNum.from_str(FEE_COEFFICIENTS.SAFETY_MARGIN));
383-
/**
384-
* In some cases especially with token transactions the calculated fee can be very low than the fee expected from the node
385-
* So, ensure a minimum fee is always set
386-
*/
387-
const minTokenFee = BigNum.from_str(FEE_COEFFICIENTS.MIN_TOKEN_TRANSACTION_FEE);
388-
if (fee.less_than(minTokenFee)) {
389-
fee = minTokenFee;
390-
}
380+
const fee = CardanoWasm.min_fee(txDraft, linearFee).checked_add(BigNum.from_str(FEE_COEFFICIENTS.SAFETY_MARGIN));
391381
this._fee = fee;
392382
}
393383

modules/sdk-coin-ada/test/unit/tokenWithdrawal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('ADA Token Operations', async () => {
3939
totalInput -
4040
1500000 /* min ada for change token utxo */ -
4141
1500000 /* min ada for recipient token utxo*/ -
42-
1000000
42+
173597
4343
) /* fee */
4444
.toString();
4545
const expectedChangeToken = '80';
@@ -127,7 +127,7 @@ describe('ADA Token Operations', async () => {
127127
1500000 /* min ada for change token utxo */ -
128128
1500000 /* min ada for recipient token utxo*/ -
129129
1500000 /* min ada for unsupported token change utxo */ -
130-
1000000
130+
179889
131131
) /* fee */
132132
.toString();
133133
const expectedChangeToken = '80';

0 commit comments

Comments
 (0)