Skip to content

Commit 6684568

Browse files
committed
SellUtils: Fix error « .value of undefined » for estimate
1 parent 21347eb commit 6684568

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/lib/swap/utils/SellUtils.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const { activeSwap: swap } = useSwapsStore();
2020
const { exchangeRates } = useFiatStore();
2121
const { activeCurrency } = useAccountStore();
2222
const { accountBalance: accountBtcBalance, accountUtxos } = useBtcAddressStore();
23-
const { estimate } = useSwapEstimate();
2423

2524
/**
2625
* Sell - Sell crypto related things
@@ -46,17 +45,21 @@ export const oasisSellLimitExceeded = computed(() => {
4645
return deniedSettlementInfo.detail.reason === DeniedReason.LIMIT_EXCEEDED;
4746
});
4847

49-
export const nimFeePerUnit = computed(() =>
50-
(estimate.value && estimate.value.from.asset === SwapAsset.NIM && estimate.value.from.feePerUnit)
51-
|| (assets.value && assets.value[SwapAsset.NIM].feePerUnit)
52-
|| 0, // Default zero fees for NIM
53-
);
48+
export const nimFeePerUnit = computed(() => {
49+
const { estimate } = useSwapEstimate();
5450

55-
export const btcFeePerUnit = computed(() =>
56-
(estimate.value && estimate.value.from.asset === SwapAsset.BTC && estimate.value.from.feePerUnit)
57-
|| (assets.value && assets.value[SwapAsset.BTC].feePerUnit)
58-
|| 1,
59-
);
51+
return (estimate.value && estimate.value.from.asset === SwapAsset.NIM && estimate.value.from.feePerUnit)
52+
|| (assets.value && assets.value[SwapAsset.NIM].feePerUnit)
53+
|| 0; // Default zero fees for NIM
54+
});
55+
56+
export const btcFeePerUnit = computed(() => {
57+
const { estimate } = useSwapEstimate();
58+
59+
return (estimate.value && estimate.value.from.asset === SwapAsset.BTC && estimate.value.from.feePerUnit)
60+
|| (assets.value && assets.value[SwapAsset.BTC].feePerUnit)
61+
|| 1;
62+
});
6063

6164
// 48 extra weight units for BTC HTLC funding tx
6265
export const btcFeeForSendingAll = computed(() =>
@@ -118,5 +121,6 @@ export async function updateSellEstimate({ fiatAmount, cryptoAmount }
118121
}
119122
} // eslint-disable-line brace-style
120123

124+
const { estimate } = useSwapEstimate();
121125
estimate.value = newEstimate;
122126
}

0 commit comments

Comments
 (0)