Calculate refund on user side only if no value provided (strictly undefined)
This commit is contained in:
parent
394d6cab5c
commit
2ce8cafdbd
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tornado/tornado-oracles",
|
"name": "@tornado/tornado-oracles",
|
||||||
"version": "3.2.0",
|
"version": "3.2.1",
|
||||||
"description": "Oracles for Tornado-specific transactions & actions",
|
"description": "Oracles for Tornado-specific transactions & actions",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
|
@ -225,7 +225,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
|||||||
* @param {AvailableTokenSymbols | Uppercase<AvailableTokenSymbols>} params.currency Currency symbol
|
* @param {AvailableTokenSymbols | Uppercase<AvailableTokenSymbols>} params.currency Currency symbol
|
||||||
* @param {number | HexadecimalStringifiedNumber } params.amount Withdrawal amount in selected currency
|
* @param {number | HexadecimalStringifiedNumber } params.amount Withdrawal amount in selected currency
|
||||||
* @param {number | HexadecimalStringifiedNumber } params.decimals Token (currency) decimals
|
* @param {number | HexadecimalStringifiedNumber } params.decimals Token (currency) decimals
|
||||||
* @param {BigNumberish} [params.refundInEth=0] Refund in ETH, if withdrawed other tokens on Mainnet (not ETH). Can not be provided, if user-side calculation
|
* @param {BigNumberish} [params.refundInEth] Refund in ETH, if withdrawed other tokens on Mainnet (not ETH). Can not be provided, if user-side calculation
|
||||||
* @param {BigNumberish} [params.tokenPriceInEth] If withdrawing other token on Mainnet or Goerli, need to provide token price in ETH (in WEI)
|
* @param {BigNumberish} [params.tokenPriceInEth] If withdrawing other token on Mainnet or Goerli, need to provide token price in ETH (in WEI)
|
||||||
* @param {number} [params.gasLimit] Predefined gas limit, if already calculated (no refetching)
|
* @param {number} [params.gasLimit] Predefined gas limit, if already calculated (no refetching)
|
||||||
* @param {number} [params.gasPrice] Predefined gas price, if already calculated (no refetching)
|
* @param {number} [params.gasPrice] Predefined gas price, if already calculated (no refetching)
|
||||||
@ -242,7 +242,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
|||||||
currency,
|
currency,
|
||||||
amount,
|
amount,
|
||||||
decimals,
|
decimals,
|
||||||
refundInEth = 0,
|
refundInEth,
|
||||||
tokenPriceInEth,
|
tokenPriceInEth,
|
||||||
predefinedGasLimit,
|
predefinedGasLimit,
|
||||||
predefinedGasPrice,
|
predefinedGasPrice,
|
||||||
@ -258,10 +258,10 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
|||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (txType === 'user_withdrawal' && !refundInEth)
|
if (txType === 'user_withdrawal' && refundInEth === undefined)
|
||||||
refundInEth = this.calculateRefundInETH(gasPrice, currency.toLowerCase() as InstanceTokenSymbol);
|
refundInEth = this.calculateRefundInETH(gasPrice, currency.toLowerCase() as InstanceTokenSymbol);
|
||||||
|
|
||||||
const feeInEth = BigNumber.from(gasCosts).add(refundInEth);
|
const feeInEth = BigNumber.from(gasCosts).add(refundInEth || 0);
|
||||||
return convertETHToToken(feeInEth, decimals, tokenPriceInEth).add(relayerFee).toHexString();
|
return convertETHToToken(feeInEth, decimals, tokenPriceInEth).add(relayerFee).toHexString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user