Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions modules/sdk-coin-ada/src/lib/transactionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ const FEE_COEFFICIENTS = {
B_COEFFICIENT: '155381',
/** Additional safety margin for the fee */
SAFETY_MARGIN: '440',
/* Min fee required for token transaction */
MIN_TOKEN_TRANSACTION_FEE: '1000000',
};

export abstract class TransactionBuilder extends BaseTransactionBuilder {
Expand Down Expand Up @@ -379,15 +377,7 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
);

// Calculate the fee based off our dummy transaction
let fee = CardanoWasm.min_fee(txDraft, linearFee).checked_add(BigNum.from_str(FEE_COEFFICIENTS.SAFETY_MARGIN));
/**
* In some cases especially with token transactions the calculated fee can be very low than the fee expected from the node
* So, ensure a minimum fee is always set
*/
const minTokenFee = BigNum.from_str(FEE_COEFFICIENTS.MIN_TOKEN_TRANSACTION_FEE);
if (fee.less_than(minTokenFee)) {
fee = minTokenFee;
}
const fee = CardanoWasm.min_fee(txDraft, linearFee).checked_add(BigNum.from_str(FEE_COEFFICIENTS.SAFETY_MARGIN));
this._fee = fee;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-ada/test/unit/tokenWithdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('ADA Token Operations', async () => {
totalInput -
1500000 /* min ada for change token utxo */ -
1500000 /* min ada for recipient token utxo*/ -
1000000
173597
) /* fee */
.toString();
const expectedChangeToken = '80';
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('ADA Token Operations', async () => {
1500000 /* min ada for change token utxo */ -
1500000 /* min ada for recipient token utxo*/ -
1500000 /* min ada for unsupported token change utxo */ -
1000000
179889
) /* fee */
.toString();
const expectedChangeToken = '80';
Expand Down