Compare commits

..

2 Commits

Author SHA1 Message Date
16ffc1e491
Add built files for test 2024-11-23 18:45:02 +00:00
c9f43ff292
Remove broken external oracle and fixed EIP-1559 gasPrice calculation
* Updated 1inch Oracle link and use multicall3 ( because this is the only contract supported on sepolia )
* Simplify EIP-1559 gasPrice calculation ( EIP-1559 removes necessity of using external oracles, just enough premium of basefee will ensure transaction being mined )
* Apply respective premium for fees ( Only applied on V6 Oracle class )
* Removed @tornado/gas-price-oracle oracle
2024-11-23 18:43:55 +00:00
6 changed files with 25 additions and 5 deletions

2
lib/feeOracle.d.ts vendored
View File

@ -118,5 +118,5 @@ export declare abstract class TornadoFeeOracle implements ITornadoFeeOracle {
*
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (hexed string)
*/
calculateWithdrawalFeeViaRelayer({ tx, txType, relayerFeePercent, currency, amount, decimals, refundInEth, tokenPriceInEth, predefinedGasLimit, predefinedGasPrice, }: GetWithdrawalFeeViaRelayerInput): Promise<HexadecimalStringifiedNumber>;
calculateWithdrawalFeeViaRelayer({ tx, txType, relayerFeePercent, currency, amount, decimals, refundInEth, tokenPriceInEth, predefinedGasLimit, predefinedGasPrice, bumpGasLimitPercent, bumpGasPricePercent, }: GetWithdrawalFeeViaRelayerInput): Promise<HexadecimalStringifiedNumber>;
}

View File

@ -341,14 +341,21 @@ var TornadoFeeOracle = /** @class */ (function () {
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (hexed string)
*/
TornadoFeeOracle.prototype.calculateWithdrawalFeeViaRelayer = function (_a) {
var tx = _a.tx, txType = _a.txType, relayerFeePercent = _a.relayerFeePercent, currency = _a.currency, amount = _a.amount, decimals = _a.decimals, refundInEth = _a.refundInEth, tokenPriceInEth = _a.tokenPriceInEth, predefinedGasLimit = _a.predefinedGasLimit, predefinedGasPrice = _a.predefinedGasPrice;
var tx = _a.tx, txType = _a.txType, relayerFeePercent = _a.relayerFeePercent, currency = _a.currency, amount = _a.amount, decimals = _a.decimals, refundInEth = _a.refundInEth, tokenPriceInEth = _a.tokenPriceInEth, predefinedGasLimit = _a.predefinedGasLimit, predefinedGasPrice = _a.predefinedGasPrice, bumpGasLimitPercent = _a.bumpGasLimitPercent, bumpGasPricePercent = _a.bumpGasPricePercent;
return __awaiter(this, void 0, void 0, function () {
var relayerFee, _b, gasPrice, gasLimit, gasCosts, hasTokenPrice, feeInEth;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
relayerFee = this.calculateRelayerFeeInWei(relayerFeePercent, amount, decimals);
return [4 /*yield*/, this.getGasParams({ tx: tx, txType: txType, predefinedGasLimit: predefinedGasLimit, predefinedGasPrice: predefinedGasPrice })];
return [4 /*yield*/, this.getGasParams({
tx: tx,
txType: txType,
predefinedGasLimit: predefinedGasLimit,
predefinedGasPrice: predefinedGasPrice,
bumpGasLimitPercent: bumpGasLimitPercent,
bumpGasPricePercent: bumpGasPricePercent,
})];
case 1:
_b = _c.sent(), gasPrice = _b.gasPrice, gasLimit = _b.gasLimit;
gasCosts = ethers_1.BigNumber.from(gasPrice).mul(gasLimit);

File diff suppressed because one or more lines are too long

2
lib/types.d.ts vendored
View File

@ -89,4 +89,6 @@ export type GetWithdrawalFeeViaRelayerInput = {
tokenPriceInEth?: HexadecimalStringifiedNumber | string;
predefinedGasPrice?: HexadecimalStringifiedNumber;
predefinedGasLimit?: number;
bumpGasLimitPercent?: number;
bumpGasPricePercent?: number;
};

View File

@ -283,9 +283,18 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
tokenPriceInEth,
predefinedGasLimit,
predefinedGasPrice,
bumpGasLimitPercent,
bumpGasPricePercent,
}: GetWithdrawalFeeViaRelayerInput): Promise<HexadecimalStringifiedNumber> {
const relayerFee = this.calculateRelayerFeeInWei(relayerFeePercent, amount, decimals);
const { gasPrice, gasLimit } = await this.getGasParams({ tx, txType, predefinedGasLimit, predefinedGasPrice });
const { gasPrice, gasLimit } = await this.getGasParams({
tx,
txType,
predefinedGasLimit,
predefinedGasPrice,
bumpGasLimitPercent,
bumpGasPricePercent,
});
const gasCosts = BigNumber.from(gasPrice).mul(gasLimit);
const hasTokenPrice =

View File

@ -117,4 +117,6 @@ export type GetWithdrawalFeeViaRelayerInput = {
tokenPriceInEth?: HexadecimalStringifiedNumber | string; // Token (currency) price in ETH wei, if withdrawing non-native currency
predefinedGasPrice?: HexadecimalStringifiedNumber; // Predefined gas price for withdrawal tx (wont be calculated again in function)
predefinedGasLimit?: number; // Predefined gas limit for withdrawal tx (wont be calculated again in function)
bumpGasLimitPercent?: number; // Gas limit bump percent to prioritize transaction (recenlty used)
bumpGasPricePercent?: number; // Gas price bump percent to prioritize transaction (rarely used)
};