Improve fee display
This commit is contained in:
parent
a27c118c7f
commit
1b87f32f96
37
index.html
37
index.html
@ -73,7 +73,7 @@
|
||||
|
||||
<script>
|
||||
/*global $, bootstrap, ethers, Tornado, TornadoContracts, moment*/
|
||||
const VERSION = '1.0.1';
|
||||
const VERSION = '1.0.2';
|
||||
|
||||
const DONATION_ADDRESS = '0x40c3d1656a26C9266f4A10fed0D87EFf79F54E64';
|
||||
const DEFAULT_GAS_LIMIT = 600_000;
|
||||
@ -1374,6 +1374,9 @@
|
||||
let withdrawTable = '';
|
||||
|
||||
if (!isWallet) {
|
||||
const relayerFeePercent = Number(relayerClient?.selectedRelayer?.tornadoServiceFee) || 0;
|
||||
const relayerFee = (BigInt(denomination) * BigInt(Math.floor(10000 * relayerFeePercent))) / BigInt(10000 * 100);
|
||||
|
||||
withdrawTable = `
|
||||
<tr>
|
||||
<td>Relayer</td>
|
||||
@ -1381,11 +1384,11 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Relayer Fee</td>
|
||||
<td>${ethers.formatUnits(fee, decimals)} ${currency.toUpperCase()} (${((Number(fee) / Number(denomination)) * 100).toFixed(5)}%)</td>
|
||||
<td>${ethers.formatUnits(relayerFee, decimals)} ${currency.toUpperCase()} ( ${relayerFeePercent}% )</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Relayer Fee Percent</td>
|
||||
<td>${relayerClient?.selectedRelayer?.tornadoServiceFee}%</td>
|
||||
<td>Total Fee</td>
|
||||
<td>${ethers.formatUnits(fee, decimals)} ${currency.toUpperCase()} ( ${((Number(fee) / Number(denomination)) * 100).toFixed(5)}% )</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Amount to receive</td>
|
||||
@ -1405,24 +1408,11 @@
|
||||
</tr>
|
||||
`;
|
||||
} else {
|
||||
const txFee = gasPrice * gasLimit;
|
||||
const txFeeInToken = !isEth
|
||||
? tornadoFeeOracle.calculateTokenAmount(txFee, tokenPriceInWei, decimals)
|
||||
: BigInt(0);
|
||||
const txFeeString = !isEth
|
||||
? `(${Number(ethers.formatUnits(txFeeInToken, decimals)).toFixed(5)} ${currency.toUpperCase()} worth) ` +
|
||||
`(${((Number(ethers.formatUnits(txFeeInToken, decimals)) / Number(amount)) * 100).toFixed(5)}%)`
|
||||
: `(${((Number(ethers.formatUnits(txFee, decimals)) / Number(amount)) * 100).toFixed(5)}%)`;
|
||||
|
||||
withdrawTable = `
|
||||
<tr>
|
||||
<td>Signer</td>
|
||||
<td><a href="${explorerUrl}/address/${signer?.address}" target="_blank" rel="noreferrer nofollow">${signer?.address}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Transaction Fee</td>
|
||||
<td>${Number(ethers.formatEther(txFee)).toFixed(5)} ${nativeCurrency.toUpperCase()} ${txFeeString}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Amount to receive</td>
|
||||
<td>${amount} ${currency.toUpperCase()}</td>
|
||||
@ -1440,6 +1430,15 @@
|
||||
|
||||
const depositDate = new Date(depositEvent.timestamp * 1000);
|
||||
|
||||
const txFee = gasPrice * gasLimit;
|
||||
const txFeeInToken = !isEth
|
||||
? tornadoFeeOracle.calculateTokenAmount(txFee, tokenPriceInWei, decimals)
|
||||
: BigInt(0);
|
||||
const txFeeString = !isEth
|
||||
? `( ${Number(ethers.formatUnits(txFeeInToken, decimals)).toFixed(5)} ${currency.toUpperCase()} worth )` +
|
||||
`( ${((Number(ethers.formatUnits(txFeeInToken, decimals)) / Number(amount)) * 100).toFixed(5)}% )`
|
||||
: `( ${((Number(ethers.formatUnits(txFee, decimals)) / Number(amount)) * 100).toFixed(5)}% )`;
|
||||
|
||||
showConfirmation(
|
||||
'Confirm Withdrawal',
|
||||
`Review your withdrawal information for ${networkName} ${currency.toUpperCase()} ${amount} deposit`,
|
||||
@ -1470,6 +1469,10 @@
|
||||
<td>Gas Limit</td>
|
||||
<td>${gasLimit}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Transaction Fee</td>
|
||||
<td>${Number(ethers.formatEther(txFee)).toFixed(5)} ${nativeCurrency.toUpperCase()} ${txFeeString}</td>
|
||||
</tr>
|
||||
${withdrawTable}
|
||||
</tbody>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user